Skip to content

Commit 263eac9

Browse files
committed
feat(hotload): Hotloading implementation
1 parent 08e3a47 commit 263eac9

15 files changed

Lines changed: 4648 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ runtime = ["ext-php-rs-bindgen/runtime"]
6161
static = ["ext-php-rs-bindgen/static"]
6262

6363
[workspace]
64-
members = ["crates/macros", "crates/cli", "crates/php-build", "tests"]
64+
members = ["crates/macros", "crates/cli", "crates/php-build", "crates/hotload", "tests"]
6565

6666
[package.metadata.docs.rs]
6767
rustdoc-args = ["--cfg", "docs"]

crates/hotload/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "ext-php-rs-hotload"
3+
description = "Hot-load Rust code into PHP at runtime"
4+
version = "0.1.0"
5+
edition = "2021"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/extphprs/ext-php-rs"
8+
9+
[lib]
10+
crate-type = ["cdylib"]
11+
12+
[dependencies]
13+
ext-php-rs = { path = "../.." }
14+
libloading = "0.8"
15+
sha2 = "0.10"
16+
hex = "0.4"
17+
parking_lot = "0.12"
18+
tree-sitter = "0.23"
19+
tree-sitter-rust = "0.23"
20+
fs2 = "0.4"

crates/hotload/src/abi.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! Hotload ABI - shared interface between host and loaded modules
2+
//!
3+
//! Modules must export these symbols:
4+
//! - `hotload_info() -> *const PluginInfo`
5+
//! - `hotload_init()`
6+
7+
use std::ffi::c_char;
8+
9+
/// Plugin metadata
10+
#[repr(C)]
11+
pub struct PluginInfo {
12+
/// Plugin name (null-terminated)
13+
pub name: *const c_char,
14+
/// Plugin version (null-terminated)
15+
pub version: *const c_char,
16+
/// Number of functions exported
17+
pub num_functions: u32,
18+
/// Array of function descriptors
19+
pub functions: *const FunctionInfo,
20+
}
21+
22+
/// Function metadata (just the name for cleanup purposes)
23+
#[repr(C)]
24+
pub struct FunctionInfo {
25+
/// Function name as it appears in PHP (null-terminated)
26+
pub name: *const c_char,
27+
}
28+
29+
/// Type for the plugin info function
30+
pub type PluginInfoFn = unsafe extern "C" fn() -> *const PluginInfo;
31+
32+
/// Type for the plugin init function (called after loading)
33+
pub type PluginInitFn = unsafe extern "C" fn();
34+
35+
/// ABI version for compatibility checking
36+
#[allow(dead_code)]
37+
pub const ABI_VERSION: u32 = 1;

0 commit comments

Comments
 (0)