Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFI #164

Merged
merged 20 commits into from
Aug 24, 2023
Merged

FFI #164

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
uses: goto-bus-stop/setup-zig@v1
with:
version: master
- name: Build test ffi lib
run: zig build-lib -dynamic tests/utils/foreign.zig && mv libforeign.* tests/utils/
- name: Run Tests
run: BUZZ_PATH=./dist zig build -Duse_mimalloc=false -Doptimize=ReleaseSafe -p dist test
- name: Cleanup
Expand All @@ -43,6 +45,8 @@ jobs:
uses: goto-bus-stop/setup-zig@v1
with:
version: master
- name: Build test ffi lib
run: zig build-lib -dynamic tests/utils/foreign.zig && mv libforeign.* tests/utils/
- name: Run tests
run: BUZZ_PATH=./dist zig build -Duse_mimalloc=false -Doptimize=ReleaseSafe -p dist test
- name: Cleanup
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,9 @@ dist/

.vscode/
*.bc
*.s
*.s
*.dylib
*.so
*.o

tests/utils/libforeign.*
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
# Unreleased

## Added

- FFI (https://github.com/buzz-language/buzz/issues/109)
- Uses MIR to generate wrappers around imported functions and to generate getters and setters to struct fields
- New `zdef` statement to declare and bind foreign functions and struct using zig code
- New `ffi` std lib
- When you need a pointer to something you can use the `Buffer` std lib object. Added:
- `Buffer.writeZ`, `Buffer.readZ`, `Buffer.writeStruct`, `Buffer.readStruct`
- `Buffer.ptr`, `Buffer.len`
- New (fancy) error reporter
- Errors have now an associated code
- `os.sleep`
- First class types (https://github.com/buzz-language/buzz/issues/21)
- Type can be passed around as values like so: `<str>`
- New `typeof` operator returns type of any value: `typeof "hello"` -> `<str>`
- Delimiters for non-standard identifiers (https://github.com/buzz-language/buzz/issues/138)

## Changed

- `Json` now return a `Box` object (which can be reused in other contexts than JSON)
- Identifiers can now have `_` since pattern delimiters have changed
- Changed pattern delimiters (https://github.com/buzz-language/buzz/issues/165)

## Fixed

- Some bugs `any`
- Runtime error stack trace was wrong

# 0.2.0 (07-26-2023)

## Added
Expand Down
5 changes: 4 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn get_buzz_prefix(b: *Build) []const u8 {
pub fn build(b: *Build) !void {
// Check minimum zig version
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse("0.11.0-dev.4333+33e4cbb20") catch return;
const min_zig = std.SemanticVersion.parse("0.12.0-dev.163+6780a6bbf") catch return;
if (current_zig.order(min_zig).compare(.lt)) {
@panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig }));
}
Expand Down Expand Up @@ -366,6 +366,7 @@ pub fn build(b: *Build) !void {
"src/lib/buzz_buffer.zig",
"src/lib/buzz_crypto.zig",
"src/lib/buzz_http.zig",
"src/lib/buzz_ffi.zig",
};
// Zig only libs
const lib_names = [_][]const u8{
Expand All @@ -379,6 +380,7 @@ pub fn build(b: *Build) !void {
"buffer",
"crypto",
"http",
"ffi",
};
const all_lib_names = [_][]const u8{
"std",
Expand All @@ -394,6 +396,7 @@ pub fn build(b: *Build) !void {
"http",
"errors",
"serialize",
"ffi",
};

// TODO: this section is slow. Modifying Buzz parser shouldn't trigger recompile of all buzz dynamic libraries
Expand Down
Loading
Loading