forked from bytecodealliance/wit-bindgen
-
Couldn't load subscription status.
- Fork 3
Open
Description
Header File
- functions with owned arguments should use
- 👍
&&in guest imported functions -
R::Ownedin guest exported func.
- 👍
- functions returning resources should return
R::Ownedin guest exported func.
Code:
- 👍 functions returning resources (g.i.) need to add
wit::ResourceImportBase{ret}
has to happen before Return is called - functions accepting a reference_wrapper need to unwrap the args
.get() - functions consuming resource (g.i.) should use
&&on args and.into_handle() - 👍 constructors (g.e.) should use
return result0.release()->into_handle(); - functions returning resources (g.e.) should
.release()the unique_ptr - functions borrowing/owning res. (g.e.) should use
int8_t* arg0(larger issue) - functions borrowing args (g.e.) should create a cref:
std::cref(*(T const*)arg0) - functions consuming res. (g.e.) should deregister them:
auto obj = T::Owned((T*)arg0);
obj->into_handle();
- and move the args
func(std::move(obj)) - create a construction forwarder:
T(wit::ResourceImportBase&&b) : wit::ResourceImportBase(std::move(b)) {}
User Class Templates
- should define the Owned type:
struct Deleter {
void operator()(R* ptr) const { R::Dtor(ptr); }
};
typedef std::unique_ptr<R, R::Deleter> Owned;
- New should return an Owned
static Owned New(uint32_t a) { return Owned(new R(a)); }
Metadata
Metadata
Assignees
Labels
No labels