Javascript code formatting corrections
This commit is contained in:
parent
c4d003e442
commit
b6aa39b82a
2 changed files with 15 additions and 21 deletions
|
|
@ -30,38 +30,33 @@
|
|||
%define JAVASCRIPT_ARRAYS_IN_DECL(NAME, CTYPE, ANY, ANYLENGTH)
|
||||
|
||||
%typemap(in, fragment=NAME) CTYPE[ANY] {
|
||||
if ($input->IsArray())
|
||||
{
|
||||
if ($input->IsArray()) {
|
||||
// Convert into Array
|
||||
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast($input);
|
||||
|
||||
int length = ANYLENGTH;
|
||||
|
||||
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
|
||||
$1 = ($*1_ltype *)malloc(sizeof($*1_ltype) * length);
|
||||
|
||||
// Get each element from array
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
for (int i = 0; i < length; i++) {
|
||||
v8::Local<v8::Value> jsvalue = SWIGV8_ARRAY_GET(array, i);
|
||||
$*1_ltype temp;
|
||||
|
||||
// Get primitive value from JSObject
|
||||
int res = SWIG_AsVal(CTYPE)(jsvalue, &temp);
|
||||
if (!SWIG_IsOK(res))
|
||||
{
|
||||
if (!SWIG_IsOK(res)) {
|
||||
SWIG_exception_fail(SWIG_ERROR, "Failed to convert $input to double");
|
||||
}
|
||||
arg$argnum[i] = temp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SWIG_exception_fail(SWIG_ERROR, "$input is not an array");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) CTYPE[ANY] {
|
||||
free($1);
|
||||
free($1);
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
|
@ -72,8 +67,7 @@
|
|||
int length = $1_dim0;
|
||||
v8::Local<v8::Array> array = SWIGV8_ARRAY_NEW(length);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
for (int i = 0; i < length; i++) {
|
||||
SWIGV8_ARRAY_SET(array, i, SWIG_From(CTYPE)($1[i]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,23 +39,23 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
|
|||
if (o->IsArray()) {
|
||||
SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o);
|
||||
|
||||
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
|
||||
if (array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
|
||||
double re, im;
|
||||
int res;
|
||||
|
||||
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re);
|
||||
if(!SWIG_IsOK(res)) {
|
||||
if (!SWIG_IsOK(res)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
|
||||
if(!SWIG_IsOK(res)) {
|
||||
if (!SWIG_IsOK(res)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
if (val) *val = Constructor(re, im);
|
||||
return SWIG_OK;
|
||||
} else if(o->IsNumber()){
|
||||
} else if (o->IsNumber()) {
|
||||
double d;
|
||||
int res = SWIG_AddCast(SWIG_AsVal(double)(o, &d));
|
||||
if (SWIG_IsOK(res)) {
|
||||
|
|
@ -81,17 +81,17 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
|
|||
if (o->IsArray()) {
|
||||
SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o);
|
||||
|
||||
if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
|
||||
if (array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2].");
|
||||
double re, im;
|
||||
int res;
|
||||
|
||||
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re);
|
||||
if(!SWIG_IsOK(res)) {
|
||||
if (!SWIG_IsOK(res)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im);
|
||||
if(!SWIG_IsOK(res)) {
|
||||
if (!SWIG_IsOK(res)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val)
|
|||
} else {
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
} else if(o->IsNumber()){
|
||||
} else if (o->IsNumber()) {
|
||||
float re;
|
||||
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
|
||||
if (SWIG_IsOK(res)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue