rt-thread-official/components/external/espruino/gen/jswrapper.c

1204 lines
52 KiB
C
Raw Normal View History

2014-02-25 01:47:49 +08:00
// Automatically generated wrapper file
// Generated by scripts/build_jsfunctions.py
#include "jswrapper.h"
#include "src/jswrap_pin.h"
#include "src/jswrap_functions.h"
#include "src/jswrap_modules.h"
#include "src/jswrap_process.h"
#include "src/jswrap_interactive.h"
#include "src/jswrap_json.h"
#include "src/jswrap_object.h"
#include "src/jswrap_string.h"
#include "src/jswrap_array.h"
#include "src/jswrap_arraybuffer.h"
#include "src/jswrap_serial.h"
#include "src/jswrap_spi_i2c.h"
#include "src/jswrap_onewire.h"
#include "src/jswrap_io.h"
#include "libs/jswrap_math.h"
#if( 'q\0\0\0' & 'q' )
#error( "architecture is big-endian. need to test and make sure this still works" )
#endif
// beware big endian!
#define CH2(a,b) ( ((b)<<8) | (a) )
#define CH4(a,b,c,d) ( ((d)<<24) | ((c)<<16) | ((b)<<8) | (a) )
#define CMP2(var, a,b) ((*(unsigned short*)&var)==CH2(a,b))
#define CMP3(var, a,b,c) (((*(unsigned int*)&var)&0x00FFFFFF)==CH4(a,b,c,0))
#define CMP4(var, a,b,c,d) ((*(unsigned int*)&var)==CH4(a,b,c,d))
JsVar *jswHandleFunctionCall(JsVar *parent, JsVar *parentName, const char *name) {
if (parent) {
// ------------------------------------------ METHODS ON OBJECT
if (CMP4(name[0],'c','l','o','n') && CMP2(name[4],'e','\0')) {
// Object.clone (src/jswrap_object.c)
jspParseEmptyFunction();
JsVar *_r = jswrap_object_clone(parent);
return _r;
} else if (CMP4(name[0],'e','m','i','t') && name[4]=='\0') {
// Object.emit (src/jswrap_object.c)
JsVar *event, *v1, *v2;
jspParseFunction(0, &event, &v1, &v2, 0);
jswrap_object_emit(parent, event, v1, v2);
jsvUnLock(event);
jsvUnLock(v1);
jsvUnLock(v2);
return 0;
} else if (CMP4(name[0],'l','e','n','g') && CMP3(name[4],'t','h','\0')) {
// Object.length (src/jswrap_object.c)
jspParseVariableName();
JsVar *_r = jswrap_object_length(parent);
return _r;
} else if (CMP3(name[0],'o','n','\0')) {
// Object.on (src/jswrap_object.c)
JsVar *event, *listener;
jspParseFunction(0, &event, &listener, 0, 0);
jswrap_object_on(parent, event, listener);
jsvUnLock(event);
jsvUnLock(listener);
return 0;
} else if (CMP4(name[0],'r','e','m','o') && CMP4(name[4],'v','e','A','l') && CMP4(name[8],'l','L','i','s') && CMP4(name[12],'t','e','n','e') && CMP3(name[16],'r','s','\0')) {
// Object.removeAllListeners (src/jswrap_object.c)
JsVar *event = jspParseSingleFunction();
jswrap_object_removeAllListeners(parent, event);
jsvUnLock(event);
return 0;
} else if (CMP4(name[0],'t','o','S','t') && CMP4(name[4],'r','i','n','g') && name[8]=='\0') {
// Object.toString (src/jswrap_object.c)
JsVar *radix = jspParseSingleFunction();
JsVar *_r = jswrap_object_toString(parent, radix);
jsvUnLock(radix);
return _r;
}
// ------------------------------------------ INSTANCE + STATIC METHODS
if (CMP4(parent->varData.str[0],'p','r','o','c') && CMP4(parent->varData.str[4],'e','s','s','\0')) {
if (CMP4(name[0],'m','e','m','o') && CMP3(name[4],'r','y','\0')) {
// process.memory (src/jswrap_process.c)
jspParseEmptyFunction();
JsVar *_r = jswrap_process_memory();
return _r;
} else if (CMP4(name[0],'e','n','v','\0')) {
// process.env (src/jswrap_process.c)
jspParseVariableName();
JsVar *_r = jswrap_process_env();
return _r;
} else if (CMP4(name[0],'v','e','r','s') && CMP4(name[4],'i','o','n','\0')) {
// process.version (src/jswrap_process.c)
jspParseVariableName();
JsVar *_r = jsvNewFromString(JS_VERSION);
return _r;
}
}
if (CMP4(parent->varData.str[0],'O','b','j','e') && CMP3(parent->varData.str[4],'c','t','\0')) {
if (CMP4(name[0],'k','e','y','s') && name[4]=='\0') {
// Object.keys (src/jswrap_object.c)
JsVar *object = jspParseSingleFunction();
JsVar *_r = jswrap_object_keys(object);
jsvUnLock(object);
return _r;
}
}
if (jsvIsFunction(parent)) {
if (CMP4(name[0],'a','p','p','l') && CMP2(name[4],'y','\0')) {
// Function.apply (src/jswrap_object.c)
JsVar *this, *args;
jspParseFunction(0, &this, &args, 0, 0);
JsVar *_r = jswrap_function_apply(parent, this, args);
jsvUnLock(this);
jsvUnLock(args);
return _r;
} else if (CMP4(name[0],'c','a','l','l') && name[4]=='\0') {
// Function.call (src/jswrap_object.c)
JsVar *this, *a, *b, *c, *d;
jspParseFunction8(0, &this, &a, &b, &c, &d, 0, 0, 0);
JsVar *_r = jswrap_function_call(parent, this, a, b, c, d);
jsvUnLock(this);
jsvUnLock(a);
jsvUnLock(b);
jsvUnLock(c);
jsvUnLock(d);
return _r;
} else if (CMP4(name[0],'r','e','p','l') && CMP4(name[4],'a','c','e','W') && CMP4(name[8],'i','t','h','\0')) {
// Function.replaceWith (src/jswrap_object.c)
JsVar *newFunc = jspParseSingleFunction();
jswrap_function_replaceWith(parent, newFunc);
jsvUnLock(newFunc);
return 0;
}
}
if (CMP4(parent->varData.str[0],'M','o','d','u') && CMP4(parent->varData.str[4],'l','e','s','\0')) {
if (CMP4(name[0],'a','d','d','C') && CMP4(name[4],'a','c','h','e') && CMP2(name[8],'d','\0')) {
// Modules.addCached (src/jswrap_modules.c)
JsVar *id, *sourcecode;
jspParseFunction(0, &id, &sourcecode, 0, 0);
jswrap_modules_addCached(id, sourcecode);
jsvUnLock(id);
jsvUnLock(sourcecode);
return 0;
} else if (CMP4(name[0],'r','e','m','o') && CMP2(name[4],'v','e')) {
if (CMP4(name[6],'A','l','l','C') && CMP4(name[10],'a','c','h','e') && CMP2(name[14],'d','\0')) {
// Modules.removeAllCached (src/jswrap_modules.c)
jspParseEmptyFunction();
jswrap_modules_removeAllCached();
return 0;
} else if (CMP4(name[6],'C','a','c','h') && CMP3(name[10],'e','d','\0')) {
// Modules.removeCached (src/jswrap_modules.c)
JsVar *id = jspParseSingleFunction();
jswrap_modules_removeCached(id);
jsvUnLock(id);
return 0;
}
} else if (CMP4(name[0],'g','e','t','C') && CMP4(name[4],'a','c','h','e') && CMP2(name[8],'d','\0')) {
// Modules.getCached (src/jswrap_modules.c)
jspParseEmptyFunction();
JsVar *_r = jswrap_modules_getCached();
return _r;
}
}
if (jsvIsArrayBuffer(parent) && parent->varData.arraybuffer.type!=ARRAYBUFFERVIEW_ARRAYBUFFER) {
if (CMP4(name[0],'i','n','t','e') && CMP4(name[4],'r','p','o','l') && CMP3(name[8],'a','t','e')) {
if (CMP3(name[11],'2','d','\0')) {
// ArrayBufferView.interpolate2d (src/jswrap_arraybuffer.c)
JsVar *width, *x, *y;
jspParseFunction(0, &width, &x, &y, 0);
JsVar *_r = jsvNewFromFloat(jswrap_arraybufferview_interpolate2d(parent, jsvGetIntegerAndUnLock(width), jsvGetFloatAndUnLock(x), jsvGetFloatAndUnLock(y)));
return _r;
} else if (name[11]==0) {
// ArrayBufferView.interpolate (src/jswrap_arraybuffer.c)
JsVar *index = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(jswrap_arraybufferview_interpolate(parent, jsvGetFloatAndUnLock(index)));
return _r;
}
} else if (name[0]=='b') {
if (CMP3(name[1],'y','t','e')) {
if (CMP4(name[4],'L','e','n','g') && CMP3(name[8],'t','h','\0')) {
// ArrayBufferView.byteLength (src/jswrap_arraybuffer.c)
jspParseVariableName();
JsVar *_r = jsvNewFromInteger(parent->varData.arraybuffer.length * JSV_ARRAYBUFFER_GET_SIZE(parent->varData.arraybuffer.type));
return _r;
} else if (CMP4(name[4],'O','f','f','s') && CMP3(name[8],'e','t','\0')) {
// ArrayBufferView.byteOffset (src/jswrap_arraybuffer.c)
jspParseVariableName();
JsVar *_r = jsvNewFromInteger(parent->varData.arraybuffer.byteOffset);
return _r;
}
} else if (CMP4(name[1],'u','f','f','e') && CMP2(name[5],'r','\0')) {
// ArrayBufferView.buffer (src/jswrap_arraybuffer.c)
jspParseVariableName();
JsVar *_r = jsvLock(parent->firstChild);
return _r;
}
}
}
if (jsvIsPin(parent)) {
if (CMP4(name[0],'s','e','t','\0')) {
// Pin.set (src/jswrap_pin.c)
jspParseEmptyFunction();
jswrap_pin_set(parent);
return 0;
} else if (CMP2(name[0],'r','e')) {
if (CMP3(name[2],'a','d','\0')) {
// Pin.read (src/jswrap_pin.c)
jspParseEmptyFunction();
JsVar *_r = jsvNewFromBool(jswrap_pin_read(parent));
return _r;
} else if (CMP4(name[2],'s','e','t','\0')) {
// Pin.reset (src/jswrap_pin.c)
jspParseEmptyFunction();
jswrap_pin_reset(parent);
return 0;
}
} else if (CMP4(name[0],'w','r','i','t') && name[4]=='e') {
if (CMP4(name[5],'A','t','T','i') && CMP3(name[9],'m','e','\0')) {
// Pin.writeAtTime (src/jswrap_pin.c)
JsVar *value, *time;
jspParseFunction(0, &value, &time, 0, 0);
jswrap_pin_writeAtTime(parent, jsvGetBoolAndUnLock(value), jsvGetFloatAndUnLock(time));
return 0;
} else if (name[5]==0) {
// Pin.write (src/jswrap_pin.c)
JsVar *value = jspParseSingleFunction();
jswrap_pin_write(parent, jsvGetBoolAndUnLock(value));
return 0;
}
}
}
if (jsvIsString(parent)) {
if (CMP4(name[0],'i','n','d','e') && CMP4(name[4],'x','O','f','\0')) {
// String.indexOf (src/jswrap_string.c)
JsVar *substring = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(jswrap_string_indexOf(parent, substring));
jsvUnLock(substring);
return _r;
} else if (CMP4(name[0],'c','h','a','r')) {
if (CMP3(name[4],'A','t','\0')) {
// String.charAt (src/jswrap_string.c)
JsVar *pos = jspParseSingleFunction();
JsVar *_r = jswrap_string_charAt(parent, jsvGetIntegerAndUnLock(pos));
return _r;
} else if (CMP4(name[4],'C','o','d','e') && CMP3(name[8],'A','t','\0')) {
// String.charCodeAt (src/jswrap_string.c)
JsVar *pos = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(jswrap_string_charCodeAt(parent, jsvGetIntegerAndUnLock(pos)));
return _r;
}
} else if (name[0]=='s') {
if (CMP4(name[1],'p','l','i','t') && name[5]=='\0') {
// String.split (src/jswrap_string.c)
JsVar *separator = jspParseSingleFunction();
JsVar *_r = jswrap_string_split(parent, separator);
jsvUnLock(separator);
return _r;
} else if (CMP4(name[1],'u','b','s','t') && name[5]=='r') {
if (CMP4(name[6],'i','n','g','\0')) {
// String.substring (src/jswrap_string.c)
JsVar *start, *end;
jspParseFunction(0, &start, &end, 0, 0);
JsVar *_r = jswrap_string_substring(parent, jsvGetIntegerAndUnLock(start), end);
jsvUnLock(end);
return _r;
} else if (name[6]==0) {
// String.substr (src/jswrap_string.c)
JsVar *start, *len;
jspParseFunction(0, &start, &len, 0, 0);
JsVar *_r = jswrap_string_substr(parent, jsvGetIntegerAndUnLock(start), len);
jsvUnLock(len);
return _r;
}
}
}
}
if (CMP4(parent->varData.str[0],'M','a','t','h') && parent->varData.str[4]=='\0') {
if (name[0]=='a') {
if (CMP4(name[1],'c','o','s','\0')) {
// Math.acos (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(acos(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP3(name[1],'b','s','\0')) {
// Math.abs (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(jswrap_math_abs(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP4(name[1],'s','i','n','\0')) {
// Math.asin (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(asin(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP3(name[1],'t','a','n')) {
if (CMP2(name[4],'2','\0')) {
// Math.atan2 (libs/jswrap_math.c)
JsVar *y, *x;
jspParseFunction(0, &y, &x, 0, 0);
JsVar *_r = jsvNewFromFloat(atan2(jsvGetFloatAndUnLock(y), jsvGetFloatAndUnLock(x)));
return _r;
} else if (name[4]==0) {
// Math.atan (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(atan(jsvGetFloatAndUnLock(x)));
return _r;
}
}
} else if (name[0]=='c') {
if (CMP4(name[1],'e','i','l','\0')) {
// Math.ceil (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(ceil(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP4(name[1],'l','i','p','\0')) {
// Math.clip (libs/jswrap_math.c)
JsVar *x, *min, *max;
jspParseFunction(0, &x, &min, &max, 0);
JsVar *_r = jsvNewFromFloat(jswrap_math_clip(jsvGetFloatAndUnLock(x), jsvGetFloatAndUnLock(min), jsvGetFloatAndUnLock(max)));
return _r;
} else if (CMP3(name[1],'o','s','\0')) {
// Math.cos (libs/jswrap_math.c)
JsVar *theta = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(sin(jsvGetFloat(theta) + (3.14159265359/2.0)));
jsvUnLock(theta);
return _r;
}
} else if (CMP2(name[0],'E','\0')) {
// Math.E (libs/jswrap_math.c)
jspParseVariableName();
JsVar *_r = jsvNewFromFloat(2.71828182846);
return _r;
} else if (CMP4(name[0],'p','o','w','\0')) {
// Math.pow (libs/jswrap_math.c)
JsVar *x, *y;
jspParseFunction(0, &x, &y, 0, 0);
JsVar *_r = jsvNewFromFloat(jswrap_math_pow(jsvGetFloatAndUnLock(x), jsvGetFloatAndUnLock(y)));
return _r;
} else if (CMP4(name[0],'f','l','o','o') && CMP2(name[4],'r','\0')) {
// Math.floor (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(floor(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP4(name[0],'l','o','g','\0')) {
// Math.log (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(log(jsvGetFloatAndUnLock(x)));
return _r;
} else if (CMP3(name[0],'P','I','\0')) {
// Math.PI (libs/jswrap_math.c)
jspParseVariableName();
JsVar *_r = jsvNewFromFloat(3.14159265359);
return _r;
} else if (name[0]=='s') {
if (CMP3(name[1],'i','n','\0')) {
// Math.sin (libs/jswrap_math.c)
JsVar *theta = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(sin(jsvGetFloatAndUnLock(theta)));
return _r;
} else if (CMP4(name[1],'q','r','t','\0')) {
// Math.sqrt (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(jswrap_math_pow(jsvGetFloat(x),0.5));
jsvUnLock(x);
return _r;
}
} else if (name[0]=='r') {
if (CMP4(name[1],'a','n','d','o') && CMP2(name[5],'m','\0')) {
// Math.random (libs/jswrap_math.c)
jspParseEmptyFunction();
JsVar *_r = jsvNewFromFloat((JsVarFloat)rand() / (JsVarFloat)RAND_MAX);
return _r;
} else if (CMP4(name[1],'o','u','n','d') && name[5]=='\0') {
// Math.round (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger((JsVarInt)round(jsvGetFloatAndUnLock(x)));
return _r;
}
} else if (CMP4(name[0],'w','r','a','p') && name[4]=='\0') {
// Math.wrap (libs/jswrap_math.c)
JsVar *x, *max;
jspParseFunction(0, &x, &max, 0, 0);
JsVar *_r = jsvNewFromFloat(wrapAround(jsvGetFloatAndUnLock(x), jsvGetFloatAndUnLock(max)));
return _r;
} else if (CMP4(name[0],'e','x','p','\0')) {
// Math.exp (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(exp(jsvGetFloatAndUnLock(x)));
return _r;
}
}
if (CMP4(parent->varData.str[0],'D','o','u','b') && CMP3(parent->varData.str[4],'l','e','\0')) {
if (CMP4(name[0],'d','o','u','b') && CMP4(name[4],'l','e','T','o') && CMP4(name[8],'I','n','t','B') && CMP4(name[12],'i','t','s','\0')) {
// Double.doubleToIntBits (libs/jswrap_math.c)
JsVar *x = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(*(JsVarInt*)&x);
jsvUnLock(x);
return _r;
}
}
if (jsvIsArray(parent)) {
if (CMP4(name[0],'c','o','n','t') && CMP4(name[4],'a','i','n','s') && name[8]=='\0') {
// Array.contains (src/jswrap_array.c)
JsVar *value = jspParseSingleFunction();
JsVar *_r = jsvNewFromBool(jswrap_array_contains(parent, value));
jsvUnLock(value);
return _r;
} else if (CMP4(name[0],'f','o','r','E') && CMP4(name[4],'a','c','h','\0')) {
// Array.forEach (src/jswrap_array.c)
JsVar *function, *thisArg;
jspParseFunction(0, &function, &thisArg, 0, 0);
jswrap_array_forEach(parent, function, thisArg);
jsvUnLock(function);
jsvUnLock(thisArg);
return 0;
} else if (CMP4(name[0],'i','n','d','e') && CMP4(name[4],'x','O','f','\0')) {
// Array.indexOf (src/jswrap_array.c)
JsVar *value = jspParseSingleFunction();
JsVar *_r = jswrap_array_indexOf(parent, value);
jsvUnLock(value);
return _r;
} else if (CMP4(name[0],'j','o','i','n') && name[4]=='\0') {
// Array.join (src/jswrap_array.c)
JsVar *separator = jspParseSingleFunction();
JsVar *_r = jswrap_array_join(parent, separator);
jsvUnLock(separator);
return _r;
} else if (CMP4(name[0],'m','a','p','\0')) {
// Array.map (src/jswrap_array.c)
JsVar *function, *thisArg;
jspParseFunction(0, &function, &thisArg, 0, 0);
JsVar *_r = jswrap_array_map(parent, function, thisArg);
jsvUnLock(function);
jsvUnLock(thisArg);
return _r;
} else if (name[0]=='p') {
if (CMP4(name[1],'u','s','h','\0')) {
// Array.push (src/jswrap_array.c)
JsVar *value = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(jsvArrayPush(parent, value));
jsvUnLock(value);
return _r;
} else if (CMP3(name[1],'o','p','\0')) {
// Array.pop (src/jswrap_array.c)
jspParseEmptyFunction();
JsVar *_r = jsvArrayPop(parent);
return _r;
}
} else if (name[0]=='s') {
if (CMP4(name[1],'p','l','i','c') && CMP2(name[5],'e','\0')) {
// Array.splice (src/jswrap_array.c)
JsVar *index, *howMany, *element1, *element2, *element3, *element4, *element5, *element6;
jspParseFunction8(0, &index, &howMany, &element1, &element2, &element3, &element4, &element5, &element6);
JsVar *_r = jswrap_array_splice(parent, jsvGetIntegerAndUnLock(index), howMany, element1, element2, element3, element4, element5, element6);
jsvUnLock(howMany);
jsvUnLock(element1);
jsvUnLock(element2);
jsvUnLock(element3);
jsvUnLock(element4);
jsvUnLock(element5);
jsvUnLock(element6);
return _r;
} else if (CMP4(name[1],'l','i','c','e') && name[5]=='\0') {
// Array.slice (src/jswrap_array.c)
JsVar *start, *end;
jspParseFunction(0, &start, &end, 0, 0);
JsVar *_r = jswrap_array_slice(parent, start, end);
jsvUnLock(start);
jsvUnLock(end);
return _r;
}
}
}
if (CMP4(parent->varData.str[0],'c','o','n','s') && CMP4(parent->varData.str[4],'o','l','e','\0')) {
if (CMP4(name[0],'l','o','g','\0')) {
// console.log (src/jswrap_interactive.c)
JsVar *text = jspParseFunctionAsArray();
if (!text) return 0; // if parse error
jswrap_interface_print(text);
jsvUnLock(text);
return 0;
}
}
if (CMP4(parent->varData.str[0],'J','S','O','N') && parent->varData.str[4]=='\0') {
if (CMP4(name[0],'p','a','r','s') && CMP2(name[4],'e','\0')) {
// JSON.parse (src/jswrap_json.c)
JsVar *string = jspParseSingleFunction();
JsVar *_r = jswrap_json_parse(string);
jsvUnLock(string);
return _r;
} else if (CMP4(name[0],'s','t','r','i') && CMP4(name[4],'n','g','i','f') && CMP2(name[8],'y','\0')) {
// JSON.stringify (src/jswrap_json.c)
JsVar *data = jspParseSingleFunction();
JsVar *_r = jswrap_json_stringify(data);
jsvUnLock(data);
return _r;
}
}
if (CMP4(parent->varData.str[0],'S','t','r','i') && CMP3(parent->varData.str[4],'n','g','\0')) {
if (CMP4(name[0],'f','r','o','m') && CMP4(name[4],'C','h','a','r') && CMP4(name[8],'C','o','d','e') && name[12]=='\0') {
// String.fromCharCode (src/jswrap_string.c)
JsVar *code = jspParseSingleFunction();
JsVar *_r = jswrap_string_fromCharCode(jsvGetIntegerAndUnLock(code));
return _r;
}
}
if (CMP4(parent->varData.str[0],'I','n','t','e') && CMP4(parent->varData.str[4],'g','e','r','\0')) {
if (CMP4(name[0],'v','a','l','u') && CMP4(name[4],'e','O','f','\0')) {
// Integer.valueOf (libs/jswrap_math.c)
JsVar *character = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(jswrap_integer_valueOf(character));
jsvUnLock(character);
return _r;
}
}
// ------------------------------------------ INSTANCE METHODS WE MUST CHECK CONSTRUCTOR FOR
JsVar *constructorName = jsvIsObject(parent)?jsvSkipOneNameAndUnLock(jsvFindChildFromString(parent, JSPARSE_CONSTRUCTOR_VAR, false)):0;
if (constructorName && jsvIsName(constructorName)) {
if (CMP4(constructorName->varData.str[0],'S','e','r','i') && CMP3(constructorName->varData.str[4],'a','l','\0')) {
jsvUnLock(constructorName);constructorName=0;
if (CMP4(name[0],'p','r','i','n') && name[4]=='t') {
if (CMP3(name[5],'l','n','\0')) {
// Serial.println (src/jswrap_serial.c)
JsVar *string = jspParseSingleFunction();
jswrap_serial_println(parent, string);
jsvUnLock(string);
return 0;
} else if (name[5]==0) {
// Serial.print (src/jswrap_serial.c)
JsVar *string = jspParseSingleFunction();
jswrap_serial_print(parent, string);
jsvUnLock(string);
return 0;
}
} else if (CMP3(name[0],'s','e','t')) {
if (CMP4(name[3],'C','o','n','s') && CMP4(name[7],'o','l','e','\0')) {
// Serial.setConsole (src/jswrap_serial.c)
jspParseEmptyFunction();
jsiSetConsoleDevice(jsiGetDeviceFromClass(parent));
return 0;
} else if (CMP3(name[3],'u','p','\0')) {
// Serial.setup (src/jswrap_serial.c)
JsVar *baudrate, *options;
jspParseFunction(0, &baudrate, &options, 0, 0);
jswrap_serial_setup(parent, jsvGetIntegerAndUnLock(baudrate), options);
jsvUnLock(options);
return 0;
}
} else if (CMP4(name[0],'o','n','D','a') && CMP3(name[4],'t','a','\0')) {
// Serial.onData (src/jswrap_serial.c)
JsVar *function;
jspParseFunction(0|JSP_NOSKIP_A, &function, 0, 0, 0);
jswrap_serial_onData(parent, function);
jsvUnLock(function);
return 0;
} else if (CMP4(name[0],'w','r','i','t') && CMP2(name[4],'e','\0')) {
// Serial.write (src/jswrap_serial.c)
JsVar *data = jspParseSingleFunction();
jswrap_serial_write(parent, data);
jsvUnLock(data);
return 0;
}
} else if (CMP4(constructorName->varData.str[0],'O','n','e','W') && CMP4(constructorName->varData.str[4],'i','r','e','\0')) {
jsvUnLock(constructorName);constructorName=0;
if (name[0]=='s') {
if (CMP4(name[1],'k','i','p','\0')) {
// OneWire.skip (src/jswrap_onewire.c)
jspParseEmptyFunction();
jswrap_onewire_skip(parent);
return 0;
} else if (name[1]=='e') {
if (CMP4(name[2],'a','r','c','h') && name[6]=='\0') {
// OneWire.search (src/jswrap_onewire.c)
jspParseEmptyFunction();
JsVar *_r = jswrap_onewire_search(parent);
return _r;
} else if (CMP4(name[2],'l','e','c','t') && name[6]=='\0') {
// OneWire.select (src/jswrap_onewire.c)
JsVar *rom = jspParseSingleFunction();
jswrap_onewire_select(parent, jsvGetIntegerAndUnLock(rom));
return 0;
}
}
} else if (CMP2(name[0],'r','e')) {
if (CMP3(name[2],'a','d','\0')) {
// OneWire.read (src/jswrap_onewire.c)
jspParseEmptyFunction();
JsVar *_r = jsvNewFromInteger(jswrap_onewire_read(parent));
return _r;
} else if (CMP4(name[2],'s','e','t','\0')) {
// OneWire.reset (src/jswrap_onewire.c)
jspParseEmptyFunction();
JsVar *_r = jsvNewFromBool(jswrap_onewire_reset(parent));
return _r;
}
} else if (CMP4(name[0],'w','r','i','t') && CMP2(name[4],'e','\0')) {
// OneWire.write (src/jswrap_onewire.c)
JsVar *data, *power;
jspParseFunction(0, &data, &power, 0, 0);
jswrap_onewire_write(parent, jsvGetIntegerAndUnLock(data), jsvGetBoolAndUnLock(power));
return 0;
}
} else if (CMP4(constructorName->varData.str[0],'I','2','C','\0')) {
jsvUnLock(constructorName);constructorName=0;
if (CMP4(name[0],'s','e','t','u') && CMP2(name[4],'p','\0')) {
// I2C.setup (src/jswrap_spi_i2c.c)
JsVar *options = jspParseSingleFunction();
jswrap_i2c_setup(parent, options);
jsvUnLock(options);
return 0;
} else if (CMP4(name[0],'r','e','a','d') && CMP4(name[4],'F','r','o','m') && name[8]=='\0') {
// I2C.readFrom (src/jswrap_spi_i2c.c)
JsVar *address, *quantity;
jspParseFunction(0, &address, &quantity, 0, 0);
JsVar *_r = jswrap_i2c_readFrom(parent, jsvGetIntegerAndUnLock(address), jsvGetIntegerAndUnLock(quantity));
return _r;
} else if (CMP4(name[0],'w','r','i','t') && CMP4(name[4],'e','T','o','\0')) {
// I2C.writeTo (src/jswrap_spi_i2c.c)
JsVar *address, *data;
jspParseFunction(0, &address, &data, 0, 0);
jswrap_i2c_writeTo(parent, jsvGetIntegerAndUnLock(address), data);
jsvUnLock(data);
return 0;
}
} else if (CMP4(constructorName->varData.str[0],'S','P','I','\0')) {
jsvUnLock(constructorName);constructorName=0;
if (CMP2(name[0],'s','e')) {
if (CMP4(name[2],'t','u','p','\0')) {
// SPI.setup (src/jswrap_spi_i2c.c)
JsVar *options = jspParseSingleFunction();
jswrap_spi_setup(parent, options);
jsvUnLock(options);
return 0;
} else if (CMP2(name[2],'n','d')) {
if (CMP4(name[4],'8','b','i','t') && name[8]=='\0') {
// SPI.send8bit (src/jswrap_spi_i2c.c)
JsVar *data, *bit0, *bit1, *nss_pin;
jspParseFunction(0, &data, &bit0, &bit1, &nss_pin);
jswrap_spi_send8bit(parent, data, jsvGetIntegerAndUnLock(bit0), jsvGetIntegerAndUnLock(bit1), jshGetPinFromVarAndUnLock(nss_pin));
jsvUnLock(data);
return 0;
} else if (CMP4(name[4],'4','b','i','t') && name[8]=='\0') {
// SPI.send4bit (src/jswrap_spi_i2c.c)
JsVar *data, *bit0, *bit1, *nss_pin;
jspParseFunction(0, &data, &bit0, &bit1, &nss_pin);
jswrap_spi_send4bit(parent, data, jsvGetIntegerAndUnLock(bit0), jsvGetIntegerAndUnLock(bit1), jshGetPinFromVarAndUnLock(nss_pin));
jsvUnLock(data);
return 0;
} else if (name[4]==0) {
// SPI.send (src/jswrap_spi_i2c.c)
JsVar *data, *nss_pin;
jspParseFunction(0, &data, &nss_pin, 0, 0);
JsVar *_r = jswrap_spi_send(parent, data, jshGetPinFromVarAndUnLock(nss_pin));
jsvUnLock(data);
return _r;
}
}
}
} else
jsvUnLock(constructorName);
}
} else { /* if (!parent) */
// ------------------------------------------ FUNCTIONS
// Handle pin names - eg LED1 or D5 (this is hardcoded in build_jsfunctions.py)
Pin pin = jshGetPinFromString(name);
if (pin != PIN_UNDEFINED) {
jspParseVariableName();
return jsvNewFromPin(pin);
}
if (name[0]=='a') {
if (CMP4(name[1],'r','g','u','m') && CMP4(name[5],'e','n','t','s') && name[9]=='\0') {
// arguments (src/jswrap_functions.c)
jspParseVariableName();
JsVar *_r = jswrap_arguments();
return _r;
} else if (CMP4(name[1],'n','a','l','o') && name[5]=='g') {
if (CMP4(name[6],'R','e','a','d') && name[10]=='\0') {
// analogRead (src/jswrap_io.c)
JsVar *pin = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(jshPinAnalog(jshGetPinFromVarAndUnLock(pin)));
return _r;
} else if (CMP4(name[6],'W','r','i','t') && CMP2(name[10],'e','\0')) {
// analogWrite (src/jswrap_io.c)
JsVar *pin, *value, *options;
jspParseFunction(0, &pin, &value, &options, 0);
jswrap_io_analogWrite(jshGetPinFromVarAndUnLock(pin), jsvGetFloatAndUnLock(value), options);
jsvUnLock(options);
return 0;
}
}
} else if (CMP4(name[0],'A','r','r','a') && name[4]=='y') {
if (CMP4(name[5],'B','u','f','f') && CMP3(name[9],'e','r','\0')) {
// ArrayBuffer.ArrayBuffer (src/jswrap_arraybuffer.c)
JsVar *byteLength = jspParseSingleFunction();
JsVar *_r = jswrap_arraybuffer_constructor(jsvGetIntegerAndUnLock(byteLength));
return _r;
} else if (name[5]==0) {
// Array.Array (src/jswrap_array.c)
JsVar *args = jspParseFunctionAsArray();
if (!args) return 0; // if parse error
JsVar *_r = jswrap_array_constructor(args);
jsvUnLock(args);
return _r;
}
} else if (name[0]=='c') {
if (CMP4(name[1],'h','a','n','g') && CMP4(name[5],'e','I','n','t') && CMP4(name[9],'e','r','v','a') && CMP2(name[13],'l','\0')) {
// changeInterval (src/jswrap_io.c)
JsVar *id, *time;
jspParseFunction(0, &id, &time, 0, 0);
jswrap_interface_changeInterval(id, jsvGetFloatAndUnLock(time));
jsvUnLock(id);
return 0;
} else if (CMP4(name[1],'l','e','a','r')) {
if (CMP4(name[5],'I','n','t','e') && CMP4(name[9],'r','v','a','l') && name[13]=='\0') {
// clearInterval (src/jswrap_io.c)
JsVar *id = jspParseSingleFunction();
jswrap_interface_clearInterval(id);
jsvUnLock(id);
return 0;
} else if (CMP4(name[5],'T','i','m','e') && CMP4(name[9],'o','u','t','\0')) {
// clearTimeout (src/jswrap_io.c)
JsVar *id = jspParseSingleFunction();
jswrap_interface_clearTimeout(id);
jsvUnLock(id);
return 0;
} else if (CMP4(name[5],'W','a','t','c') && CMP2(name[9],'h','\0')) {
// clearWatch (src/jswrap_io.c)
JsVar *id = jspParseSingleFunction();
jswrap_interface_clearWatch(id);
jsvUnLock(id);
return 0;
}
}
} else if (name[0]=='e') {
if (CMP4(name[1],'c','h','o','\0')) {
// echo (src/jswrap_interactive.c)
JsVar *echoOn = jspParseSingleFunction();
jswrap_interface_echo(jsvGetBoolAndUnLock(echoOn));
return 0;
} else if (CMP4(name[1],'d','i','t','\0')) {
// edit (src/jswrap_interactive.c)
JsVar *funcName;
jspParseFunction(0|JSP_NOSKIP_A, &funcName, 0, 0, 0);
jswrap_interface_edit(funcName);
jsvUnLock(funcName);
return 0;
} else if (CMP4(name[1],'v','a','l','\0')) {
// eval (src/jswrap_functions.c)
JsVar *code = jspParseSingleFunction();
JsVar *_r = jswrap_eval(code);
jsvUnLock(code);
return _r;
}
} else if (name[0]=='d') {
if (CMP4(name[1],'i','g','i','t') && CMP2(name[5],'a','l')) {
if (CMP4(name[7],'P','u','l','s') && CMP2(name[11],'e','\0')) {
// digitalPulse (src/jswrap_io.c)
JsVar *pin, *value, *time;
jspParseFunction(0, &pin, &value, &time, 0);
jswrap_io_digitalPulse(jshGetPinFromVarAndUnLock(pin), jsvGetBoolAndUnLock(value), jsvGetFloatAndUnLock(time));
return 0;
} else if (CMP4(name[7],'R','e','a','d') && name[11]=='\0') {
// digitalRead (src/jswrap_io.c)
JsVar *pin = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger(jswrap_io_digitalRead(pin));
jsvUnLock(pin);
return _r;
} else if (CMP4(name[7],'W','r','i','t') && CMP2(name[11],'e','\0')) {
// digitalWrite (src/jswrap_io.c)
JsVar *pin, *value;
jspParseFunction(0, &pin, &value, 0, 0);
jswrap_io_digitalWrite(pin, jsvGetIntegerAndUnLock(value));
jsvUnLock(pin);
return 0;
}
} else if (CMP4(name[1],'u','m','p','\0')) {
// dump (src/jswrap_interactive.c)
jspParseEmptyFunction();
jsiDumpState();
return 0;
}
} else if (CMP3(name[0],'g','e','t')) {
if (CMP4(name[3],'S','e','r','i') && CMP3(name[7],'a','l','\0')) {
// getSerial (src/jswrap_interactive.c)
jspParseEmptyFunction();
JsVar *_r = jswrap_interface_getSerial();
return _r;
} else if (CMP4(name[3],'T','i','m','e') && name[7]=='\0') {
// getTime (src/jswrap_interactive.c)
jspParseEmptyFunction();
JsVar *_r = jsvNewFromFloat((JsVarFloat)jshGetSystemTime() / (JsVarFloat)jshGetTimeFromMilliseconds(1000));
return _r;
}
} else if (CMP4(name[0],'F','l','o','a') && name[4]=='t') {
if (CMP4(name[5],'3','2','A','r') && CMP4(name[9],'r','a','y','\0')) {
// Float32Array.Float32Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_FLOAT32, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
} else if (CMP4(name[5],'6','4','A','r') && CMP4(name[9],'r','a','y','\0')) {
// Float64Array.Float64Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_FLOAT64, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
}
} else if (name[0]=='S') {
if (CMP2(name[1],'P','I')) {
if (CMP2(name[3],'1','\0')) {
// Object SPI1 (src/jswrap_spi_i2c.c)
#if SPIS>=1
jspParseVariableName();
return jspNewObject(jsiGetParser(), "SPI1", "SPI");
#endif //SPIS>=1
} else if (CMP2(name[3],'3','\0')) {
// Object SPI3 (src/jswrap_spi_i2c.c)
#if SPIS>=3
jspParseVariableName();
return jspNewObject(jsiGetParser(), "SPI3", "SPI");
#endif //SPIS>=3
} else if (CMP2(name[3],'2','\0')) {
// Object SPI2 (src/jswrap_spi_i2c.c)
#if SPIS>=2
jspParseVariableName();
return jspNewObject(jsiGetParser(), "SPI2", "SPI");
#endif //SPIS>=2
}
} else if (CMP4(name[1],'e','r','i','a') && name[5]=='l') {
if (CMP2(name[6],'1','\0')) {
// Object Serial1 (src/jswrap_serial.c)
#if USARTS>=1
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial1", "Serial");
#endif //USARTS>=1
} else if (CMP2(name[6],'3','\0')) {
// Object Serial3 (src/jswrap_serial.c)
#if USARTS>=3
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial3", "Serial");
#endif //USARTS>=3
} else if (CMP2(name[6],'2','\0')) {
// Object Serial2 (src/jswrap_serial.c)
#if USARTS>=2
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial2", "Serial");
#endif //USARTS>=2
} else if (CMP2(name[6],'5','\0')) {
// Object Serial5 (src/jswrap_serial.c)
#if USARTS>=5
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial5", "Serial");
#endif //USARTS>=5
} else if (CMP2(name[6],'4','\0')) {
// Object Serial4 (src/jswrap_serial.c)
#if USARTS>=4
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial4", "Serial");
#endif //USARTS>=4
} else if (CMP2(name[6],'6','\0')) {
// Object Serial6 (src/jswrap_serial.c)
#if USARTS>=6
jspParseVariableName();
return jspNewObject(jsiGetParser(), "Serial6", "Serial");
#endif //USARTS>=6
}
} else if (CMP4(name[1],'t','r','i','n') && CMP2(name[5],'g','\0')) {
// String.String (src/jswrap_string.c)
JsVar *str = jspParseSingleFunction();
JsVar *_r = jswrap_string_constructor(str);
jsvUnLock(str);
return _r;
}
} else if (CMP4(name[0],'l','o','a','d') && name[4]=='\0') {
// load (src/jswrap_interactive.c)
jspParseEmptyFunction();
jsiSetTodo(TODO_FLASH_LOAD);
return 0;
} else if (CMP4(name[0],'O','n','e','W') && CMP4(name[4],'i','r','e','\0')) {
// OneWire.OneWire (src/jswrap_onewire.c)
JsVar *pin = jspParseSingleFunction();
JsVar *_r = jswrap_onewire_constructor(jshGetPinFromVarAndUnLock(pin));
return _r;
} else if (CMP4(name[0],'N','a','N','\0')) {
// NaN (libs/jswrap_math.c)
jspParseVariableName();
JsVar *_r = jsvNewFromFloat(NAN);
return _r;
} else if (name[0]=='p') {
if (CMP4(name[1],'a','r','s','e')) {
if (CMP4(name[5],'I','n','t','\0')) {
// parseInt (src/jswrap_functions.c)
JsVar *string, *radix;
jspParseFunction(0, &string, &radix, 0, 0);
JsVar *_r = jswrap_parseInt(string, radix);
jsvUnLock(string);
jsvUnLock(radix);
return _r;
} else if (CMP4(name[5],'F','l','o','a') && CMP2(name[9],'t','\0')) {
// parseFloat (src/jswrap_functions.c)
JsVar *string = jspParseSingleFunction();
JsVar *_r = jsvNewFromFloat(jswrap_parseFloat(string));
jsvUnLock(string);
return _r;
}
} else if (CMP4(name[1],'i','n','M','o') && CMP3(name[5],'d','e','\0')) {
// pinMode (src/jswrap_io.c)
JsVar *pin, *mode;
jspParseFunction(0, &pin, &mode, 0, 0);
jswrap_io_pinMode(jshGetPinFromVarAndUnLock(pin), mode);
jsvUnLock(mode);
return 0;
} else if (CMP4(name[1],'r','i','n','t') && name[5]=='\0') {
// print (src/jswrap_interactive.c)
JsVar *text = jspParseFunctionAsArray();
if (!text) return 0; // if parse error
jswrap_interface_print(text);
jsvUnLock(text);
return 0;
} else if (CMP3(name[1],'e','e','k')) {
if (CMP3(name[4],'1','6','\0')) {
// peek16 (src/jswrap_io.c)
JsVar *addr = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger((JsVarInt)*(unsigned short*)jsvGetInteger(addr));
jsvUnLock(addr);
return _r;
} else if (CMP2(name[4],'8','\0')) {
// peek8 (src/jswrap_io.c)
JsVar *addr = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger((JsVarInt)*(unsigned char*)jsvGetInteger(addr));
jsvUnLock(addr);
return _r;
} else if (CMP3(name[4],'3','2','\0')) {
// peek32 (src/jswrap_io.c)
JsVar *addr = jspParseSingleFunction();
JsVar *_r = jsvNewFromInteger((JsVarInt)*(unsigned int*)jsvGetInteger(addr));
jsvUnLock(addr);
return _r;
}
} else if (CMP3(name[1],'o','k','e')) {
if (CMP3(name[4],'1','6','\0')) {
// poke16 (src/jswrap_io.c)
JsVar *addr, *value;
jspParseFunction(0, &addr, &value, 0, 0);
(*(unsigned short*)jsvGetInteger(addr)) = (unsigned short)jsvGetInteger(value);
jsvUnLock(addr);
jsvUnLock(value);
return 0;
} else if (CMP2(name[4],'8','\0')) {
// poke8 (src/jswrap_io.c)
JsVar *addr, *value;
jspParseFunction(0, &addr, &value, 0, 0);
(*(unsigned char*)jsvGetInteger(addr)) = (unsigned char)jsvGetInteger(value);
jsvUnLock(addr);
jsvUnLock(value);
return 0;
} else if (CMP3(name[4],'3','2','\0')) {
// poke32 (src/jswrap_io.c)
JsVar *addr, *value;
jspParseFunction(0, &addr, &value, 0, 0);
(*(unsigned int*)jsvGetInteger(addr)) = (unsigned int)jsvGetInteger(value);
jsvUnLock(addr);
jsvUnLock(value);
return 0;
}
}
} else if (name[0]=='s') {
if (CMP4(name[1],'a','v','e','\0')) {
// save (src/jswrap_interactive.c)
jspParseEmptyFunction();
jsiSetTodo(TODO_FLASH_SAVE);
return 0;
} else if (CMP2(name[1],'e','t')) {
if (CMP4(name[3],'B','u','s','y') && CMP4(name[7],'I','n','d','i') && CMP4(name[11],'c','a','t','o') && CMP2(name[15],'r','\0')) {
// setBusyIndicator (src/jswrap_interactive.c)
JsVar *pin = jspParseSingleFunction();
jswrap_interface_setBusyIndicator(pin);
jsvUnLock(pin);
return 0;
} else if (CMP4(name[3],'D','e','e','p') && CMP4(name[7],'S','l','e','e') && CMP2(name[11],'p','\0')) {
// setDeepSleep (src/jswrap_interactive.c)
JsVar *sleep = jspParseSingleFunction();
jswrap_interface_setDeepSleep(jsvGetBoolAndUnLock(sleep));
return 0;
} else if (CMP4(name[3],'I','n','t','e') && CMP4(name[7],'r','v','a','l') && name[11]=='\0') {
// setInterval (src/jswrap_io.c)
JsVar *function, *timeout;
jspParseFunction(0|JSP_NOSKIP_A, &function, &timeout, 0, 0);
JsVar *_r = jswrap_interface_setInterval(function, jsvGetFloatAndUnLock(timeout));
jsvUnLock(function);
return _r;
} else if (CMP4(name[3],'S','l','e','e') && CMP4(name[7],'p','I','n','d') && CMP4(name[11],'i','c','a','t') && CMP3(name[15],'o','r','\0')) {
// setSleepIndicator (src/jswrap_interactive.c)
JsVar *pin = jspParseSingleFunction();
jswrap_interface_setSleepIndicator(pin);
jsvUnLock(pin);
return 0;
} else if (CMP4(name[3],'T','i','m','e') && CMP4(name[7],'o','u','t','\0')) {
// setTimeout (src/jswrap_io.c)
JsVar *function, *timeout;
jspParseFunction(0|JSP_NOSKIP_A, &function, &timeout, 0, 0);
JsVar *_r = jswrap_interface_setTimeout(function, jsvGetFloatAndUnLock(timeout));
jsvUnLock(function);
return _r;
} else if (CMP4(name[3],'W','a','t','c') && CMP2(name[7],'h','\0')) {
// setWatch (src/jswrap_io.c)
JsVar *function, *pin, *options;
jspParseFunction(0|JSP_NOSKIP_A, &function, &pin, &options, 0);
JsVar *_r = jswrap_interface_setWatch(function, jshGetPinFromVarAndUnLock(pin), options);
jsvUnLock(function);
jsvUnLock(options);
return _r;
}
}
} else if (CMP2(name[0],'r','e')) {
if (CMP4(name[2],'q','u','i','r') && CMP2(name[6],'e','\0')) {
// require (src/jswrap_modules.c)
JsVar *moduleName = jspParseSingleFunction();
JsVar *_r = jswrap_require(moduleName);
jsvUnLock(moduleName);
return _r;
} else if (CMP4(name[2],'s','e','t','\0')) {
// reset (src/jswrap_interactive.c)
jspParseEmptyFunction();
jsiSetTodo(TODO_RESET);
return 0;
}
} else if (name[0]=='U') {
if (CMP3(name[1],'i','n','t')) {
if (CMP4(name[4],'1','6','A','r') && CMP4(name[8],'r','a','y','\0')) {
// Uint16Array.Uint16Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_UINT16, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
} else if (CMP4(name[4],'8','A','r','r') && CMP3(name[8],'a','y','\0')) {
// Uint8Array.Uint8Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_UINT8, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
} else if (CMP4(name[4],'3','2','A','r') && CMP4(name[8],'r','a','y','\0')) {
// Uint32Array.Uint32Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_UINT32, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
}
} else if (CMP3(name[1],'S','B','\0')) {
// Object USB (src/jswrap_serial.c)
#if defined(USB)
jspParseVariableName();
return jspNewObject(jsiGetParser(), "USB", "Serial");
#endif //defined(USB)
}
} else if (CMP4(name[0],'t','r','a','c') && CMP2(name[4],'e','\0')) {
// trace (src/jswrap_interactive.c)
JsVar *root;
jspParseFunction(0|JSP_NOSKIP_A, &root, 0, 0, 0);
jswrap_interface_trace(root);
jsvUnLock(root);
return 0;
} else if (name[0]=='I') {
if (CMP2(name[1],'2','C')) {
if (CMP2(name[3],'1','\0')) {
// Object I2C1 (src/jswrap_spi_i2c.c)
#if I2CS>=1
jspParseVariableName();
return jspNewObject(jsiGetParser(), "I2C1", "I2C");
#endif //I2CS>=1
} else if (CMP2(name[3],'3','\0')) {
// Object I2C3 (src/jswrap_spi_i2c.c)
#if I2CS>=3
jspParseVariableName();
return jspNewObject(jsiGetParser(), "I2C3", "I2C");
#endif //I2CS>=3
} else if (CMP2(name[3],'2','\0')) {
// Object I2C2 (src/jswrap_spi_i2c.c)
#if I2CS>=2
jspParseVariableName();
return jspNewObject(jsiGetParser(), "I2C2", "I2C");
#endif //I2CS>=2
}
} else if (CMP2(name[1],'n','t')) {
if (CMP4(name[3],'1','6','A','r') && CMP4(name[7],'r','a','y','\0')) {
// Int16Array.Int16Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_INT16, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
} else if (CMP4(name[3],'8','A','r','r') && CMP3(name[7],'a','y','\0')) {
// Int8Array.Int8Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_INT8, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
} else if (CMP4(name[3],'3','2','A','r') && CMP4(name[7],'r','a','y','\0')) {
// Int32Array.Int32Array (src/jswrap_arraybuffer.c)
JsVar *arr, *byteOffset, *length;
jspParseFunction(0, &arr, &byteOffset, &length, 0);
JsVar *_r = jswrap_typedarray_constructor(ARRAYBUFFERVIEW_INT32, arr, jsvGetInteger(byteOffset), jsvGetInteger(length));
jsvUnLock(arr);
jsvUnLock(byteOffset);
jsvUnLock(length);
return _r;
}
}
}
}
return JSW_HANDLEFUNCTIONCALL_UNHANDLED;
}
bool jswIsBuiltInObject(const char *name) {
return
strcmp(name, "Pin")==0 ||
strcmp(name, "Modules")==0 ||
strcmp(name, "process")==0 ||
strcmp(name, "console")==0 ||
strcmp(name, "JSON")==0 ||
strcmp(name, "Hardware")==0 ||
strcmp(name, "Object")==0 ||
strcmp(name, "Function")==0 ||
strcmp(name, "Integer")==0 ||
strcmp(name, "Double")==0 ||
strcmp(name, "String")==0 ||
strcmp(name, "Array")==0 ||
strcmp(name, "ArrayBuffer")==0 ||
strcmp(name, "ArrayBufferView")==0 ||
strcmp(name, "Uint8Array")==0 ||
strcmp(name, "Int8Array")==0 ||
strcmp(name, "Uint16Array")==0 ||
strcmp(name, "Int16Array")==0 ||
strcmp(name, "Uint32Array")==0 ||
strcmp(name, "Int32Array")==0 ||
strcmp(name, "Float32Array")==0 ||
strcmp(name, "Float64Array")==0 ||
strcmp(name, "Serial")==0 ||
strcmp(name, "SPI")==0 ||
strcmp(name, "I2C")==0 ||
strcmp(name, "OneWire")==0 ||
strcmp(name, "Math")==0;
}
bool jswIsBuiltInLibrary(const char *name) {
return
;
}
/** Given a variable, return the basic object name of it */
const char *jswGetBasicObjectName(JsVar *var) {
if (jsvIsFunction(var)) return "Function";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_INT32) return "Int32Array";
if (jsvIsString(var)) return "String";
if (jsvIsPin(var)) return "Pin";
if (jsvIsFloat(var)) return "Double";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_ARRAYBUFFER) return "ArrayBuffer";
if (jsvIsObject(var)) return "Object";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_UINT8) return "Uint8Array";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_UINT16) return "Uint16Array";
if (jsvIsRoot(var)) return "Hardware";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_FLOAT64) return "Float64Array";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_INT8) return "Int8Array";
if (jsvIsInt(var)) return "Integer";
if (jsvIsArray(var)) return "Array";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_INT16) return "Int16Array";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_FLOAT32) return "Float32Array";
if (jsvIsArrayBuffer(var) && var->varData.arraybuffer.type==ARRAYBUFFERVIEW_UINT32) return "Uint32Array";
return 0;
}
/** Given the name of a Basic Object, eg, Uint8Array, String, etc. Return the prototype object's name - or 0. */
const char *jswGetBasicObjectPrototypeName(const char *objectName) {
if (!strcmp(objectName, "Uint8Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Int8Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Uint16Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Int16Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Uint32Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Int32Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Float32Array")) return "ArrayBufferView";
if (!strcmp(objectName, "Float64Array")) return "ArrayBufferView";
return strcmp(objectName,"Object") ? "Object" : 0;
}