Advertisement

Why does asIObjectType not store their typeid?

Started by May 26, 2009 04:03 PM
7 comments, last by Wavesonics 15 years, 6 months ago
As the title says, it seems like it's be nice not to have to create an object to get it's type id. I want to just be able to pull the object type and get it from that.
==============================
A Developers Blog | Dark Rock Studios - My Site
I can't answer the why, but you don't need to create an object to get the type ID. You can use asIScriptEngine::GetTypeIdByDecl() or asIScriptModule::GetTypeIdByDecl() to get a type ID from the type name.
Advertisement
hhhmm... problem is, I'm pulling these classes from a script by the interface they implement, so I don't know what their declaration looks like.
==============================
A Developers Blog | Dark Rock Studios - My Site
The only reason is that nobody asked for it before :)

However, until I update the interface you should follow SiCrane's advice. You only need the name of the type, i.e.

module->GetTypeIdByDecl("MyClass");

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

If you already have the asIObjectType * but not the name, then you can use asIObjectType::GetName().
oh i didnt realize just the name would suffice, sounds great :)
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
Ah crap, so my class inherits from an interface, so it looks like this:
Quote:
class A : B {
}


So just passing "A" to:
GetTypeIdByDecl()

does not turn it up, instead I need to pass:
"A : B"

A few suggestions, any or all of them would be nice additions to make things like this smoother:

1) Store typeId in asIObjectType
2) Allow type look up by name rather than decl (might not possible?)
3) Provide a "getDecl" method in addition to the "getName" method

==============================
A Developers Blog | Dark Rock Studios - My Site
"A : B" shouldn't be necessary, in fact it would be an invalid declaration. Seems like you've hit another bug. I'll need to verify this.

You should know that the classes declared in the scripts are only visible to the GetTypeIdByDecl in the module. GetTypeIdByDecl in the engine will only return type ids for the application registered types.



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

Ah, yep that it :)

I was getting a false positive w\ the last method I presented, sorry.
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement