-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional bindings to 'tag' values and fix tests
- Loading branch information
Showing
18 changed files
with
592 additions
and
94 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
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
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
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
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,61 @@ | ||
#define CAML_NAME_SPACE | ||
#include <caml/mlvalues.h> | ||
#include <caml/fail.h> | ||
#include <caml/memory.h> | ||
#include <caml/alloc.h> | ||
|
||
#include "binaryen-c.h" | ||
#include "ocaml_helpers.h" | ||
|
||
CAMLprim value | ||
caml_binaryen_add_tag(value _module, value _name, value _params, value _results) { | ||
CAMLparam4(_module, _name, _params, _results); | ||
BinaryenModuleRef module = BinaryenModuleRef_val(_module); | ||
char* name = Safe_String_val(_name); | ||
BinaryenType params = BinaryenType_val(_params); | ||
BinaryenType results = BinaryenType_val(_results); | ||
BinaryenTagRef tag = BinaryenAddTag(module, name, params, results); | ||
CAMLreturn(alloc_BinaryenTagRef(tag)); | ||
} | ||
|
||
CAMLprim value | ||
caml_binaryen_get_tag(value _module, value _name) { | ||
CAMLparam2(_module, _name); | ||
BinaryenModuleRef module = BinaryenModuleRef_val(_module); | ||
char* name = Safe_String_val(_name); | ||
BinaryenTagRef tag = BinaryenGetTag(module, name); | ||
CAMLreturn(alloc_BinaryenTagRef(tag)); | ||
} | ||
|
||
CAMLprim value | ||
caml_binaryen_remove_tag(value _module, value _name) { | ||
CAMLparam2(_module, _name); | ||
BinaryenModuleRef module = BinaryenModuleRef_val(_module); | ||
char* name = Safe_String_val(_name); | ||
BinaryenRemoveTag(module, name); | ||
CAMLreturn(Val_unit); | ||
} | ||
|
||
CAMLprim value | ||
caml_binaryen_tag_get_name(value _tag) { | ||
CAMLparam1(_tag); | ||
BinaryenTagRef tag = BinaryenTagRef_val(_tag); | ||
const char* name = BinaryenTagGetName(tag); | ||
CAMLreturn(caml_copy_string(name)); | ||
} | ||
|
||
CAMLprim value | ||
caml_binaryen_tag_get_params(value _tag) { | ||
CAMLparam1(_tag); | ||
BinaryenTagRef tag = BinaryenTagRef_val(_tag); | ||
BinaryenType ty = BinaryenTagGetParams(tag); | ||
CAMLreturn(alloc_BinaryenType(ty)); | ||
} | ||
|
||
CAMLprim value | ||
caml_binaryen_tag_get_results(value _tag) { | ||
CAMLparam1(_tag); | ||
BinaryenTagRef tag = BinaryenTagRef_val(_tag); | ||
BinaryenType ty = BinaryenTagGetResults(tag); | ||
CAMLreturn(alloc_BinaryenType(ty)); | ||
} |
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,43 @@ | ||
//Provides: caml_binaryen_add_tag | ||
//Requires: caml_jsstring_of_string | ||
function caml_binaryen_add_tag(wasm_mod, name, params, results) { | ||
return wasm_mod.addTag( | ||
caml_jsstring_of_string(name), | ||
params, | ||
results, | ||
); | ||
} | ||
|
||
//Provides: caml_binaryen_get_tag | ||
//Requires: caml_jsstring_of_string | ||
function caml_binaryen_get_tag(wasm_mod, name) { | ||
return wasm_mod.getTag(caml_jsstring_of_string(name)); | ||
} | ||
|
||
//Provides: caml_binaryen_remove_tag | ||
//Requires: caml_jsstring_of_string | ||
function caml_binaryen_remove_tag(wasm_mod, name) { | ||
return wasm_mod.removeTag(caml_jsstring_of_string(name)); | ||
} | ||
|
||
//Provides: caml_binaryen_tag_get_name | ||
//Requires: Binaryen | ||
//Requires: caml_string_of_jsstring | ||
function caml_binaryen_tag_get_name(tag) { | ||
var tag_info = Binaryen.getTagInfo(tag); | ||
return caml_string_of_jsstring(tag_info.name); | ||
} | ||
|
||
//Provides: caml_binaryen_tag_get_params | ||
//Requires: Binaryen | ||
function caml_binaryen_tag_get_params(tag) { | ||
var tag_info = Binaryen.getTagInfo(tag); | ||
return tag_info.params; | ||
} | ||
|
||
//Provides: caml_binaryen_tag_get_results | ||
//Requires: Binaryen | ||
function caml_binaryen_tag_get_results(tag) { | ||
var tag_info = Binaryen.getTagInfo(tag); | ||
return tag_info.results; | ||
} |
Oops, something went wrong.