mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
29 lines
870 B
Rust
29 lines
870 B
Rust
use std::sync::Arc;
|
|
|
|
use crate::bindings::{apply_binding_table, bind_global_value};
|
|
use oxide_kernel::kernel::{KernelCore, KernelSession};
|
|
use oxide_types::object::JsObject;
|
|
use oxide_types::value::JsValue;
|
|
|
|
pub fn bind_json(core: &Arc<KernelCore>, session: &KernelSession, global: &mut JsObject) {
|
|
let json_ptr = session.builtin_world().json_object.as_ptr() as *mut JsObject;
|
|
let json = unsafe { &mut *json_ptr };
|
|
|
|
apply_binding_table(
|
|
session.builtin_world(),
|
|
json,
|
|
core,
|
|
&[
|
|
("parse", crate::builtins::json::json_parse as *const (), 1),
|
|
("stringify", crate::builtins::json::json_stringify as *const (), 1),
|
|
],
|
|
);
|
|
|
|
bind_global_value(
|
|
core,
|
|
global,
|
|
"JSON",
|
|
JsValue::from_js_object(session.builtin_world().json_object.as_ptr() as *mut JsObject),
|
|
);
|
|
}
|