Referencing and casting objects of known type?

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Sat Sep 20, 2008 12:39 pm

Hello.
The problem's: how to get reference to data buffer of Binary Object?
1. How to recognize that PARAM_OBJECT-ed param was a Binary Object (and not for example Sprite Object).
2. Is there any reflection mechanysm allowing to access given CRunObject*'s Fields/Properties/Methods?

I've noticed that there's GetData and CallFunction methods prepared at runtime.cpp. If they are a way to do something like reflection can, still, there's no use of them if other objects are closed source nor have been documented :(.

And on the other hand some bugs with Binary Object:
[size=70:2r07ykla]Binary Object has one uncallable expression "Get Cursor Position" (due to these space bar in name ><).

Next thing is setting Cursor Position:
[code:2r07ykla]System: Always (every tick)
> BinarySet cursor position to 0
System: For "i" from 0 to 999999
> BinaryWrite unsigned integer 0[/code:2r07ykla]
This drains whole memory. On the other hand, "Set Cursor Position" appears to be setting cursor for reading values correctly.[/size:2r07ykla]
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Sun Sep 21, 2008 3:09 pm

[quote="BROO":31gzq68k]1. How to recognize that PARAM_OBJECT-ed param was a Binary Object (and not for example Sprite Object).[/quote:31gzq68k]
Generally I think you'd have to put a magic number in the target object's CRunObject, and check that that value is expected. I think I can come up with a better system in future though, using the plugin name (which isn't currently available at runtime).

[quote:31gzq68k]2. Is there any reflection mechanysm allowing to access given CRunObject*'s Fields/Properties/Methods?[/quote:31gzq68k]
As you mention, GetData and CallFunction can be implemented to return data like the binary object's buffer - however, the Binary object doesn't have any such implementation yet, I don't think. If you ask Rich for the source to it, I'm sure he can send it to you. Also, if you have the Binary object's CRunObject definition (copy and paste its ExtObject from Main.h and rename it to BinaryObject so it doesn't conflict with your object), you can then cast a CRunObject to a BinaryObject, and directly access its member variables.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Thu Sep 25, 2008 1:42 am

Yes,the access to Binary's ExtObject seems easiest. Let me know if you want it.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests