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

Function writeFunctionTableMethod

Source/buildbindingpython.go:414–434  ·  view source on GitHub ↗
(method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, ClassName string, isGlobal bool)

Source from the content-addressed store, hash-verified

412}
413
414func writeFunctionTableMethod(method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, ClassName string, isGlobal bool) error {
415 linearMethodName := ""
416 if (isGlobal) {
417 linearMethodName = strings.ToLower(NameSpace + "_" + method.MethodName)
418 } else {
419 linearMethodName = strings.ToLower(NameSpace + "_" + ClassName + "_" + method.MethodName)
420 }
421
422 params, err := getMethodCParams(method, NameSpace, ClassName, isGlobal)
423 if err != nil {
424 return err
425 }
426
427 w.Writeln("err = symbolLookupMethod(ctypes.c_char_p(str.encode(\"%s\")), methodAddress)", linearMethodName)
428 w.Writeln("if err != 0:")
429 w.Writeln(" raise E%sException(ErrorCodes.COULDNOTLOADLIBRARY, str(err))", NameSpace)
430 w.Writeln("methodType = ctypes.CFUNCTYPE(ctypes.c_int32, " + params + ")")
431 w.Writeln("self.lib.%s = methodType(int(methodAddress.value))", linearMethodName)
432 w.Writeln("")
433 return nil
434}
435
436func getMethodCParams(method ComponentDefinitionMethod, NameSpace string, ClassName string, isGlobal bool) (string, error) {
437 parameters := ""

Callers 1

Calls 2

getMethodCParamsFunction · 0.85
WritelnMethod · 0.80

Tested by

no test coverage detected