Commit Graph

42 Commits

Author SHA1 Message Date
8210452970 Relative imports!
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.
2018-03-24 11:10:36 -07:00
8a71735e0f Expose an API to let the host resolve relative import strings.
This is a breaking API change: wrenInterpret() now takes an additional
parameter for the module name to interpret the code in.
2018-03-23 07:54:09 -07:00
91853a7fa9 Fix comment on foreign allocate function.
Fix #453.
2017-10-12 06:37:49 -07:00
a7418d64e6 Remove obsolete comment 2017-05-29 12:02:50 -07:00
417ed7aeed Add wren.hpp. 2017-03-25 10:05:33 -07:00
02bcefcbe4 Add test for user data.
Also moved the VM parameter in the error callback to be first like it
is in other callbacks.
2017-03-22 07:26:19 -07:00
907db83e1c Merge branch 'user-data' of https://github.com/foobit/wren into foobit-user-data 2017-03-22 07:12:26 -07:00
18f8f48bb6 Docs for configuring the VM. 2017-02-12 11:04:38 -08:00
dc2f2d9e41 support for user defined state data associated with the WrenVM object 2017-01-19 22:54:25 -05:00
60a0353a27 Tweak list C API:
- 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.
2016-07-28 08:06:36 -07:00
b8675e2d91 Merge branch 'get_slot_list_values' of https://github.com/dradtke/wren into dradtke-get_slot_list_values 2016-07-28 07:53:19 -07:00
59e9eb127e Add wrenAbortFiber().
Thanks, @underscorediscovery!
2016-06-09 19:14:21 -07:00
6bcc64eb61 Wren 0.1.0!
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.
2016-05-21 10:53:05 -07:00
0a060a9678 WrenValue -> WrenHandle. 2016-05-20 20:55:28 -07:00
cf258b9074 Add support for retrieving list values from a slot
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.
2016-05-19 14:11:48 -05:00
0c1fc15e3c Fix typos and re-word explanation of gc heapGrowthPercentage 2016-05-03 18:48:08 +01:00
984fa1ddd1 Use errorFn for runtime errors. 2016-03-17 07:17:03 -07:00
c5855a6fe9 Squashed commit of the following:
commit f93ec6430f9629b5a28765a3961379d1e8296e50
Author: Bob Nystrom <robert@stuffwithstuff.com>
Date:   Wed Mar 16 08:03:25 2016 -0700

    Tiny tweaks.

commit 332a08fe33cddffec82dbd377ee0c941a0066f64
Merge: a673981 14b7a08
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 .
2016-03-16 08:04:03 -07:00
ef3aa07d84 Add API to get the type of object in a slot. 2016-02-19 07:18:00 -08:00
fde6cfc142 Generate wrenAllocateForeign() to match the other setSlot methods.
Thanks, Michel!
2016-01-24 09:25:04 -08:00
e0ac88c22a Revamp wrenCall to work with slots.
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.
2015-12-29 07:58:47 -08:00
ed6fad6153 Get rid of fiber for finalizers.
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.
2015-12-28 08:06:29 -08:00
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
910049cd19 Update the docs around slots. 2015-12-16 16:39:27 -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
4b3c818ec5 Start moving embedding API towards "slot" register-API.
- 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.
2015-12-16 10:22:42 -08:00
3b09b35b59 Get rid of source path in module.
It wasn't useful anyway since it always had the module name for all but
the main script.
2015-10-15 18:17:42 -07: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
efceee4320 Let the host application control how System prints text. 2015-09-15 23:01:43 -07:00
36f3059e48 Get finalizers working. 2015-08-31 21:56:21 -07:00
1e0a2e6036 Get rid of WrenMethod and just use WrenValue for both.
Thanks, Michel!
2015-08-31 07:57:48 -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
56d4d3e671 Allow passing WrenValues to wrenCall(). 2015-08-07 07:57:23 -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
512500be17 fix typo: orde => order 2015-04-17 23:13:36 -03:00
8dcd336638 Merge branch 'master' into foreign-methods 2015-03-25 20:06:55 -07:00
e4a785a071 Remove oldSize from allocate API.
binary_trees - wren            .......... 0.29s 0.0048 107.79% relative to baseline
delta_blue - wren              .......... 0.12s 0.0017 106.95% relative to baseline
fib - wren                     .......... 0.30s 0.0042 119.95% relative to baseline
for - wren                     .......... 0.12s 0.0020 107.57% relative to baseline
method_call - wren             .......... 0.15s 0.0256 106.09% relative to baseline
map_numeric - wren             .......... 0.44s 0.0199 105.27% relative to baseline
map_string - wren              .......... 0.14s 0.0049 100.18% relative to baseline
string_equals - wren           .......... 0.30s 0.0032 100.57% relative to baseline

Thanks, Michel!
2015-03-25 07:45:29 -07:00
0bd19da392 Bind C methods to Wren using foreign declarations. 2015-03-24 07:58:15 -07:00
92c17e81f6 Reorganize source files.
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!
2015-03-14 15:00:50 -07:00