From what I understand this allow to modify an object prototype at runtime and is neko specific because "prototype" is null when targeting php.
What I'm not sure about is "Will new instances of this prototype be affected without?" my guess is yes. (Ok I could write a simple test code to be sure)
Anyway I found solutions that are target specific using the Reflection API.
This is my first attempt writing macros, so I think it's normal. I used macros to provide a part of solution to workaround the prototype trick.
BTW haxe macros are awesome =)
* Static init in php
This is the unsolved thing. I faced that trying the @:relation thing. In php Static members of a class will be initialized when you "require_once" the class file. This cause an initialization list to be empty when it should be populated. (ie sys.db.Manager::init_list).
As a temporary workaround, the first thing I do in the entry point is to call the constructors of each of my spod objects.
Maybe I could find a way to automatically "require_once" the needed stuff but I guess this issue should be addressed to Franco since it appears to be a more general one and not only a spod_macro_php one.
I'm attaching a patch, just for review, if you mind, I'll be glad.
> Hi Guys,
> I almost made work the spod_macro thing targeting php.
> I'm sharing with you to get your advises which could really help.
> My struggles:
> * The use of what I'll call the "prototype trick".
> class_proto.prototype._manager = this;
> untyped __dollar__objsetproto(x,class_proto.prototype);
You have to look at how the current php.db.Manager handle this.
> Le 29/08/2011 15:44, Julien CASTETS a écrit :
>> Hi Guys,
>> I almost made work the spod_macro thing targeting php.
> I've commited changes, please test with it.
> For prototypes, it's now using a single initialization in the
> For relations, it's now generating two methods : get_xxx and set_xxx
> that will call the target relation manager __get and __set methods.
I've also added support for blob mapping to haxe.io.Bytes.
In php/_std/sys/db/Mysql.hx (convert) :
case "blob": return haxe.io.Bytes.ofData(v);
Franco, could you confirm it's the right way to do it ?