@@ -133,11 +133,6 @@ namespace {
133133 }
134134 }
135135
136- inline std::string gom_type_name_from_string (String* s) {
137- std::string result = std::string (Char (s));
138- return result;
139- }
140-
141136 inline std::string gom_value_from_string (String* s) {
142137 if (!Strncmp (s, " OGF::" , 5 )) {
143138 return std::string (Char (s)+5 );
@@ -147,21 +142,6 @@ namespace {
147142
148143 void gom_msg (const char * msg, Node* n);
149144
150- inline std::string gom_type_name (SwigType* ty) {
151- // TODO: is there a simple way of getting the fully qualified
152- // type name from Swig instead of adding one thing at a time
153- // with SwigType_isxxx() ?
154- String* s = SwigType_str (SwigType_base (ty),nullptr );
155- std::string result = gom_type_name_from_string (s);
156- if (SwigType_ispointer (ty)) {
157- result = result + " *" ;
158- }
159- if (SwigType_isarray (ty)) {
160- result = result + " []" ;
161- }
162- return result;
163- }
164-
165145 inline std::string gom_enum_name (Node* n) {
166146 String* s = Getattr (n, " name" );
167147 if (s == nullptr ) {
@@ -173,7 +153,7 @@ namespace {
173153
174154 inline OGF::MetaClass* gom_class_from_member (Node* n) {
175155 Node* clazz = Getattr (n," parentNode" );
176- std::string class_name = gom_type_name_from_string (
156+ std::string class_name = gom_string (
177157 Getattr (clazz," name" )
178158 );
179159 OGF::MetaClass* result = dynamic_cast <OGF::MetaClass*>(
@@ -185,7 +165,7 @@ namespace {
185165
186166 inline OGF::MetaBuiltinStruct* gom_struct_from_member (Node* n) {
187167 Node* clazz = Getattr (n," parentNode" );
188- std::string class_name = gom_type_name_from_string (
168+ std::string class_name = gom_string (
189169 Getattr (clazz," name" )
190170 );
191171 OGF::MetaBuiltinStruct* result = dynamic_cast <OGF::MetaBuiltinStruct*>(
@@ -258,39 +238,6 @@ namespace {
258238 }
259239 }
260240
261- void copy_gom_args (Node* from, OGF::MetaMethod* to) {
262- Parm* parms = Getattr (from," parms" );
263- if (parms != nullptr ) {
264- int param_id = 1 ;
265- for (Node* p = parms; p != nullptr ; p = nextSibling (p)) {
266- SwigType* type_in = Getattr (p," type" );
267- String* name_in = Getattr (p," name" );
268- String* value_in = Getattr (p," value" );
269-
270- std::string name;
271- if (name_in == nullptr ) {
272- OGF::Logger::warn (" GomGen" )
273- << " anonymous arg in signal/slot"
274- << std::endl;
275- name = GEO::String::format (" prm_%d" ,param_id);
276- } else {
277- name = gom_string (name_in);
278- }
279-
280- std::string type = gom_type_name (type_in);
281- OGF::MetaArg arg (name, type);
282- copy_gom_attributes (p, &arg);
283- if (value_in != nullptr ) {
284- std::string default_value = gom_value_from_string (value_in);
285- gom_unquote (default_value);
286- // gom_unqualify(default_value);
287- arg.default_value ().set_value (default_value);
288- }
289- to->add_arg (arg);
290- param_id++;
291- }
292- }
293- }
294241
295242// -------------------------------- Debugging ------------------------------
296243
@@ -913,7 +860,7 @@ namespace {
913860 virtual int classHandler (Node *n) {
914861
915862 if (!checkAttribute (n, " gom:kind" , " class" )) {
916- std::string name = gom_type_name_from_string (Getattr (n, " name" ));
863+ std::string name = gom_string (Getattr (n, " name" ));
917864 if (mode_ == GOMGEN_LUAWRAP_MODE) {
918865 if (checkAttribute (n, " gom:kind" , " namespace" )) {
919866 OGF::MetaNamespace* mnamespace =
@@ -936,7 +883,7 @@ namespace {
936883 if (checkAttribute (n, " gom:kind" , " class" )) {
937884
938885 bool abstract = (checkAttribute (n, " gom:abstract" , " true" )!=0 );
939- std::string name = gom_type_name_from_string (Getattr (n, " name" ));
886+ std::string name = gom_string (Getattr (n, " name" ));
940887
941888 int nb_superclasses = 0 ;
942889 OGF::MetaClass* superclass = nullptr ;
@@ -961,7 +908,7 @@ namespace {
961908 if (baselist != nullptr ) {
962909 for (int i=0 ; i<Len (baselist); i++) {
963910 std::string cur_base_name =
964- gom_type_name_from_string (Getitem (baselist, i));
911+ gom_string (Getitem (baselist, i));
965912
966913 OGF::MetaClass* cur_base =
967914 dynamic_cast <OGF::MetaClass*>(
@@ -1009,6 +956,10 @@ namespace {
1009956 new OGF::MetaBuiltinType (name + " *" )
1010957 );
1011958
959+ OGF::Meta::instance ()->bind_meta_type (
960+ new OGF::MetaBuiltinType (" const " + name + " *" )
961+ );
962+
1012963 OGF::MetaClass* mclass =
1013964 new OGF::MetaClass (name, superclass, abstract);
1014965 OGF::Meta::instance ()->bind_meta_type (mclass);
@@ -1109,6 +1060,69 @@ namespace {
11091060 user_attributes = nullptr ;
11101061 }
11111062
1063+ void copy_gom_args (Node* from, OGF::MetaMethod* to) {
1064+ Parm* parms = Getattr (from," parms" );
1065+ if (parms != nullptr ) {
1066+ int param_id = 1 ;
1067+ for (Node* p = parms; p != nullptr ; p = nextSibling (p)) {
1068+ SwigType* type_in = Getattr (p," type" );
1069+ String* name_in = Getattr (p," name" );
1070+ String* value_in = Getattr (p," value" );
1071+
1072+ std::string name;
1073+ if (name_in == nullptr ) {
1074+ OGF::Logger::warn (" GomGen" )
1075+ << " anonymous arg in signal/slot"
1076+ << std::endl;
1077+ name = GEO::String::format (" prm_%d" ,param_id);
1078+ } else {
1079+ name = gom_string (name_in);
1080+ }
1081+
1082+ std::string type = gom_type_name (type_in);
1083+ OGF::MetaArg arg (name, type);
1084+ copy_gom_attributes (p, &arg);
1085+ if (value_in != nullptr ) {
1086+ std::string default_value =
1087+ gom_value_from_string (value_in);
1088+ gom_unquote (default_value);
1089+ // gom_unqualify(default_value);
1090+ arg.default_value ().set_value (default_value);
1091+ }
1092+ to->add_arg (arg);
1093+ param_id++;
1094+ }
1095+ }
1096+ }
1097+
1098+ std::string gom_type_name (SwigType* ty) {
1099+ if (mode_ == GOMGEN_GOM_MODE) {
1100+ // in GOMGEN mode, use base type (and re-decorate with "*" if
1101+ // type was a pointer type).
1102+ String* s = SwigType_str (SwigType_base (ty),nullptr );
1103+ std::string result = gom_string (s);
1104+ if (SwigType_ispointer (ty)) {
1105+ result = result + " *" ;
1106+ }
1107+ return result;
1108+ } else {
1109+ std::string result = gom_string (SwigType_str (ty,nullptr ));
1110+ result = OGF::String::remove_suffix (result, " const &" );
1111+ if (OGF::String::string_ends_with (result, " *" )) {
1112+ result = OGF::String::remove_suffix (result, " *" );
1113+ if (OGF::String::string_ends_with (result, " const" )) {
1114+ result = OGF::String::remove_suffix (result, " const" );
1115+ result = " const " + result;
1116+ }
1117+ result += " *" ;
1118+ }
1119+ if (result == " char const*" ) {
1120+ result = " const char*" ;
1121+ }
1122+ return result;
1123+ }
1124+ }
1125+
11121126 private:
11131127 GomMemberType gom_member_type;
11141128 bool gomclass_flag;
0 commit comments