diff --git a/Examples/javascript/constant/Makefile b/Examples/javascript/constant/Makefile index 1ac61ec6b..bebb1f302 100755 --- a/Examples/javascript/constant/Makefile +++ b/Examples/javascript/constant/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig JAVASCRIPT_EXE = $(TOP)/../Tools/javascript/javascript -CXXSRCS = example.cpp +CXXSRCS = JSCXXSRCS = $(TOP)/../Tools/javascript/javascript.cxx JS_SCRIPT = runme.js TARGET = example @@ -10,7 +10,7 @@ SWIGOPT = -I$(TOP)/../Lib/javascript -I$(TOP)/../Lib/javascript/jsc all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_cpp + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript clean:: $(MAKE) -f $(TOP)/Makefile javascript_clean diff --git a/Examples/javascript/pointer/typemaps.i b/Examples/javascript/pointer/typemaps.i new file mode 100644 index 000000000..e69de29bb diff --git a/Examples/javascript/simple/Makefile b/Examples/javascript/simple/Makefile index 1ac61ec6b..4fbfa2802 100755 --- a/Examples/javascript/simple/Makefile +++ b/Examples/javascript/simple/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig JAVASCRIPT_EXE = $(TOP)/../Tools/javascript/javascript -CXXSRCS = example.cpp +SRCS = example.c JSCXXSRCS = $(TOP)/../Tools/javascript/javascript.cxx JS_SCRIPT = runme.js TARGET = example @@ -9,8 +9,8 @@ INTERFACE = example.i SWIGOPT = -I$(TOP)/../Lib/javascript -I$(TOP)/../Lib/javascript/jsc all:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_cpp + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript clean:: $(MAKE) -f $(TOP)/Makefile javascript_clean diff --git a/Examples/javascript/simple/example.cpp b/Examples/javascript/simple/example.c old mode 100755 new mode 100644 similarity index 70% rename from Examples/javascript/simple/example.cpp rename to Examples/javascript/simple/example.c index e7d3b0f11..1c2af789c --- a/Examples/javascript/simple/example.cpp +++ b/Examples/javascript/simple/example.c @@ -1,9 +1,3 @@ -#include -#include -#include -#include -using namespace std; - /* File : example.c */ /* A global variable */ @@ -22,7 +16,3 @@ int gcd(int x, int y) { } - - - - diff --git a/Examples/javascript/simple/example.i b/Examples/javascript/simple/example.i old mode 100755 new mode 100644 index 7c345964c..24093b9bf --- a/Examples/javascript/simple/example.i +++ b/Examples/javascript/simple/example.i @@ -1,15 +1,7 @@ /* File : example.i */ %module example -%include "std_string.i" - %inline %{ extern int gcd(int x, int y); -extern float gcd(float x, float y); -extern char* helloString(char* s); -extern void delete_helloString(char *newstr); -extern std::string helloString(std::string s); -extern void bar(int x, int y = 3, int z = 4); - extern double Foo; %} diff --git a/Examples/javascript/variables/Makefile b/Examples/javascript/variables/Makefile index 1ac61ec6b..4fbfa2802 100755 --- a/Examples/javascript/variables/Makefile +++ b/Examples/javascript/variables/Makefile @@ -1,7 +1,7 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig JAVASCRIPT_EXE = $(TOP)/../Tools/javascript/javascript -CXXSRCS = example.cpp +SRCS = example.c JSCXXSRCS = $(TOP)/../Tools/javascript/javascript.cxx JS_SCRIPT = runme.js TARGET = example @@ -9,8 +9,8 @@ INTERFACE = example.i SWIGOPT = -I$(TOP)/../Lib/javascript -I$(TOP)/../Lib/javascript/jsc all:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_cpp + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript clean:: $(MAKE) -f $(TOP)/Makefile javascript_clean diff --git a/Examples/javascript/variables/example_wrap.c b/Examples/javascript/variables/example_wrap.c new file mode 100644 index 000000000..7fc9567cd --- /dev/null +++ b/Examples/javascript/variables/example_wrap.c @@ -0,0 +1,2593 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.6 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +#define SWIG_AsCharPtrAndSize(val, cptr, psize, alloc) SWIG_JSC_AsCharPtrAndSize(context, val, cptr, psize, alloc) +#define SWIG_FromCharPtrAndSize(cptr, size) SWIG_JSC_FromCharPtrAndSize(context, cptr, size) +#define SWIG_FromCharPtr(cptr) SWIG_JSC_FromCharPtr(context, cptr) + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +#include +#include +#include +#include +#include +#include + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg) +#define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg) +#define SWIG_fail goto fail + +#define SWIG_JSC_FROM_DECL_ARGS(arg1) (JSContextRef context, arg1) +#define SWIG_JSC_FROM_CALL_ARGS(arg1) (context, arg1) +#define SWIG_JSC_AS_DECL_ARGS(arg1, arg2) (JSContextRef context, arg1, arg2) +#define SWIG_JSC_AS_CALL_ARGS(arg1, arg2) (context, arg1, arg2) + + +typedef struct { + bool swigCMemOwn; + void *swigCObject; + swig_type_info *info; +}SWIG_PRV_DATA; + + + +void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) { + JSStringRef message = JSStringCreateWithUTF8CString(type); + *exception = JSValueMakeString(context, message); + JSStringRelease(message); +} + +void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) { + SWIG_Javascript_Raise(context, exception, msg); +} + + + + +JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + JSValueRef jsresult; + + JSObjectRef obj = JSValueToObject(context, thisObject, NULL); + SWIG_PRV_DATA *cdata = (SWIG_PRV_DATA *) JSObjectGetPrivate(obj); + + cdata->swigCMemOwn = false; + + jsresult = JSValueMakeUndefined(context); + return jsresult; +} + +JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + JSValueRef jsresult; + long result; + + JSObjectRef obj = JSValueToObject(context, thisObject, NULL); + SWIG_PRV_DATA *cdata = (SWIG_PRV_DATA*) JSObjectGetPrivate(obj); + + result = (long) cdata->swigCObject; + jsresult = JSValueMakeNumber(context, result); + + return jsresult; +} + +JSStaticValue _SwigObject_values[] = { + { + 0, 0, 0, 0 + } +}; + +JSStaticFunction _SwigObject_functions[] = { + { + "disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone + },{ + "getCPtr",_wrap_SwigObject_getCPtr, kJSPropertyAttributeNone + }, + { + 0, 0, 0 + } +}; + +JSClassDefinition _SwigObject_objectDefinition; + +JSClassRef _SwigObject_classRef; + + + +int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) { + SWIG_PRV_DATA *cdata = (SWIG_PRV_DATA *) JSObjectGetPrivate(objRef); + if(cdata == NULL) { + return SWIG_ERROR; + } + if(cdata->info != info) { + bool type_valid = false; + swig_cast_info *t = info->cast; + while(t != NULL) { + if(t->type == cdata->info) { + type_valid = true; + break; + } + t = t->next; + } + if(!type_valid) { + return SWIG_TypeError; + } + } + + *ptr = cdata->swigCObject; + + if(flags & SWIG_POINTER_DISOWN) { + cdata->swigCMemOwn = false; + } + + return SWIG_OK; +} + +int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) { + if(!JSValueIsObject(context, valRef)) { + return SWIG_TypeError; + } + + JSObjectRef objRef = JSValueToObject(context, valRef, NULL); + if(objRef == NULL) { + return SWIG_ERROR; + } + + return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags); +} + +JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) { + + JSClassRef classRef; + if(info->clientdata == NULL) { + classRef = _SwigObject_classRef; + } else { + classRef = (JSClassRef) info->clientdata; + } + + JSObjectRef result = JSObjectMake(context, classRef, NULL); + + SWIG_PRV_DATA* cdata = (SWIG_PRV_DATA*) malloc(sizeof(SWIG_PRV_DATA)); + cdata->swigCObject = ptr; + cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; + cdata->info = info; + + JSObjectSetPrivate(result, cdata); + + return result; +} + +#define SWIG_ConvertPtr(obj, ptr, info, flags) SWIG_JSC_ConvertPtr(context, obj, ptr, info, flags) +#define SWIG_NewPointerObj(ptr, info, flags) SWIG_JSC_NewPointerObj(context, ptr, info, flags) + +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_JSC_ConvertInstancePtr(context, obj, pptr, type, flags) +#define SWIG_NewInstanceObj(thisvalue, type, flags) SWIG_JSC_NewPointerObj(context, thisvalue, type, flags) + + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_Point swig_types[0] +#define SWIGTYPE_p_char swig_types[1] +#define SWIGTYPE_p_int swig_types[2] +static swig_type_info *swig_types[4]; +static swig_module_info swig_module = {swig_types, 3, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + + + +#define SWIGVERSION 0x020006 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "example.h" + + +extern int ivar; +extern short svar; +extern long lvar; +extern unsigned int uivar; +extern unsigned short usvar; +extern unsigned long ulvar; +extern signed char scvar; +extern unsigned char ucvar; +extern char cvar; +extern float fvar; +extern double dvar; +extern char *strvar; +extern const char cstrvar[]; +extern int *iptrvar; +extern char name[256]; + +extern Point *ptptr; +extern Point pt; + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, double *val) +{ + if(!JSValueIsNumber(context, obj)) { + return SWIG_TypeError; + } + if(val) *val = JSValueToNumber(context, obj, NULL); + + return SWIG_OK; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, long* val) +{ + if (!JSValueIsNumber(context, obj)) { + return SWIG_TypeError; + } + if(val) *val = (long) JSValueToNumber(context, obj, NULL); + + return SWIG_OK; +} + + +SWIGINTERN int +SWIG_AsVal_int SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, int *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef + SWIG_From_int SWIG_JSC_FROM_DECL_ARGS(int value) +{ + return JSValueMakeNumber(context, value); +} + + +SWIGINTERN int +SWIG_AsVal_short SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, short *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < SHRT_MIN || v > SHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (short)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef + SWIG_From_long SWIG_JSC_FROM_DECL_ARGS(long value) +{ + return JSValueMakeNumber(context, value); +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_short SWIG_JSC_FROM_DECL_ARGS(short value) +{ + return SWIG_From_long SWIG_JSC_FROM_CALL_ARGS(value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, unsigned long *val) +{ + if(!JSValueIsNumber(context, obj)) { + return SWIG_TypeError; + } + + long longVal = (long) JSValueToNumber(context, obj, NULL); + + if(longVal < 0) { + return SWIG_OverflowError; + } + + if(val) *val = longVal; + + return SWIG_OK; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_unsigned_SS_long SWIG_JSC_FROM_DECL_ARGS(unsigned long value) +{ + return (value > LONG_MAX) ? + JSValueMakeNumber(context, value) : JSValueMakeNumber(context, (long)(value)); +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_unsigned_SS_int SWIG_JSC_FROM_DECL_ARGS(unsigned int value) +{ + return SWIG_From_unsigned_SS_long SWIG_JSC_FROM_CALL_ARGS(value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_short SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, unsigned short *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v > USHRT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned short)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_unsigned_SS_short SWIG_JSC_FROM_DECL_ARGS(unsigned short value) +{ + return SWIG_From_unsigned_SS_long SWIG_JSC_FROM_CALL_ARGS(value); +} + + +SWIGINTERN int +SWIG_AsVal_signed_SS_char SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, signed char *val) +{ + long v; + int res = SWIG_AsVal_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < SCHAR_MIN || v > SCHAR_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (signed char)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_signed_SS_char SWIG_JSC_FROM_DECL_ARGS(signed char value) +{ + return SWIG_From_long SWIG_JSC_FROM_CALL_ARGS(value); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_char SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, unsigned char *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UCHAR_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned char)(v); + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_unsigned_SS_char SWIG_JSC_FROM_DECL_ARGS(unsigned char value) +{ + return SWIG_From_unsigned_SS_long SWIG_JSC_FROM_CALL_ARGS(value); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_JSC_AsCharPtrAndSize(JSContextRef context, JSValueRef valRef, char** cptr, size_t* psize, int *alloc) +{ + if(JSValueIsString(context, valRef)) { + JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL); + size_t len = JSStringGetMaximumUTF8CStringSize(js_str); + size_t abs_len = JSStringGetLength(js_str); + char* cstr = (char*) malloc(len * sizeof(char)); + JSStringGetUTF8CString(js_str, cstr, len); + + if(alloc) *alloc = SWIG_NEWOBJ; + if(psize) *psize = abs_len + 1; + if(cptr) *cptr = cstr; + + return SWIG_OK; + } else { + if(JSValueIsObject(context, valRef)) { + JSObjectRef obj = JSValueToObject(context, valRef, NULL); + // try if the object is a wrapped char[] + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + return SWIG_TypeError; + } else { + return SWIG_TypeError; + } + } +} + + +SWIGINTERN int +SWIG_JSC_AsCharArray(JSContextRef context, JSValueRef obj, char *val, size_t size) +{ + char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ; + int res = SWIG_JSC_AsCharPtrAndSize(context, obj, &cptr, &csize, &alloc); + if (SWIG_IsOK(res)) { + if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize; + if (csize <= size) { + if (val) { + if (csize) memcpy(val, cptr, csize*sizeof(char)); + if (csize < size) memset(val + csize, 0, (size - csize)*sizeof(char)); + } + if (alloc == SWIG_NEWOBJ) { + free((char*)cptr); + res = SWIG_DelNewMask(res); + } + return res; + } + if (alloc == SWIG_NEWOBJ) free((char*)cptr); + } + return SWIG_TypeError; +} + + + + +SWIGINTERN int +SWIG_AsVal_char SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, char *val) +{ + int res = SWIG_JSC_AsCharArray(context, obj, val, 1); + if (!SWIG_IsOK(res)) { + long v; + res = SWIG_AddCast(SWIG_AsVal_long SWIG_JSC_AS_CALL_ARGS(obj, &v)); + if (SWIG_IsOK(res)) { + if ((CHAR_MIN <= v) && (v <= CHAR_MAX)) { + if (val) *val = (char)(v); + } else { + res = SWIG_OverflowError; + } + } + } + return res; +} + + +SWIGINTERNINLINE JSValueRef +SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + // TODO: handle extra long strings + //swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + //return pchar_descriptor ? + // SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); + return JSValueMakeUndefined(context); + } else { + JSStringRef jsstring = JSStringCreateWithUTF8CString(carray); + JSValueRef result = JSValueMakeString(context, jsstring); + JSStringRelease(jsstring); + return result; + } + } else { + return JSValueMakeUndefined(context); + } +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_char SWIG_JSC_FROM_DECL_ARGS(char c) +{ + return SWIG_JSC_FromCharPtrAndSize(context, &c,1); +} + + +SWIGINTERN int +SWIG_AsVal_float SWIG_JSC_AS_DECL_ARGS(JSValueRef obj, float *val) +{ + double v; + int res = SWIG_AsVal_double SWIG_JSC_AS_CALL_ARGS(obj, &v); + if (SWIG_IsOK(res)) { + if ((v < -FLT_MAX || v > FLT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (float)(v); + } + } + return res; +} + + +SWIGINTERN JSValueRef +SWIG_From_double SWIG_JSC_FROM_DECL_ARGS (double val) +{ + return JSValueMakeNumber(context, val); +} + + +SWIGINTERNINLINE JSValueRef +SWIG_From_float SWIG_JSC_FROM_DECL_ARGS(float value) +{ + return SWIG_From_double SWIG_JSC_FROM_CALL_ARGS(value); +} + + + + + +SWIGINTERNINLINE JSValueRef +SWIG_JSC_FromCharPtr(JSContextRef context, const char *cptr) +{ + return SWIG_JSC_FromCharPtrAndSize(context, cptr, (cptr ? strlen(cptr) : 0)); +} + + +extern int status; +extern char path[256]; + + +extern void print_vars(); +extern int *new_int(int value); +extern Point *new_Point(int x, int y); +extern char *Point_print(Point *p); +extern void pt_print(); + + + + +bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject, + const char* className, + JSClassDefinition* definition) { + + JSStringRef js_className = JSStringCreateWithUTF8CString(className); + JSObjectRef classObject = JSObjectMake(context, JSClassCreate(definition), NULL); + JSObjectSetProperty(context, parentObject, + js_className, classObject, + kJSPropertyAttributeNone, NULL); + JSStringRelease(js_className); + + return true; +} + +bool JS_registerNamespace(JSGlobalContextRef context, + JSObjectRef namespaceObj, JSObjectRef parentNamespace, + const char* name) +{ + JSStringRef js_name = JSStringCreateWithUTF8CString(name); + JSObjectSetProperty(context, parentNamespace, + js_name, namespaceObj, + kJSPropertyAttributeNone, NULL); + JSStringRelease(js_name); + + return true; +} + + +bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object, + const char* functionName, JSObjectCallAsFunctionCallback callback) +{ + JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName); + JSObjectSetProperty(context, object, js_functionName, + JSObjectMakeFunctionWithCallback(context, js_functionName, callback), + kJSPropertyAttributeNone, NULL); + JSStringRelease(js_functionName); + return true; +} + +bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + char buffer[256]; + char msg[512]; + int res; + + JSStringGetUTF8CString(propertyName, buffer, 256); + res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); + + if(res<0) { + SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); + } else { + SWIG_exception(SWIG_ERROR, msg); + } + + return false; +} + +JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) { + JSValueRef val; + + JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr); + val = JSValueMakeString(context, jsstring); + JSStringRelease(jsstring); + + return val; +} + + +bool _wrap_ivar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + int arg1 ; + int val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_int SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ivar_set" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ivar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_ivar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + int result; + + result = (int)ivar; + jsresult = SWIG_From_int SWIG_JSC_FROM_CALL_ARGS((int)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_svar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + short arg1 ; + short val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_short SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "svar_set" "', argument " "1"" of type '" "short""'"); + } + arg1 = (short)(val1); + svar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_svar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + short result; + + result = (short)svar; + jsresult = SWIG_From_short SWIG_JSC_FROM_CALL_ARGS((short)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_lvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + long arg1 ; + long val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_long SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "lvar_set" "', argument " "1"" of type '" "long""'"); + } + arg1 = (long)(val1); + lvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_lvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + long result; + + result = (long)lvar; + jsresult = SWIG_From_long SWIG_JSC_FROM_CALL_ARGS((long)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_uivar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + unsigned int arg1 ; + unsigned int val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "uivar_set" "', argument " "1"" of type '" "unsigned int""'"); + } + arg1 = (unsigned int)(val1); + uivar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_uivar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + unsigned int result; + + result = (unsigned int)uivar; + jsresult = SWIG_From_unsigned_SS_int SWIG_JSC_FROM_CALL_ARGS((unsigned int)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_usvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + unsigned short arg1 ; + unsigned short val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_unsigned_SS_short SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "usvar_set" "', argument " "1"" of type '" "unsigned short""'"); + } + arg1 = (unsigned short)(val1); + usvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_usvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + unsigned short result; + + result = (unsigned short)usvar; + jsresult = SWIG_From_unsigned_SS_short SWIG_JSC_FROM_CALL_ARGS((unsigned short)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_ulvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + unsigned long arg1 ; + unsigned long val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_unsigned_SS_long SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ulvar_set" "', argument " "1"" of type '" "unsigned long""'"); + } + arg1 = (unsigned long)(val1); + ulvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_ulvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + unsigned long result; + + result = (unsigned long)ulvar; + jsresult = SWIG_From_unsigned_SS_long SWIG_JSC_FROM_CALL_ARGS((unsigned long)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_scvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + signed char arg1 ; + signed char val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_signed_SS_char SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "scvar_set" "', argument " "1"" of type '" "signed char""'"); + } + arg1 = (signed char)(val1); + scvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_scvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + signed char result; + + result = (signed char)scvar; + jsresult = SWIG_From_signed_SS_char SWIG_JSC_FROM_CALL_ARGS((signed char)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_ucvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + unsigned char arg1 ; + unsigned char val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_unsigned_SS_char SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ucvar_set" "', argument " "1"" of type '" "unsigned char""'"); + } + arg1 = (unsigned char)(val1); + ucvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_ucvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + unsigned char result; + + result = (unsigned char)ucvar; + jsresult = SWIG_From_unsigned_SS_char SWIG_JSC_FROM_CALL_ARGS((unsigned char)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_cvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + char arg1 ; + char val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_char SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "cvar_set" "', argument " "1"" of type '" "char""'"); + } + arg1 = (char)(val1); + cvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_cvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + char result; + + result = (char)cvar; + jsresult = SWIG_From_char SWIG_JSC_FROM_CALL_ARGS((char)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_fvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + float arg1 ; + float val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_float SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "fvar_set" "', argument " "1"" of type '" "float""'"); + } + arg1 = (float)(val1); + fvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_fvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + float result; + + result = (float)fvar; + jsresult = SWIG_From_float SWIG_JSC_FROM_CALL_ARGS((float)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_dvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + double arg1 ; + double val1 ; + int ecode1 = 0 ; + + ecode1 = SWIG_AsVal_double SWIG_JSC_AS_CALL_ARGS(value, &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dvar_set" "', argument " "1"" of type '" "double""'"); + } + arg1 = (double)(val1); + dvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_dvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + double result; + + result = (double)dvar; + jsresult = SWIG_From_double SWIG_JSC_FROM_CALL_ARGS((double)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_strvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + + res1 = SWIG_JSC_AsCharPtrAndSize(context, value, &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "strvar_set" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + if (strvar) free((char*)strvar); + if (arg1) { + size_t size = strlen((const char *)((const char *)(arg1))) + 1; + strvar = (char *)(char *)memcpy((char *)malloc((size)*sizeof(char)), arg1, sizeof(char)*(size)); + } else { + strvar = 0; + } + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_strvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + char *result = 0 ; + + result = (char *)strvar; + jsresult = SWIG_FromCharPtr((const char *)result); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_cstrvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + char *result = 0 ; + + result = (char *)(char *)cstrvar; + jsresult = SWIG_FromCharPtr((const char *)result); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_iptrvar_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + int *arg1 = (int *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + res1 = SWIG_ConvertPtr(value, &argp1,SWIGTYPE_p_int, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "iptrvar_set" "', argument " "1"" of type '" "int *""'"); + } + arg1 = (int *)(argp1); + iptrvar = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_iptrvar_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + int *result = 0 ; + + result = (int *)iptrvar; + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 ); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_name_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + char *arg1 ; + char temp1[256] ; + int res1 ; + + res1 = SWIG_JSC_AsCharArray(context, value, temp1, 256); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "name_set" "', argument " "1"" of type '" "char [256]""'"); + } + arg1 = (char *)(temp1); + if (arg1) memcpy(name,arg1,256*sizeof(char)); + else memset(name,0,256*sizeof(char)); + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_name_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + char *result = 0 ; + + result = (char *)(char *)name; + { + size_t size = 256; + + while (size && (result[size - 1] == '\0')) --size; + + jsresult = SWIG_FromCharPtrAndSize(result, size); + } + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_ptptr_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + Point *arg1 = (Point *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + res1 = SWIG_ConvertPtr(value, &argp1,SWIGTYPE_p_Point, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ptptr_set" "', argument " "1"" of type '" "Point *""'"); + } + arg1 = (Point *)(argp1); + ptptr = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_ptptr_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + Point *result = 0 ; + + result = (Point *)ptptr; + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Point, 0 | 0 ); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +bool _wrap_pt_set(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) +{ + Point arg1 ; + void *argp1 ; + int res1 = 0 ; + + { + res1 = SWIG_ConvertPtr(value, &argp1, SWIGTYPE_p_Point, 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pt_set" "', argument " "1"" of type '" "Point""'"); + } + if (!argp1) { + SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "pt_set" "', argument " "1"" of type '" "Point""'"); + } else { + arg1 = *((Point *)(argp1)); + } + } + pt = arg1; + + + return true; + + goto fail; +fail: + return false; +} + + +JSValueRef _wrap_pt_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + Point result; + + result = pt; + jsresult = SWIG_NewPointerObj((Point *)memcpy((Point *)malloc(sizeof(Point)),&result,sizeof(Point)), SWIGTYPE_p_Point, SWIG_POINTER_OWN | 0 ); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_status_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + int result; + + result = (int)status; + jsresult = SWIG_From_int SWIG_JSC_FROM_CALL_ARGS((int)(result)); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_path_get(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception) +{ + JSValueRef jsresult; + char *result = 0 ; + + result = (char *)(char *)path; + { + size_t size = 256; + + while (size && (result[size - 1] == '\0')) --size; + + jsresult = SWIG_FromCharPtrAndSize(result, size); + } + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_print_vars(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + JSValueRef jsresult; + + print_vars(); + jsresult = JSValueMakeUndefined(context); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_new_int(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + int arg1 ; + int val1 ; + int ecode1 = 0 ; + JSValueRef jsresult; + int *result = 0 ; + + ecode1 = SWIG_AsVal_int SWIG_JSC_AS_CALL_ARGS(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_int" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (int *)new_int(arg1); + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int, 0 | 0 ); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_new_Point(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + JSValueRef jsresult; + Point *result = 0 ; + + ecode1 = SWIG_AsVal_int SWIG_JSC_AS_CALL_ARGS(argv[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Point" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int SWIG_JSC_AS_CALL_ARGS(argv[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_Point" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (Point *)new_Point(arg1,arg2); + jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Point, 0 | 0 ); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_Point_print(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + Point *arg1 = (Point *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + JSValueRef jsresult; + char *result = 0 ; + + res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Point, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Point_print" "', argument " "1"" of type '" "Point *""'"); + } + arg1 = (Point *)(argp1); + result = (char *)Point_print(arg1); + jsresult = SWIG_FromCharPtr((const char *)result); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +JSValueRef _wrap_pt_print(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + JSValueRef jsresult; + + pt_print(); + jsresult = JSValueMakeUndefined(context); + + return jsresult; + + goto fail; +fail: + return NULL; +} + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_Point = {"_p_Point", "Point *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_Point, + &_swigt__p_char, + &_swigt__p_int, +}; + +static swig_cast_info _swigc__p_Point[] = { {&_swigt__p_Point, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_Point, + _swigc__p_char, + _swigc__p_int, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + + + +JSStaticValue example_values[] = { + { + "ivar",_wrap_ivar_get, _wrap_ivar_set,kJSPropertyAttributeNone + },{ + "svar",_wrap_svar_get, _wrap_svar_set,kJSPropertyAttributeNone + },{ + "lvar",_wrap_lvar_get, _wrap_lvar_set,kJSPropertyAttributeNone + },{ + "uivar",_wrap_uivar_get, _wrap_uivar_set,kJSPropertyAttributeNone + },{ + "usvar",_wrap_usvar_get, _wrap_usvar_set,kJSPropertyAttributeNone + },{ + "ulvar",_wrap_ulvar_get, _wrap_ulvar_set,kJSPropertyAttributeNone + },{ + "scvar",_wrap_scvar_get, _wrap_scvar_set,kJSPropertyAttributeNone + },{ + "ucvar",_wrap_ucvar_get, _wrap_ucvar_set,kJSPropertyAttributeNone + },{ + "cvar",_wrap_cvar_get, _wrap_cvar_set,kJSPropertyAttributeNone + },{ + "fvar",_wrap_fvar_get, _wrap_fvar_set,kJSPropertyAttributeNone + },{ + "dvar",_wrap_dvar_get, _wrap_dvar_set,kJSPropertyAttributeNone + },{ + "strvar",_wrap_strvar_get, _wrap_strvar_set,kJSPropertyAttributeNone + },{ + "cstrvar",_wrap_cstrvar_get, JS_veto_set_variable,kJSPropertyAttributeNone + },{ + "iptrvar",_wrap_iptrvar_get, _wrap_iptrvar_set,kJSPropertyAttributeNone + },{ + "name",_wrap_name_get, _wrap_name_set,kJSPropertyAttributeNone + },{ + "ptptr",_wrap_ptptr_get, _wrap_ptptr_set,kJSPropertyAttributeNone + },{ + "pt",_wrap_pt_get, _wrap_pt_set,kJSPropertyAttributeNone + },{ + "status",_wrap_status_get, JS_veto_set_variable,kJSPropertyAttributeNone + },{ + "path",_wrap_path_get, JS_veto_set_variable,kJSPropertyAttributeNone + }, + { + 0, 0, 0, 0 + } +}; + +JSStaticFunction example_functions[] = { + { + "print_vars",_wrap_print_vars, kJSPropertyAttributeNone + },{ + "new_int",_wrap_new_int, kJSPropertyAttributeNone + },{ + "new_Point",_wrap_new_Point, kJSPropertyAttributeNone + },{ + "Point_print",_wrap_Point_print, kJSPropertyAttributeNone + },{ + "pt_print",_wrap_pt_print, kJSPropertyAttributeNone + }, + { + 0, 0, 0 + } +}; + +JSClassDefinition example_classDefinition; + + +SWIGRUNTIME void +SWIG_JSC_SetModule(swig_module_info *swig_module) {} + +SWIGRUNTIME swig_module_info * +SWIG_JSC_GetModule(void) { + return 0; +} + +#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer) + + +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ /* c-mode */ +#endif +} +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + bool example_initialize(JSGlobalContextRef context) { + SWIG_InitializeModule(0); + + JSObjectRef global_object = JSContextGetGlobalObject(context); + + /* Initialize the base swig type object */ + _SwigObject_objectDefinition.staticFunctions = _SwigObject_functions; + _SwigObject_objectDefinition.staticValues = _SwigObject_values; + _SwigObject_classRef = JSClassCreate(&_SwigObject_objectDefinition); + + /* Create objects for namespaces */ + example_classDefinition.staticFunctions = example_functions; + example_classDefinition.staticValues = example_values; + JSObjectRef example_object = JSObjectMake(context, JSClassCreate(&example_classDefinition), NULL); + + + /* Create classes */ + + + /* Register namespaces */ + + JS_registerNamespace(context, example_object, global_object, "example"); + + return true; + } + +#ifdef __cplusplus +} +#endif + +