connect wasm to monaco
This commit is contained in:
@@ -1,8 +1,30 @@
|
||||
import Lean
|
||||
import Lean.Server.Watchdog
|
||||
|
||||
@[export my_length]
|
||||
def myLength (s : String) : IO Unit := do
|
||||
IO.println "hello"
|
||||
IO.println Lean.origin
|
||||
IO.println s
|
||||
open Lean
|
||||
open Server
|
||||
open Watchdog
|
||||
open Lsp
|
||||
open IO
|
||||
open JsonRpc
|
||||
|
||||
#check JsonRpc.Request
|
||||
|
||||
@[export game_send_message]
|
||||
def sendMessage (s : String) : IO Unit := do
|
||||
let expectedMethod := "initialize"
|
||||
let j ← ofExcept (Json.parse s)
|
||||
let m ← match fromJson? j with
|
||||
| Except.ok (m : JsonRpc.Message) => pure m
|
||||
| Except.error inner => throw $ userError s!"JSON '{j.compress}' did not have the format of a JSON-RPC message.\n{inner}"
|
||||
let initRequest ← match m with
|
||||
| Message.request id method params? =>
|
||||
if method = expectedMethod then
|
||||
let j := toJson params?
|
||||
match fromJson? j with
|
||||
| Except.ok v => pure $ JsonRpc.Request.mk id expectedMethod (v : InitializeParams)
|
||||
| Except.error inner => throw $ userError s!"Unexpected param '{j.compress}' for method '{expectedMethod}'\n{inner}"
|
||||
else
|
||||
throw $ userError s!"Expected method '{expectedMethod}', got method '{method}'"
|
||||
| _ => throw $ userError s!"Expected JSON-RPC request, got: '{(toJson m).compress}'"
|
||||
IO.println s!"{initRequest.param.editDelay}"
|
||||
return ()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <lean/lean.h>
|
||||
|
||||
extern lean_object* my_length(lean_object*, lean_object*);
|
||||
extern lean_object* game_send_message(lean_object*, lean_object*);
|
||||
|
||||
// see https://leanprover.github.io/lean4/doc/dev/ffi.html#initialization
|
||||
extern void lean_initialize_runtime_module();
|
||||
@@ -29,5 +29,5 @@ int main() {
|
||||
|
||||
void send_message(char* msg){
|
||||
lean_object * s = lean_mk_string(msg);
|
||||
my_length(s, lean_io_mk_world());
|
||||
game_send_message(s, lean_io_mk_world());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user