Created
January 23, 2016 19:09
-
-
Save ngsankha/3ad475c9f8a46862266e to your computer and use it in GitHub Desktop.
ChakraCore embedding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::mem; | |
struct JsRuntimeHandle; | |
struct JsThreadServiceCallback; | |
struct JsRef; | |
type JsContextRef = JsRef; | |
type JsValueRef = JsRef; | |
type JsErrorCode = usize; | |
enum JsRuntimeAttributes { | |
JsRuntimeAttributeNone | |
} | |
#[link(name = "ChakraCore")] | |
extern { | |
fn JsCreateRuntime(attributes: JsRuntimeAttributes, threadService: Option<JsThreadServiceCallback>, runtime: *mut JsRuntimeHandle) -> JsErrorCode; | |
fn JsCreateContext(runtime: JsRuntimeHandle, newContext: *mut JsContextRef) -> JsErrorCode; | |
} | |
fn main() { | |
unsafe { | |
let mut rt: JsRuntimeHandle = mem::transmute(()); | |
let mut cx: JsContextRef = mem::transmute(()); | |
JsCreateRuntime(JsRuntimeAttributes::JsRuntimeAttributeNone, None, &mut rt); | |
println!("{}", JsCreateContext(rt, &mut cx)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment