You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I extended ABS for myself to be able to call functions from go plugins. Perhaps something like this can be considered for main.
Simplest plugin example :
package main
func Add(argc int32, argv []interface{}) interface{} {
x := argv[0].(float64)
y := argv[1].(float64)
return x + y // Returned values automatically converted to ABS data types
}
Compiled with go build -buildmode=plugin, can be called from an ABS script like this:
# arg1 : path to compiled plugin ; arg2 : Plugin gets a name which is used in execShared
importShared("plugin.so", "plugin") /
# arg1: Name from arg2 of importShared ; arg2 : Name of exported functions from the go plugin ; arg3 : Array which gets passed to the go function called, basic types automatically converted.
execShared("plugin", "Add", [1, 2]) // returns 3
The implementation is kind of bad, as it would be nice to be able to get a library "object" instead of having to "name" all loaded plugins, but I like the simplicity of not having to worry about ABS-specific or go-specific types (as is the case with something like luajit ffi, or python C extensions). I can share some code if anyone is interested.
The text was updated successfully, but these errors were encountered:
I would be +1 on the ability to load external plugins. One thing to consider, the public interface could probably be looking a little different eg. we could make this work with x = require('plugin.so') and then be able to call x.something. I don't have a strong sense on what we need to do to get this working, but I'd be happy to engage with you if you wished to send a PR / proposal.
I extended ABS for myself to be able to call functions from go plugins. Perhaps something like this can be considered for main.
Simplest plugin example :
Compiled with
go build -buildmode=plugin
, can be called from an ABS script like this:The implementation is kind of bad, as it would be nice to be able to get a library "object" instead of having to "name" all loaded plugins, but I like the simplicity of not having to worry about ABS-specific or go-specific types (as is the case with something like luajit ffi, or python C extensions). I can share some code if anyone is interested.
The text was updated successfully, but these errors were encountered: