X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fnasal%2Fmisc.c;h=5a531d536d7d2a0cd0bccfb1c92a2323c8cbeb18;hb=e5acc3f0482caea19e9c7873271758153d56aef8;hp=8640aea09769c2b90bc5c17f796cb8d7a7a5058f;hpb=dd1ea541ecc4403bcea2ca8c60c03971d1f4338f;p=simgear.git diff --git a/simgear/nasal/misc.c b/simgear/nasal/misc.c index 8640aea0..5a531d53 100644 --- a/simgear/nasal/misc.c +++ b/simgear/nasal/misc.c @@ -107,6 +107,24 @@ naRef naNewCCode(struct Context* c, naCFunction fptr) { naRef r = naNew(c, T_CCODE); PTR(r).ccode->fptr = fptr; + PTR(r).ccode->fptru = 0; + return r; +} + +naRef naNewCCodeU(struct Context* c, naCFunctionU fptr, void* user_data) +{ + return naNewCCodeUD(c, fptr, user_data, 0); +} + +naRef naNewCCodeUD( struct Context* c, + naCFunctionU fptr, + void* user_data, + void (*destroy)(void*) ) +{ + naRef r = naNew(c, T_CCODE); + PTR(r).ccode->fptru = fptr; + PTR(r).ccode->user_data = user_data; + PTR(r).ccode->destroy = destroy; return r; } @@ -121,12 +139,25 @@ naRef naNewFunc(struct Context* c, naRef code) naRef naNewGhost(naContext c, naGhostType* type, void* ptr) { - naRef ghost = naNew(c, T_GHOST); + naRef ghost; + // ensure 'simple' ghost users don't see garbage for these fields + type->get_member = 0; + type->set_member = 0; + + ghost = naNew(c, T_GHOST); PTR(ghost).ghost->gtype = type; PTR(ghost).ghost->ptr = ptr; return ghost; } +naRef naNewGhost2(naContext c, naGhostType* t, void* ptr) +{ + naRef ghost = naNew(c, T_GHOST); + PTR(ghost).ghost->gtype = t; + PTR(ghost).ghost->ptr = ptr; + return ghost; +} + naGhostType* naGhost_type(naRef ghost) { if(!IS_GHOST(ghost)) return 0; @@ -213,6 +244,7 @@ int naIsFunc(naRef r) { return IS_FUNC(r); } int naIsCode(naRef r) { return IS_CODE(r); } int naIsCCode(naRef r) { return IS_CCODE(r); } int naIsGhost(naRef r) { return IS_GHOST(r); } +int naIsIdentical(naRef l, naRef r) { return IDENTICAL(l, r); } void naSetUserData(naContext c, void* p) { c->userData = p; } void* naGetUserData(naContext c)