jerryscript-project / iotjs Goto Github PK
View Code? Open in Web Editor NEWPlatform for Internet of Things with JavaScript http://www.iotjs.net
License: Other
Platform for Internet of Things with JavaScript http://www.iotjs.net
License: Other
Currently IoT.js binds its native javascipt function using external handler API of Jerry Engine. The prototype of the handler is defined as:
typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj_p,
const jerry_api_value_t *this_p,
jerry_api_value_t *ret_val_p,
const jerry_api_value_t args_p [],
const uint16_t args_count);
And each module should implement handlers like:
static bool ToString(const jerry_api_object_t *function_obj_p,
const jerry_api_value_t *this_p,
jerry_api_value_t *ret_val_p,
const jerry_api_value_t args_p [],
const uint16_t args_cnt) {
assert(args_cnt == 0);
JObject buffer_obj(this_p, false);
char* buffer = reinterpret_cast<char*>(buffer_obj.GetNative());
assert(buffer != NULL);
JObject jstring(buffer);
jstring.Ref();
*ret_val_p = jstring.val();
return true;
}
In spite of JObject
wrapper for object type, there is no wrapping layer for external handlers. I think we should introduce a layer that wrap external handler in consistent way with JObject
wrapper so that developers who does not know about jerry also could work with it more easily.
https://github.com/Samsung/iotjs/wiki/IoT.js%20API%20Reference
Need Function.prototype.apply(ECMA262 15.3.4.3) supported by Jerry.
Readable stream has two mode: flowing and paused.
Currently IoT.js only implemented paused mode. But many use cases run in flowing mode so we need to implement flowing mode before start implementing other modules like fs
, net
, etc.
Need Array.isArray(ECMA262-15.4.3.2) supported by Jerry.
process.compile and process.compileNativePtr have no error handling routine when jerry_api_eval return error.
Need to change the build.py script so that it generates math library in jerry third-party.
Need debug message logging like in JerryScript
+#ifdef JERRY_ENABLE_LOG
+#define JERRY_LOG(lvl, ...) \
+ do \
+ { \
+ if (lvl <= jerry_debug_level && jerry_log_file) \
+ { \
+ fprintf (jerry_log_file, __VA_ARGS__); \
+ } \
+ } \
+ while (0)
+
+#define JERRY_DLOG(...) JERRY_LOG (1, __VA_ARGS__)
+#define JERRY_DDLOG(...) JERRY_LOG (2, __VA_ARGS__)
+#define JERRY_DDDLOG(...) JERRY_LOG (3, __VA_ARGS__)
+#else /* !JERRY_ENABLE_LOG */
+#define JERRY_DLOG(...) \
+ do \
+ { \
+ if (false) \
+ { \
+ jerry_ref_unused_variables (0, __VA_ARGS__); \
+ } \
+ } while (0)
+#define JERRY_DDLOG(...) JERRY_DLOG (__VA_ARGS__)
+#define JERRY_DDDLOG(...) JERRY_DLOG (__VA_ARGS__)
+#endif /* !JERRY_ENABLE_LOG */
Complete implementation of fs module.
Required Items:
Need Array.prototype.shift(ECMA262-15.4.4.9) supported by Jerry.
Timers methods need to be exposed to global.
Implement in start_iotjs()
Running test_next_tick.js should end with five lines of output but it is printing only 2 lines before finish.
Main loop should remain as long as there are requests to be handled.
From #90, IoT.js registers commonly used string literal as external magic string of jerry engine.
Unfortunately we need to periodically maintain list of magic string by hand.
I think we can automate this by running a script at build process like "iotjs_js.h" file gereration.
Used in Compile
and CompileNativePtr
in 'iotjs_module_process.cpp'.
Nodejs search for a module in the order of
(1) ./node_modules
(2) $NODE_PATH/node_modules
(3) $HOME/node_modules
(4) $HOME/node_libraries
(5) (node execpath)/node/lib
We need to determine the search order w.r.t. multiple plaforms since enviroment or cwd is not available in small devices.
Need arguments(ECMA262 10.6) supported by Jerry.
Now we have automatic build test feature.
The build test is mainly done by "tools/check_test.py" script.
Document it, expected contents are:
NuttX build with current iotjs, run simple hello world script.
console.log("Hello IoT.js");
Implement Timers methods
Required Items:
Lots of test file use print
to print out text to screen.
But print
is not offered by our API, instead we can use console
.
As of today, nodejs is on the discuss to support hardware and libuv is ready with uv_device_t PR.
For IoT.js, how are we going to support hardware control and manage devices?
First PR #105 needs some more adjustments and we need to discuss how to provide the API and manage H/W boards and devices. GPIO-control-ideas is prepared to draw everyones sketch.
Please add comments and write down to WiKi page.
Need Object.create(ECMA262 12.2.3.5) supported by Jerry.
We've landed first implementation for socket.write()
, socket.readStart()
.
To finish connection, socket.end()
is needed which will shutdown writable stream and readable stream as well but only if there are no more data to read.
For #31
Need Array.prototype.slice(ECMA262 15.4.4.10) supported by Jerry.
As described in https://github.com/Samsung/iotjs/wiki/IoT.js-Package page we may need a built-in package downloader module, but should optional in compile time so that not consume flash space if not needed.
Condition
What
install <package>
list
remove <package>
Currently, to make module a function we wrapping over js source with wrapper looking somewhat ugly.
const char* wrapper[2] = {
"(function (a, b, c) { function wwwwrap(exports,require, module) {",
" }; wwwwrap(a, b, c); });" };
This double wrapping is because single wrapping results in bug with losing captured variables. This is probably bug on eval functionality of jerry.
After applying daf7b02 commit,
readable stream does not emit 'end' event after pushing null into stream.
process has native_sources property with text source that will consume JerryScript heap.
I think it's better remove this and related implementation to native side to save the JavaScript heap.
Introduce a automated build system for continuous integration. There are several well-known build systems such as buildbot, jenkins, hudson, and etc. By using automated build system, we can not only reduce our merge or integration cost but also eliminate human mistakes.
The process of source integrating is a work of routine. But it requires for people delicate work from start to end to finish without making any mistake. Unfortunately we human being make mistakes even more when the work is a kind of routine. And also it takes a time to be done.
By using automated build system, we are free from such matters. The most of the steps in a process of source integration - except an important step, reviewing - are programmable.
Automated build system may conduct following routines.
It also can do followings in conjunction with github web hook API.
Hello.
Code buffer size argument of jerry_api_eval
in JHANDLER_FUNCTION(Compile, handler)
and JHANDLER_FUNCTION(CompileNativePtr, handler)
is calculated incorrectly : sizeof (code)
equals to size of pointer, not buffer size.
Maybe, this could be fixed with the following:
diff --git a/src/iotjs_module_process.cpp b/src/iotjs_module_process.cpp
index 282bc09..bd73a3f 100644
--- a/src/iotjs_module_process.cpp
+++ b/src/iotjs_module_process.cpp
@@ -87,7 +87,7 @@ JHANDLER_FUNCTION(Compile, handler){
char* code = handler.GetArg(0)->GetCString();
JRawValueType ret_val;
- jerry_api_eval(code,sizeof(code),true,false,&ret_val);
+ jerry_api_eval(code,strlen(code),true,false,&ret_val);
JObject::ReleaseCString(code);
JObject ret(&ret_val);
@@ -116,7 +116,7 @@ JHANDLER_FUNCTION(CompileNativePtr, handler){
strcat(code,wrapper[1]);
JRawValueType ret_val;
- jerry_api_eval(code,sizeof(code),true,false,&ret_val);
+ jerry_api_eval(code,len,true,false,&ret_val);
JObject::ReleaseCString(code);
JObject ret(&ret_val);
We need to
Need Array.prototype.push(ECMA262-15.4.4.7) supported by Jerry.
Many warnings are reported during release build which are not appear in debug build.
The pattern of this problem is below form:
int a = <expr>;
assert(a);
assert
eats its argument expression and ends in empty expression on release build, resulting the a
unused.
Let's introduce redefinition of assert()
like this:
#ifdef NDEBUG
#define IOTJS_ASSERT(x) ((void)(x))
#else
#define IOTJS_ASSERT(x) assert(x)
#endif
As described in https://github.com/Samsung/iotjs/wiki/IoT.js-Package page, we may need to embed downloaded packages inside iotjs. It can be done such as
Application script should exist at the root of the specific folder.
https://github.com/Samsung/iotjs/wiki/IoT.js-API:-Net
net
net.Server
net.Socket
It looks like read
returns empty buffer very occasionally.
Run iotjs with invalid file name, some random string.
I think it should show some error or waring that file does not exist on invalid file.
Currently it shows nothing.
Test with 1777b85
current message for assert failure is always same position
src/iotjs_binding.cpp:329: iotjs::JObject iotjs::JObject::Call(iotjs::JObject&, iotjs::JArgList&): Assertion `is_ok' failed.
Aborted (core dumped)
need to fix this to show real position.
// Todo: use splice when available
var j, leng = timers_list.length;
for (j = idx; j < leng; j++) {
timers_list[j] = timers_list[j+1];
}
timers_list.pop();
This is meta issue for all works related with Jerry Javascript Engine.
We have to discuss the following topics.
Need String.prototype.slice(ECMA262 15.5.4.13) supported by Jerry.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.