(component ComponentDefinition, w LanguageWriter, implw LanguageWriter)
| 504 | } |
| 505 | |
| 506 | func 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") |
no test coverage detected