NostrScript is a WebAssembly implementation that interacts with Damus. It enables dynamic scripting that can be used to power custom list views, enabling pluggable algorithms. The web has JavaScript, Damus has NostrScript. NostrScripts can be written in any language that compiles to WASM. This commit adds a WASM interpreter I've written as a mostly-single C file for portability and embeddability. In the future we could JIT-compile these for optimal performance if NostrScripts get large and complicated. For now an interpreter is simple enough for algorithm list view plugins. Changelog-Added: Add initial NostrScript implementation Signed-off-by: William Casarin <jb55@jb55.com>
24 lines
543 B
C
24 lines
543 B
C
//
|
|
// nostrscript.h
|
|
// damus
|
|
//
|
|
// Created by William Casarin on 2023-06-02.
|
|
//
|
|
|
|
#ifndef nostrscript_h
|
|
#define nostrscript_h
|
|
|
|
#define NSCRIPT_LOADED 1
|
|
#define NSCRIPT_PARSE_ERR 2
|
|
#define NSCRIPT_INIT_ERR 3
|
|
|
|
#include <stdio.h>
|
|
#include "wasm.h"
|
|
|
|
int nscript_load(struct wasm_parser *p, struct wasm_interp *interp, unsigned char *wasm, unsigned long len);
|
|
int nscript_nostr_cmd(struct wasm_interp *interp, int, void*, int);
|
|
int nscript_pool_send_to(struct wasm_interp *interp, const u16*, int, const u16 *, int);
|
|
|
|
|
|
#endif /* nostrscript_h */
|