🚀 Phase 10.11: Everything is Plugin革命完了!

主な変更:
- ConsoleBox/MathBoxプラグイン実装・登録完了
- nyash_box.toml 2ファイルシステム設計(中央レジストリ+個別仕様書)
- 全プラグインにnyash_box.tomlテンプレート追加
- プラグイン優先機能(NYASH_USE_PLUGIN_BUILTINS=1)文書化
- ビルトインBox削除準備(ChatGPT5実装中)
- ネイティブビルドデモ追加(Linux/Windows動作確認済み)

Everything is Box → Everything is Plugin への歴史的転換!
開発20日目にしてビルトインBox全削除という革命的決定。

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-30 01:33:52 +09:00
parent 15e0a1ab34
commit 1b98f85df9
34 changed files with 1410 additions and 62 deletions

View File

@ -0,0 +1,40 @@
[box]
name = "ArrayBox"
version = "1.0.0"
description = "Array operations Box"
author = "Nyash Team"
[provides]
boxes = ["ArrayBox"]
[ArrayBox]
type_id = 11
[ArrayBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[ArrayBox.methods.len]
id = 1
args = []
returns = { type = "i64" }
[ArrayBox.methods.get]
id = 2
args = [ { name = "index", type = "i64" } ]
returns = { type = "box" }
[ArrayBox.methods.push]
id = 3
args = [ { name = "value", type = "box" } ]
returns = { type = "i64" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_array_plugin.dll"
linux = "target/release/libnyash_array_plugin.so"
macos = "target/release/libnyash_array_plugin.dylib"

View File

@ -0,0 +1,16 @@
[package]
name = "nyash-console-plugin"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
once_cell = "1.20"
[profile.release]
lto = true
strip = true
opt-level = "z"

View File

@ -0,0 +1,35 @@
[box]
name = "ConsoleBox"
version = "0.1.0"
description = "Standard output (stdout) printing"
author = "Nyash Team"
[provides]
boxes = ["ConsoleBox"]
[ConsoleBox]
type_id = 5
[ConsoleBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[ConsoleBox.methods.log]
id = 1
args = [ { name = "text", type = "string" } ]
returns = { type = "void" }
[ConsoleBox.methods.println]
id = 2
args = [ { name = "text", type = "string" } ]
returns = { type = "void" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_console_plugin.dll"
linux = "target/release/libnyash_console_plugin.so"
macos = "target/release/libnyash_console_plugin.dylib"

View File

@ -0,0 +1,133 @@
//! Nyash ConsoleBox Plugin - BID-FFI v1
//! Provides simple stdout printing via ConsoleBox
use std::collections::HashMap;
use std::os::raw::c_char;
use std::sync::{Mutex, atomic::{AtomicU32, Ordering}};
// ===== Error Codes (BID-1) =====
const NYB_SUCCESS: i32 = 0;
const NYB_E_SHORT_BUFFER: i32 = -1;
const NYB_E_INVALID_TYPE: i32 = -2;
const NYB_E_INVALID_METHOD: i32 = -3;
const NYB_E_INVALID_ARGS: i32 = -4;
const NYB_E_PLUGIN_ERROR: i32 = -5;
// ===== Method IDs =====
const METHOD_BIRTH: u32 = 0;
const METHOD_LOG: u32 = 1; // log(text)
const METHOD_PRINTLN: u32 = 2; // println(text)
const METHOD_FINI: u32 = u32::MAX;
// ===== Type ID =====
const TYPE_ID_CONSOLE_BOX: u32 = 5; // keep in sync with nyash.toml [box_types]
// ===== Instance management =====
struct ConsoleInstance { /* no state for now */ }
use once_cell::sync::Lazy;
static INSTANCES: Lazy<Mutex<HashMap<u32, ConsoleInstance>>> = Lazy::new(|| {
Mutex::new(HashMap::new())
});
static INSTANCE_COUNTER: AtomicU32 = AtomicU32::new(1);
// ===== TLV helpers (minimal) =====
// TLV layout: [u16 ver=1][u16 argc][entries...]
// Entry: [u16 tag][u16 size][payload...]
fn parse_first_string(args: &[u8]) -> Result<String, ()> {
if args.len() < 4 { return Err(()); }
let argc = u16::from_le_bytes([args[2], args[3]]) as usize;
if argc == 0 { return Err(()); }
let mut p = 4usize;
// first entry
if args.len() < p + 4 { return Err(()); }
let tag = u16::from_le_bytes([args[p], args[p+1]]); p += 2;
let sz = u16::from_le_bytes([args[p], args[p+1]]) as usize; p += 2;
if tag != 6 && tag != 7 { // String or Bytes
return Err(());
}
if args.len() < p + sz { return Err(()); }
let s = String::from_utf8_lossy(&args[p..p+sz]).to_string();
Ok(s)
}
// Write TLV birth result: Handle(tag=8,size=8) with (type_id, instance_id)
unsafe fn write_tlv_birth(type_id: u32, instance_id: u32, out: *mut u8, out_len: *mut usize) -> i32 {
let need = 4 + 4 + 8; // header + entry + payload
if *out_len < need { *out_len = need; return NYB_E_SHORT_BUFFER; }
let mut buf = Vec::with_capacity(need);
// header
buf.extend_from_slice(&1u16.to_le_bytes());
buf.extend_from_slice(&1u16.to_le_bytes());
// entry: Handle
buf.extend_from_slice(&8u16.to_le_bytes());
buf.extend_from_slice(&8u16.to_le_bytes());
buf.extend_from_slice(&type_id.to_le_bytes());
buf.extend_from_slice(&instance_id.to_le_bytes());
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, need);
*out_len = need;
NYB_SUCCESS
}
unsafe fn write_tlv_void(out: *mut u8, out_len: *mut usize) -> i32 {
let need = 4 + 4; // header + entry
if *out_len < need { *out_len = need; return NYB_E_SHORT_BUFFER; }
let mut buf = Vec::with_capacity(need);
buf.extend_from_slice(&1u16.to_le_bytes());
buf.extend_from_slice(&1u16.to_le_bytes());
buf.extend_from_slice(&9u16.to_le_bytes()); // Void
buf.extend_from_slice(&0u16.to_le_bytes());
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, need);
*out_len = need;
NYB_SUCCESS
}
// ===== Entry points =====
#[no_mangle]
pub extern "C" fn nyash_plugin_abi() -> u32 { 1 }
#[no_mangle]
pub extern "C" fn nyash_plugin_init() -> i32 {
eprintln!("[ConsoleBox] Plugin initialized");
NYB_SUCCESS
}
#[no_mangle]
pub extern "C" fn nyash_plugin_invoke(
type_id: u32,
method_id: u32,
instance_id: u32,
args: *const u8,
args_len: usize,
result: *mut u8,
result_len: *mut usize,
) -> i32 {
if type_id != TYPE_ID_CONSOLE_BOX { return NYB_E_INVALID_TYPE; }
unsafe {
match method_id {
METHOD_BIRTH => {
let id = INSTANCE_COUNTER.fetch_add(1, Ordering::Relaxed);
if let Ok(mut m) = INSTANCES.lock() {
m.insert(id, ConsoleInstance{});
} else { return NYB_E_PLUGIN_ERROR; }
return write_tlv_birth(TYPE_ID_CONSOLE_BOX, id, result, result_len);
}
METHOD_FINI => {
if let Ok(mut m) = INSTANCES.lock() { m.remove(&instance_id); }
return NYB_SUCCESS;
}
METHOD_LOG | METHOD_PRINTLN => {
let slice = std::slice::from_raw_parts(args, args_len);
match parse_first_string(slice) {
Ok(s) => {
if method_id == METHOD_LOG { print!("{}", s); } else { println!("{}", s); }
return write_tlv_void(result, result_len);
}
Err(_) => return NYB_E_INVALID_ARGS,
}
}
_ => NYB_E_INVALID_METHOD,
}
}
}

View File

@ -0,0 +1,35 @@
[box]
name = "CounterBox"
version = "1.0.0"
description = "Process-wide counter (singleton)"
author = "Nyash Team"
[provides]
boxes = ["CounterBox"]
[CounterBox]
type_id = 7
[CounterBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[CounterBox.methods.inc]
id = 1
args = []
returns = { type = "i64" }
[CounterBox.methods.get]
id = 2
args = []
returns = { type = "i64" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_counter_plugin.dll"
linux = "target/release/libnyash_counter_plugin.so"
macos = "target/release/libnyash_counter_plugin.dylib"

View File

@ -0,0 +1,35 @@
[box]
name = "FileBox"
version = "1.0.0"
description = "File I/O operations Box"
author = "Nyash Team"
[provides]
boxes = ["FileBox"]
[FileBox]
type_id = 6
[FileBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[FileBox.methods.open]
id = 1
args = [ { name = "path", type = "string" }, { name = "mode", type = "string", default = "r" } ]
returns = { type = "void", error = "string" }
[FileBox.methods.read]
id = 2
args = []
returns = { type = "string" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_filebox_plugin.dll"
linux = "target/release/libnyash_filebox_plugin.so"
macos = "target/release/libnyash_filebox_plugin.dylib"

View File

@ -0,0 +1,35 @@
[box]
name = "IntegerBox"
version = "1.0.0"
description = "Basic integer box (get/set)"
author = "Nyash Team"
[provides]
boxes = ["IntegerBox"]
[IntegerBox]
type_id = 12
[IntegerBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[IntegerBox.methods.get]
id = 1
args = []
returns = { type = "i64" }
[IntegerBox.methods.set]
id = 2
args = [ { name = "value", type = "i64" } ]
returns = { type = "void" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_integer_plugin.dll"
linux = "target/release/libnyash_integer_plugin.so"
macos = "target/release/libnyash_integer_plugin.dylib"

View File

@ -0,0 +1,35 @@
[box]
name = "MapBox"
version = "1.0.0"
description = "Key-value map Box"
author = "Nyash Team"
[provides]
boxes = ["MapBox"]
[MapBox]
type_id = 12
[MapBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[MapBox.methods.size]
id = 1
args = []
returns = { type = "i64" }
[MapBox.methods.get]
id = 2
args = [ { name = "key", type = "i64" } ]
returns = { type = "box" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_map_plugin.dll"
linux = "target/release/libnyash_map_plugin.so"
macos = "target/release/libnyash_map_plugin.dylib"

View File

@ -0,0 +1,16 @@
[package]
name = "nyash-math-plugin"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
once_cell = "1.20"
[profile.release]
lto = true
strip = true
opt-level = "z"

View File

@ -0,0 +1,56 @@
[box]
name = "Nyash Math/Time Plugin"
version = "0.1.0"
description = "Minimal MathBox/TimeBox"
author = "Nyash Team"
[provides]
boxes = ["MathBox", "TimeBox"]
[MathBox]
type_id = 50
[MathBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[MathBox.methods.sqrt]
id = 1
args = [ { name = "x", type = "i64" } ]
returns = { type = "f64" }
[MathBox.methods.sin]
id = 2
args = [ { name = "x", type = "i64" } ]
returns = { type = "f64" }
[MathBox.methods.cos]
id = 3
args = [ { name = "x", type = "i64" } ]
returns = { type = "f64" }
[MathBox.methods.round]
id = 4
args = [ { name = "x", type = "i64" } ]
returns = { type = "f64" }
[TimeBox]
type_id = 51
[TimeBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[TimeBox.methods.now]
id = 1
args = []
returns = { type = "i64" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_math_plugin.dll"
linux = "target/release/libnyash_math_plugin.so"
macos = "target/release/libnyash_math_plugin.dylib"

View File

@ -0,0 +1,155 @@
//! Nyash Math/Time Plugin - BID-FFI v1 (minimal)
//! MathBox: sqrt(i64) -> i64
//! TimeBox: now() -> i64 (unix seconds)
use std::collections::HashMap;
use std::sync::{Mutex, atomic::{AtomicU32, Ordering}};
// Error codes
const OK: i32 = 0;
const E_SHORT: i32 = -1;
const E_TYPE: i32 = -2;
const E_METHOD: i32 = -3;
const E_ARGS: i32 = -4;
const E_FAIL: i32 = -5;
// Type IDs (align with nyash.toml [box_types])
const TID_MATH: u32 = 50;
const TID_TIME: u32 = 51;
// Methods
const M_BIRTH: u32 = 0;
const M_FINI: u32 = u32::MAX;
// MathBox
const M_SQRT: u32 = 1;
const M_SIN: u32 = 2;
const M_COS: u32 = 3;
const M_ROUND: u32 = 4;
// TimeBox
const T_NOW: u32 = 1;
use once_cell::sync::Lazy;
#[derive(Default)]
struct Empty;
static MATH_INST: Lazy<Mutex<HashMap<u32, Empty>>> = Lazy::new(|| Mutex::new(HashMap::new()));
static TIME_INST: Lazy<Mutex<HashMap<u32, Empty>>> = Lazy::new(|| Mutex::new(HashMap::new()));
static ID: AtomicU32 = AtomicU32::new(1);
// TLV helpers
mod tlv {
pub fn header(argc: u16) -> Vec<u8> { let mut b=Vec::with_capacity(4); b.extend_from_slice(&1u16.to_le_bytes()); b.extend_from_slice(&argc.to_le_bytes()); b }
pub fn encode_handle(buf: &mut Vec<u8>, t: u32, i: u32) { buf.push(8); buf.push(0); buf.push(8); buf.push(0); buf.extend_from_slice(&t.to_le_bytes()); buf.extend_from_slice(&i.to_le_bytes()); }
pub fn encode_i64(buf: &mut Vec<u8>, v: i64) { buf.push(3); buf.push(0); buf.push(8); buf.push(0); buf.extend_from_slice(&v.to_le_bytes()); }
pub fn encode_void(buf: &mut Vec<u8>) { buf.push(9); buf.push(0); buf.push(0); buf.push(0); }
pub fn decode_first(args:&[u8]) -> Option<(u16,u16,usize)> { if args.len()<8 {return None;} let argc=u16::from_le_bytes([args[2],args[3]]); if argc==0{return None;} let tag=u16::from_le_bytes([args[4],args[5]]); let sz=u16::from_le_bytes([args[6],args[7]]); Some((tag,sz,8)) }
}
#[no_mangle]
pub extern "C" fn nyash_plugin_abi() -> u32 { 1 }
#[no_mangle]
pub extern "C" fn nyash_plugin_init() -> i32 { OK }
#[no_mangle]
pub extern "C" fn nyash_plugin_invoke(
type_id: u32,
method_id: u32,
instance_id: u32,
args: *const u8,
args_len: usize,
result: *mut u8,
result_len: *mut usize,
) -> i32 {
unsafe {
match (type_id, method_id) {
(TID_MATH, M_BIRTH) => birth(TID_MATH, &MATH_INST, result, result_len),
(TID_TIME, M_BIRTH) => birth(TID_TIME, &TIME_INST, result, result_len),
(TID_MATH, M_FINI) => fini(&MATH_INST, instance_id),
(TID_TIME, M_FINI) => fini(&TIME_INST, instance_id),
(TID_MATH, M_SQRT) => sqrt_call(args, args_len, result, result_len),
(TID_MATH, M_SIN) => trig_call(args, args_len, result, result_len, true),
(TID_MATH, M_COS) => trig_call(args, args_len, result, result_len, false),
(TID_MATH, M_ROUND) => round_call(args, args_len, result, result_len),
(TID_TIME, T_NOW) => now_call(result, result_len),
(TID_MATH, _) | (TID_TIME, _) => E_METHOD,
_ => E_TYPE,
}
}
}
unsafe fn birth<T>(tid: u32, map: &Lazy<Mutex<HashMap<u32,T>>>, out: *mut u8, out_len: *mut usize) -> i32 where T: Default {
let need = 4+4+8; if *out_len < need { *out_len = need; return E_SHORT; }
let id = ID.fetch_add(1, Ordering::Relaxed);
if let Ok(mut m) = map.lock() { m.insert(id, T::default()); } else { return E_FAIL; }
let mut buf = tlv::header(1); tlv::encode_handle(&mut buf, tid, id);
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, buf.len()); *out_len = buf.len(); OK
}
unsafe fn fini<T>(map: &Lazy<Mutex<HashMap<u32,T>>>, instance_id: u32) -> i32 {
if let Ok(mut m) = map.lock() { m.remove(&instance_id); OK } else { E_FAIL }
}
unsafe fn sqrt_call(args: *const u8, args_len: usize, out: *mut u8, out_len: *mut usize) -> i32 {
if args_len < 8 { return E_ARGS; }
let a = std::slice::from_raw_parts(args, args_len);
if let Some((tag, sz, p)) = tlv::decode_first(a) {
if tag == 3 && sz == 8 && a.len() >= p+8 {
let mut b=[0u8;8]; b.copy_from_slice(&a[p..p+8]);
let x = i64::from_le_bytes(b) as f64;
let r = x.sqrt();
let need = 4+4+8; if *out_len < need { *out_len = need; return E_SHORT; }
let mut buf = tlv::header(1);
// encode f64 (tag=5)
buf.push(5); buf.push(0); buf.push(8); buf.push(0); buf.extend_from_slice(&r.to_le_bytes());
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, buf.len()); *out_len = buf.len();
return OK;
}
}
E_ARGS
}
unsafe fn now_call(out: *mut u8, out_len: *mut usize) -> i32 {
let ts = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs() as i64).unwrap_or(0);
let need = 4+4+8; if *out_len < need { *out_len = need; return E_SHORT; }
let mut buf = tlv::header(1); tlv::encode_i64(&mut buf, ts);
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, buf.len()); *out_len = buf.len();
OK
}
unsafe fn trig_call(args: *const u8, args_len: usize, out: *mut u8, out_len: *mut usize, is_sin: bool) -> i32 {
if args_len < 8 { return E_ARGS; }
let a = std::slice::from_raw_parts(args, args_len);
if let Some((tag, sz, p)) = tlv::decode_first(a) {
if tag == 3 && sz == 8 && a.len() >= p+8 {
let mut b=[0u8;8]; b.copy_from_slice(&a[p..p+8]);
let x = i64::from_le_bytes(b) as f64;
let r = if is_sin { x.sin() } else { x.cos() };
let need = 4+4+8; if *out_len < need { *out_len = need; return E_SHORT; }
let mut buf = tlv::header(1);
// encode f64 (tag=5)
buf.push(5); buf.push(0); buf.push(8); buf.push(0); buf.extend_from_slice(&r.to_le_bytes());
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, buf.len()); *out_len = buf.len();
return OK;
}
}
E_ARGS
}
unsafe fn round_call(args: *const u8, args_len: usize, out: *mut u8, out_len: *mut usize) -> i32 {
if args_len < 8 { return E_ARGS; }
let a = std::slice::from_raw_parts(args, args_len);
if let Some((tag, sz, p)) = tlv::decode_first(a) {
if tag == 3 && sz == 8 && a.len() >= p+8 {
let mut b=[0u8;8]; b.copy_from_slice(&a[p..p+8]);
let x = i64::from_le_bytes(b) as f64;
let r = x.round();
let need = 4+4+8; if *out_len < need { *out_len = need; return E_SHORT; }
let mut buf = tlv::header(1);
// encode f64 (tag=5)
buf.push(5); buf.push(0); buf.push(8); buf.push(0); buf.extend_from_slice(&r.to_le_bytes());
std::ptr::copy_nonoverlapping(buf.as_ptr(), out, buf.len()); *out_len = buf.len();
return OK;
}
}
E_ARGS
}

View File

@ -0,0 +1,160 @@
[box]
name = "Nyash Net Plugin"
version = "0.2.0"
description = "HTTP/TCP networking boxes"
author = "Nyash Team"
[provides]
boxes = [
"HttpServerBox", "HttpClientBox", "HttpResponseBox", "HttpRequestBox",
"SocketServerBox", "SocketClientBox", "SocketConnBox"
]
[HttpServerBox]
type_id = 20
[HttpServerBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[HttpServerBox.methods.start]
id = 1
args = [ { name = "port", type = "i64" } ]
returns = { type = "void" }
returns_result = true
[HttpServerBox.methods.stop]
id = 2
args = []
returns = { type = "void" }
returns_result = true
[HttpServerBox.methods.accept]
id = 3
args = []
returns = { type = "box" }
returns_result = true
[HttpClientBox]
type_id = 23
[HttpClientBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[HttpClientBox.methods.get]
id = 1
args = [ { name = "url", type = "string" } ]
returns = { type = "box" }
returns_result = true
[HttpClientBox.methods.post]
id = 2
args = [ { name = "url", type = "string" }, { name = "body", type = "string" } ]
returns = { type = "box" }
returns_result = true
[HttpResponseBox]
type_id = 22
[HttpResponseBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[HttpResponseBox.methods.setStatus]
id = 1
args = [ { name = "status", type = "i64" } ]
returns = { type = "void" }
[HttpResponseBox.methods.setHeader]
id = 2
args = [ { name = "key", type = "string" }, { name = "value", type = "string" } ]
returns = { type = "void" }
[HttpResponseBox.methods.write]
id = 3
args = [ { name = "body", type = "string" } ]
returns = { type = "void" }
[HttpResponseBox.methods.readBody]
id = 4
args = []
returns = { type = "string" }
[HttpResponseBox.methods.getStatus]
id = 5
args = []
returns = { type = "i64" }
[HttpResponseBox.methods.getHeader]
id = 6
args = [ { name = "key", type = "string" } ]
returns = { type = "string" }
[HttpRequestBox]
type_id = 21
[HttpRequestBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[HttpRequestBox.methods.path]
id = 1
args = []
returns = { type = "string" }
[HttpRequestBox.methods.readBody]
id = 2
args = []
returns = { type = "string" }
[HttpRequestBox.methods.respond]
id = 3
args = [ { name = "resp", type = "box" } ]
returns = { type = "void" }
[SocketServerBox]
type_id = 30
[SocketServerBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[SocketServerBox.methods.bind]
id = 1
args = [ { name = "port", type = "i64" } ]
returns = { type = "void" }
[SocketServerBox.methods.accept]
id = 2
args = []
returns = { type = "box" }
[SocketClientBox]
type_id = 32
[SocketClientBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[SocketClientBox.methods.connect]
id = 1
args = [ { name = "host", type = "string" }, { name = "port", type = "i64" } ]
returns = { type = "void" }
[SocketClientBox.methods.send]
id = 2
args = [ { name = "data", type = "string" } ]
returns = { type = "void" }
[SocketClientBox.methods.receive]
id = 3
args = []
returns = { type = "string" }
[SocketClientBox.methods.close]
id = 4
args = []
returns = { type = "void" }
[SocketConnBox]
type_id = 31
[SocketConnBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[SocketConnBox.methods.send]
id = 1
args = [ { name = "data", type = "string" } ]
returns = { type = "void" }
[SocketConnBox.methods.recv]
id = 2
args = []
returns = { type = "string" }
[SocketConnBox.methods.close]
id = 3
args = []
returns = { type = "void" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_net_plugin.dll"
linux = "target/release/libnyash_net_plugin.so"
macos = "target/release/libnyash_net_plugin.dylib"

View File

@ -0,0 +1,62 @@
[box]
name = "Nyash Python Plugin"
version = "0.1.0"
description = "CPython runtime and object interop"
author = "Nyash Team"
[provides]
boxes = ["PyRuntimeBox", "PyObjectBox"]
[PyRuntimeBox]
type_id = 40
[PyRuntimeBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[PyRuntimeBox.methods.eval]
id = 1
args = [ { name = "code", type = "string" } ]
returns = { type = "box" }
[PyRuntimeBox.methods.import]
id = 2
args = [ { name = "name", type = "string" } ]
returns = { type = "box" }
[PyObjectBox]
type_id = 41
[PyObjectBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[PyObjectBox.methods.getattr]
id = 1
args = [ { name = "name", type = "string" } ]
returns = { type = "box" }
[PyObjectBox.methods.call]
id = 2
args = [ { name = "args", type = "varargs" } ]
returns = { type = "box" }
[PyObjectBox.methods.str]
id = 3
args = []
returns = { type = "string" }
[PyObjectBox.methods.callKw]
id = 5
args = [ { name = "kwargs", type = "dict" } ]
returns = { type = "box" }
[implementation]
ffi_version = 1
thread_safe = false
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_python_plugin.dll"
linux = "target/release/libnyash_python_plugin.so"
macos = "target/release/libnyash_python_plugin.dylib"

View File

@ -0,0 +1,30 @@
[box]
name = "StringBox"
version = "1.0.0"
description = "String operations Box"
author = "Nyash Team"
[provides]
boxes = ["StringBox"]
[StringBox]
type_id = 10
[StringBox.lifecycle]
birth = { id = 0 }
fini = { id = 4294967295 }
[StringBox.methods.length]
id = 1
args = []
returns = { type = "i64" }
[implementation]
ffi_version = 1
thread_safe = true
[artifacts]
windows = "target/x86_64-pc-windows-msvc/release/nyash_string_plugin.dll"
linux = "target/release/libnyash_string_plugin.so"
macos = "target/release/libnyash_string_plugin.dylib"