Merge branch 'master' into array_fix
This commit is contained in:
commit
1a4dc82931
1964 changed files with 57298 additions and 30865 deletions
|
|
@ -12,15 +12,16 @@
|
|||
#include <complex.h>
|
||||
%}
|
||||
|
||||
#define complex _Complex
|
||||
|
||||
/* C complex constructor */
|
||||
#define CCplxConst(r, i) ((r) + I*(i))
|
||||
|
||||
%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag);
|
||||
%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag);
|
||||
%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag);
|
||||
%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag);
|
||||
%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag);
|
||||
%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag);
|
||||
|
||||
/* declaring the typemaps */
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex);
|
||||
%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex);
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ static JSStaticFunction $jsmangledname_functions[] = {
|
|||
* jsc_nspace_declaration: template for a namespace declaration
|
||||
* - $jsnspace: mangled name of the namespace
|
||||
* - $jsglobalvariables: list of variable entries
|
||||
* - $jsglobalfunctions: list if fuction entries
|
||||
* - $jsglobalfunctions: list of function entries
|
||||
* ----------------------------------------------------------------------------- */
|
||||
%fragment ("jsc_nspace_declaration", "templates")
|
||||
%{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ SWIG_AsVal_dec(Type)(JSValueRef o, Type *val)
|
|||
float re;
|
||||
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = Constructor(re, 0.0);
|
||||
if (val) *val = Constructor(re, 0.0f);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,64 @@
|
|||
%insert(init) %{
|
||||
SWIGRUNTIME void
|
||||
SWIG_JSC_SetModule(swig_module_info *swig_module) {}
|
||||
SWIG_JSC_SetModule(void *clientdata, swig_module_info *swig_module) {
|
||||
JSGlobalContextRef context;
|
||||
JSObjectRef globalObject;
|
||||
JSStringRef moduleName;
|
||||
JSClassDefinition classDef;
|
||||
JSClassRef classRef;
|
||||
JSObjectRef object;
|
||||
|
||||
if(clientdata == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
context = (JSGlobalContextRef)clientdata;
|
||||
|
||||
globalObject = JSContextGetGlobalObject(context);
|
||||
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
|
||||
|
||||
classDef = kJSClassDefinitionEmpty;
|
||||
classRef = JSClassCreate(&classDef);
|
||||
|
||||
object = JSObjectMake(context, classRef, NULL);
|
||||
JSObjectSetPrivate(object, (void*)swig_module);
|
||||
|
||||
JSObjectSetProperty(context, globalObject, moduleName, object, kJSPropertyAttributeNone, NULL);
|
||||
|
||||
JSClassRelease(classRef);
|
||||
JSStringRelease(moduleName);
|
||||
}
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_JSC_GetModule(void) {
|
||||
return 0;
|
||||
SWIG_JSC_GetModule(void *clientdata) {
|
||||
JSGlobalContextRef context;
|
||||
JSObjectRef globalObject;
|
||||
JSStringRef moduleName;
|
||||
JSValueRef value;
|
||||
JSObjectRef object;
|
||||
|
||||
if(clientdata == 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
context = (JSGlobalContextRef)clientdata;
|
||||
|
||||
globalObject = JSContextGetGlobalObject(context);
|
||||
moduleName = JSStringCreateWithUTF8CString("swig_module_info_data");
|
||||
|
||||
if(JSObjectHasProperty(context, globalObject, moduleName) == false) {
|
||||
JSStringRelease(moduleName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
value = JSObjectGetProperty(context, globalObject, moduleName, NULL);
|
||||
object = JSValueToObject(context, value, NULL);
|
||||
JSStringRelease(moduleName);
|
||||
|
||||
return (swig_module_info*)JSObjectGetPrivate(object);
|
||||
}
|
||||
|
||||
#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(pointer)
|
||||
#define SWIG_GetModule(clientdata) SWIG_JSC_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_JSC_SetModule(clientdata, pointer)
|
||||
%}
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
|
@ -26,7 +76,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
bool SWIGJSC_INIT (JSGlobalContextRef context, JSObjectRef *exports) {
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_InitializeModule((void*)context);
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, voi
|
|||
/* special case: JavaScript null => C NULL pointer */
|
||||
if(JSValueIsNull(context, valRef)) {
|
||||
*ptr=0;
|
||||
return SWIG_OK;
|
||||
return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
|
||||
}
|
||||
|
||||
if(!JSValueIsObject(context, valRef)) {
|
||||
|
|
@ -317,6 +317,30 @@ unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
|
|||
}
|
||||
}
|
||||
|
||||
SWIGRUNTIME
|
||||
bool SWIGJSC_ValueIsArray(JSContextRef context, JSValueRef value) {
|
||||
if (JSValueIsObject(context, value)) {
|
||||
static JSStringRef ArrayString = NULL;
|
||||
static JSStringRef isArrayString = NULL;
|
||||
JSObjectRef array = NULL;
|
||||
JSObjectRef isArray = NULL;
|
||||
JSValueRef retval = NULL;
|
||||
|
||||
if (!ArrayString)
|
||||
ArrayString = JSStringCreateWithUTF8CString("Array");
|
||||
if (!isArrayString)
|
||||
isArrayString = JSStringCreateWithUTF8CString("isArray");
|
||||
|
||||
array = (JSObjectRef)JSObjectGetProperty(context, JSContextGetGlobalObject(context), ArrayString, NULL);
|
||||
isArray = (JSObjectRef)JSObjectGetProperty(context, array, isArrayString, NULL);
|
||||
retval = JSObjectCallAsFunction(context, isArray, NULL, 1, &value, NULL);
|
||||
|
||||
if (JSValueIsBoolean(context, retval))
|
||||
return JSValueToBoolean(context, retval);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SWIGRUNTIME
|
||||
JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) {
|
||||
JSObjectRef arr;
|
||||
|
|
@ -324,6 +348,8 @@ JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueR
|
|||
|
||||
if (JSValueIsUndefined(context, value)) {
|
||||
arr = JSObjectMakeArray(context, 0, 0, 0);
|
||||
} else if (!SWIGJSC_ValueIsArray(context, value)) {
|
||||
arr = JSObjectMakeArray(context, 1, &value, 0);
|
||||
} else {
|
||||
arr = JSValueToObject(context, value, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
#include <complex>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%naturalvar complex;
|
||||
template<typename T> class complex;
|
||||
%template() complex<double>;
|
||||
%template() complex<float>;
|
||||
}
|
||||
|
||||
/* defining the complex as/from converters */
|
||||
|
||||
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
|
||||
|
|
|
|||
|
|
@ -20,22 +20,29 @@
|
|||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T> class map {
|
||||
template<class K, class T, class C = std::less<K> > class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair< const K, T > value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
map(const map& other);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
const T& get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
|
|
@ -45,14 +52,14 @@ namespace std {
|
|||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
std::map< K, T, C >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@
|
|||
namespace std {
|
||||
|
||||
template<class T, class U> struct pair {
|
||||
typedef T first_type;
|
||||
typedef U second_type;
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
pair(const pair& other);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &other);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,17 @@ namespace std {
|
|||
template<class T> class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
|
|
@ -48,10 +55,17 @@ namespace std {
|
|||
template<> class vector<bool> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef bool value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef bool const_reference;
|
||||
|
||||
vector();
|
||||
vector(size_type n);
|
||||
vector(const vector& other);
|
||||
|
||||
size_type size() const;
|
||||
size_type capacity() const;
|
||||
void reserve(size_type n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue