Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Config groups and object property accessors


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 iforce2d   Members   -  Reputation: 222

Like
0Likes
Like

Posted 27 December 2012 - 08:24 AM

After creating an object type with RegisterObjectType, I want to let the users of my program dynamically add and remove properties for the object type, and also let them access the properties with the convenient .xxx style of coding.

 

So I use RegisterObjectMethod to create the necessary get_xxx and set_xxx functions, and everything works great. To make this easily reversible later, I enclose it in a BeginConfigGroup/EndConfigGroup.

 

The trouble is, using RemoveConfigGroup after this does not seem to remove these object methods. No errors or other problems occur, but the get_xxx/set_xxx functions remain as if they had not been removed, and can happily be used still.

 

The same RegisterObjectMethod procedure can then be repeated, also with no errors, but this seems to cause a duplicate of the functions to be registered, so that scripts fail to compile with the message "Found multiple get accessors for property 'xxx'"

 

Just wondering if this is the expected behavior. And if so, is there a better way to do what I'm trying to do... thanks!



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3445

Like
0Likes
Like

Posted 27 December 2012 - 09:40 AM

It's currently not possible to register only part of an object type in a separate configuration group. Methods, properties, and behaviours will be placed in the same group that was used when RegisterObjectType() was called. To do what you want you need to put the full object type in the configuration group, and then re-register it as a whole when exchanging the properties.

 

Unfortunately this is not clear in the manual. I'll have to update the manual to make this clear.

 

I'll also add to my to-do list to investigate the possibility to add the support for registering parts of types in different modules. 

 

 

When registering methods AngelScript checks for duplicates. The problem here is that you're registering the virtual property with a different type, so it will be seen as a method overload rather than a duplicate method. The get_ method should have given an error though, as it is not possible to overload a method with just a difference in the return type.


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

#3 iforce2d   Members   -  Reputation: 222

Like
0Likes
Like

Posted 29 December 2012 - 08:40 AM

Thanks Andreas.

 

After a while I came to realize that I need separate script engines. Many object types refer to each other so they need to be in the same config group, which cascaded into basically replacing everything anyway. Another reason is that I want to keep these property settings separate for different documents in the workspace, even when the object type names are the same. For example the user could have two documents open, and in one of them the 'body' class could be given a 'xxx' property, without giving that property to the 'body' class in the other document.

 

Plus, coding-wise it was somewhat easier and less error-prone to simply drop everything and create it afresh. Luckily I don't need to keep any persistent state (global variables etc) in the script engine itself, so I could do this :)

 

Keep up the good work!



#4 Andreas Jonsson   Moderators   -  Reputation: 3445

Like
0Likes
Like

Posted 29 December 2012 - 11:08 AM

Have you looked in to access masks?

 

With these you'll be able to use a single engine instance and expose different interfaces to different scripts. I'm not sure this is exactly what you're trying to do, but if you haven't seen this feature yet, it may be worth looking in to.


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

#5 iforce2d   Members   -  Reputation: 222

Like
0Likes
Like

Posted 29 December 2012 - 10:52 PM

I did notice the access mask feature, but I did not look into them much because using separate engines worked ok and did not require any managing of masks for each document that the user might open.






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