Skip to content

Commit

Permalink
update state machine (#73)
Browse files Browse the repository at this point in the history
update wasm
  • Loading branch information
dragazo authored Jul 17, 2024
1 parent f1b2fd6 commit ff2d7e1
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 295 deletions.
2 changes: 1 addition & 1 deletion extensions/StateMachine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
path = path.substring(0, path.lastIndexOf("/"));
var s = document.createElement('script');
s.type = "module";
s.innerHTML = `import init, {check_state, transition, visualize} from '${path}/pkg/stateflow_trans_ext.js';
s.innerHTML = `import init, {check_state, transition, visualize} from '${path}/pkg/netsblox_stateflow_ext.js';
await init();
Expand Down
7 changes: 7 additions & 0 deletions extensions/StateMachine/pkg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Building

This extension must be built with `wasm-pack` for the `web` target:

```bash
wasm-pack build --release --target web
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
/* eslint-disable */
/**
*/
export function setup(): void;
/**
*/
export function visualize(): void;
/**
* @param {any} proc
Expand All @@ -21,12 +24,15 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly setup: () => void;
readonly visualize: () => void;
readonly transition: (a: number, b: number, c: number) => void;
readonly check_state: (a: number, b: number, c: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
readonly __wbindgen_start: () => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ function getInt32Memory0() {
return cachedInt32Memory0;
}

let cachedFloat64Memory0 = null;

function getFloat64Memory0() {
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
}
return cachedFloat64Memory0;
}

function debugString(val) {
// primitive types
const type = typeof val;
Expand Down Expand Up @@ -180,6 +189,12 @@ function debugString(val) {
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
/**
*/
export function setup() {
wasm.setup();
}

/**
*/
export function visualize() {
Expand Down Expand Up @@ -248,10 +263,6 @@ async function __wbg_load(module, imports) {
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbindgen_is_function = function(arg0) {
const ret = typeof(getObject(arg0)) === 'function';
return ret;
};
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
Expand All @@ -263,6 +274,14 @@ function __wbg_get_imports() {
const ret = getObject(arg0);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_is_function = function(arg0) {
const ret = typeof(getObject(arg0)) === 'function';
return ret;
};
imports.wbg.__wbindgen_number_new = function(arg0) {
const ret = arg0;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'string' ? obj : undefined;
Expand All @@ -271,13 +290,38 @@ function __wbg_get_imports() {
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_alert_36d8fb43aa48a428 = function(arg0, arg1) {
alert(getStringFromWasm0(arg0, arg1));
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'number' ? obj : undefined;
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
};
imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
const ret = getObject(arg0) === getObject(arg1);
return ret;
};
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
const ret = new Error();
return addHeapObject(ret);
};
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
const ret = getObject(arg1).stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
let deferred0_0;
let deferred0_1;
try {
deferred0_0 = arg0;
deferred0_1 = arg1;
console.error(getStringFromWasm0(arg0, arg1));
} finally {
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
}
};
imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) {
let result;
try {
Expand Down Expand Up @@ -336,10 +380,28 @@ function __wbg_get_imports() {
const ret = getObject(arg0).push(getObject(arg1));
return ret;
};
imports.wbg.__wbg_newwithargs_33d0ffcb48344669 = function(arg0, arg1, arg2, arg3) {
const ret = new Function(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
return addHeapObject(ret);
};
imports.wbg.__wbg_instanceof_Object_71ca3c0a59266746 = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof Object;
} catch (_) {
result = false;
}
const ret = result;
return ret;
};
imports.wbg.__wbg_apply_0a5aa603881e6d79 = function() { return handleError(function (arg0, arg1, arg2) {
const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_set_1f9b04f170055d33 = function() { return handleError(function (arg0, arg1, arg2) {
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
return ret;
}, arguments) };
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
const ret = debugString(getObject(arg1));
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
Expand All @@ -361,10 +423,11 @@ function __wbg_init_memory(imports, maybe_memory) {
function __wbg_finalize_init(instance, module) {
wasm = instance.exports;
__wbg_init.__wbindgen_wasm_module = module;
cachedFloat64Memory0 = null;
cachedInt32Memory0 = null;
cachedUint8Memory0 = null;


wasm.__wbindgen_start();
return wasm;
}

Expand All @@ -388,7 +451,7 @@ async function __wbg_init(input) {
if (wasm !== undefined) return wasm;

if (typeof input === 'undefined') {
input = new URL('stateflow_trans_ext_bg.wasm', import.meta.url);
input = new URL('netsblox_stateflow_ext_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function setup(): void;
export function visualize(): void;
export function transition(a: number, b: number, c: number): void;
export function check_state(a: number, b: number, c: number): number;
export function __wbindgen_malloc(a: number, b: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
export function __wbindgen_free(a: number, b: number, c: number): void;
export function __wbindgen_exn_store(a: number): void;
export function __wbindgen_start(): void;
12 changes: 6 additions & 6 deletions extensions/StateMachine/pkg/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "stateflow-trans-ext",
"name": "netsblox-stateflow-ext",
"type": "module",
"version": "0.1.0",
"files": [
"stateflow_trans_ext_bg.wasm",
"stateflow_trans_ext.js",
"stateflow_trans_ext.d.ts"
"netsblox_stateflow_ext_bg.wasm",
"netsblox_stateflow_ext.js",
"netsblox_stateflow_ext.d.ts"
],
"main": "stateflow_trans_ext.js",
"types": "stateflow_trans_ext.d.ts",
"main": "netsblox_stateflow_ext.js",
"types": "netsblox_stateflow_ext.d.ts",
"sideEffects": [
"./snippets/*"
]
Expand Down
Loading

0 comments on commit ff2d7e1

Please sign in to comment.