1.1 --- a/jitcraft/Functions.h Mon Jul 09 22:25:52 2012 -0700
1.2 +++ b/jitcraft/Functions.h Tue Jul 10 02:11:13 2012 -0700
1.3 @@ -67,6 +67,9 @@
1.4 static inline size_t offsetOfType() {
1.5 return offsetof(Function, type_);
1.6 }
1.7 + static inline size_t offsetOfName() {
1.8 + return offsetof(Function, name_);
1.9 + }
1.10 // End GC Descriptor.
1.11
1.12 static inline Function *cast(Object *obj) {
1.13 @@ -75,6 +78,45 @@
1.14 }
1.15 };
1.16
1.17 +// A Native is a function with a very specialized calling convention, intended
1.18 +// for earlier ISourcePawnEngine API compatibility.
1.19 +class Native : public Object
1.20 +{
1.21 + Barriered<Type> type_;
1.22 + Barriered<String> name_;
1.23 + void *function_;
1.24 +
1.25 + public:
1.26 + static Native *New(Zone *zone, Handle<Type> type, Handle<String> name);
1.27 +
1.28 + void *function() {
1.29 + return function_;
1.30 + }
1.31 + Type *type() {
1.32 + return type_;
1.33 + }
1.34 + String *name() {
1.35 + return name_;
1.36 + }
1.37 + void bind(void *function) {
1.38 + function_ = function;
1.39 + }
1.40 +
1.41 + // Begin GC Descriptor.
1.42 + static inline size_t offsetOfType() {
1.43 + return offsetof(Native, type_);
1.44 + }
1.45 + static inline size_t offsetOfName() {
1.46 + return offsetof(Native, name_);
1.47 + }
1.48 + // End GC Descriptor.
1.49 +
1.50 + static inline Native *cast(Object *obj) {
1.51 + assert(!obj || obj->is(MapKind_Native));
1.52 + return reinterpret_cast<Native *>(obj);
1.53 + }
1.54 +};
1.55 +
1.56 }
1.57
1.58 #endif // _include_jitcraft_function_h_