darfink / chakracore-rs Goto Github PK
View Code? Open in Web Editor NEWAn idiomatic Rust wrapper for the JSRT interface
An idiomatic Rust wrapper for the JSRT interface
I am trying to figure out how to use function callbacks. In this example, I'm simply creating a numeric array and trying to filter for just the even numbers. Unfortunately, the returned array is always empty. Any idea how to make this work? Here is what I last tried:
extern crate chakracore as js;
use std::io::prelude::*;
use std::fs::File;
use js::Property;
fn main() {
let runtime = js::Runtime::new().unwrap();
let context = js::Context::new(&runtime).unwrap();
let guard = context.make_current().unwrap();
// create a JavaScript Array
let length = 10;
let array = js::value::Array::new(&guard, length);
for i in 0..length {
array.set_index(&guard, i, &js::value::Number::new(&guard, i as i32));
}
println!("array: {:?}", array.len(&guard));
// try filtering it
let is_even = js::value::Function::new(&guard, Box::new(|guard, info| {
// let i = info.arguments[0].to_integer(guard);
// println!("i: {:?}", i);
// Ok(js::value::Boolean::new(guard, i % 2 == 0).into())
println!("is_even");
Ok(js::value::Boolean::new(guard, true).into())
}));
let fn_filter = array.get(&guard, &Property::new(&guard, "filter")).into_function().unwrap();
let filtered_array = fn_filter.call(&guard, &[&is_even]).unwrap(); //.into_array().unwrap();
println!("filtered_array: {:?}", filtered_array);
// for v in filtered_array.iter(&guard){
// println!("filtered v: {:?}", v);
// }
}
Implement JsGetAndClearExceptionWithMetadata when stable.
Problem:
The JsAddRef
and JsRelease
APIs require a current context to be set in order to work. However, they are being exposed through the Clone
and Drop
traits that don't require a ContextGuard
to be present when clone
is called, or the value is dropped.
This results in the following panics, when a value is cloned and/or dropped w/o a current context:
thread '<unnamed>' panicked at 'Call to 'JsAddRef(value, ::std::ptr::null_mut())' failed with: NoCurrentContext', /
Users/sam/.cargo/git/checkouts/chakracore-rs-259abda0f25cff98/cbe5ca1/src/value/function.rs:158
thread '<unnamed>' panicked at 'Call to 'unsafe { JsRelease(self.as_raw(), &mut count) }' failed with: NoCurrentContext', /Users/sam/.cargo/git/checkouts/chakracore-rs-259abda0f25cff98/cbe5ca1/src/value/function.rs:158
I'm struggling to think of a way to expose a safe API through clone/drop, tbh. Especially drop
seems to be problematic, because Rust offers no way to control under which circumstances a value might be dropped.
A possible way to fix it could be to tie the lifetime of a Context or Value to the lifetime of the ContextGuard, which would require the value to be dropped before the context guard is dropped, i.e. before the current context is unset, and would require the context guard to be alive in order to clone a value.
The downside is that this complicates storing contexts or values in Rust data structures, but it's the only possible solution I can think of at this point.
Sorry I feel like I am going to be that annoying guy who doesn't ever know whats going on but I was trying to build on Ubuntu now and the normal target works.
However I wanted to build targeting musl so libc is build into the binary (lets it run on any linux system and a FROM scratch docker container)
I then get this
cargo run --target=x86_64-unknown-linux-musl
Compiling rocket_contrib v0.2.8
Compiling chakracore-sys v0.2.2
error: failed to run custom build command for `chakracore-sys v0.2.2`
process didn't exit successfully: `/home/corbinu/Developer/corbinu/rocket-challenge/target/debug/build/chakracore-sys-795c32afd2d7755e/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=CHAKRA_SOURCE
cargo:rerun-if-env-changed=CHAKRA_BUILD
/usr/bin/pkg-config
chakracore-sys/build.rs:51: Using default ChakraCore build (version: 1.5.1)
chakracore-sys/build.rs:103: Binaries already built, using existing...
cargo:rustc-link-search=native=/home/corbinu/Developer/corbinu/rocket-challenge/target/x86_64-unknown-linux-musl/debug/build/chakracore-sys-201a0b8ad8cf6a2f/out/lib-1.5.1
cargo:rustc-link-lib=static=ChakraCoreStatic
--- stderr
thread 'main' panicked at 'No package configuration for 'libunwind-ptrace' found', /checkout/src/libcore/option.rs:823
note: Run with `RUST_BACKTRACE=1` for a backtrace.
I tried installing libunwind-dev
and that din't help any thoughts?
While testing out the current master I ran into this gotcha. JSON.stringify
can throw, for instance when the toJSON method on the value throws, or when passed a circular object graph. It would be useful for Value::to_json
to return a Result
in order to allow the user to catch this exception.
Perhaps it worked in the past, but nowadays the following occurs:
Compiling syntex_syntax v0.58.1
error[E0423]: expected function, tuple struct or tuple variant, found struct `ast::Name`
--> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\syntex_syntax-0.58.1\src\symbol.rs:146:27
|
146 | name: ast::Name($index),
| ^^^^^^^^^
...
165 | / declare_keywords! {
166 | | // Invalid identifier
167 | | (0, Invalid, "")
168 | |
... |
231 | | (56, CrateRoot, "{{root}}")
232 | | }
| |_- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Is it possible to build library without full source code only with binary releases?
C:\Users\camer\rs\chakracore-rs\chakracore-sys>echo %CHAKRA_SOURCE%
C:\Users\camer\rs\ChakraCore
C:\Users\camer\rs\chakracore-rs\chakracore-sys>echo %CHAKRA_BUILD%
C:\Users\camer\rs\ChakraCore\Build\VcBuild\bin\x64_release
C:\Users\camer\rs\chakracore-rs\chakracore-sys>cargo test -vv
Fresh unicode-width v0.1.4
Fresh utf8-ranges v1.0.0
Fresh rustc-serialize v0.3.24
Fresh unicode-segmentation v1.2.0
Fresh log v0.3.8
Fresh glob v0.2.11
Fresh bitflags v0.8.2
Fresh cfg-if v0.1.2
Fresh unicode-xid v0.0.4
Fresh regex-syntax v0.4.1
Fresh void v1.0.2
Fresh bitflags v0.9.1
Fresh winapi-build v0.1.1
Fresh ansi_term v0.9.0
Fresh winapi v0.2.8
Fresh peeking_take_while v0.1.2
Fresh lazy_static v0.2.8
Fresh libc v0.2.29
Fresh strsim v0.6.0
Fresh pkg-config v0.3.9
Fresh vec_map v0.8.0
Fresh syntex_pos v0.58.1
Fresh unreachable v1.0.0
Fresh memchr v1.0.1
Fresh thread_local v0.3.4
Fresh nom v3.2.0
Fresh aho-corasick v0.6.3
Fresh kernel32-sys v0.2.2
Fresh cexpr v0.2.2
Fresh regex v0.2.2
Fresh term v0.4.6
Fresh atty v0.2.2
Fresh term_size v0.3.0
Fresh libloading v0.4.0
Fresh env_logger v0.4.3
Fresh syntex_errors v0.58.1
Fresh textwrap v0.7.0
Fresh clang-sys v0.18.0
Fresh syntex_syntax v0.58.1
Fresh clap v2.26.0
Fresh aster v0.41.0
Fresh quasi v0.32.0
Fresh syntex v0.58.1
Fresh quasi_codegen v0.32.0
Fresh bindgen v0.25.5
Compiling chakracore-sys v0.2.2 (file:///C:/Users/camer/rs/chakracore-rs/chakracore-sys)
Running `C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\build\chakracore-sys-386c670e5139aed9\build-script-build`
cargo:rerun-if-env-changed=CHAKRA_SOURCE
cargo:rerun-if-env-changed=CHAKRA_BUILD
chakracore-sys/build.rs:48: Using custom ChakraCore build
thread 'main' panicked at 'Library search path '"C:\\Users\\camer\\rs\\ChakraCore\\Build\\VcBuild\\bin\\x64_release\\lib"' does not exist', build.rs:234
stack backtrace:
0: std::sys_common::backtrace::_print
at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
1: std::panicking::default_hook::{{closure}}
at C:\projects\rust\src\libstd\panicking.rs:354
2: std::panicking::default_hook
at C:\projects\rust\src\libstd\panicking.rs:371
3: std::panicking::rust_panic_with_hook
at C:\projects\rust\src\libstd\panicking.rs:549
4: std::panicking::begin_panic<collections::string::String>
at C:\projects\rust\src\libstd\panicking.rs:511
5: build_script_build::linking::add_path<&std::path::PathBuf>
at .\build.rs:234
6: build_script_build::linking::setup
at .\build.rs:194
7: build_script_build::main
at .\build.rs:56
8: panic_unwind::__rust_maybe_catch_panic
at C:\projects\rust\src\libpanic_unwind\lib.rs:98
9: std::rt::lang_start
at C:\projects\rust\src\libstd\rt.rs:52
10: main
11: __scrt_common_main_seh
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
12: BaseThreadInitThunk
error: failed to run custom build command for `chakracore-sys v0.2.2 (file:///C:/Users/camer/rs/chakracore-rs/chakracore-sys)`
process didn't exit successfully: `C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\build\chakracore-sys-386c670e5139aed9\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=CHAKRA_SOURCE
cargo:rerun-if-env-changed=CHAKRA_BUILD
chakracore-sys/build.rs:48: Using custom ChakraCore build
--- stderr
thread 'main' panicked at 'Library search path '"C:\\Users\\camer\\rs\\ChakraCore\\Build\\VcBuild\\bin\\x64_release\\lib"' does not exist', build.rs:234
stack backtrace:
0: std::sys_common::backtrace::_print
at C:\projects\rust\src\libstd\sys_common\backtrace.rs:71
1: std::panicking::default_hook::{{closure}}
at C:\projects\rust\src\libstd\panicking.rs:354
2: std::panicking::default_hook
at C:\projects\rust\src\libstd\panicking.rs:371
3: std::panicking::rust_panic_with_hook
at C:\projects\rust\src\libstd\panicking.rs:549
4: std::panicking::begin_panic<collections::string::String>
at C:\projects\rust\src\libstd\panicking.rs:511
5: build_script_build::linking::add_path<&std::path::PathBuf>
at .\build.rs:234
6: build_script_build::linking::setup
at .\build.rs:194
7: build_script_build::main
at .\build.rs:56
8: panic_unwind::__rust_maybe_catch_panic
at C:\projects\rust\src\libpanic_unwind\lib.rs:98
9: std::rt::lang_start
at C:\projects\rust\src\libstd\rt.rs:52
10: main
11: __scrt_common_main_seh
at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
To get past this error, I did mkdir %CHAKRA_BUILD%\lib
.
This was non-obvious to me since I have experience with V8 which takes care of synchronization for you.
Before setting a context, you might need to unset the current one. Which is what your ContextGuard does as it is dropped. Except it doesn't prevent another thread from trying to set the same context concurrently.
I was thinking an Arc<Mutex<()>>
might work for entering a context.
I'm not sure what's the logic with setting the "previous" context as the current context from the Context#exit
method. I'm assuming people won't be using more than 1 context per runtime, so inner guards are probably infrequent.
Any ideas?
How is the soundness of Context::make_current
guaranteed? For example, what happens if user calls it for two different contexts and then drops the guard in reverse order?
It doesn't seem that chakracore
is published, though chakracore-sys
is.
Btw thanks for this project, I'm hoping to use it in a thing. It's not immediately clear what works or what doesn't, but if I run into something I know I can just use chakracore-sys
like you mentioned.
I'm trying to use call_with_this
like in #20, but I'm getting an access violation exception. If I choose to debug into it with Visual Studio, it shows this:
The code to reproduce is here:
https://github.com/ctaggart/typescript_ts/pull/2/files#diff-6382a243b48dc8580db0fb4e2fb6e26f
cargo run --example create
I'm using ChakraCore v1.7.0.
I made a simple program (uses ChakraCore 0.11, current master) which segfaults when releasing a Context:
Process 29099 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x907f32000)
frame #0: 0x000000010021a07c libChakraCore.dylib`VirtualTableInfoBase::GetVirtualTable(ptr=0x0000000907f32000) at vtinfo.h:89
86 class VirtualTableInfoBase
87 {
88 public:
-> 89 static INT_PTR GetVirtualTable(void * ptr) { return (*(INT_PTR*)ptr); }
90 protected:
91 static void SetVirtualTable(void * ptr, INT_PTR vt) { *(INT_PTR*)ptr = vt; }
92 };
Target 0: (rustproxy) stopped.
(lldb) fr v
(void *) ptr = 0x0000000907f32000
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x907f32000)
* frame #0: 0x000000010021a07c libChakraCore.dylib`VirtualTableInfoBase::GetVirtualTable(ptr=0x0000000907f32000) at vtinfo.h:89
frame #1: 0x00000001003a2545 libChakraCore.dylib`VirtualTableInfo<JsrtContextCore>::HasVirtualTable(ptr=0x0000000907f32000) at vtinfo.h:101
frame #2: 0x00000001003a2525 libChakraCore.dylib`JsrtContext::Is(ref=0x0000000907f32000) at JsrtContextCore.cpp:17
frame #3: 0x00000001002ee3ac libChakraCore.dylib`::JsRelease(ref=0x0000000907f32000, count=0x00007ffeefbfe948) at Jsrt.cpp:682
frame #4: 0x000000010002bb4b rustproxy`chakracore::util::release_reference::hb73d2b9d781d679f(reference=JsRef @ 0x00007ffeefbfe938) at util.rs:34
frame #5: 0x000000010002613a rustproxy`_$LT$chakracore..context..Context$u20$as$u20$core..ops..drop..Drop$GT$::drop::hd59efd86683630b5(self=0x00007ffeefbfeae8) at macros.rs:75
frame #6: 0x0000000100001af5 rustproxy`core::ptr::drop_in_place::h161661c845e43bd1((null)=0x00007ffeefbfeae8) at ptr.rs:59
frame #7: 0x0000000100001a8a rustproxy`core::ptr::drop_in_place::h1072f79302fb8014((null)=0x00007ffeefbfeab0) at ptr.rs:59
frame #8: 0x0000000100002bb4 rustproxy`rustproxy::main::h0a8ee1b9fd89ba26 at main.rs:210
<snip>
This is likely due to the latest ChakraCore, but I thought I'd still bring it up.
This isn't the first segfault I've seen related to the "Virtual Table"
Hi!
According to the Chakracore JSRT docs, runtimes "[...] are rental threaded, so a runtime that is not currently active on a thread (i.e. isn’t running any JavaScript code or responding to any calls from the host) can be used on any thread that doesn’t already have an active runtime on it.".
The way I understand it is that Runtime should implement Send
, so it can be sent between threads. However, trying to send a runtime between threads results in the following errors:
error[E0277]: the trait bound `*mut libc::c_void: std::marker::Send` is not satisfied in `js::Runtime`
= help: within `js::Runtime`, the trait `std::marker::Send` is not implemented for `*mut libc::c_void`
= note: required because it appears within the type `chakracore_sys::JsRuntimeHandle`
= note: required because it appears within the type `js::Runtime`
error[E0277]: the trait bound `std::ops::Fn() + 'static: std::marker::Send` is not satisfied
= help: the trait `std::marker::Send` is not implemented for `std::ops::Fn() + 'static`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::ops::Fn() + 'static>`
= note: required because it appears within the type `std::boxed::Box<std::ops::Fn() + 'static>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::boxed::Box<std::ops::Fn() + 'static>>`
= note: required because it appears within the type `std::boxed::Box<std::boxed::Box<std::ops::Fn() + 'static>>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<std::boxed::Box<std::ops::Fn() + 'static>>>`
= note: required because it appears within the type `js::Runtime`
Having some trouble build on macOS 10.12
I followed the brew install instructions and force linked but perhaps I am just missing something simple
chakracore-sys-2d117dd71bab5fd5/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=CHAKRA_SOURCE
cargo:rerun-if-env-changed=CHAKRA_BUILD
/usr/local/bin/pkg-config
chakracore-sys/build.rs:51: Using default ChakraCore build (version: 1.5.1)
chakracore-sys/build.rs:103: Binaries already built, using existing...
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:79:9: error: unknown type name 'uintptr_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:84:9: error: unknown type name 'uint32_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:85:9: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:932:18: error: unknown type name 'uint32_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:933:17: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:934:15: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:935:19: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:948:14: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:949:15: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:950:15: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:962:14: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:963:15: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:978:14: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:979:14: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:981:15: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:997:18: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:998:18: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:1014:19: error: unknown type name 'int64_t', err: true
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCore.h:248:20: error: unknown type name 'uint16_t', err: true
fatal error: too many errors emitted, stopping now [-ferror-limit=], err: true
--- stderr
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:79:9: error: unknown type name 'uintptr_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:84:9: error: unknown type name 'uint32_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCommon.h:85:9: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:932:18: error: unknown type name 'uint32_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:933:17: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:934:15: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:935:19: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:948:14: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:949:15: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:950:15: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:962:14: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:963:15: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:978:14: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:979:14: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:981:15: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:997:18: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:998:18: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraDebug.h:1014:19: error: unknown type name 'int64_t'
/Users/corbinu/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.2/target/source-1.5.1/lib/Jsrt/ChakraCore.h:248:20: error: unknown type name 'uint16_t'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
thread 'main' panicked at 'Failed to generate binding: ()', src/libcore/result.rs:860
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Hi! Thanks for making this! ❤️
I'm running into the following compilation problem:
/home/saghul/.cargo/registry/src/github.com-1ecc6299db9ec823/chakracore-sys-0.2.3/target/source-1.7.6/lib/Backend/IRBuilderAsmJs.cpp:1063:14: error: comparison of two values with different enumeration types in switch statement ('Js::AsmJsRetType::Which' and 'Js::AsmJsVarType::Which') [-Werror,-Wenum-compare-switch]
case Js::AsmJsVarType::Which::Int64:
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In case it matters, I'm using Rust 1.127.0. Cheers!
How can you load a JavaScript module and then call properties or functions in that module? For example, how would I load C:\Users\camer\ts\TsAst\node_modules\typescript\lib\typescript.js
and then access ts.version
which should return 2.4.2
JsString?
Looks like there may be a breaking change in JsCopyString.
chakra-core/ChakraCore#3433
C:\Users\camer\rs\chakracore-rs\chakracore-sys>cargo test -vv
Fresh bitflags v0.9.1
Fresh cfg-if v0.1.2
Fresh void v1.0.2
Fresh vec_map v0.8.0
Fresh bitflags v0.8.2
Fresh winapi-build v0.1.1
Fresh rustc-serialize v0.3.24
Fresh glob v0.2.11
Fresh unicode-xid v0.0.4
Fresh lazy_static v0.2.8
Fresh strsim v0.6.0
Fresh pkg-config v0.3.9
Fresh utf8-ranges v1.0.0
Fresh unicode-width v0.1.4
Fresh peeking_take_while v0.1.2
Fresh winapi v0.2.8
Fresh log v0.3.8
Fresh regex-syntax v0.4.1
Fresh libc v0.2.29
Fresh unicode-segmentation v1.2.0
Fresh ansi_term v0.9.0
Fresh unreachable v1.0.0
Fresh syntex_pos v0.58.1
Fresh memchr v1.0.1
Fresh thread_local v0.3.4
Fresh aho-corasick v0.6.3
Fresh nom v3.2.0
Fresh kernel32-sys v0.2.2
Fresh regex v0.2.2
Fresh cexpr v0.2.2
Fresh term_size v0.3.0
Fresh atty v0.2.2
Fresh libloading v0.4.0
Fresh term v0.4.6
Fresh env_logger v0.4.3
Fresh textwrap v0.7.0
Fresh clang-sys v0.18.0
Fresh syntex_errors v0.58.1
Fresh clap v2.26.0
Fresh syntex_syntax v0.58.1
Fresh aster v0.41.0
Fresh quasi v0.32.0
Fresh syntex v0.58.1
Fresh quasi_codegen v0.32.0
Fresh bindgen v0.25.5
Compiling chakracore-sys v0.2.2 (file:///C:/Users/camer/rs/chakracore-rs/chakracore-sys)
Running `rustc --crate-name chakracore_sys src\lib.rs --emit=dep-info,link -C debuginfo=2 --test -C metadata=7017975e9837d42b -C extra-filename=-7017975e9837d42b --out-dir C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps -L dependency=C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps --extern libc=C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps\liblibc-275c4a96a27a8a7e.rlib -L native=C:\Users\camer\rs\ChakraCore\Build\VcBuild\bin\x64_release\lib -l dylib=ChakraCore`
error[E0061]: this function takes 5 parameters but 4 parameters were supplied
--> src\lib.rs:70:30
|
70 | js!(JsCopyString(result_as_string,
| ^^^^^^^^^^^^^^^^ expected 5 parameters
|
::: C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\build\chakracore-sys-60176a7cbd0e748e\out/ffi.rs
|
3607 | / pub fn JsCopyString(value: JsValueRef, buffer: *mut libc::c_char,
3608 | | bufferSize: usize, writtenLength: *mut usize,
3609 | | actualLength: *mut usize) -> JsErrorCode;
| |_________________________________________________________________- defined here
error: aborting due to previous error(s)
error: Could not compile `chakracore-sys`.
Caused by:
process didn't exit successfully: `rustc --crate-name chakracore_sys src\lib.rs --emit=dep-info,link -C debuginfo=2 --test -C metadata=7017975e9837d42b -C extra-filename=-7017975e9837d42b --out-dir C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps -L dependency=C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps --extern libc=C:\Users\camer\rs\chakracore-rs\chakracore-sys\target\debug\deps\liblibc-275c4a96a27a8a7e.rlib -L native=C:\Users\camer\rs\ChakraCore\Build\VcBuild\bin\x64_release\lib -l dylib=ChakraCore` (exit code: 101)
C:\Users\camer\rs\chakracore-rs\chakracore-sys>rustup show
Default host: x86_64-pc-windows-msvc
installed toolchains
--------------------
stable-i686-pc-windows-gnu
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)
beta-x86_64-pc-windows-gnu
nightly-x86_64-pc-windows-gnu
nightly-x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.19.0 (0ade33941 2017-07-17)
Quoting the JSRT docs:
When a JavaScript exception occurs during script execution, the containing runtime is put into an exception state. While in an exception state, no code can run and all API calls will fail with the error code JsErrorInExceptionState until the host retrieves and clears the exception using the JsGetAndClearException API.
It would be useful to expose the JsGetAndClearException
API on the context so the runtime can continue to be used after an exception occurred.
EDIT: Reading through the source code I noticed that most places use util::handle_exception
to do just that. I might've run into an edge-case where it doesn't do that. Let me try to narrow down the problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.