1919 WREN_VERSION_MINOR * 1000 + \
2020 WREN_VERSION_PATCH)
2121
22+ #ifndef WREN_API
23+ #if defined(_MSC_VER ) || defined(WREN_API_DLLEXPORT )
24+ #define WREN_API __declspec( dllexport )
25+ #else
26+ #define WREN_API
27+ #endif
28+ #endif //WREN_API
29+
2230// A single virtual machine for executing Wren code.
2331//
2432// Wren has no global state, so all state stored by a running interpreter lives
@@ -291,24 +299,24 @@ typedef enum
291299// Initializes [configuration] with all of its default values.
292300//
293301// Call this before setting the particular fields you care about.
294- void wrenInitConfiguration (WrenConfiguration * configuration );
302+ WREN_API void wrenInitConfiguration (WrenConfiguration * configuration );
295303
296304// Creates a new Wren virtual machine using the given [configuration]. Wren
297305// will copy the configuration data, so the argument passed to this can be
298306// freed after calling this. If [configuration] is `NULL`, uses a default
299307// configuration.
300- WrenVM * wrenNewVM (WrenConfiguration * configuration );
308+ WREN_API WrenVM * wrenNewVM (WrenConfiguration * configuration );
301309
302310// Disposes of all resources is use by [vm], which was previously created by a
303311// call to [wrenNewVM].
304- void wrenFreeVM (WrenVM * vm );
312+ WREN_API void wrenFreeVM (WrenVM * vm );
305313
306314// Immediately run the garbage collector to free unused memory.
307- void wrenCollectGarbage (WrenVM * vm );
315+ WREN_API void wrenCollectGarbage (WrenVM * vm );
308316
309317// Runs [source], a string of Wren source code in a new fiber in [vm] in the
310318// context of resolved [module].
311- WrenInterpretResult wrenInterpret (WrenVM * vm , const char * module ,
319+ WREN_API WrenInterpretResult wrenInterpret (WrenVM * vm , const char * module ,
312320 const char * source );
313321
314322// Creates a handle that can be used to invoke a method with [signature] on
@@ -319,7 +327,7 @@ WrenInterpretResult wrenInterpret(WrenVM* vm, const char* module,
319327//
320328// When you are done with this handle, it must be released using
321329// [wrenReleaseHandle].
322- WrenHandle * wrenMakeCallHandle (WrenVM * vm , const char * signature );
330+ WREN_API WrenHandle * wrenMakeCallHandle (WrenVM * vm , const char * signature );
323331
324332// Calls [method], using the receiver and arguments previously set up on the
325333// stack.
@@ -331,11 +339,11 @@ WrenHandle* wrenMakeCallHandle(WrenVM* vm, const char* signature);
331339// signature.
332340//
333341// After this returns, you can access the return value from slot 0 on the stack.
334- WrenInterpretResult wrenCall (WrenVM * vm , WrenHandle * method );
342+ WREN_API WrenInterpretResult wrenCall (WrenVM * vm , WrenHandle * method );
335343
336344// Releases the reference stored in [handle]. After calling this, [handle] can
337345// no longer be used.
338- void wrenReleaseHandle (WrenVM * vm , WrenHandle * handle );
346+ WREN_API void wrenReleaseHandle (WrenVM * vm , WrenHandle * handle );
339347
340348// The following functions are intended to be called from foreign methods or
341349// finalizers. The interface Wren provides to a foreign method is like a
@@ -375,23 +383,23 @@ void wrenReleaseHandle(WrenVM* vm, WrenHandle* handle);
375383// return, you get a very fast FFI.
376384
377385// Returns the number of slots available to the current foreign method.
378- int wrenGetSlotCount (WrenVM * vm );
386+ WREN_API int wrenGetSlotCount (WrenVM * vm );
379387
380388// Ensures that the foreign method stack has at least [numSlots] available for
381389// use, growing the stack if needed.
382390//
383391// Does not shrink the stack if it has more than enough slots.
384392//
385393// It is an error to call this from a finalizer.
386- void wrenEnsureSlots (WrenVM * vm , int numSlots );
394+ WREN_API void wrenEnsureSlots (WrenVM * vm , int numSlots );
387395
388396// Gets the type of the object in [slot].
389- WrenType wrenGetSlotType (WrenVM * vm , int slot );
397+ WREN_API WrenType wrenGetSlotType (WrenVM * vm , int slot );
390398
391399// Reads a boolean value from [slot].
392400//
393401// It is an error to call this if the slot does not contain a boolean value.
394- bool wrenGetSlotBool (WrenVM * vm , int slot );
402+ WREN_API bool wrenGetSlotBool (WrenVM * vm , int slot );
395403
396404// Reads a byte array from [slot].
397405//
@@ -403,19 +411,19 @@ bool wrenGetSlotBool(WrenVM* vm, int slot);
403411// number of bytes in the array.
404412//
405413// It is an error to call this if the slot does not contain a string.
406- const char * wrenGetSlotBytes (WrenVM * vm , int slot , int * length );
414+ WREN_API const char * wrenGetSlotBytes (WrenVM * vm , int slot , int * length );
407415
408416// Reads a number from [slot].
409417//
410418// It is an error to call this if the slot does not contain a number.
411- double wrenGetSlotDouble (WrenVM * vm , int slot );
419+ WREN_API double wrenGetSlotDouble (WrenVM * vm , int slot );
412420
413421// Reads a foreign object from [slot] and returns a pointer to the foreign data
414422// stored with it.
415423//
416424// It is an error to call this if the slot does not contain an instance of a
417425// foreign class.
418- void * wrenGetSlotForeign (WrenVM * vm , int slot );
426+ WREN_API void * wrenGetSlotForeign (WrenVM * vm , int slot );
419427
420428// Reads a string from [slot].
421429//
@@ -424,25 +432,25 @@ void* wrenGetSlotForeign(WrenVM* vm, int slot);
424432// function returns, since the garbage collector may reclaim it.
425433//
426434// It is an error to call this if the slot does not contain a string.
427- const char * wrenGetSlotString (WrenVM * vm , int slot );
435+ WREN_API const char * wrenGetSlotString (WrenVM * vm , int slot );
428436
429437// Creates a handle for the value stored in [slot].
430438//
431439// This will prevent the object that is referred to from being garbage collected
432440// until the handle is released by calling [wrenReleaseHandle()].
433- WrenHandle * wrenGetSlotHandle (WrenVM * vm , int slot );
441+ WREN_API WrenHandle * wrenGetSlotHandle (WrenVM * vm , int slot );
434442
435443// Stores the boolean [value] in [slot].
436- void wrenSetSlotBool (WrenVM * vm , int slot , bool value );
444+ WREN_API void wrenSetSlotBool (WrenVM * vm , int slot , bool value );
437445
438446// Stores the array [length] of [bytes] in [slot].
439447//
440448// The bytes are copied to a new string within Wren's heap, so you can free
441449// memory used by them after this is called.
442- void wrenSetSlotBytes (WrenVM * vm , int slot , const char * bytes , size_t length );
450+ WREN_API void wrenSetSlotBytes (WrenVM * vm , int slot , const char * bytes , size_t length );
443451
444452// Stores the numeric [value] in [slot].
445- void wrenSetSlotDouble (WrenVM * vm , int slot , double value );
453+ WREN_API void wrenSetSlotDouble (WrenVM * vm , int slot , double value );
446454
447455// Creates a new instance of the foreign class stored in [classSlot] with [size]
448456// bytes of raw storage and places the resulting object in [slot].
@@ -453,89 +461,89 @@ void wrenSetSlotDouble(WrenVM* vm, int slot, double value);
453461// and then the constructor will be invoked when the allocator returns.
454462//
455463// Returns a pointer to the foreign object's data.
456- void * wrenSetSlotNewForeign (WrenVM * vm , int slot , int classSlot , size_t size );
464+ WREN_API void * wrenSetSlotNewForeign (WrenVM * vm , int slot , int classSlot , size_t size );
457465
458466// Stores a new empty list in [slot].
459- void wrenSetSlotNewList (WrenVM * vm , int slot );
467+ WREN_API void wrenSetSlotNewList (WrenVM * vm , int slot );
460468
461469// Stores a new empty map in [slot].
462- void wrenSetSlotNewMap (WrenVM * vm , int slot );
470+ WREN_API void wrenSetSlotNewMap (WrenVM * vm , int slot );
463471
464472// Stores null in [slot].
465- void wrenSetSlotNull (WrenVM * vm , int slot );
473+ WREN_API void wrenSetSlotNull (WrenVM * vm , int slot );
466474
467475// Stores the string [text] in [slot].
468476//
469477// The [text] is copied to a new string within Wren's heap, so you can free
470478// memory used by it after this is called. The length is calculated using
471479// [strlen()]. If the string may contain any null bytes in the middle, then you
472480// should use [wrenSetSlotBytes()] instead.
473- void wrenSetSlotString (WrenVM * vm , int slot , const char * text );
481+ WREN_API void wrenSetSlotString (WrenVM * vm , int slot , const char * text );
474482
475483// Stores the value captured in [handle] in [slot].
476484//
477485// This does not release the handle for the value.
478- void wrenSetSlotHandle (WrenVM * vm , int slot , WrenHandle * handle );
486+ WREN_API void wrenSetSlotHandle (WrenVM * vm , int slot , WrenHandle * handle );
479487
480488// Returns the number of elements in the list stored in [slot].
481- int wrenGetListCount (WrenVM * vm , int slot );
489+ WREN_API int wrenGetListCount (WrenVM * vm , int slot );
482490
483491// Reads element [index] from the list in [listSlot] and stores it in
484492// [elementSlot].
485- void wrenGetListElement (WrenVM * vm , int listSlot , int index , int elementSlot );
493+ WREN_API void wrenGetListElement (WrenVM * vm , int listSlot , int index , int elementSlot );
486494
487495// Sets the value stored at [index] in the list at [listSlot],
488496// to the value from [elementSlot].
489- void wrenSetListElement (WrenVM * vm , int listSlot , int index , int elementSlot );
497+ WREN_API void wrenSetListElement (WrenVM * vm , int listSlot , int index , int elementSlot );
490498
491499// Takes the value stored at [elementSlot] and inserts it into the list stored
492500// at [listSlot] at [index].
493501//
494502// As in Wren, negative indexes can be used to insert from the end. To append
495503// an element, use `-1` for the index.
496- void wrenInsertInList (WrenVM * vm , int listSlot , int index , int elementSlot );
504+ WREN_API void wrenInsertInList (WrenVM * vm , int listSlot , int index , int elementSlot );
497505
498506// Returns the number of entries in the map stored in [slot].
499- int wrenGetMapCount (WrenVM * vm , int slot );
507+ WREN_API int wrenGetMapCount (WrenVM * vm , int slot );
500508
501509// Returns true if the key in [keySlot] is found in the map placed in [mapSlot].
502- bool wrenGetMapContainsKey (WrenVM * vm , int mapSlot , int keySlot );
510+ WREN_API bool wrenGetMapContainsKey (WrenVM * vm , int mapSlot , int keySlot );
503511
504512// Retrieves a value with the key in [keySlot] from the map in [mapSlot] and
505513// stores it in [valueSlot].
506- void wrenGetMapValue (WrenVM * vm , int mapSlot , int keySlot , int valueSlot );
514+ WREN_API void wrenGetMapValue (WrenVM * vm , int mapSlot , int keySlot , int valueSlot );
507515
508516// Takes the value stored at [valueSlot] and inserts it into the map stored
509517// at [mapSlot] with key [keySlot].
510- void wrenSetMapValue (WrenVM * vm , int mapSlot , int keySlot , int valueSlot );
518+ WREN_API void wrenSetMapValue (WrenVM * vm , int mapSlot , int keySlot , int valueSlot );
511519
512520// Removes a value from the map in [mapSlot], with the key from [keySlot],
513521// and place it in [removedValueSlot]. If not found, [removedValueSlot] is
514522// set to null, the same behaviour as the Wren Map API.
515- void wrenRemoveMapValue (WrenVM * vm , int mapSlot , int keySlot ,
523+ WREN_API void wrenRemoveMapValue (WrenVM * vm , int mapSlot , int keySlot ,
516524 int removedValueSlot );
517525
518526// Looks up the top level variable with [name] in resolved [module] and stores
519527// it in [slot].
520- void wrenGetVariable (WrenVM * vm , const char * module , const char * name ,
528+ WREN_API void wrenGetVariable (WrenVM * vm , const char * module , const char * name ,
521529 int slot );
522530
523531// Looks up the top level variable with [name] in resolved [module],
524532// returns false if not found. The module must be imported at the time,
525533// use wrenHasModule to ensure that before calling.
526- bool wrenHasVariable (WrenVM * vm , const char * module , const char * name );
534+ WREN_API bool wrenHasVariable (WrenVM * vm , const char * module , const char * name );
527535
528536// Returns true if [module] has been imported/resolved before, false if not.
529- bool wrenHasModule (WrenVM * vm , const char * module );
537+ WREN_API bool wrenHasModule (WrenVM * vm , const char * module );
530538
531539// Sets the current fiber to be aborted, and uses the value in [slot] as the
532540// runtime error object.
533- void wrenAbortFiber (WrenVM * vm , int slot );
541+ WREN_API void wrenAbortFiber (WrenVM * vm , int slot );
534542
535543// Returns the user data associated with the WrenVM.
536- void * wrenGetUserData (WrenVM * vm );
544+ WREN_API void * wrenGetUserData (WrenVM * vm );
537545
538546// Sets user data associated with the WrenVM.
539- void wrenSetUserData (WrenVM * vm , void * userData );
547+ WREN_API void wrenSetUserData (WrenVM * vm , void * userData );
540548
541549#endif
0 commit comments