diff -r b765a6383849 -r b40b0e18a918 jitcraft/Functions.h --- a/jitcraft/Functions.h Mon Jul 09 22:25:52 2012 -0700 +++ b/jitcraft/Functions.h Tue Jul 10 02:11:13 2012 -0700 @@ -67,6 +67,9 @@ static inline size_t offsetOfType() { return offsetof(Function, type_); } + static inline size_t offsetOfName() { + return offsetof(Function, name_); + } // End GC Descriptor. static inline Function *cast(Object *obj) { @@ -75,6 +78,45 @@ } }; +// A Native is a function with a very specialized calling convention, intended +// for earlier ISourcePawnEngine API compatibility. +class Native : public Object +{ + Barriered type_; + Barriered name_; + void *function_; + + public: + static Native *New(Zone *zone, Handle type, Handle name); + + void *function() { + return function_; + } + Type *type() { + return type_; + } + String *name() { + return name_; + } + void bind(void *function) { + function_ = function; + } + + // Begin GC Descriptor. + static inline size_t offsetOfType() { + return offsetof(Native, type_); + } + static inline size_t offsetOfName() { + return offsetof(Native, name_); + } + // End GC Descriptor. + + static inline Native *cast(Object *obj) { + assert(!obj || obj->is(MapKind_Native)); + return reinterpret_cast(obj); + } +}; + } #endif // _include_jitcraft_function_h_