WebAssembly / wasm-c-api

Wasm C API prototype
Apache License 2.0
550 stars 77 forks source link

What are Foreigns good for? #67

Closed jakobkummerow closed 5 years ago

jakobkummerow commented 5 years ago

The current definition of Foreign seems very minimal:

class Foreign : public Ref {
public:
  Foreign() = delete;
  ~Foreign();

  static auto make(Store*) -> own<Foreign*>;
  auto copy() const -> own<Foreign*>;
};

And there are no examples using them. What are they useful for? Are they supposed to wrap a value of some sort? Are they a work in progress and will be expanded later?

rossberg commented 5 years ago

This provides a way to create host references. You can attach data by setting host info on the reference.

jakobkummerow commented 5 years ago

Ah, I had overlooked the inherited set_host_info path. Still, it would be nice to have an example using Foreign :-)