Age | Commit message (Collapse) | Author |
|
Extend the ubus binding to cover ubus event handling APIs.
Instantiating ubus event listener:
listener = conn.listener(
"event.type.*",
function (type, data) {
...event callback...
}
);
listener.remove();
Broadcasting events:
conn.event("event.type.foo", { ...event data... });
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Add more detailled error messages
- Introduce helpers for fetching and validating function call arguments
- Get rid of some uneeded blob->jso->ucv conversions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Extend the ubus binding to cover ubus object publishing, notifications on
objects, as well as subscriber APIs.
Instantiating ubus objects:
obj = conn.publish("objname", {
methodname: {
args: { ...argspec... },
call: function(request) { ...method handler... }
},
...
}, function() { ...subscription status change handler... });
obj.notify(...);
obj.remove();
Emitting notifications:
obj.notify("notificationtype", { ...notification data... },
function(type, data) { ...data callback... },
function(idx, ret) { ...status callback... },
function() { ...completion callback... },
100 /* timeout */
);
Instantiating subscribers:
sub = conn.subscriber(
function(notify) { ...notification handler... },
function(id) { ...object gone handler... }
);
sub.subscribe("objname");
sub.unsubscribe("objname");
sub.remove();
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce a new ubus.defer() method which initiates asynchroneous requests
and invokes the completion callback passed as 4th argument once the reply
is received.
This allows multiplexing mutliple ubus requests with the same ucode VM
context / the same uloop event loop.
In case the ucode context is not running under an active uloop, the ubus
module will spawn uloop itself once the first asynchroneous request is
launched and terminate the loop once all pending requests finished.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fix instances of misspelled "resource".
This commit breaks the exported libucode ABI.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Ensure that most functions follow the subject_verb naming schema
- Move type related function from value.c to types.c
- Rename value.c to vallist.c
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ensure that all custom typedef and vector declaration type names end with
a "_t" suffix.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The naming is an artifact from before the introduction of the new type
system. In the current code, there is nothing special about prototypes,
they're simple object values.
Also introduce a new singular uc_add_function() convenience macro while
we're at it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Instead of relying on json_object values internally, use custom types to
represent the different ucode value types which brings a number of
advantages compared to the previous approach:
- Due to the use of tagged pointers, small integer, string and bool
values can be stored directly in the pointer addresses, vastly
reducing required heap memory
- Ability to create circular data structures such as
`let o; o = { test: o };`
- Ability to register custom `tostring()` function through prototypes
- Initial mark/sweep GC implementation to tear down circular object
graphs on VM deinit
The change also paves the way for possible future extensions such as
constant variables and meta methods for custom ressource types.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Replace the former AST walking interpreter implementation with a single pass
bytecode compiler and a corresponding virtual machine.
The rewrite lays the groundwork for a couple of improvements with will be
subsequently implemented:
- Ability to precompile ucode sources into binary byte code
- Strippable debug information
- Reduced runtime memory usage
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Also handle calls to C functions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Register prototype object directly together with the type instead of
setting it manually whenever an extended type value is instantiated.
This also allows freeing the various prototype objects in dlopened
modules.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Also introduce convenience macro for registering function arrays in modules.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Also move shared library output files to the lib/ directory
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|