Răsfoiți Sursa

cppparser: hack fix for method defs in parentheses

rdb 6 ani în urmă
părinte
comite
fb5440bd07
2 a modificat fișierele cu 476 adăugiri și 444 ștergeri
  1. 447 444
      dtool/src/cppparser/cppBison.cxx.prebuilt
  2. 29 0
      dtool/src/cppparser/cppBison.yxx

Fișier diff suprimat deoarece este prea mare
+ 447 - 444
dtool/src/cppparser/cppBison.cxx.prebuilt


+ 29 - 0
dtool/src/cppparser/cppBison.yxx

@@ -1218,6 +1218,35 @@ constructor_prototype:
   CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($1);
   CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($1);
   ii->add_func_modifier($4, $6);
   ii->add_func_modifier($4, $6);
 
 
+  $$ = new CPPInstance(type, ii, 0, @1.file);
+}
+/* This is a hack to support functions with the identifier enveloped by a
+   pair of parentheses. */
+        | TYPENAME_IDENTIFIER '(' IDENTIFIER ')' '('
+{
+  // Create a scope for this function.
+  CPPScope *scope = new CPPScope($3->get_scope(current_scope, global_scope),
+                                 $3->_names.back(), V_private);
+
+  // It still needs to be able to pick up any template arguments, if this is
+  // a definition for a method template.  Add a fake "using" declaration to
+  // accomplish this.
+  scope->_using.insert(current_scope);
+
+  push_scope(scope);
+}
+        function_parameter_list ')' function_post
+{
+  pop_scope();
+  CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer);
+  if (type == nullptr) {
+    yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1);
+  }
+  assert(type != nullptr);
+
+  CPPInstanceIdentifier *ii = new CPPInstanceIdentifier($3);
+  ii->add_func_modifier($7, $9);
+
   $$ = new CPPInstance(type, ii, 0, @1.file);
   $$ = new CPPInstance(type, ii, 0, @1.file);
 }
 }
         | TYPENAME_IDENTIFIER '('
         | TYPENAME_IDENTIFIER '('

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff