Advertisement

Unable to find interface in namespace

Started by August 16, 2012 01:01 PM
4 comments, last by behc 12 years, 3 months ago
It seems like methods GetInterfaceCount() and GetInterface() are ignoring namespaced interfaces. For example:

psg->SetDefaultNamespace("Base::Control");
psg->RegisterInterface("IComponent");
psg->SetDefaultNamespace("");



//Code pretty much the same code as in the angelscript's game sample
asIObjectType *pt = 0;
bool f = false;
uint otc = pm->GetObjectTypeCount();
for(uint i = 0; i < otc; ++i){
pt = pm->GetObjectTypeByIndex(i);
uint ic = pt->GetInterfaceCount();
for(uint j = 0; j < ic; ++j)
if(strcmp(pt->GetInterface(j)->GetName(),pintfn) == 0){
f = true;
break;
}
}
if(!f)
return false;
//...




class SpectatorControl : Base::Control::IComponent{
SpectatorControl(Actor @t){
@a = t;
}
//...
Actor @a;
};

Probably not a feature? Or am I failing it again..?
I also tried nesting these methods in SetDefaultNamespace(), but it didn't make any difference.
Without namespaces the method above works correctly.
I'll investigate this.

Thanks for the report.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Which version of AngelScript are you using?

There is a bug fix in the latest WIP that I believe is related to your problem. Basically, when inheriting from a class or interface in a different namespace, the compiler would compile without error, but would ignore the base class.

The fix is in revision 1388, that was checked in on August 9th.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Allright, updated to r1394 and it works now if I omit namespaces in the name comparison.
So it's

if(strcmp(pt->GetInterface(j)->GetName(),"IComponent") == 0)

instead of

if(strcmp(pt->GetInterface(j)->GetName(),"Base::Control::IComponent") == 0)

Haven't tested yet, but this may cause problems later since there's probably going to be other namespaces with "IComponent" involved in the same script module. But it's working for now, thanks.
Great. Thanks for confirming that the bug had indeed already been fixed.

The namespace for an object is obtained with asIObjectType::GetNamespace(), so if needed you can compare this too.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

//offtopic, can someone up vote first post, my browser hung and after some random clicking to recover/crash it I unintentionally did down vote. And now I see no means to revert this. Sorry for inconvenience

This topic is closed to new replies.

Advertisement