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:
[ ] Implement a CMake file in the cmake folder for finding Crystal folders (and installing CMake script for Crystal can be a plus, but not needed). The following paths are needed:
Also finding libcrystal.a and libgc.a which are located at $(CRYSTAL_SRC)/ext/libcrystal.a and $(CRYSTAL_LIB)/libgc.a respectively.
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.
[ ] Implement the build with the previous CMake script in the cr_loader CMakeLists.txt. We must build the cr_loader as a dynamic library, linked with all dependencies (static libs from Crystal and dynamic libs like pcre).
[ ] Implement a test called cr-loader-test (in folder source/tests/cr_loader_test) for testing the cr_loader standalone.
[ ] Implement a test called metacall-crystal-test (in folder source/tests/metacall_crystal_test) with a Crystal script in order to do a integration test with Crystal and MetaCall.
[ ] Implement the bindings for MetaCall library in Crystal lang for the functions that will be used in Crystal. The minimal set of headers needed for a plugin are:
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)).
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.
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:
The TODO list is the following:
Also finding
libcrystal.a
andlibgc.a
which are located at$(CRYSTAL_SRC)/ext/libcrystal.a
and$(CRYSTAL_LIB)/libgc.a
respectively.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.
[ ] Implement the build with the previous CMake script in the cr_loader CMakeLists.txt. We must build the cr_loader as a dynamic library, linked with all dependencies (static libs from Crystal and dynamic libs like pcre).
[ ] Implement a test called
cr-loader-test
(in folder source/tests/cr_loader_test) for testing the cr_loader standalone.[ ] Implement a test called
metacall-crystal-test
(in folder source/tests/metacall_crystal_test) with a Crystal script in order to do a integration test with Crystal and MetaCall.[ ] Implement the bindings for MetaCall library in Crystal lang for the functions that will be used in Crystal. The minimal set of headers needed for a plugin are:
include <reflect/reflect_type.h>
include <reflect/reflect_function.h>
include <reflect/reflect_scope.h>
include <reflect/reflect_context.h>
include <log/log.h>