-
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add simple script to make a binary file with predictable sequence * Start stubbing out File, add LWT dependencies * Update lockfile * Start sketching out a binary file open API * Initial File.openAsync API
- Loading branch information
Showing
15 changed files
with
190 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"hash": "d01dd9df3419402f9844a0633785faa8", | ||
"hash": "7cee57e249e10e60991a8110ca529db5", | ||
"root": "revery@path:.", | ||
"node": { | ||
"revery@path:.": { | ||
|
@@ -11,10 +11,11 @@ | |
"opam": null | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/js_of_ocaml@opam:3.2.0", | ||
"@opam/js_of_ocaml-compiler@opam:3.2.1", | ||
"@opam/js_of_ocaml-lwt@opam:3.2.1", "[email protected]", | ||
"@opam/js_of_ocaml-lwt@opam:3.2.1", "@opam/lwt@opam:4.1.0", | ||
"@opam/lwt_ppx@opam:1.2.1", "[email protected]", | ||
"reason-gl-matrix@github:bryphe/reason-gl-matrix#24499b2", | ||
"reason-glfw@github:bryphe/reason-glfw#82ea419", | ||
"reason-reactify@github:bryphe/reason-reactify#a62c8e4" | ||
|
@@ -43,7 +44,7 @@ | |
"opam": null | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/lwt@opam:4.1.0", "[email protected]", "[email protected]" | ||
] | ||
}, | ||
|
@@ -56,7 +57,7 @@ | |
"opam": null | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/js_of_ocaml-compiler@opam:3.2.1", "@opam/lwt@opam:4.1.0", | ||
"@opam/lwt_ppx@opam:1.2.1", | ||
"esy-cmake@github:bryphe/esy-cmake#8afd4a1", | ||
|
@@ -73,7 +74,7 @@ | |
"opam": null | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/js_of_ocaml-compiler@opam:3.2.1", "[email protected]", | ||
"[email protected]" | ||
] | ||
|
@@ -364,7 +365,7 @@ | |
} | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/result@opam:1.3", "[email protected]" | ||
] | ||
}, | ||
|
@@ -585,7 +586,7 @@ | |
} | ||
}, | ||
"dependencies": [ | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.2.1", | ||
"@esy-ocaml/[email protected]", "@opam/dune@opam:1.3.0", | ||
"@opam/ocamlfind@opam:1.8.0", "[email protected]" | ||
] | ||
}, | ||
|
@@ -609,18 +610,18 @@ | |
"[email protected]" | ||
] | ||
}, | ||
"@opam/dune@opam:1.2.1": { | ||
"@opam/dune@opam:1.3.0": { | ||
"record": { | ||
"name": "@opam/dune", | ||
"version": "opam:1.2.1", | ||
"version": "opam:1.3.0", | ||
"source": | ||
"archive:https://github.com/ocaml/dune/releases/download/1.2.1/dune-1.2.1.tbz#md5:f96bdf1a893a2178c2ad9c388439bd18", | ||
"archive:https://github.com/ocaml/dune/releases/download/1.3.0/dune-1.3.0.tbz#md5:d7c926bd6b7549cb54d5463aaccf0c91", | ||
"files": [], | ||
"opam": { | ||
"name": "dune", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"opam": | ||
"opam-version: \"2.0\"\nname: \"dune\"\nversion: \"1.2.1\"\nsynopsis: \"Fast, portable and opinionated build system\"\ndescription: \"\"\"\ndune is a build system that was designed to simplify the release of\nJane Street packages. It reads metadata from \"dune\" files following a\nvery simple s-expression syntax.\n\ndune is fast, it has very low-overhead and support parallel builds on\nall platforms. It has no system dependencies, all you need to build\ndune and packages using dune is OCaml. You don't need or make or bash\nas long as the packages themselves don't use bash explicitly.\n\ndune supports multi-package development by simply dropping multiple\nrepositories into the same directory.\n\nIt also supports multi-context builds, such as building against\nseveral opam roots/switches simultaneously. This helps maintaining\npackages across several versions of OCaml and gives cross-compilation\nfor free.\"\"\"\nmaintainer: \"[email protected]\"\nauthors: \"Jane Street Group, LLC <[email protected]>\"\nlicense: \"MIT\"\nhomepage: \"https://github.com/ocaml/dune\"\nbug-reports: \"https://github.com/ocaml/dune/issues\"\ndepends: [\n \"ocaml\" {>= \"4.02.3\"}\n]\nconflicts: [\n \"jbuilder\" {!= \"transition\"}\n]\nbuild: [\n [\"ocaml\" \"configure.ml\" \"--libdir\" lib] {opam-version < \"2\"}\n [\"ocaml\" \"bootstrap.ml\"]\n [\"./boot.exe\" \"--release\" \"--subst\"] {pinned}\n [\"./boot.exe\" \"--release\" \"-j\" jobs]\n]\ndev-repo: \"git+https://github.com/ocaml/dune.git\"\nurl {\n src: \"https://github.com/ocaml/dune/releases/download/1.2.1/dune-1.2.1.tbz\"\n checksum: \"md5=f96bdf1a893a2178c2ad9c388439bd18\"\n}", | ||
"opam-version: \"2.0\"\nname: \"dune\"\nversion: \"1.3.0\"\nsynopsis: \"Fast, portable and opinionated build system\"\ndescription: \"\"\"\ndune is a build system that was designed to simplify the release of\nJane Street packages. It reads metadata from \"dune\" files following a\nvery simple s-expression syntax.\n\ndune is fast, it has very low-overhead and support parallel builds on\nall platforms. It has no system dependencies, all you need to build\ndune and packages using dune is OCaml. You don't need or make or bash\nas long as the packages themselves don't use bash explicitly.\n\ndune supports multi-package development by simply dropping multiple\nrepositories into the same directory.\n\nIt also supports multi-context builds, such as building against\nseveral opam roots/switches simultaneously. This helps maintaining\npackages across several versions of OCaml and gives cross-compilation\nfor free.\"\"\"\nmaintainer: \"[email protected]\"\nauthors: \"Jane Street Group, LLC <[email protected]>\"\nlicense: \"MIT\"\nhomepage: \"https://github.com/ocaml/dune\"\nbug-reports: \"https://github.com/ocaml/dune/issues\"\ndepends: [\n \"ocaml\" {>= \"4.02\"}\n]\nconflicts: [\n \"jbuilder\" {!= \"transition\"}\n]\nbuild: [\n [\"ocaml\" \"configure.ml\" \"--libdir\" lib] {opam-version < \"2\"}\n [\"ocaml\" \"bootstrap.ml\"]\n [\"./boot.exe\" \"--release\" \"--subst\"] {pinned}\n [\"./boot.exe\" \"--release\" \"-j\" jobs]\n]\ndev-repo: \"git+https://github.com/ocaml/dune.git\"\nurl {\n src: \"https://github.com/ocaml/dune/releases/download/1.3.0/dune-1.3.0.tbz\"\n checksum: \"md5=d7c926bd6b7549cb54d5463aaccf0c91\"\n}", | ||
"override": { | ||
"build": [ | ||
[ "ocaml", "bootstrap.ml" ], | ||
|
@@ -661,11 +662,11 @@ | |
"name": "conf-which", | ||
"version": "1", | ||
"opam": | ||
"opam-version: \"2.0\"\nname: \"conf-which\"\nversion: \"1\"\nsynopsis: \"Virtual package relying on which\"\ndescription:\n \"This package can only install if the which program is installed on the system.\"\nmaintainer: \"[email protected]\"\nauthors: \"Carlo Wood\"\nlicense: \"GPL-2+\"\nhomepage: \"http://www.gnu.org/software/which/\"\nbug-reports: \"https://github.com/ocaml/opam-repository/issues\"\ndepends: [\"ocaml\"]\nbuild: [\"which\" \"which\"]\ndepexts: [\n [\"which\"] {os-distribution = \"centos\"}\n [\"which\"] {os-distribution = \"fedora\"}\n [\"which\"] {os-distribution = \"opensuse\"}\n [\"debianutils\"] {os-distribution = \"debian\"}\n [\"debianutils\"] {os-distribution = \"ubuntu\"}\n [\"which\"] {os-distribution = \"nixos\"}\n [\"which\"] {os-distribution = \"archlinux\"}\n]", | ||
"opam-version: \"2.0\"\nname: \"conf-which\"\nversion: \"1\"\nsynopsis: \"Virtual package relying on which\"\ndescription:\n \"This package can only install if the which program is installed on the system.\"\nmaintainer: \"[email protected]\"\nauthors: \"Carlo Wood\"\nlicense: \"GPL-2+\"\nhomepage: \"http://www.gnu.org/software/which/\"\nbug-reports: \"https://github.com/ocaml/opam-repository/issues\"\nbuild: [\"which\" \"which\"]\ndepexts: [\n [\"which\"] {os-distribution = \"centos\"}\n [\"which\"] {os-distribution = \"fedora\"}\n [\"which\"] {os-distribution = \"opensuse\"}\n [\"debianutils\"] {os-distribution = \"debian\"}\n [\"debianutils\"] {os-distribution = \"ubuntu\"}\n [\"which\"] {os-distribution = \"nixos\"}\n [\"which\"] {os-distribution = \"archlinux\"}\n]", | ||
"override": null | ||
} | ||
}, | ||
"dependencies": [ "@esy-ocaml/[email protected]", "[email protected]" ] | ||
"dependencies": [ "@esy-ocaml/[email protected]" ] | ||
}, | ||
"@opam/conf-m4@opam:1": { | ||
"record": { | ||
|
@@ -677,11 +678,11 @@ | |
"name": "conf-m4", | ||
"version": "1", | ||
"opam": | ||
"opam-version: \"2.0\"\nname: \"conf-m4\"\nversion: \"1\"\nsynopsis: \"Virtual package relying on m4\"\ndescription:\n \"This package can only install if the m4 binary is installed on the system.\"\nmaintainer: \"[email protected]\"\nlicense: \"GPL-3\"\nhomepage: \"http://www.gnu.org/software/m4/m4.html\"\nbug-reports: \"https://github.com/ocaml/opam-repository/issues\"\ndepends: [\"ocaml\"]\nbuild: [\"sh\" \"-exc\" \"echo | m4\"]\ndepexts: [\n [\"m4\"] {os-distribution = \"debian\"}\n [\"m4\"] {os-distribution = \"ubuntu\"}\n [\"m4\"] {os-distribution = \"fedora\"}\n [\"m4\"] {os-distribution = \"rhel\"}\n [\"m4\"] {os-distribution = \"centos\"}\n [\"m4\"] {os-distribution = \"alpine\"}\n [\"m4\"] {os-distribution = \"nixos\"}\n [\"m4\"] {os-distribution = \"opensuse\"}\n [\"m4\"] {os-distribution = \"oraclelinux\"}\n [\"m4\"] {os-distribution = \"archlinux\"}\n]", | ||
"opam-version: \"2.0\"\nname: \"conf-m4\"\nversion: \"1\"\nsynopsis: \"Virtual package relying on m4\"\ndescription:\n \"This package can only install if the m4 binary is installed on the system.\"\nmaintainer: \"[email protected]\"\nauthors: \"GNU Project\"\nlicense: \"GPL-3\"\nhomepage: \"http://www.gnu.org/software/m4/m4.html\"\nbug-reports: \"https://github.com/ocaml/opam-repository/issues\"\nbuild: [\"sh\" \"-exc\" \"echo | m4\"]\ndepexts: [\n [\"m4\"] {os-distribution = \"debian\"}\n [\"m4\"] {os-distribution = \"ubuntu\"}\n [\"m4\"] {os-distribution = \"fedora\"}\n [\"m4\"] {os-distribution = \"rhel\"}\n [\"m4\"] {os-distribution = \"centos\"}\n [\"m4\"] {os-distribution = \"alpine\"}\n [\"m4\"] {os-distribution = \"nixos\"}\n [\"m4\"] {os-distribution = \"opensuse\"}\n [\"m4\"] {os-distribution = \"oraclelinux\"}\n [\"m4\"] {os-distribution = \"archlinux\"}\n]", | ||
"override": null | ||
} | ||
}, | ||
"dependencies": [ "@esy-ocaml/[email protected]", "[email protected]" ] | ||
"dependencies": [ "@esy-ocaml/[email protected]" ] | ||
}, | ||
"@opam/cmdliner@opam:1.0.2": { | ||
"record": { | ||
|
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
Binary file not shown.
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
(executable | ||
(name Bin) | ||
(preprocess (pps lwt_ppx)) | ||
(public_name Bin) | ||
(js_of_ocaml) | ||
(libraries | ||
js_of_ocaml | ||
Revery | ||
)) | ||
(install | ||
(section bin) | ||
(files binary.dat index.html Bin.bc.js)) |
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,16 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>This is the title of the webpage!</title> | ||
<style> | ||
html, body { | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page, just like this <strong>p</strong> tag and its contents.</p> | ||
<script src="Bin.bc.js"></script> | ||
</body> | ||
</html> |
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,10 @@ | ||
const fs = require("fs"); | ||
|
||
const testData = new Uint8Array(5); | ||
testData[0] = 255; | ||
testData[1] = 0; | ||
testData[2] = 1; | ||
testData[3] = 2; | ||
testData[4] = 128; | ||
|
||
fs.writeFileSync("binary.dat", new Buffer(testData)); |
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,19 @@ | ||
|
||
type byteArray = Bigarray.Array1.t(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout); | ||
|
||
exception FileOpenException(string); | ||
|
||
type successFunction = (byteArray) => unit; | ||
type failureFunction = (string) => unit; | ||
|
||
external open_sync_raw: (string, successFunction, failureFunction) => unit = "caml_open_sync_raw"; | ||
|
||
let openAsync = (p) => { | ||
let (promise, resolver) = Lwt.task(); | ||
|
||
let success = (ba) => Lwt.wakeup_later(resolver, ba); | ||
let failure = (message) => Lwt.wakeup_later_exn(resolver, FileOpenException(message)); | ||
|
||
open_sync_raw(p, success, failure); | ||
promise | ||
}; |
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,9 @@ | ||
|
||
type byteArray = Bigarray.Array1.t(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout); | ||
|
||
exception FileOpenException(string); | ||
|
||
type successFunction = (byteArray) => unit; | ||
type failureFunction = (string) => unit; | ||
|
||
let openAsync: (string) => Lwt.t(byteArray); |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
(library | ||
(name Revery) | ||
(public_name Revery) | ||
(libraries Reglfw)) | ||
(js_of_ocaml (javascript_files file.js)) | ||
(cxx_names file) | ||
(libraries lwt lwt.unix reglfw)) |
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,38 @@ | ||
#include <stdio.h> | ||
|
||
#include <caml/mlvalues.h> | ||
#include <caml/bigarray.h> | ||
#include <caml/memory.h> | ||
#include <caml/alloc.h> | ||
#include <caml/callback.h> | ||
|
||
#include <string.h> | ||
|
||
extern "C" { | ||
|
||
CAMLprim value | ||
caml_open_sync_raw(value vFileName, value vSuccess, value vFailure) { | ||
CAMLparam1(vFileName); | ||
FILE *pFile = fopen("binary.dat", "rb"); | ||
|
||
if (!pFile) { | ||
caml_callback(vFailure, caml_copy_string("Unable to load file")); | ||
} else { | ||
fseek(pFile, 0, SEEK_END); | ||
long lSize = ftell(pFile); | ||
fseek(pFile, 0, SEEK_SET); | ||
|
||
char *pData = (char *)malloc(lSize + 1); | ||
fread(pData, lSize, 1, pFile); | ||
|
||
fclose(pFile); | ||
|
||
long dims[1]; | ||
dims[0] = lSize; | ||
value ba = caml_ba_alloc(CAML_BA_UINT8 | CAML_BA_C_LAYOUT, 1, pData, (long long int *)dims); | ||
caml_callback(vSuccess, ba); | ||
} | ||
|
||
CAMLreturn(Val_unit); | ||
} | ||
} |
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,51 @@ | ||
// Provides: caml_thread_create | ||
function caml_thread_create() { } | ||
|
||
// Provides: caml_thread_initialize | ||
function caml_thread_initialize() { } | ||
|
||
// Provides: caml_mutex_new | ||
function caml_mutex_new() { } | ||
|
||
// Provides: lwt_unix_iov_max | ||
function lwt_unix_iov_max() { } | ||
|
||
// Provides: lwt_unix_init_notification | ||
function lwt_unix_init_notification() { } | ||
|
||
// Provides: lwt_unix_init_signals | ||
function lwt_unix_init_signals() { } | ||
|
||
// Provides: lwt_unix_set_signal | ||
function lwt_unix_set_signal() { } | ||
|
||
// Provides: lwt_unix_system_byte_order | ||
function lwt_unix_system_byte_order() { } | ||
|
||
// Provides: lwt_unix_get_page_size | ||
function lwt_unix_get_page_size() { } | ||
|
||
// Provides: caml_open_sync_raw | ||
function caml_open_sync_raw(fileName, onSuccess, onFailure) { | ||
var f = caml_js_from_string(fileName); | ||
console.log(f); | ||
var data = new Uint8Array([17, 211, 2]); | ||
|
||
var result = null; | ||
|
||
function onSuccess () { | ||
var res = new Uint8Array(oReq.response); | ||
var ba = caml_ba_create_from(res, null, 0, 0, 0, [res.length]) | ||
onSuccess(ba); | ||
}; | ||
|
||
function onFailure () { | ||
onFailure(caml_js_to_string("failed to load file: " + f)); | ||
}; | ||
|
||
var oReq = new XMLHttpRequest(); | ||
oReq.addEventListener("load", onSuccess, onFailure); | ||
oReq.responseType = "arraybuffer" | ||
oReq.open("GET", fileName, true); | ||
oReq.send(); | ||
} |