Jump to content
  • Advertisement
Sign in to follow this  
B_old

Registering an uninstanciable reference type: Identifier 'XXX' is not a data type

This topic is 1660 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a C++ type that I don't want to instantiate from scripts and only use as handles, preferably by passing it to the constructor for script classes that should be able to interact with it.

 

I followed the documentation and used asOBJ_NOCOUNT and did not provide a factory behavior. Actually, this is all I did (never mind the wrapper):

engine.register_object_type("Scene", 0, asOBJ_REF | asOBJ_NOCOUNT);

engine.register_object_method("Scene", "const string &name() const", asMETHODPR(scene::Scene, name, () const, const std::string&));

When I try to load a script that looks like this:

class Scene_test
{
	Scene_test(Scene@ scene)
	{
		scene_ = scene;
	}

	void on_scene_loaded()
	{
		print("Hello World");
	}

	Scene@ scene_;
};

I get an error stating "Identifier 'Scene' is not a data type".

 

Any idea what I'm missing?

Share this post


Link to post
Share on other sites
Advertisement

You haven't used SetDefaultNamespace() have you?

 

I also have a bunch of reference types which I don't want script to be able to create, only reference existing(-in-C++) ones. I register them in the same way as you. However, due to the namespace, I have to refer to them in script as:

 

mynamespace::Scene@

Share this post


Link to post
Share on other sites

I don't see any problem in your code. 

 

For what line is the code indicating this error? For the constructor declaration or the class member?

Share this post


Link to post
Share on other sites

Oh, namespace was indeed a problem. Sorry. The default namespace was set to "scene", but writing scene::Scene in the script did not change the error message. As a test I changed the namespace to "", after which I get "There is no copy operator for the type 'Scene' available."

Share this post


Link to post
Share on other sites

The copy operator error is because you're doing a value assign in the constructor. You need to prefix the left hand expression with @ to indicate a handle assign (i.e. replacement of the reference).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!