[Announce] GCCSharp - libgccjit bindings for C#
David Malcolm
dmalcolm@redhat.com
Thu Jan 1 00:00:00 GMT 2015
On Thu, 2015-04-23 at 12:29 -0700, Mukul Sabharwal wrote:
> I'd like to introduce GCCSharp [ http://github.com/mjsabby/GCCSharp ]
> - libgccjit bindings for C# that are are modeled after the C Bindings,
> but improve type-safety by strongly typing the different pointers used
> (i.e. gcc_jit_context* is different from gcc_jit_result*, etc.); this
> also improves productivity in a C# IDE.
>
> My primary use case for libgccjit is actually not using it is as JIT
> but as an AOT for a toy-but-turing-complete language, hence the
> project name GCCSharp which does not include the term JIT.
>
> The bindings have only been tested on Linux (which is where I need
> this for my language port), I suppose for completeness I will work on
> testing this on Windows, but that will likely require a source build
> of GCC that I haven't gotten to yet.
>
> Feedback and patches are welcome.
Hi Mukul; thanks for working on this!
I've added a link to your project to the wiki page at:
https://gcc.gnu.org/wiki/JIT
On the subject of feedback, libgccjit's C API is rather verbose, but in
an object-oriented language it's possible to greatly simplify the client
code by using methods and namespaces.
(Caveat: I have zero C# experience, and am relying on the syntax
similarity with Java, with which I have close-to-but-not-zero
experience)
So rather than e.g.
GCCJITTypeRef voidType = GCC.JITContextGetType(ctxt,
GCC_JIT_TYPES.GCC_JIT_TYPE_VOID);
would it be possible to have something like:
TypeRef voidType = ctxt.GetType(TYPES.VOID);
where "TypeRef" would be a namespaced-lookup of
"GCCSharp.TypeRef"
and "TYPES" would be (after namespace lookup) be "GCCSharp.TYPES", with
the GetType being a method of the
GCCSharp.Context class?
I did something like this for the C++ bindings, and for the Python
bindings. The Python bindings do it by using two layers: a low-level
layer that binds the C API into the Python world, and then a
higher-level layer that adds an object-oriented approach to the API.
I hope that this would still work well within IDEs, and I think it looks
more elegant.
Hope this is constructive (and please forgive me if I'm missing
something)
Dave
More information about the Jit
mailing list