Referencing and casting objects of known type?

This forum is currently in read-only mode.
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • 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:

    Binary Object has one uncallable expression "Get Cursor Position" (due to these space bar in name ><). Next thing is setting Cursor Position: 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 1. How to recognize that PARAM_OBJECT-ed param was a Binary Object (and not for example Sprite Object).

    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?

    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.

  • Yes,the access to Binary's ExtObject seems easiest. Let me know if you want it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)