Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 B_old   Members   -  Reputation: 668

Like
0Likes
Like

Posted 26 May 2014 - 03:32 PM

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?



Sponsor:

#2 iraxef   Members   -  Reputation: 400

Like
1Likes
Like

Posted 26 May 2014 - 03:51 PM

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@



#3 Andreas Jonsson   Moderators   -  Reputation: 3455

Like
0Likes
Like

Posted 26 May 2014 - 03:53 PM

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?


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

#4 B_old   Members   -  Reputation: 668

Like
0Likes
Like

Posted 26 May 2014 - 04:03 PM

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."



#5 Andreas Jonsson   Moderators   -  Reputation: 3455

Like
1Likes
Like

Posted 26 May 2014 - 04:07 PM

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).


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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS