1
0
forked from Mirror/wren
Commit Graph

13 Commits

Author SHA1 Message Date
1d16e85a85 Add an API to load a top-level variable into a slot. 2015-12-26 10:53:14 -08:00
15043b897f Add a benchmark for wrenCall(). 2015-12-23 17:29:53 -08:00
6f37d379f4 Add C API functions for working with lists:
- 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.
2015-12-16 16:28:26 -08:00
7fcdcf2f1a wrenReturn___() -> wrenSlotSet___().
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.
2015-12-16 13:00:13 -08:00
01e8f9053e Add a benchmark to test the Wren C API.
I've got some ideas on how to tweak the embedding API, but I want to
see what performance impact they have first, so this adds a little
benchmark that just calls a foreign method a ton of times.
2015-12-15 16:02:13 -08:00
79354f5a97 Do some work on wrenCall().
- 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.
2015-09-29 19:29:10 -07:00
f757c9efac Better embedding API support (and tests!) for strings with null bytes.
- 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().
2015-09-24 08:02:31 -07:00
66b89a493f Combine io.c and vm.c.
(This is mainly to free up io.c as a built in module.)
2015-09-13 22:29:47 -07:00
48bdbc7745 First pass at implementing foreign classes.
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.
2015-08-15 12:07:53 -07:00
7a79b8fac6 Simplify the API tests.
Use fewer test suites with more tests in each one since there's so much
boilerplate for defining an API test.
2015-08-13 09:09:27 -07:00
0b97b27cf4 Add an API for storing handles to values outside of the VM.
It's pretty bare bones now, but it lets you get a reference to an object
from a foreign call and then return it later.
2015-08-06 22:24:15 -07:00
d66556b713 Add API tests for returning null or numbers. 2015-05-24 10:04:24 -07:00
7084d6bfd5 Add infrastructure to test embedding API. 2015-05-24 09:23:30 -07:00