metacall / core

MetaCall: The ultimate polyglot programming experience.
https://metacall.io
Apache License 2.0
1.56k stars 160 forks source link

Implement Crystal Loader #38

Open viferga opened 4 years ago

viferga commented 4 years ago

This is a Proof of Concept for Crystal Loader. The idea is to allow it to be fully implemented in Crystal lang, with a minimal C wrapper: crystal_lib.zip. It is based on this repository: https://github.com/ysbaddaden/crystal_library (with minimal modifications and the addition of the Dockerfile).

In order to build and run the test, use Docker or read the README.md. For Docker:

docker build -t metacall/crystal .

The TODO list is the following:

Then we must implement the build and linkage of the library as in the Makefile but for CMake, it can be done inside the same CMake script with a function or ad-hoc in the CMakeLists.txt of the cr_loader.

include <reflect/reflect_type.h>

include <reflect/reflect_function.h>

include <reflect/reflect_scope.h>

include <reflect/reflect_context.h>

include <log/log.h>


For the C bindings we can:
1) Do them manually: https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/
2) Do them automatically: https://github.com/crystal-lang/crystal_lib (but this seems experimental and less explicit).

- [ ] Implement cr_loader functionality in Crystal, using the bindings from the previous step (TODO: Extend this point later on with more design and implementation details like [AST or Compiler Internals](https://github.com/crystal-lang/crystal/wiki/Compiler-internals)).
watzon commented 4 years ago

https://github.com/olbat/libgen/ has a bit simpler interface for generating bindings. It uses crystal_lib on the back end. Doesn't always work, but it does most of the time.