(component ComponentDefinition, class ComponentDefinitionClass, w LanguageWriter, NameSpace string)
| 722 | |
| 723 | |
| 724 | func writePythonClass(component ComponentDefinition, class ComponentDefinitionClass, w LanguageWriter, NameSpace string) error { |
| 725 | pythonBaseClassName := fmt.Sprintf("%s", component.Global.BaseClassName) |
| 726 | |
| 727 | w.Writeln("''' Class Implementation for %s", class.ClassName) |
| 728 | w.Writeln("'''") |
| 729 | |
| 730 | parentClass := "" |
| 731 | if (!component.isBaseClass(class)) { |
| 732 | if (class.ParentClass != "") { |
| 733 | parentClass = fmt.Sprintf("%s", class.ParentClass) |
| 734 | } else { |
| 735 | parentClass = pythonBaseClassName |
| 736 | } |
| 737 | w.Writeln("class %s(%s):", class.ClassName, parentClass) |
| 738 | w.Writeln(" def __init__(self, handle, wrapper):") |
| 739 | w.Writeln(" %s.__init__(self, handle, wrapper)", parentClass) |
| 740 | |
| 741 | } else { |
| 742 | w.Writeln("class %s:", class.ClassName) |
| 743 | w.Writeln(" def __init__(self, handle, wrapper):") |
| 744 | w.Writeln(" if not handle or not wrapper:") |
| 745 | w.Writeln(" raise E%sException(ErrorCodes.INVALIDPARAM)", NameSpace) |
| 746 | w.Writeln(" self._handle = handle") |
| 747 | w.Writeln(" self._wrapper = wrapper") |
| 748 | w.Writeln(" ") |
| 749 | w.Writeln(" def __del__(self):") |
| 750 | w.Writeln(" self._wrapper.%s(self)", component.Global.ReleaseMethod) |
| 751 | } |
| 752 | |
| 753 | for i:=0; i<len(class.Methods); i++ { |
| 754 | err := writeMethod(class.Methods[i], w, NameSpace, class.ClassName, []string{}, false) |
| 755 | if (err != nil) { |
| 756 | return err |
| 757 | } |
| 758 | } |
| 759 | return nil |
| 760 | } |
| 761 | |
| 762 | func writeMethod(method ComponentDefinitionMethod, w LanguageWriter, NameSpace string, ClassName string, implementationLines []string, isGlobal bool) error { |
| 763 | preCallLines := []string{} |
no test coverage detected