https://github.com/banane9/ironwren
.NET integration for Wren
https://github.com/banane9/ironwren
Last synced: 2 months ago
JSON representation
.NET integration for Wren
- Host: GitHub
- URL: https://github.com/banane9/ironwren
- Owner: Banane9
- License: lgpl-3.0
- Created: 2016-05-03T21:14:39.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-10-16T12:48:04.000Z (over 2 years ago)
- Last Synced: 2025-04-12T03:15:09.438Z (2 months ago)
- Language: C#
- Size: 1.33 MB
- Stars: 31
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
IronWren [](https://ci.appveyor.com/project/Banane9/ironwren/branch/master)
=========================.NET integration for the scripting language [Wren](https://github.com/munificent/wren).
Available on NuGet [here](https://www.nuget.org/packages/IronWren/)!
###Features###
- [x] C# style wrapper around Wren's C-API.
- [x] No `IntPtr`s get exposed, making the value- and function-handles typesafe.
- [x] Ability to automatically generate Wren integration code for classes defined in C#.###Usage###
Basic usage (more extensively shown in [IronWren.ConsoleTesting/Program.cs](https://github.com/Banane9/IronWren/blob/master/IronWren.ConsoleTesting/Program.cs)):
``` CSharp
private static void Main(string[] args)
{
var config = new WrenConfig();
config.Write += (v, text) => Console.Write(text);
using (var vm = new WrenVM(config))
{
var result = vm.Interpret("System.print(\"Hi from Wren!\")");
}
Console.ReadLine();
}
```#####AutoMapper#####
The AutoMapper provides the ability to easily create a Wren class from a C# type, only requiring it to be decorated with the right Attributes.
An example can be found in [IronWren.ConsoleTesting/WrenVector.cs](https://github.com/Banane9/IronWren/blob/master/IronWren.ConsoleTesting/WrenVector.cs).
The Attributes are:
- `[WrenClass]` - For optionally specifying an alternative name.
- `[WrenCode]` - For dropping a string field's content into the class source.
- `[WrenConstructor]` - For marking the constructor that should be used by Wren and which overloads should exist there.
- `[WrenFinalizer]` - For marking a method that should be called when the object is GCed by the Wren VM.
- `[WrenIndexer]` - For marking methods that are get/set methods of an indexer.
- `[WrenMethod]` - For marking a method that should be present in Wren and its arguments.
- `[WrenProperty]` - For marking methods that are get/set methods of a property.The AutoMapper will automatically handle the binding between the methods and Wren.
-------------------------------------------------------------------------------------------------------------------------------
