WriteLoadingOfMethod the loading of a method from a library into a LanguagWriter
(class ComponentDefinitionClass, method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, useStrictC bool)
| 336 | |
| 337 | // WriteLoadingOfMethod the loading of a method from a library into a LanguagWriter |
| 338 | func 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 | |
| 356 | func buildDynamicCLoadTableFromSymbolLookupMethodCode(component ComponentDefinition, w LanguageWriter, NameSpace string, BaseName string, useStrictC bool) error { |
no test coverage detected