Skip to content

Commit

Permalink
fix: resource connections (#224)
Browse files Browse the repository at this point in the history
* fix: resource connections

* fixup

* inline exports and imports population
  • Loading branch information
guybedford authored Oct 23, 2023
1 parent c47e492 commit fa1526d
Show file tree
Hide file tree
Showing 3 changed files with 290 additions and 144 deletions.
7 changes: 5 additions & 2 deletions crates/js-component-bindgen/src/esm_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl EsmBindgen {
/// first segment
/// arbitrary nesting of interfaces is supported in order to support virtual WASI interfaces
/// only two-level nesting supports serialization into imports currently
pub fn add_import_binding(&mut self, path: &[String], func_name: String) {
pub fn add_import_binding(&mut self, path: &[String], binding_name: String) {
let mut iface = &mut self.imports;
for i in 0..path.len() - 1 {
if !iface.contains_key(&path[i]) {
Expand All @@ -39,7 +39,10 @@ impl EsmBindgen {
),
};
}
iface.insert(path[path.len() - 1].to_string(), Binding::Local(func_name));
iface.insert(
path[path.len() - 1].to_string(),
Binding::Local(binding_name),
);
}

/// add an exported function binding, optionally on an interface id or kebab name
Expand Down
3 changes: 3 additions & 0 deletions crates/js-component-bindgen/src/function_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum ErrHandling {
ResultCatchHandler,
}

#[derive(Clone, Debug)]
pub enum ResourceData {
Host {
id: u32,
Expand Down Expand Up @@ -52,6 +53,8 @@ pub enum ResourceData {
/// In the case of an imported resource tables, in place of "rep" we just store
/// the direct JS object being referenced, since in JS the object is its own handle.
///
///
#[derive(Clone, Debug)]
pub struct ResourceTable {
pub imported: bool,
pub data: ResourceData,
Expand Down
Loading

0 comments on commit fa1526d

Please sign in to comment.