Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CodeGen/Steamworks.NET_CodeGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def main():
steamworksparser.Settings.fake_gameserver_interfaces = True
___parser = steamworksparser.parse(steam_path)

# interface gen must run before struct, see parse_func() in interface.py
interfaces.main(___parser)
constants.main(___parser)
enums.main(___parser)
Expand Down
22 changes: 22 additions & 0 deletions CodeGen/src/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,28 @@ def parse_func(f, interface, func):
if c:
g_Output.append("\t\t/// <para>" + c + "</para>")
g_Output.append("\t\t/// </summary>")

strAsyncType: str = None
strAsyncStruct: str = None

for attr in func.attributes:
if attr.name in ("STEAM_CALL_RESULT", "STEAM_CALL_BACK"):
if attr.name == "STEAM_CALL_RESULT":
strAsyncType = "CallResult"
elif attr.name == "STEAM_CALL_BACK":
strAsyncType = "Callback"
strAsyncStruct = attr.value

# attach async marker to struct definiation
# this requires interface gen runs before struct gen to behave correctly
for callback in f.callbacks:
if callback.name == strAsyncStruct:
callback.asyncMarkerInterfaceName = f"I{strAsyncType}Struct"

if strAsyncType is not None:
g_Output.append(f"\t\t[SteamHasAsync{strAsyncType}(typeof({strAsyncStruct}))]")


g_Output.append("\t\tpublic static " + wrapperreturntype + " " + func.name.rstrip("0") + "(" + wrapperargs + ") {")

g_Output.extend(functionBody)
Expand Down
8 changes: 7 additions & 1 deletion CodeGen/src/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ def parse(struct):
lines.append("\t[StructLayout(LayoutKind.Sequential)]")
break

lines.append("\tpublic struct " + structname + " {")
# make struct implement an "ICallResultStruct" or something simliar, if
# this is a callback struct
strPotentialAsyncMarker = ""
if struct.asyncMarkerInterfaceName:
strPotentialAsyncMarker = f": {struct.asyncMarkerInterfaceName}"

lines.append("\tpublic struct " + structname + strPotentialAsyncMarker + " {")

lines.extend(insert_constructors(structname))

Expand Down
20 changes: 20 additions & 0 deletions com.rlabrecque.steamworks.net/Runtime/CallbackMarkers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file is provided under The MIT License as part of Steamworks.NET.
// Copyright (c) 2013-2022 Riley Labrecque
// Please see the included LICENSE.txt for additional information.

// This file is automatically generated.
// Changes to this file will be reverted when you update Steamworks.NET

#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
#define DISABLESTEAMWORKS
#endif

#if !DISABLESTEAMWORKS

namespace Steamworks {
public interface ICallResultStruct { }

public interface ICallbackStruct { }
}

#endif // !DISABLESTEAMWORKS