@Araq can we have native PNode to NimNode conversion :)
I looked at your code quite a lot when I did my implementation. If you had had
the new version back then I would probably have used it, but at this point I'm
pretty much where I need to be with my own implementation so it makes less
sense to replace it.
But I will pilfer more ideas from your ne
To reduce the boiler plate I highly suggest looking into my rewrite of
Nimscripter(it's still not pushed as the master branch due to some bug on the
Nim -> Nimscript front, but the code works for interop). A simple example is as
follows:
# Nim
import std/json
import nimscr
That worked out well. A bit of a hassle to do all the manual translation, but
the resulting client API is clean at least so I'm fine with it :)
To use overloading use something like:
proc aInt(x: int) = discard "VM implements it"
proc aString(x: string) = discard "VM implements it"
proc a(x: int) = aInt(x)
proc a(x: string) = aString(x)
Run
Would you suggest that I marshal and unmarshal via string instead? I mean it is
straightforward, but it takes a lot of boilerplate code on both sides. I don't
mind the boilerplate on the host side, but the script side I would like to keep
as clean as possible ...
Can you do type overloading on
I don't know why you don't get a compile-time error for `value: any` but it's
not supported. If you want to `cast` (and you shouldn't) cast the address of
the JsonNode to `int` (but `GC_Ref` it first) and use `PNode(kind: nkIntLit,
intVal: address)`. And in the VM don't forget to `GC_unref` it.
Could I for example consider VMArgs as just bits and tell Nim that I want it to
cast bit x..^1 as a JsonNode?
Hi @araq. Yes that is ofc one way to do it :) In fact that was basically what I
was doing, I had ´setInContext( "some.dot.path", $node )´ in the script call,
`proc setInContext*( path: string, value: string ) = discard` in the host
function declaration and `let value = args.getString( 1 )` in th
Well the PNode does not support JSON, you should be able to pass the JSON as a
string though (PNode(kind: nkStrLit, strVal: "{json_here")).
I'm trying to pass a JsonNode from my script into the compiled program. I can
get it to work by marshalling the data and unmarshalling on the other side, but
if I switch to the strategy of getting a PNode instead of a discreet value,
like with VMArgs.getStr etc, I can't then get Nim to correctly
11 matches
Mail list logo