MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / WriteLoadingOfMethod

Function WriteLoadingOfMethod

Source/buildbindingccpp.go:338–353  ·  view source on GitHub ↗

WriteLoadingOfMethod the loading of a method from a library into a LanguagWriter

(class ComponentDefinitionClass, method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, useStrictC bool)

Source from the content-addressed store, hash-verified

336
337// WriteLoadingOfMethod the loading of a method from a library into a LanguagWriter
338func WriteLoadingOfMethod(class ComponentDefinitionClass, method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, useStrictC bool) {
339 nullPtrStr := "nullptr"
340 if (useStrictC) {
341 nullPtrStr = "NULL"
342 }
343
344 w.Writeln("#ifdef _WIN32")
345 w.Writeln("pWrapperTable->m_%s_%s = (P%s%s_%sPtr) GetProcAddress(hLibrary, \"%s_%s_%s\");", class.ClassName, method.MethodName, NameSpace, class.ClassName, method.MethodName, strings.ToLower(NameSpace), strings.ToLower(class.ClassName), strings.ToLower(method.MethodName))
346 w.Writeln("#else // _WIN32")
347 w.Writeln("pWrapperTable->m_%s_%s = (P%s%s_%sPtr) dlsym(hLibrary, \"%s_%s_%s\");", class.ClassName, method.MethodName, NameSpace, class.ClassName, method.MethodName, strings.ToLower(NameSpace), strings.ToLower(class.ClassName), strings.ToLower(method.MethodName))
348 w.Writeln("dlerror();")
349 w.Writeln("#endif // _WIN32")
350 w.Writeln("if (pWrapperTable->m_%s_%s == %s)", class.ClassName, method.MethodName, nullPtrStr)
351 w.Writeln(" return %s_ERROR_COULDNOTFINDLIBRARYEXPORT;", strings.ToUpper(NameSpace))
352 w.Writeln("")
353}
354
355
356func buildDynamicCLoadTableFromSymbolLookupMethodCode(component ComponentDefinition, w LanguageWriter, NameSpace string, BaseName string, useStrictC bool) error {

Callers 1

Calls 1

WritelnMethod · 0.80

Tested by

no test coverage detected