Giter VIP home page Giter VIP logo

iotjs's People

Contributors

akhilkedia avatar akosthekiss avatar bzsolt avatar chunseoklee avatar daeyeon avatar danielballaszte avatar fbmrk avatar galpeter avatar haesik avatar hs0225 avatar ilyoan avatar irishair7 avatar jiangzidong avatar knightburton avatar kolipka avatar laszlolango avatar lemmaa avatar nova0821 avatar robertsipka avatar rtakacs avatar rzr avatar sae-bom avatar seanshpark avatar seo-young avatar tadziopazur avatar tdusnoki avatar wateret avatar yichoi avatar yuyupo avatar zherczeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iotjs's Issues

Wrapper for Javascript native function binding.

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.

Complete document: API References

ReadableStream flowing mode

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.

Debug message to console

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 fs module

Complete implementation of fs module.

Required Items:

  • fs.access()
  • fs.accessSync()
  • fs.exist() (deprecated)
  • fs.existSync() (deprecated)
  • fs.stat()
  • fs.statSync()
  • fs.chmod()
  • fs.chmodSync()
  • fs.chown()
  • fs.chownSync()
  • fs.rename()
  • fs.renameSync()
  • fs.close()
  • fs.closeSync()
  • fs.open()
  • fs.openSync()
  • fs.read()
  • fs.readSync()
  • fs.readFile()
  • fs.readFileSync()
  • fs.write()
  • fs.writeSync()
  • fs.writeFile()
  • fs.writeFileSync()
  • fs.appendFile()
  • fs.appendFileSync()
  • fs.truncate()
  • fs.truncateSync()
  • fs.mkdir()
  • fs.mkdirSync()
  • fs.rmdir()
  • fs.rmdirSync()
  • fs.readdir()
  • fs.readdirSync()
  • fs.unlink()
  • fs.unlinkSync()

next tick not working correctly.

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.

Automate Jerry external magic string registration.

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.

Determine module search path order

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.

Documentation build test.

Now we have automatic build test feature.
The build test is mainly done by "tools/check_test.py" script.

Document it, expected contents are:

  • build check process
  • kind of test suite
    • run pass
    • run fail
  • how to write test suite
  • test suite attributes

NuttX build and run simple hello world

NuttX build with current iotjs, run simple hello world script.

console.log("Hello IoT.js");

Complete Timers module

Implement Timers methods

Required Items:

  • setTimeout()
  • clearTime()
  • setInterval()
  • clearInterval

Change `print` to `console`

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.

Hardware control APIs

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.

Implement socket.end

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

Revise ugly looking module wrapper

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.

Process native_sources to native side

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.

Merge & Build automation

RFC: Merge & Build Automation.

Summary

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.

Motive

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.

What can be done by automated build system

Automated build system may conduct following routines.

  • Daily building and reporting result.
  • Daily testing including benchmark and reporting result.
  • Build by trigger.
  • Test by trigger.

It also can do followings in conjunction with github web hook API.

  • If there is a new issue registered, report it.
  • If there is a new pull request, report it.
  • If there is a reviewed pull request, build it.
    • If the build and test finished successfully, merge it to master.

Complete HTTP module

  • http.METHODS
  • http.STATUS_CODES
  • http.createServer([requestListener])
  • Class: http.Server
    • Event: 'request'
    • Event: 'connection'
    • Event: 'close'
    • server.listen(port[, hostname][, backlog][, callback])
    • server.close([callback])
    • server.setTimeout(msecs, callback)
    • server.timeout
  • Class: http.ServerResponse
    • Event: 'close'
    • Event: 'finish'
    • response.writeHead(statusCode[, statusMessage][, headers])
    • response.setTimeout(msecs, callback)
    • response.statusCode
    • response.statusMessage
    • response.setHeader(name, value)
    • response.headersSent
    • response.getHeader(name)
    • response.removeHeader(name)
    • response.write(chunk[, encoding][, callback])
    • response.end([data][, encoding][, callback])
  • http.request(options[, callback])
  • http.get(options[, callback])
  • Class: http.ClientRequest
    • Event: 'response'
    • Event: 'socket'
    • request.write(chunk[, encoding][, callback])
    • request.end([data][, encoding][, callback])
    • request.setTimeout(timeout[, callback])
  • http.IncomingMessage
    • Event: 'close'
    • message.headers
    • message.setTimeout(msecs, callback)
    • message.method
    • message.url
    • message.statusCode
    • message.statusMessage
    • message.socket

Size of script code buffer

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);

Prepare module package description

We need to

  • describe what package.json should contain for the module
  • how it is registered to registry server
  • how it is downloaded to the device
  • how it is used in the program

Remove "unused variable" warnings on release build.

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

Implement process.exit()

Implement process.exit(), process.exitCode and event: uncaughtException

Currently, raised an uncaught exception, the program abort. This should be treated in uncaughtException handler and if no handler for it, program exit with corresponding exitcode.

related #78, #36

Complete assert module

  • assert
    • assert.fail
    • assert.equal
    • assert.notEqual
    • assert.strictEqual
    • assert.notStrictEqual
    • assert.throws
    • assert.doesNotThrows

Embedding packages in iotjs

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

  1. download packages to some specific folder
  2. give option to build script to enable embedding with the specific folder
  3. convert package scripts to C code
  4. require() finds packages in embed area

Application script should exist at the root of the specific folder.

Complete net module

https://github.com/Samsung/iotjs/wiki/IoT.js-API:-Net

net

  • createServer()
  • connect(options, connectListener)
  • connect(port, host, connectListener)
  • createConnection(opitions, connectListener)
  • createConnection(port, host, connectListener)

net.Server

  • listen(options, callback)
  • listen(port, host, callback)
  • close()
  • event: listening
  • event: connection
  • event: close
  • event: error

net.Socket

  • new Socket(options)
  • connect(port, host, connectListener)
  • write(data, callback)
  • end(data)
  • destroy()
  • resume()
  • pause()
  • setTimeout()
  • setKeepAlive()
  • event: lookup
  • event: connect
  • event: data
  • event: drain
  • event: end
  • event: timeout
  • event: close
  • event: error

Show correct source position when assert failure

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.