e-xyza / zigler Goto Github PK
View Code? Open in Web Editor NEWzig nifs in elixir
License: MIT License
zig nifs in elixir
License: MIT License
should pull the desired zig version into the zig
directory.
the way the parser works now is kind of atrocious, so I should probably fix it.
this might be useful for certain libraries, like BLAS.
create a foreign repo that tests to make sure zigler is usable
add support for linking in shared libraries.
and make it so that you can :config it.
for when you're passing IN an array, we don't have this yet.
they should be able to be translated directly into line numbers in the elixir code!!
and test it.
e.ErlNifTerms
and stuff are nice because they are direct c interops, but why can't we just have nice things like elixir.Term
. Zig is not C.
punt to displaying the error in the actual zig source file itself.
there's no documentation right now, which is a bad situation to be in.
results in this error:
** (CompileError) lib/zigler_test.ex:1: zig hasn't been downloaded. Run mix zigler.get_zig
expanding macro: Zigler.Compiler.before_compile/1
lib/zigler_test.ex:1: ZiglerTest (module)
(elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
this may be more important as zig is a fast moving target at the moment.
seems to occur with nested modules?
figure out why and fix it.
WIndows support is likely to be extremely challenging: The erlang ABI actually has a different look to the header file. (erl_nif.h is not trivially human parsable as a result).
The correct strategy is likely to create a separate erl_nif_windows.h, and build against that.
this is slightly unpreferred, but erlang does it when performing releases, so it should be looked into.
it's a bit of a rat's nest.
e.g. identity function from typing tests
this should occur both in the temporary compilation swap space as well as the resulting .so file in the priv/ space?
there should be some very sweet compile time guarantees possible on this front.
I think you can have FreeBSD support already:
I have the following packages installed:
# pkg install -r FreeBSD lang/zig lang/erlang-runtime22 devel/elixir-hex devel/llvm80
This gives us zig-0.5.0 and the rest should be self explanatory.
I suppressed the side-effect-only Logger https://github.com/ityonemo/zigler/blob/master/lib/zigler/compiler.ex#L24
$ export NIFTY_LLVM_VERSION=80
$ mix do deps.get --all, deps.compile, compile
$ mix zigler.get_zig 0.5.0
...
$ mix test --trace
Compiling 17 files (.ex)
13:19:58.168 [info] compiling using command: `/repos/zigler/zig/zig-freebsd-x86_64-0.5.0/zig build-lib zig_nif.zig -dynamic --disable-gen-h --override-lib-dir /repos/zigler/zig/zig-freebsd-x86_64-0.5.0/lib/zig`
13:19:58.176 [info] compiling using command: `/repos/zigler/zig/zig-freebsd-x86_64-0.5.0/zig build-lib zig_nif.zig -dynamic --disable-gen-h --override-lib-dir /repos/zigler/zig/zig-freebsd-x86_64-0.5.0/lib/zig`
13:20:04.925 [info] compiling using command: `/repos/zigler/zig/zig-freebsd-x86_64-0.5.0/zig build-lib zig_nif.zig -dynamic --disable-gen-h --override-lib-dir /repos/zigler/zig/zig-freebsd-x86_64-0.5.0/lib/zig --release-safe`
Generated zigler app
ZiglerTest.CompilerErrorParserTest
* test the compiler line parser (0.04ms)
ZiglerTest.CompilerErrorTest
* test compiler error catches and rewrites internal error (270.6ms)
* test compiler error catches mismatched arity (35.3ms)
* test compiler error catches and rewrites external error (485.7ms)
* test compiler error catches mismatched nif (7.9ms)
ZiglerTest.ParserTest
* test the nif parser can identify nifs (0.01ms)
* test the docstring multiline parser can identify multiline docstrings (0.05ms)
* test the function header parser can identify bool function headers (0.07ms)
* test the function header parser can identify one-arity function headers (0.04ms)
* test the docstring line parser will ignore a non docline (0.00ms)
* test the function header parser can identify zero-arity function headers (0.02ms)
* test the docstring line parser can identify a single docline (0.02ms)
* test the function header parser can identify two-arity function headers (0.05ms)
* test the function header parser can identify beam.env headers (0.05ms)
* test the docstring line parser can identify a single docline when it's got indentation (0.01ms)
* test the function header parser can identify string function headers (0.04ms)
* test the function header parser can identify erlnifenv headers (0.06ms)
ZiglerTest.UnitParserTest
* test the identifier parser fails on non_identifiers (0.00ms)
* test the test header parser can identify test headers (0.08ms)
* test the identifier parser can correctly identify identifiers (0.01ms)
* test the import parser leaves pub imports alone (0.02ms)
* test the identifier parser fails on strange symbols (0.00ms)
* test the import parser can identify import statements (0.01ms)
ZiglerTest.CodeTest
* test when given a code multiline string the code module can return plain code with no nifs, and assign files and lines correctly (0.04ms)
* test when given a code multiline string the code module can do the correct thing with multiple functions (0.1ms)
* test when given a code multiline string the code module can identify more complex nif headers (0.09ms)
* test when given a code multiline string the code module can find a nif and correctly assign it, adding line numbers (0.07ms)
ZiglerTest.Types.EmptyTest
* test zero arity zig functions work (0.06ms)
ZiglerTest.MutationTest
* test passing binaries across a function self-call works (0.07ms)
* test we can mutate binaries (0.00ms)
ZigTest.TypespecTest
* test zigler correctly creates typespecs for degenerate (2.0ms)
* test zigler correctly creates typespecs for generic beam types (23.0ms)
* test zigler correctly creates typespecs for floats (0.5ms)
* test zigler correctly creates typespecs for integers (0.9ms)
* test zigler correctly creates typespecs for bools (0.7ms)
* test zigler correctly creates typespecs for float lists (0.4ms)
* test zigler correctly creates typespecs for strings (0.7ms)
* test zigler correctly creates typespecs for int lists (2.8ms)
ZiglerTest.ZigdocTest
* test gets the docs (695.7ms)
ZiglerTest.AllocatorsTest
* test elixir persistent memory works (0.1ms)
* test elixir basic allocator works (0.1ms)
ZiglerTest.DoubleZigTest
* test two zig definitions in the different sigils (0.06ms)
* test two zig definitions in the same sigil (0.05ms)
ZiglerTest.ExternalFilesTest
* test a recursive external file can be called (0.05ms)
* test a relative external file can be called (0.04ms)
ZiglerTest.Types.EgressTest
* test lists can be egressed from c_int lists (0.1ms)
* test lists can be egressed from internal literals (0.00ms)
* test integers can be egressed c_int (0.00ms)
* test lists can be egressed from f16 lists (0.00ms)
* test lists can be egressed from i32 lists (0.00ms)
* test floats can be egressed f32 (0.00ms)
* test floats can be egressed f64 (0.00ms)
* test lists can be egressed from c_long lists (0.00ms)
* test strings can be egressed from a slice (0.06ms)
* test integers can be egressed i32 (0.00ms)
* test integers can be egressed c_long (0.00ms)
* test lists can be egressed from i64 lists (0.00ms)
* test bools can be exported correctly (0.00ms)
* test characters can be egressed correctly (0.00ms)
* test strings can be egressed from a c_string (0.00ms)
* test lists can be egressed from f32 lists (0.00ms)
* test lists can be egressed from f64 lists (0.00ms)
* test integers can be egressed i64 (0.00ms)
ZiglerTest.Types.IngressTest
* test 32-bit integers can be ingressed and are guarded for invalid values (3.5ms)
* test binaries can be ingressed as slices and are guarded for invalid values (0.09ms)
* test atoms can be ingressed and are guarded for invalid values (0.02ms)
* test f32 lists can be ingressed correctly (0.07ms)
* test pids can be ingressed as beam.pid correctly (0.00ms)
* test f16 lists can be ingressed and are guarded for invalid values (0.09ms)
* test binaries can be ingressed as binary structs and are guarded for invalid values (0.01ms)
* test pids can be ingressed as e.ErlNifPid correctly (0.00ms)
* test binaries can be ingressed as binary structs via e.ErlNifBinary and are guarded for invalid values (0.01ms)
* test i32 lists can be ingressed correctly (0.00ms)
* test 16-bit floats can be ingressed and are guarded for invalid values (0.01ms)
* test f64 lists can be ingressed even with empties (0.00ms)
* test binaries can be ingressed as slices correctly (0.00ms)
* test atoms can be ingressed correctly (0.00ms)
* test 16-bit floats can be ingressed correctly (0.00ms)
* test pids can be ingressed as beam.pid and are guarded for invalid values (0.01ms)
* test f32 lists can be ingressed and are guarded for invalid values (0.02ms)
* test i64 lists can be ingressed even with empties (0.00ms)
* test i64 lists can be ingressed and are guarded for invalid values (0.02ms)
* test binaries can be ingressed as c_strings correctly (0.00ms)
* test usize can be ingressed correctly (0.00ms)
* test 64-bit integers can be ingressed correctly (0.00ms)
* test binaries can be ingressed as binary structs correctly (0.00ms)
* test c integers can be ingressed and are guarded for invalid values (0.01ms)
* test 32-bit integers can be ingressed correctly (0.00ms)
* test c integers can be ingressed correctly (0.00ms)
* test f32 lists can be ingressed even with empties (0.00ms)
* test f16 lists can be ingressed correctly (0.00ms)
* test binaries can be ingressed as binary structs via e.ErlNifBinary correctly (0.00ms)
* test i32 lists can be ingressed and are guarded for invalid values (0.02ms)
* test i32 lists can be ingressed even with empties (0.00ms)
* test usize can be ingressed and are guarded for invalid values (0.02ms)
* test c longs can be ingressed and are guarded for invalid values (0.02ms)
* test 64-bit floats can be ingressed correctly (0.00ms)
* test 64-bit integers can be ingressed and are guarded for invalid values (0.02ms)
* test f64 lists can be ingressed correctly (0.00ms)
* test bools can be ingressed and are guarded for invalid values (0.02ms)
* test characters can be ingressed correctly (0.00ms)
* test pids can be ingressed as e.ErlNifPid and are guarded for invalid values (0.01ms)
* test f16 lists can be ingressed even with empties (0.00ms)
* test 32-bit floats can be ingressed correctly (0.00ms)
* test isize can be ingressed and are guarded for invalid values (0.01ms)
* test c longs can be ingressed correctly (0.00ms)
* test binaries can be ingressed as c_strings and are guarded for invalid values (0.01ms)
* test f64 lists can be ingressed and are guarded for invalid values (0.02ms)
* test 64-bit floats can be ingressed and are guarded for invalid values (0.02ms)
* test 32-bit floats can be ingressed and are guarded for invalid values (0.01ms)
* test characters can be ingressed and are guarded for invalid values (0.02ms)
* test bools can be ingressed correctly (0.00ms)
* test isize can be ingressed correctly (0.00ms)
* test i64 lists can be ingressed correctly (0.00ms)
ZiglerTest.ReadmeTest
* test allocations (0.1ms)
* test example_zig (0.05ms)
* test zig_collections (0.09ms)
ZiglerTest
* test sigil-Z2 creates a function of the correct arity (0.05ms)
* test sigil-Z creates a public function (0.06ms)
ZiglerTest.ZigTest
* zigtest the truth (0.00ms)
ZiglerTest.ZigFailingTest
* test if we have a failing test, it can be caught (5.8ms)
ZiglerTest.ZigIndirectTest
* zigtest function one (0.00ms)
ZiglerTest.ZigDeepTest
* zigtest function one (0.00ms)
Finished in 31.5 seconds
120 tests, 3 zigtests, 0 failures
Randomized with seed 960707
Which looks perfect to me. It would be nice if zigler knew to use the pre-installed lang/zig
port, rather than needing to download stuff.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.