Class: MilkTea::Steamworks::Generator
- Inherits:
-
Object
- Object
- MilkTea::Steamworks::Generator
- Defined in:
- lib/milk_tea/bindings/steamworks.rb
Constant Summary collapse
- HEADER_GUARD =
"MT_LANG_STEAMWORKS_H"- MANUAL_OPAQUE_TYPES =
%w[ CCallbackBase CallbackMsg_t ISteamNetworkingConnectionSignaling ISteamNetworkingSignalingRecvContext ScePadTriggerEffectParam SteamDatagramRelayAuthTicket ].freeze
- SPECIAL_TYPE_REWRITES =
{ "CGameID" => "uint64_gameid", "CSteamID" => "uint64_steamid", "SteamInputActionEvent_t::AnalogAction_t" => "SteamInputActionEvent_t_AnalogAction_t", "SteamInputActionEvent_t::DigitalAction_t" => "SteamInputActionEvent_t_DigitalAction_t", }.freeze
- MANUAL_FUNCTION_POINTER_TYPEDEFS =
{ "SteamAPIWarningMessageHook_t" => ["void", ["int", "const char *"]], }.freeze
- MANUAL_SUPPORT_STRUCT_DEFINITIONS =
[ "typedef struct SteamInputActionEvent_t_AnalogAction_t {", " InputAnalogActionHandle_t actionHandle;", " InputAnalogActionData_t analogActionData;", "} SteamInputActionEvent_t_AnalogAction_t;", "", "typedef struct SteamInputActionEvent_t_DigitalAction_t {", " InputDigitalActionHandle_t actionHandle;", " InputDigitalActionData_t digitalActionData;", "} SteamInputActionEvent_t_DigitalAction_t;", ].freeze
- MANUAL_FUNCTIONS =
[ { return_type: "ESteamAPIInitResult", name: "SteamAPI_InitFlat", params: [{ name: "pOutErrMsg", type: "SteamErrMsg *" }] }, { return_type: "void", name: "SteamAPI_Shutdown", params: [] }, { return_type: "bool", name: "SteamAPI_RestartAppIfNecessary", params: [{ name: "unOwnAppID", type: "uint32" }] }, { return_type: "void", name: "SteamAPI_ReleaseCurrentThreadMemory", params: [] }, { return_type: "void", name: "SteamAPI_WriteMiniDump", params: [{ name: "uStructuredExceptionCode", type: "uint32" }, { name: "pvExceptionInfo", type: "void *" }, { name: "uBuildID", type: "uint32" }] }, { return_type: "void", name: "SteamAPI_SetMiniDumpComment", params: [{ name: "pchMsg", type: "const char *" }] }, { return_type: "bool", name: "SteamAPI_IsSteamRunning", params: [] }, { return_type: "const char *", name: "SteamAPI_GetSteamInstallPath", params: [] }, { return_type: "void", name: "SteamAPI_SetTryCatchCallbacks", params: [{ name: "bTryCatchCallbacks", type: "bool" }] }, { return_type: "bool", name: "SteamAPI_InitSafe", params: [] }, { return_type: "void", name: "SteamAPI_UseBreakpadCrashHandler", params: [{ name: "pchVersion", type: "const char *" }, { name: "pchDate", type: "const char *" }, { name: "pchTime", type: "const char *" }, { name: "bFullMemoryDumps", type: "bool" }, { name: "pvContext", type: "void *" }, { name: "pfnPreMinidumpCallback", type: "PFNPreMinidumpCallback" }] }, { return_type: "void", name: "SteamAPI_SetBreakpadAppID", params: [{ name: "unAppID", type: "uint32" }] }, { return_type: "void", name: "SteamAPI_ManualDispatch_Init", params: [] }, { return_type: "void", name: "SteamAPI_ManualDispatch_RunFrame", params: [{ name: "hSteamPipe", type: "HSteamPipe" }] }, { return_type: "bool", name: "SteamAPI_ManualDispatch_GetNextCallback", params: [{ name: "hSteamPipe", type: "HSteamPipe" }, { name: "pCallbackMsg", type: "CallbackMsg_t *" }] }, { return_type: "void", name: "SteamAPI_ManualDispatch_FreeLastCallback", params: [{ name: "hSteamPipe", type: "HSteamPipe" }] }, { return_type: "bool", name: "SteamAPI_ManualDispatch_GetAPICallResult", params: [{ name: "hSteamPipe", type: "HSteamPipe" }, { name: "hSteamAPICall", type: "SteamAPICall_t" }, { name: "pCallback", type: "void *" }, { name: "cubCallback", type: "int" }, { name: "iCallbackExpected", type: "int" }, { name: "pbFailed", type: "bool *" }] }, { return_type: "ESteamAPIInitResult", name: "SteamInternal_SteamAPI_Init", params: [{ name: "pszInternalCheckInterfaceVersions", type: "const char *" }, { name: "pOutErrMsg", type: "SteamErrMsg *" }] }, { return_type: "void", name: "SteamAPI_RunCallbacks", params: [] }, { return_type: "void", name: "SteamGameServer_RunCallbacks", params: [] }, { return_type: "HSteamPipe", name: "SteamAPI_GetHSteamPipe", params: [] }, { return_type: "HSteamUser", name: "SteamAPI_GetHSteamUser", params: [] }, { return_type: "HSteamPipe", name: "SteamGameServer_GetHSteamPipe", params: [] }, { return_type: "HSteamUser", name: "SteamGameServer_GetHSteamUser", params: [] }, { return_type: "void *", name: "SteamInternal_ContextInit", params: [{ name: "pContextInitData", type: "void *" }] }, { return_type: "void *", name: "SteamInternal_CreateInterface", params: [{ name: "ver", type: "const char *" }] }, { return_type: "void *", name: "SteamInternal_FindOrCreateUserInterface", params: [{ name: "hSteamUser", type: "HSteamUser" }, { name: "pszVersion", type: "const char *" }] }, { return_type: "void *", name: "SteamInternal_FindOrCreateGameServerInterface", params: [{ name: "hSteamUser", type: "HSteamUser" }, { name: "pszVersion", type: "const char *" }] }, { return_type: "void", name: "SteamAPI_RegisterCallback", params: [{ name: "pCallback", type: "CCallbackBase *" }, { name: "iCallback", type: "int" }] }, { return_type: "void", name: "SteamAPI_UnregisterCallback", params: [{ name: "pCallback", type: "CCallbackBase *" }] }, { return_type: "void", name: "SteamAPI_RegisterCallResult", params: [{ name: "pCallback", type: "CCallbackBase *" }, { name: "hAPICall", type: "SteamAPICall_t" }] }, { return_type: "void", name: "SteamAPI_UnregisterCallResult", params: [{ name: "pCallback", type: "CCallbackBase *" }, { name: "hAPICall", type: "SteamAPICall_t" }] }, { return_type: "void", name: "SteamGameServer_Shutdown", params: [] }, { return_type: "bool", name: "SteamGameServer_BSecure", params: [] }, { return_type: "uint64", name: "SteamGameServer_GetSteamID", params: [] }, { return_type: "ESteamAPIInitResult", name: "SteamInternal_GameServer_Init_V2", params: [{ name: "unIP", type: "uint32" }, { name: "usGamePort", type: "uint16" }, { name: "usQueryPort", type: "uint16" }, { name: "eServerMode", type: "EServerMode" }, { name: "pchVersionString", type: "const char *" }, { name: "pszInternalCheckInterfaceVersions", type: "const char *" }, { name: "pOutErrMsg", type: "SteamErrMsg *" }] }, ].freeze
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(json_path: nil, json_source: nil, source_label: nil) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(json_path: nil, json_source: nil, source_label: nil) ⇒ Generator
Returns a new instance of Generator.
230 231 232 233 234 235 |
# File 'lib/milk_tea/bindings/steamworks.rb', line 230 def initialize(json_path: nil, json_source: nil, source_label: nil) raise ArgumentError, "json_path or json_source is required" if json_path.nil? && json_source.nil? @json_source = json_source || File.read(json_path) @source_label = source_label || File.(json_path.to_s) end |
Instance Method Details
#generate ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/milk_tea/bindings/steamworks.rb', line 237 def generate lines = [] lines << "/* generated by mtc steamworks from #{@source_label} */" lines << "#ifndef #{HEADER_GUARD}" lines << "#define #{HEADER_GUARD}" lines << "" lines << "#include <stdbool.h>" lines << "#include <stddef.h>" lines << "#include <stdint.h>" lines << "" lines << "#ifdef __cplusplus" lines << 'extern "C" {' lines << "#endif" lines << "" lines.concat(emit_forward_declarations) lines << "" unless lines.last.empty? lines.concat(emit_typedefs) lines << "" unless lines.last.empty? lines.concat(emit_flat_aliases) lines << "" unless lines.last.empty? lines.concat(emit_enums) lines << "" unless lines.last.empty? lines.concat(emit_structs) lines << "" unless lines.last.empty? lines.concat(emit_manual_function_pointer_typedefs) lines << "" unless lines.last.empty? lines.concat(emit_constants) lines << "" unless lines.last.empty? lines.concat(emit_manual_functions) lines << "" unless lines.last.empty? lines.concat(emit_accessors) lines << "" unless lines.last.empty? lines.concat(emit_interface_methods) lines << "" unless lines.last.empty? lines.concat(emit_struct_methods) lines << "" unless lines.last.empty? lines.concat(emit_inline_wrappers) lines << "" lines << "#ifdef __cplusplus" lines << "}" lines << "#endif" lines << "" lines << "#endif" lines.join("\n") + "\n" end |