Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Checklist (Direct/Host side) #16

Open
16 of 21 tasks
cpetig opened this issue Mar 17, 2024 · 1 comment
Open
16 of 21 tasks

Resource Checklist (Direct/Host side) #16

cpetig opened this issue Mar 17, 2024 · 1 comment

Comments

@cpetig
Copy link
Owner

cpetig commented Mar 17, 2024

Header File

  • guest imported classes should include a definition header
  • g.i. resource returning functions should return R::Owned
  • g.i. res. consuming functions should received R::Owned
  • exported res. shouldn't include a header
  • g.e. function consuming should use && args

Code:

  • g.i. dtor should become X00X5Bresource_dropX5D
    • Contents:
  auto ptr = T::remove_resource(idx);
  assert(ptr.has_value());
  T::Dtor(*ptr);
  • g.i. ctor should call new and
    • return result0.release()->get_handle();
  • g.i. borrowing funcs should (**T::lookup_resource(arg0))
    • stretch goal: With assertion that lookup succeeded
  • g.i. consuming funs should
  auto objptr = T::remove_resource(arg0);
  assert(objptr.has_value());
  func(T::Owned(*objptr));
  • Missing functions for guest export:
extern "C" int32_t X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_newX5Dr(uint8_t* rep) {
  return exports::foo::foo::resources::R::store_resource(std::move(rep));
}
extern "C" void X5BexportX5DfooX3AfooX2FresourcesX00X5Bresource_dropX5Dr(int32_t idx) {
  exports::foo::foo::resources::R::remove_resource(idx);
}
  • g.e. Dtor should become a normal dtor with if (this->rep) X5BdtorX5Dr(this->rep);
  • g.e. ctor should this->index = ret; this->rep = *lookup_resource(ret);
  • g.e. methods should call get_rep() instead of get_handle()
  • g.e. res. returning funcs should go via wit::ResourceExportBase
  • g.e. res. borrowing funcs should add .get() and use get_rep()
  • g.e. res. consuming funcs should receive &&
  • g.e. res. consuming funcs should use
  auto rep = o.take_rep();
  R::remove_resource(o.get_handle());
  consume(rep);
  • create ResourceExportBase based move ctors
@cpetig
Copy link
Owner Author

cpetig commented Mar 29, 2024

  • The generated code should define ResourceTable::resources, not ResourceExportBase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant