Skip to content

Commit

Permalink
feat: add modified module definition for php protobufs
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Jan 17, 2024
1 parent 0a915ee commit 8d4574c
Show file tree
Hide file tree
Showing 9 changed files with 937 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ generate: install
protoc --experimental_allow_proto3_optional \
--rust_out=proto/v1/src \
--go_out=proto/v1/go \
--php_out=proto/v1/php \
proto/v1/api.proto

generate-php: install
protoc --experimental_allow_proto3_optional \
--php_out=proto/v1/php \
proto/v1/module-no-option.proto

generate-web-list-mods-response:
cd scripts/protobuf-list-modules-response && cargo run --release -- $(take)
mv scripts/protobuf-list-modules-response/ListModulesResponse.pb api/
77 changes: 77 additions & 0 deletions proto/v1/module-no-option.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
syntax = "proto3";

import "google/protobuf/timestamp.proto";

// Used to type the arguments and return types from wasm elements such as import
// and export functions.
enum ValType {
I32 = 0;
I64 = 1;
F32 = 2;
F64 = 3;
V128 = 4;
FuncRef = 5;
ExternRef = 6;
}

// Contained by an import or export element within a wasm binary.
message Function {
repeated ValType params = 1;
repeated ValType results = 2;
string name = 3;
}

// A function and module namespace that is defined outside of the current
// module, and referenced & called by the current module.
message Import {
string module_name = 1;
Function func = 2;
}

// A function that is defined inside the current module, made available to
// outside modules / environments.
message Export { Function func = 1; }

// The language (or most similar match) used to produce a wasm module.
enum SourceLanguage {
Unknown = 0;
Rust = 1;
Go = 2;
C = 3;
Cpp = 4;
AssemblyScript = 5;
Swift = 6;
JavaScript = 7;
Haskell = 8;
Zig = 9;
}

// Details about a wasm module, either extracted directly from the binary, or
// inferred somehow.
message Module {
// ID for this module, generated by the database.
int64 id = 1;
// sha256 hash of the modules raw bytes
string hash = 3;
// function imports called by the module (see:
// <https://github.com/WebAssembly/design/blob/main/Modules.md#imports)>
repeated Import imports = 4;
// function exports provided by the module (see:
// <https://github.com/WebAssembly/design/blob/main/Modules.md#exports)>
repeated Export exports = 5;
// size in bytes of the module
uint64 size = 6;
// path or locator to the module
string location = 7;
// programming language used to produce this module
SourceLanguage source_language = 8;
// arbitrary metadata provided by the operator of this module
map<string, string> metadata = 9;
// timestamp when this module was loaded and stored
google.protobuf.Timestamp inserted_at = 10;
// the interned strings stored in the wasm binary (panic/abort messages, etc.)
repeated string strings = 11;
// function hashes
map<string, string> function_hashes = 15;
}

59 changes: 59 additions & 0 deletions proto/v1/php/Export.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions proto/v1/php/GPBMetadata/Proto/V1/ModuleNoOption.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions proto/v1/php/Import.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8d4574c

Please sign in to comment.