cppparser: fix issue with templated external method definitions

This commit is contained in:
rdb 2016-11-03 18:04:14 +01:00
parent c0fd29d822
commit d54d43ac34
4 changed files with 28 additions and 10 deletions

View File

@ -5426,7 +5426,16 @@ yyreduce:
case 174: case 174:
#line 1619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ #line 1619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */
{ {
push_scope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope)); // Create a scope for this function (in case it is a function)
CPPScope *scope = new CPPScope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope),
CPPNameComponent(""), 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);
} }
#line 5432 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ #line 5432 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */
break; break;

View File

@ -1617,7 +1617,16 @@ instance_identifier:
} }
| instance_identifier '(' | instance_identifier '('
{ {
push_scope($1->get_scope(current_scope, global_scope)); // Create a scope for this function (in case it is a function)
CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope),
CPPNameComponent(""), 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);
} }
formal_parameter_list ')' function_post formal_parameter_list ')' function_post
{ {

View File

@ -42,15 +42,14 @@ is_fully_specified() const {
void CPPClassTemplateParameter:: void CPPClassTemplateParameter::
output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
if (complete) { if (complete) {
if (_ident != NULL) { out << "class";
out << "class ";
_ident->output(out, scope);
} else {
out << "class";
}
if (_packed) { if (_packed) {
out << "..."; out << "...";
} }
if (_ident != NULL) {
out << " ";
_ident->output(out, scope);
}
if (_default_type) { if (_default_type) {
out << " = "; out << " = ";
_default_type->output(out, indent_level, scope, false); _default_type->output(out, indent_level, scope, false);

View File

@ -139,11 +139,12 @@ public:
Templates _templates; Templates _templates;
CPPNameComponent _name; CPPNameComponent _name;
typedef set<CPPScope *> Using;
Using _using;
protected: protected:
CPPScope *_parent_scope; CPPScope *_parent_scope;
CPPStructType *_struct_type; CPPStructType *_struct_type;
typedef set<CPPScope *> Using;
Using _using;
CPPVisibility _current_vis; CPPVisibility _current_vis;
private: private: