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

Function buildGoWrapper

Source/buildbindinggo.go:506–645  ·  view source on GitHub ↗
(component ComponentDefinition, w LanguageWriter, implw LanguageWriter)

Source from the content-addressed store, hash-verified

504}
505
506func buildGoWrapper(component ComponentDefinition, w LanguageWriter, implw LanguageWriter) error {
507 NameSpace := component.NameSpace
508 global := component.Global
509 packageName := strings.ToLower(component.BaseName)
510
511 w.Writeln("")
512 w.Writeln("package %s", packageName)
513 w.Writeln("")
514
515 buildGoEnums(component, w)
516 err := buildGoStructs(component, w)
517 if (err != nil) {
518 return err
519 }
520 buildGoInterfaces(component, w)
521
522 implw.Writeln("")
523 implw.Writeln("package %s", packageName)
524 implw.Writeln("")
525 implw.Writeln("// #include <string.h>")
526 implw.Writeln("import \"C\"")
527 implw.Writeln("")
528 implw.Writeln("import (")
529 implw.Writeln(" \"fmt\"")
530 implw.Writeln(" \"errors\"")
531 implw.Writeln(" \"syscall\"")
532 implw.Writeln(" \"unsafe\"")
533 implw.Writeln(")")
534 implw.Writeln("")
535
536 buildGoImplementation(component, implw)
537
538 buildGoImplementationHandle(component, implw)
539
540 buildGoHelperFunctions(implw)
541
542 buildGoErrorHandling(component, implw)
543
544 implw.Writeln("")
545 implw.Writeln("func (implementation *%sImplementation) GetWrapperHandle(handle %sHandle) (%sImplementationHandle, error) {", NameSpace, NameSpace, NameSpace)
546 implw.Writeln(" implementation_handle, ok := handle.(%sImplementationHandle)", NameSpace)
547 implw.Writeln(" if ok {")
548 implw.Writeln(" handle_implementation := implementation_handle.GetWrapper()")
549 implw.Writeln(" if (handle_implementation == implementation) {")
550 implw.Writeln(" return implementation_handle, nil")
551 implw.Writeln(" }")
552 implw.Writeln(" return nil, errors.New(\"Invalid Implementation for DLL handle.\")")
553 implw.Writeln(" }")
554 implw.Writeln(" return nil, errors.New(\"Could not cast DLL handle.\")")
555 implw.Writeln("}")
556 implw.Writeln("")
557
558 buildGoInitialize(component, implw)
559
560 implw.Writeln("")
561 implw.Writeln("func (implementation *%sImplementation) NewHandle() (%sImplementationHandle) {", NameSpace, NameSpace)
562 implw.Writeln(" handle := new (%sImplementationHandleStruct)", NameSpace)
563 implw.Writeln(" handle.Implementation = implementation")

Callers 1

BuildBindingGoFunction · 0.85

Calls 15

buildGoEnumsFunction · 0.85
buildGoStructsFunction · 0.85
buildGoInterfacesFunction · 0.85
buildGoImplementationFunction · 0.85
buildGoHelperFunctionsFunction · 0.85
buildGoErrorHandlingFunction · 0.85
buildGoInitializeFunction · 0.85
buildGoCallFunctionFunction · 0.85
buildGoClassFunction · 0.85
writeGoMethodFunction · 0.85
majorVersionFunction · 0.85

Tested by

no test coverage detected