Byte Ptr To Object

BlitzMax Forums/BlitzMax Programming/Byte Ptr To Object

beanage(Posted 2009) [#1]
I was wondering if this was possible; converting from a byte pointer to an object? Somehow accidently I once saw the debugger showing an misdirected byte pointer of mine as an object, and.. that made me curious.

[Edit] OK do NOT say anything I searched the forum on this.. extremely interesting.. still I _am_ curious how the debugger just linked the byte ptr to the object (the pointer was to point to a flag, but maxIDE made an expandable TGraphicsMode Object node outa it!)


ImaginaryHuman(Posted 2009) [#2]
I think there is some hacky way to do it whereby you can convert an object into a pointer and vice versa, but it's kind of like going behind the scenes, behind BRL's API, so I'm not sure if you can trust that it will work in future. I don't recall how to do it... there is a thread somewhere.


beanage(Posted 2009) [#3]
Yea it looks hacky.. actually.. is the integer returned by ObjectToHandle() always the pointer?


Tommo(Posted 2009) [#4]

is the integer returned by ObjectToHandle() always the pointer?



No, it's just a index of a object table.


ImaginaryHuman(Posted 2009) [#5]
Yeah it returns like a key in a TMap or something, which is a tree of some kind.


beanage(Posted 2009) [#6]
Isnt anyone here who may know how the debugger could posssibly convert from a misdirected byte pointer to an object? I do not want to dig through the IDE code to find this information.

Mmmmhgnah.. how is the binary object accessing handled in the current blitzMax lua implementations? Just with reflection? My problem is simpel .. everyone says "reflection is slow" and "beware of Handles being slow".. a scripting lang based on *both* seems like slow squared to me. I will have to find my workaround (<= one of the most sweet English words I know, there is no real adequate in German and I love it :).

[Edit:] Oh I forgot to mention that scripting system thing previously.. sry.


N(Posted 2009) [#7]
how is the binary object accessing handled in the current blitzMax lua implementations?
I use virtual method tables and directly access fields. Reflection is too slow for method calls (not to mention it's limited in the number of arguments you can use) and doesn't really handle fields very nicely - probably due to the fact that everything that isn't an object is converted to a string. I also don't use handles.


beanage(Posted 2009) [#8]
Glue Code. *Deep breath*

I have.. kind of a personal objection against this.. in a previous live of mine I used to write this per hand, and since this very day I hated it -- understandably. I backed this hate up by telling myself using glue code would collide with the DRY- principle anyway, and theres always a workaround etc.
A highly impractical opinion as I begin to realize.. glue code (especially generated, which I previously did not consider in the first place, unfortunately) seems to be the ultimate relatively _simple_ way.

I will rethink my opinion - as a matter of practicability..
taking a closer look at LuGI motivated me :)