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

ToJS / FromJS #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions IdrisScript.idr
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ interface ToJS from (to : JSType) where
implementation ToJS String JSString where
toJS str = MkJSString (believe_me str)

implementation ToJS Nat JSNumber where
toJS num = MkJSNumber (believe_me num)

implementation ToJS Int JSNumber where
toJS num = MkJSNumber (believe_me num)

implementation ToJS Integer JSNumber where
toJS num = MkJSNumber (believe_me num)

implementation ToJS Double JSNumber where
toJS num = MkJSNumber (believe_me num)

Expand All @@ -100,6 +106,9 @@ implementation FromJS JSString String where
implementation FromJS JSNumber Int where
fromJS (MkJSNumber num) = cast {from=Double} {to=Int} (believe_me num)

implementation FromJS JSNumber Integer where
fromJS (MkJSNumber num) = cast {from=Double} {to=Integer} (believe_me num)

implementation FromJS JSNumber Double where
fromJS (MkJSNumber num) = believe_me num

Expand Down
2 changes: 1 addition & 1 deletion IdrisScript/Objects.idr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ setProperty : (prop : String)
-> (obj : JSValue (JSObject c))
-> JS_IO (JSValue (JSObject c))
setProperty prop val obj = do
jscall "%0[%1] = %2" (Ptr -> String -> Ptr -> JS_IO Ptr)
jscall "%0[%1] = %2" (Ptr -> String -> Ptr -> JS_IO ())
(unpack obj) prop (unpack val)
pure obj

Expand Down