(component ComponentDefinition, w io.Writer, implw io.Writer, NameSpace string, BaseName string)
| 843 | |
| 844 | |
| 845 | func buildNodeWrapperClass(component ComponentDefinition, w io.Writer, implw io.Writer, NameSpace string, BaseName string) error { |
| 846 | |
| 847 | fmt.Fprintf(w, "\n") |
| 848 | fmt.Fprintf(w, "#ifndef %s_NODEWRAPPER_H\n", strings.ToUpper(NameSpace)) |
| 849 | fmt.Fprintf(w, "#define %s_NODEWRAPPER_H\n", strings.ToUpper(NameSpace)) |
| 850 | fmt.Fprintf(w, "\n") |
| 851 | fmt.Fprintf(w, "#include \"%s_dynamic.h\"\n", strings.ToLower(NameSpace)) |
| 852 | fmt.Fprintf(w, "#include <node.h>\n") |
| 853 | fmt.Fprintf(w, "#include <node_object_wrap.h>\n") |
| 854 | fmt.Fprintf(w, "#include <string>\n") |
| 855 | fmt.Fprintf(w, "\n") |
| 856 | |
| 857 | fmt.Fprintf(w, "#define NODEWRAPPER_FIELDCOUNT 4\n") |
| 858 | fmt.Fprintf(w, "#define NODEWRAPPER_TABLEINDEX 2\n") |
| 859 | fmt.Fprintf(w, "#define NODEWRAPPER_HANDLEINDEX 3\n") |
| 860 | |
| 861 | fmt.Fprintf(w, "/*************************************************************************************************************************\n") |
| 862 | fmt.Fprintf(w, " Forward declarations \n") |
| 863 | fmt.Fprintf(w, "**************************************************************************************************************************/\n") |
| 864 | |
| 865 | fmt.Fprintf(w, "\n") |
| 866 | fmt.Fprintf(w, "class C%sWrapper;\n", NameSpace) |
| 867 | fmt.Fprintf(w, "\n") |
| 868 | |
| 869 | fmt.Fprintf(w, "/*************************************************************************************************************************\n") |
| 870 | fmt.Fprintf(w, " Class C%sBaseClass \n", NameSpace) |
| 871 | fmt.Fprintf(w, "**************************************************************************************************************************/\n") |
| 872 | fmt.Fprintf(w, "\n") |
| 873 | |
| 874 | fmt.Fprintf(w, "class C%sBaseClass : public node::ObjectWrap {\n", NameSpace) |
| 875 | fmt.Fprintf(w, "private:\n") |
| 876 | fmt.Fprintf(w, "protected:\n") |
| 877 | fmt.Fprintf(w, "public:\n") |
| 878 | fmt.Fprintf(w, " C%sBaseClass ();\n", NameSpace) |
| 879 | fmt.Fprintf(w, " static void RaiseError (v8::Isolate * isolate, std::string Message);\n") |
| 880 | fmt.Fprintf(w, " static void CheckError (v8::Isolate * isolate, s%sDynamicWrapperTable * sWrapperTable, %sHandle pInstance, %sResult errorCode);\n", NameSpace, NameSpace, NameSpace) |
| 881 | fmt.Fprintf(w, " static void setHandle (%sHandle pHandle);\n", NameSpace) |
| 882 | fmt.Fprintf(w, " static %sHandle getHandle (v8::Handle<v8::Object> objecthandle);\n", NameSpace) |
| 883 | fmt.Fprintf(w, " static s%sDynamicWrapperTable * getDynamicWrapperTable (v8::Handle<v8::Object> objecthandle);\n", NameSpace) |
| 884 | fmt.Fprintf(w, "};\n") |
| 885 | fmt.Fprintf(w, "\n") |
| 886 | fmt.Fprintf(w, "\n") |
| 887 | |
| 888 | for i := 0; i < len(component.Classes); i++ { |
| 889 | class := component.Classes[i] |
| 890 | |
| 891 | fmt.Fprintf(w, "/*************************************************************************************************************************\n") |
| 892 | fmt.Fprintf(w, " Class C%s%s \n", NameSpace, class.ClassName) |
| 893 | fmt.Fprintf(w, "**************************************************************************************************************************/\n") |
| 894 | fmt.Fprintf(w, "class C%s%s : public C%sBaseClass {\n", NameSpace, class.ClassName, NameSpace) |
| 895 | fmt.Fprintf(w, "private:\n") |
| 896 | fmt.Fprintf(w, " static void New(const v8::FunctionCallbackInfo<v8::Value>& args);\n") |
| 897 | fmt.Fprintf(w, " static v8::Persistent<v8::Function> constructor;\n") |
| 898 | |
| 899 | for j := 0; j < len(class.Methods); j++ { |
| 900 | method := class.Methods[j] |
| 901 | fmt.Fprintf(w, " static void %s (const v8::FunctionCallbackInfo<v8::Value>& args);\n", method.MethodName) |
| 902 | } |
no test coverage detected