public: publish selfhost snapshot to public repo (SSOT using + AST merge + JSON VM fixes)
- SSOT using profiles (aliases/packages via nyash.toml), AST prelude merge - Parser/member guards; Builder pin/PHI and instance→function rewrite (dev on) - VM refactors (handlers split) and JSON roundtrip/nested stabilization - CURRENT_TASK.md updated with scope and acceptance criteria Notes: dev-only guards remain togglable via env; no default behavior changes for prod.
This commit is contained in:
@ -29,4 +29,4 @@ pub const JN_FINI: u32 = u32::MAX;
|
||||
|
||||
// Type IDs (for Handle TLV)
|
||||
pub const T_JSON_DOC: u32 = 70;
|
||||
pub const T_JSON_NODE: u32 = 71;
|
||||
pub const T_JSON_NODE: u32 = 71;
|
||||
|
||||
@ -2,12 +2,14 @@
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::ffi;
|
||||
use crate::provider::{provider_kind, provider_parse, DocInst, NodeRep, ProviderKind, DOCS, NODES, NEXT_ID};
|
||||
use crate::provider::{
|
||||
provider_kind, provider_parse, DocInst, NodeRep, ProviderKind, DOCS, NEXT_ID, NODES,
|
||||
};
|
||||
use crate::tlv_helpers::*;
|
||||
use serde_json::Value;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::os::raw::{c_char, c_void};
|
||||
use std::sync::{Arc, atomic::Ordering};
|
||||
use std::sync::{atomic::Ordering, Arc};
|
||||
|
||||
pub extern "C" fn jsondoc_resolve(name: *const c_char) -> u32 {
|
||||
if name.is_null() {
|
||||
@ -68,8 +70,11 @@ pub extern "C" fn jsondoc_invoke_id(
|
||||
ProviderKind::Yyjson => {
|
||||
let c = CString::new(text.as_bytes()).unwrap_or_default();
|
||||
let mut ec: i32 = -1;
|
||||
let p =
|
||||
ffi::nyjson_parse_doc(c.as_ptr(), text.len(), &mut ec as *mut i32);
|
||||
let p = ffi::nyjson_parse_doc(
|
||||
c.as_ptr(),
|
||||
text.len(),
|
||||
&mut ec as *mut i32,
|
||||
);
|
||||
if p.is_null() {
|
||||
doc.root = None;
|
||||
doc.doc_ptr = None;
|
||||
@ -160,4 +165,4 @@ pub extern "C" fn jsondoc_invoke_id(
|
||||
_ => E_METHOD,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@ use std::os::raw::{c_char, c_void};
|
||||
// External C functions for yyjson provider
|
||||
extern "C" {
|
||||
pub fn nyash_json_shim_parse(text: *const c_char, len: usize) -> i32;
|
||||
pub fn nyjson_parse_doc(text: *const c_char, len: usize, out_err_code: *mut i32) -> *mut c_void;
|
||||
pub fn nyjson_parse_doc(text: *const c_char, len: usize, out_err_code: *mut i32)
|
||||
-> *mut c_void;
|
||||
pub fn nyjson_doc_free(doc: *mut c_void);
|
||||
pub fn nyjson_doc_root(doc: *mut c_void) -> *mut c_void;
|
||||
pub fn nyjson_is_null(v: *mut c_void) -> i32;
|
||||
@ -22,4 +23,4 @@ extern "C" {
|
||||
pub fn nyjson_arr_get_val(v: *mut c_void, idx: usize) -> *mut c_void;
|
||||
pub fn nyjson_obj_size_val(v: *mut c_void) -> usize;
|
||||
pub fn nyjson_obj_get_key(v: *mut c_void, key: *const c_char) -> *mut c_void;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,9 +26,7 @@ pub struct NyashTypeBoxFfi {
|
||||
pub struct_size: u16,
|
||||
pub name: *const c_char,
|
||||
pub resolve: Option<extern "C" fn(*const c_char) -> u32>,
|
||||
pub invoke_id: Option<
|
||||
extern "C" fn(u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32,
|
||||
>,
|
||||
pub invoke_id: Option<extern "C" fn(u32, u32, *const u8, usize, *mut u8, *mut usize) -> i32>,
|
||||
pub capabilities: u32,
|
||||
}
|
||||
|
||||
@ -38,7 +36,7 @@ unsafe impl Send for NyashTypeBoxFfi {}
|
||||
// Export JsonDocBox
|
||||
#[no_mangle]
|
||||
pub static nyash_typebox_JsonDocBox: NyashTypeBoxFfi = NyashTypeBoxFfi {
|
||||
abi_tag: 0x54594258, // 'TYBX'
|
||||
abi_tag: 0x54594258, // 'TYBX'
|
||||
version: 1,
|
||||
struct_size: std::mem::size_of::<NyashTypeBoxFfi>() as u16,
|
||||
name: b"JsonDocBox\0".as_ptr() as *const c_char,
|
||||
@ -50,7 +48,7 @@ pub static nyash_typebox_JsonDocBox: NyashTypeBoxFfi = NyashTypeBoxFfi {
|
||||
// Export JsonNodeBox
|
||||
#[no_mangle]
|
||||
pub static nyash_typebox_JsonNodeBox: NyashTypeBoxFfi = NyashTypeBoxFfi {
|
||||
abi_tag: 0x54594258, // 'TYBX'
|
||||
abi_tag: 0x54594258, // 'TYBX'
|
||||
version: 1,
|
||||
struct_size: std::mem::size_of::<NyashTypeBoxFfi>() as u16,
|
||||
name: b"JsonNodeBox\0".as_ptr() as *const c_char,
|
||||
@ -70,14 +68,14 @@ pub static nyash_plugin_version: &[u8] = b"0.1.0\0";
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nyash_plugin_init() -> i32 {
|
||||
// Currently no initialization needed
|
||||
0 // OK
|
||||
0 // OK
|
||||
}
|
||||
|
||||
// Plugin cleanup (if needed in future)
|
||||
#[no_mangle]
|
||||
pub extern "C" fn nyash_plugin_fini() -> i32 {
|
||||
// Currently no cleanup needed
|
||||
0 // OK
|
||||
0 // OK
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -108,4 +106,4 @@ mod tests {
|
||||
assert_eq!(nyash_typebox_JsonDocBox.struct_size, expected_size);
|
||||
assert_eq!(nyash_typebox_JsonNodeBox.struct_size, expected_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,12 +2,12 @@
|
||||
|
||||
use crate::constants::*;
|
||||
use crate::ffi::*;
|
||||
use crate::provider::{provider_kind, NodeRep, ProviderKind, NODES, NEXT_ID};
|
||||
use crate::provider::{provider_kind, NodeRep, ProviderKind, NEXT_ID, NODES};
|
||||
use crate::tlv_helpers::*;
|
||||
use serde_json::Value;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::os::raw::{c_char, c_void};
|
||||
use std::sync::{Arc, atomic::Ordering};
|
||||
use std::sync::{atomic::Ordering, Arc};
|
||||
|
||||
pub extern "C" fn jsonnode_resolve(name: *const c_char) -> u32 {
|
||||
if name.is_null() {
|
||||
@ -372,4 +372,4 @@ pub extern "C" fn jsonnode_invoke_id(
|
||||
_ => E_METHOD,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ pub enum NodeRep {
|
||||
|
||||
// Document instance
|
||||
pub struct DocInst {
|
||||
pub root: Option<Arc<Value>>, // Serde provider
|
||||
pub doc_ptr: Option<usize>, // Yyjson provider (opaque pointer value)
|
||||
pub root: Option<Arc<Value>>, // Serde provider
|
||||
pub doc_ptr: Option<usize>, // Yyjson provider (opaque pointer value)
|
||||
pub last_err: Option<String>,
|
||||
}
|
||||
|
||||
@ -66,4 +66,4 @@ pub fn provider_parse(text: &str) -> Result<Value, String> {
|
||||
serde_json::from_str::<Value>(text).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,4 +126,4 @@ pub fn read_arg_i64(args: *const u8, args_len: usize, n: usize) -> Option<i64> {
|
||||
off += 4 + size;
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user