-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjs.jl
More file actions
executable file
·40 lines (31 loc) · 813 Bytes
/
Copy pathjs.jl
File metadata and controls
executable file
·40 lines (31 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module JavaScript
macro __NODE_FILE__()
path = joinpath(dirname(@__FILE__), "julia.node")
return :($path)
end
type Value
ptr::Ptr{Void}
function Value()
res = new()
finalizer(res, finalize_value)
res
end
end
# bitstype 8 ValueBits
function finalize_value(x::Value)
ccall((:j2_destroy_value, @__NODE_FILE__), Void, (Any,), x)
end
const SHARED = Dict()
function catch_message(e)
sprint(showerror, e, catch_backtrace())
end
function convert(::Type{Array}, x::Value)
ccall((:j2_to_julia_array, @__NODE_FILE__), Any, (Any,), x)
end
end
function js(src)
ccall((:JSEval, @JavaScript.__NODE_FILE__), Any, (Cstring,), src)
end
macro js_str(src)
js(src)
end