mirror of
git://jb55.com/damus
synced 2024-10-06 19:53:22 +00:00
97f10e865f
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>
34 lines
720 B
C
34 lines
720 B
C
|
|
#ifndef PROTOVERSE_ERROR_H
|
|
#define PROTOVERSE_ERROR_H
|
|
|
|
#include "cursor.h"
|
|
|
|
struct error {
|
|
int pos;
|
|
const char *msg;
|
|
};
|
|
|
|
struct errors {
|
|
struct cursor cur;
|
|
int enabled;
|
|
};
|
|
|
|
#define note_error(errs, p, fmt, ...) note_error_(errs, p, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
|
|
|
|
static inline int cursor_push_error(struct cursor *cur, struct error *err)
|
|
{
|
|
return cursor_push_int(cur, err->pos) &&
|
|
cursor_push_c_str(cur, err->msg);
|
|
}
|
|
|
|
static inline int cursor_pull_error(struct cursor *cur, struct error *err)
|
|
{
|
|
return cursor_pull_int(cur, &err->pos) &&
|
|
cursor_pull_c_str(cur, &err->msg);
|
|
}
|
|
|
|
int note_error_(struct errors *errs, struct cursor *p, const char *fmt, ...);
|
|
|
|
#endif /* PROTOVERSE_ERROR_H */
|