diff options
author | 2021-07-21 02:07:07 -0700 | |
---|---|---|
committer | 2021-07-21 02:07:07 -0700 | |
commit | a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868 (patch) | |
tree | 8a10690daafe99a8d908119f9bb855cd0f3d368a /src/javascript/jsc/headergen | |
parent | f2ea2027300949b919f9d595ce3039c8bc82d21a (diff) | |
download | bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.tar.gz bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.tar.zst bun-a8a4f280469d4d3baf8ea6e9dbce9ec06bd3d868.zip |
most of the bindings!
Diffstat (limited to 'src/javascript/jsc/headergen')
-rw-r--r-- | src/javascript/jsc/headergen/sizegen.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/javascript/jsc/headergen/sizegen.cpp b/src/javascript/jsc/headergen/sizegen.cpp new file mode 100644 index 000000000..6999fcda0 --- /dev/null +++ b/src/javascript/jsc/headergen/sizegen.cpp @@ -0,0 +1,40 @@ +#include <iostream> +#include <fstream> +#include <ctime> +using namespace std; + +#include "headers-cpp.h" + +int main() { + time_t rawtime; + struct tm * timeinfo; + char buf [80]; + + time (&rawtime); + timeinfo = localtime (&rawtime); + + strftime (buf,80,"%Y-%m-%d %H:%M:%s",timeinfo); + + cout << "// Auto-generated by src/javascript/jsc/headergen/sizegen.cpp at " << buf << ".\n"; + cout << "// These are the byte sizes for the different object types with bindings in JavaScriptCore.\n"; + cout << "// This allows us to safely return stack allocated C++ types to Zig.\n"; + cout << "// It is only safe to do this when these sizes are correct.\n"; + cout << "// That means:\n"; + cout << "// 1. We can't dynamically link JavaScriptCore\n"; + cout << "// 2. It's important that this is run whenever JavaScriptCore is updated or the bindings on the Zig side change.\n"; + cout << "// Failure to do so will lead to undefined behavior and probably some frustrated people.\n"; + cout << "// --- Regenerate this: --- \n"; + cout << "// 1. \"make jsc-bindings-headers\"\n"; + cout << "// 2. \"make sizegen\"\n"; + cout << "// 3. \"make jsc-bindings-headers\"\n"; + cout << "// You can verify the numbers written in this file at runtime via the `extern`d types\n"; + cout << "// Run \"jsc-bindings-headers\" twice because it uses these values in the output. That's how all the bJSC__.* types are created - from these values. \n"; + cout << "// The data for this file is generated in headers-cpp.h \n"; + int i = 0; + int len = sizeof(sizes)/sizeof(sizes[0]); + for (i = 0; i < len ; i++) { + cout << "pub const " << names[i] << " = " << sizes[i] << ";\n"; + } + + return 0; +}
\ No newline at end of file |