Re: context pointer always NULL for "c-tor" when created w/ Reflex::ClassBuilder::AddFunctionMember ?

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Tue, 17 May 2011 11:04:10 +0200


Hi Sebastien,

I don't know how you bind it to Go. How does the constructor get invoked? I.e. is Reflex::FunctionMember::Invoke() really called? Can you send the backtrace?

Cheers, Axel.

Sebastien Binet wrote on 05/17/2011 10:46 AM:
>
> hi there,
>
> (still playing with Go)
> I am seeing something rather strange:
>
> say I have these structs:
>
> /** edm **/
> typedef struct {
> double E;
> double T;
> } Det;
>
> typedef struct {
> Det A;
> Det B;
> } Event;
>
> size_t g_sz_det = sizeof(Det);
> size_t g_sz_evt = sizeof(Event);
>
>
> and the corresponding c-tor stub functions:
> /* stub functions for Event */
> void ctor_Event(void *retaddr, void *mem, void* args, void* ctx)
> {
> fprintf(stderr, "::ctor-fct[Event] [%p] [%p] [%p] [%p]\n", retaddr, mem, args, ctx);
> void* dummy = 0;
> if (retaddr) *(void**)retaddr = (Event*)realloc(mem, sizeof(Event));
> else dummy = (Event*)realloc(mem, sizeof(Event));
> if (dummy) {}
> }
>
> /* etc... */
>
> the ctor_Event stub function is attached to the Event Reflex::Type like
> so:
> Reflex::ClassBuilder cb = ...;
> Reflex::Type ty_ctor = Reflex::FunctionTypeBuilder(ty_void);
> void *ctx = &g_sz_evt;
> cb.AddFunctionMember(ty_ctor, "Event", &ctor_Event, ctx, NULL,
> Reflex::PUBLIC|Reflex::CONSTRUCTOR);
>
>
> so far so good, and when iterating over the function members of the
> "Event" type I do see:
> :: Evt-size: 32 32
> :: Evt-mbrs: 2
> :: Evt-type: 117
> :: Evt-name: Event
> :: Evt-id: 0x11c28d0
> :: Evt-fct-mbrs: 3
> :: fct-mbr[0][Event] - ctx [0x6033b8] stub-fct[0x401960]
> :: fct-mbr[1][IsA] - ctx [0x11c3910] stub-fct[0x7f9892ed2290]
> :: fct-mbr[2][ShowMembers] - ctx [0x11c3910] stub-fct[0x7f9892ed1d00]
>
> ie: the correct address for both the context pointer and the stub
> function (calling resp. Member::Stubcontext() and Member::Stubfunction())
>
> but when the ctor_Event function is invoked:
> ::ctor-fct[Event] [(nil)] [0x13b3500] [0x11c85d0] [(nil)]
>
> the ctx pointer is always NULL, eventhough FunctionMember::Invoke does
> pass the fStubCtx to fStubFP:
>
> // parameters need more checking FIXME
> fStubFP(retaddr, mem, paramList, fStubCtx);
>
>
> (I'd like to use that context pointer to pass a few extra informations
> needed for the proper initialization of the Go runtime when
> instantiating the struct instance...)
>
> am I doing something wrong ?
>
> -s
>
Received on Tue May 17 2011 - 11:04:14 CEST

This archive was generated by hypermail 2.2.0 : Tue May 17 2011 - 17:50:01 CEST