mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
cppparser: fix issue with typedefs to forward declared templates
I don't know if this is the right solution, but it does fix an issue accessing std::ios::openmode caused by the ios typedef being defined before ios_base is fully specified.
This commit is contained in:
parent
8a9d83b604
commit
5582e174b6
@ -252,7 +252,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (i + 1 < (int)_names.size() && scope != nullptr) {
|
while (i + 1 < (int)_names.size() && scope != nullptr) {
|
||||||
CPPScope *next_scope = scope->find_scope(_names[i].get_name());
|
CPPScope *next_scope = scope->find_scope(_names[i].get_name(), global_scope);
|
||||||
if (next_scope == nullptr) {
|
if (next_scope == nullptr) {
|
||||||
if (error_sink != nullptr) {
|
if (error_sink != nullptr) {
|
||||||
error_sink->error("Symbol " + _names[i].get_name() +
|
error_sink->error("Symbol " + _names[i].get_name() +
|
||||||
@ -511,7 +511,7 @@ find_scope(CPPScope *current_scope, CPPScope *global_scope,
|
|||||||
if (scope == nullptr) {
|
if (scope == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return scope->find_scope(get_simple_name());
|
return scope->find_scope(get_simple_name(), global_scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CPPScope *CPPScope::
|
CPPScope *CPPScope::
|
||||||
find_scope(const string &name, bool recurse) const {
|
find_scope(const string &name, CPPScope *global_scope, bool recurse) const {
|
||||||
Namespaces::const_iterator ni = _namespaces.find(name);
|
Namespaces::const_iterator ni = _namespaces.find(name);
|
||||||
if (ni != _namespaces.end()) {
|
if (ni != _namespaces.end()) {
|
||||||
return (*ni).second->get_scope();
|
return (*ni).second->get_scope();
|
||||||
@ -617,13 +617,21 @@ find_scope(const string &name, bool recurse) const {
|
|||||||
ti = _types.find(name);
|
ti = _types.find(name);
|
||||||
if (ti != _types.end()) {
|
if (ti != _types.end()) {
|
||||||
type = (*ti).second;
|
type = (*ti).second;
|
||||||
// Resolve if this is a typedef or const.
|
// Resolve if this is a typedef or const, or a TBD type.
|
||||||
while (type->get_subtype() == CPPDeclaration::ST_const ||
|
while (type->get_subtype() == CPPDeclaration::ST_const ||
|
||||||
type->get_subtype() == CPPDeclaration::ST_typedef) {
|
type->get_subtype() == CPPDeclaration::ST_typedef ||
|
||||||
|
type->get_subtype() == CPPDeclaration::ST_tbd) {
|
||||||
if (type->as_typedef_type() != nullptr) {
|
if (type->as_typedef_type() != nullptr) {
|
||||||
type = type->as_typedef_type()->_type;
|
type = type->as_typedef_type()->_type;
|
||||||
} else {
|
} else if (type->as_const_type() != nullptr) {
|
||||||
type = type->as_const_type()->_wrapped_around;
|
type = type->as_const_type()->_wrapped_around;
|
||||||
|
} else {
|
||||||
|
CPPType *new_type = type->resolve_type((CPPScope *)this, global_scope);
|
||||||
|
if (new_type != type) {
|
||||||
|
type = new_type;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,14 +661,14 @@ find_scope(const string &name, bool recurse) const {
|
|||||||
|
|
||||||
Using::const_iterator ui;
|
Using::const_iterator ui;
|
||||||
for (ui = _using.begin(); ui != _using.end(); ++ui) {
|
for (ui = _using.begin(); ui != _using.end(); ++ui) {
|
||||||
CPPScope *scope = (*ui)->find_scope(name, false);
|
CPPScope *scope = (*ui)->find_scope(name, global_scope, false);
|
||||||
if (scope != nullptr) {
|
if (scope != nullptr) {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recurse && _parent_scope != nullptr) {
|
if (recurse && _parent_scope != nullptr) {
|
||||||
return _parent_scope->find_scope(name);
|
return _parent_scope->find_scope(name, global_scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -87,7 +87,8 @@ public:
|
|||||||
CPPDeclaration::SubstDecl &subst,
|
CPPDeclaration::SubstDecl &subst,
|
||||||
CPPScope *global_scope,
|
CPPScope *global_scope,
|
||||||
bool recurse = true) const;
|
bool recurse = true) const;
|
||||||
CPPScope *find_scope(const string &name, bool recurse = true) const;
|
CPPScope *find_scope(const string &name, CPPScope *global_scope,
|
||||||
|
bool recurse = true) const;
|
||||||
CPPScope *find_scope(const string &name,
|
CPPScope *find_scope(const string &name,
|
||||||
CPPDeclaration::SubstDecl &subst,
|
CPPDeclaration::SubstDecl &subst,
|
||||||
CPPScope *global_scope,
|
CPPScope *global_scope,
|
||||||
|
@ -2267,6 +2267,10 @@ get_type(CPPType *type, bool global) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type->get_subtype() == CPPType::ST_tbd) {
|
||||||
|
type = type->resolve_type(&parser, &parser);
|
||||||
|
}
|
||||||
|
|
||||||
TypeIndex index = 0;
|
TypeIndex index = 0;
|
||||||
|
|
||||||
// First, check to see if it's already there.
|
// First, check to see if it's already there.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user