Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Remote Functions and Optional Data Field #54

Merged
merged 23 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/.vitepress/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ const beforeMount = (monaco: Monaco) => {

const Calls = ["SingleSync", "SingleAsync", "ManySync", "ManyAsync"] as const;

const Options = ["typescript", "write_checks", "casing", "server_output", "client_output", "manual_event_loop"] as const;
const Options = ["typescript", "write_checks", "casing", "server_output", "client_output", "manual_event_loop", "yield_type"] as const;

const Casing = ["PascalCase", "camelCase", "snake_case"].map((value) => `"${value}"`);
const YieldType = ["yield", "future", "promise"].map((value) => `"${value}"`);

const setting = [...Locations, ...Brand, ...Calls, ...Casing] as const;

Expand Down Expand Up @@ -151,6 +152,7 @@ const beforeMount = (monaco: Monaco) => {
opt: Options,

casing: Casing,
yield_type: YieldType,

typescript: Operators,
write_checks: Operators,
Expand Down Expand Up @@ -292,6 +294,22 @@ const beforeMount = (monaco: Monaco) => {
documentation: "Event",
range: range,
},
{
label: "func",
kind: monaco.languages.CompletionItemKind.Snippet,
insertText: [
"func ${1} = {",
"\tcall: ${2},",
"\targs: ${3},",
"\trets: ${4},",
"}\n",
].join("\n"),
insertTextRules:
monaco.languages.CompletionItemInsertTextRule
.InsertAsSnippet,
documentation: "Event",
range: range,
},
];
return { suggestions };
} else {
Expand Down
25 changes: 24 additions & 1 deletion zap/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
pub struct Config<'src> {
pub tydecls: Vec<TyDecl<'src>>,
pub evdecls: Vec<EvDecl<'src>>,
pub fndecls: Vec<FnDecl<'src>>,

pub write_checks: bool,
pub typescript: bool,
Expand All @@ -16,6 +17,7 @@ pub struct Config<'src> {
pub client_output: &'src str,

pub casing: Casing,
pub yield_type: YieldType,
}

impl<'src> Config<'src> {
Expand All @@ -41,13 +43,34 @@ impl Casing {
}
}

#[derive(Debug, Clone, Copy)]
pub enum YieldType {
Yield,
Future,
Promise,
}

#[derive(Debug, Clone)]
pub struct FnDecl<'src> {
pub name: &'src str,
pub call: FnCall,
pub args: Option<Ty<'src>>,
pub rets: Option<Ty<'src>>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FnCall {
Async,
Sync,
}

#[derive(Debug, Clone)]
pub struct EvDecl<'src> {
pub name: &'src str,
pub from: EvSource,
pub evty: EvType,
pub call: EvCall,
pub data: Ty<'src>,
pub data: Option<Ty<'src>>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down
Loading
Loading