This is a breaking change because existing imports in user Wren code
that assume the path is relative to the entrypoint file will now likely
fail.
Also, stack trace output and host API calls that take a module string
now need the resolved module string, not the short name that appears in
the import.
- Rename "size" -> "count" to be consistent with other usage.
- Remove "Slot" from the function names, since that's implicit.
- Make the getListElement() just move the element to another slot. This
matches other APIs where we distinguish accessing a value and
converting it to some specific type.
There's nothing new in this "release", but now is as good a time as any
to start versioning. Going forward, I plan to do periodic releases and
update the changelog so users can see what's going on.
This PR adds support for retrieving list information from a slot. Rather
than take the whole list, two different methods are provided for
retrieving a) the length of the list, and b) a specific value in the
list.
commit f93ec6430f9629b5a28765a3961379d1e8296e50
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date: Wed Mar 16 08:03:25 2016 -0700
Tiny tweaks.
commit 332a08fe33cddffec82dbd377ee0c941a0066f64
Merge: a67398114b7a08
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date: Wed Mar 16 08:01:00 2016 -0700
Merge branch 'errorFn' of https://github.com/ppvk/wren into ppvk-errorFn
commit 14b7a086ce
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:33:37 2016 -0500
missing semicolon, accessing vm through parser in
commit 924eaa1f9d
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:25:32 2016 -0500
fixed missing errorFn in wren.h
commit 3761df111f
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:23:51 2016 -0500
Added an errorFn to the CLI
commit d51137b4ab
Author: Paul VanKeuren <paul.vankeuren@gmail.com>
Date: Tue Mar 15 11:21:16 2016 -0500
Added a WrenErrorFn typedef, an errorFn slot in WrenConfiguration. exits early if is not defined, otherwise it runs the errorFn .
Now, you call wrenEnsureSlots() and then wrenSetSlot___() to set up the
receiver and arguments before the call. Then wrenCall() is passed a
handle to the stub function that makes the call. After that, you can
get the result using wrenGetSlot___().
This is a little more verbose to use, but it's more flexible, simpler,
and much faster in the VM. The call benchmark is 185% of the previous
speed.
Instead, finalizers just get access to the foreign object's raw bytes.
This is deliberately limiting, since it discourages the user from
interacting with the VM in the middle of a GC.
- wrenEnsureSlots()
Lets you go the foreign slot stack to make room for a temporary work
area.
- wrenSetSlotNewList()
Creates a new empty list and stores it in a slot.
- wrenInsertInList()
Takes a value from one slot and inserts it into the list in another.
Still need more functions like getting elements from a list, removing,
etc. but this at least lets you create, populate, and return lists from
foreign methods.
This turns those functions into general-purpose functions for writing
raw C values into slots on the foreign call stack.
Writing a return just means writing a value to slot 0.
- wrenGetArgumentCount() -> wrenGetSlotCount()
- wrenGetArgument___() -> wrenGetSlot___()
Also, the get functions assert that the value is the right type instead
of checking at runtime. This puts the onus on the caller to be safe,
but maximizes performance.
- Add an explicit va_list version. That lets variadic functions
forward to it.
- Fix a GC bug in wrenCall() with return values.
- Make the call API test not re-enter the VM.
- Test that a foreign method can return strings.
- Test that a foreign method can return a string with null bytes.
- Test wrenCall().
- Allow passing NULL for "v" to wrenCall().
- Allow "a" for passing an explicit length byte array to wrenCall().
Most of the pieces are there:
- You can declare a foreign class.
- It will call your C function to provide an allocator function.
- Whenever a foreign object is created, it calls the allocator.
- Foreign methods can access the foreign bytes of an object.
- Most of the runtime checking is in place for things like subclassing
foreign classes.
There is still some loose ends to tie up:
- Finalizers are not called.
- Some of the error-handling could be better.
- The GC doesn't track how much memory a marked foreign object uses.
This makes it clear which files are part of the VM (i.e. the Wren library)
and which are part of the CLI. Makes a directory for the latter so it has
some room to grow.
This probably totally broke the VS project. If you can fix that, send me
a PR!