-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from viodotcom/eval-json-segfault
JSON segfault crisis: ditch cgo
- Loading branch information
Showing
26 changed files
with
860 additions
and
688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Build CJyafn Shared Object | ||
|
||
on: | ||
push: | ||
branches: | ||
- stable | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
build-so: | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: stable | ||
- name: Build shared object | ||
run: | | ||
bash ./utils/build-linux-so.sh | ||
- name: Artifact update | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: linux-x64 | ||
if-no-files-found: error | ||
path: target/release/libcjyafn.so | ||
retention-days: 1 | ||
|
||
release: | ||
needs: [build-so] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download so | ||
uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: "*.so" | ||
tag_name: commit-id=${{ github.sha }} | ||
prerelease: false | ||
make_latest: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* One simple example of the use of cjyafn in C directly, to debug the interface between | ||
* C and Go. To run, do: | ||
* ``` | ||
* gcc jyafn.c ../target/release/libcjyafn.a -lm && ./a.out | ||
* ``` | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include "cjyafn.h" | ||
|
||
typedef struct { | ||
char* buffer; | ||
long length; | ||
} READ; | ||
|
||
READ read_file() { | ||
char* buffer = 0; | ||
long length; | ||
READ contents; | ||
FILE * f = fopen("testdata/silly-map.jyafn", "rb"); | ||
|
||
if (f) { | ||
fseek (f, 0, SEEK_END); | ||
length = ftell (f); | ||
fseek (f, 0, SEEK_SET); | ||
buffer = malloc (length); | ||
if (buffer) { | ||
fread (buffer, 1, length, f); | ||
} | ||
fclose (f); | ||
} | ||
|
||
contents.buffer = buffer; | ||
contents.length = length; | ||
|
||
return contents; | ||
} | ||
|
||
void main() { | ||
READ contents = read_file(); | ||
if (contents.buffer == 0) { | ||
printf("failed to read file\n"); | ||
exit(1); | ||
} | ||
|
||
Outcome out = function_load(contents.buffer, contents.length); | ||
if (out.err != 0) { | ||
printf(error_to_string(out.err)); | ||
// free(out.err); | ||
exit(1); | ||
} | ||
|
||
void* func = out.ok; | ||
|
||
out = function_eval_json(func, "{\"a\": 4.0, \"x\": \"a\"}"); | ||
if (out.err != 0) { | ||
printf(error_to_string(out.err)); | ||
// free(out.err); | ||
exit(1); | ||
} | ||
|
||
printf("outcome = %s\n", out.ok); | ||
} |
Oops, something went wrong.