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

feat(import) Add Imports.Namespace to set the current import namespace #29

Merged
merged 2 commits into from
Jun 4, 2019

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Jun 4, 2019

Fix #25.

Basically, this patch allows to define imported function in any
namepace. The Imports.Namespace sets the current namespce for the
next defined imported functions:

wasm.NewImports().Namespace("ns").Append("f", f, C.f)

By default, the namespace is env, so both statements are identical:

wasm.NewImports().Namespace("env").Append(…)
wasm.NewImports().Append(…)

To register imported functions in different namespaces, one writes:

wasm.NewImports().Namespace("ns1").Append(…).Append(…).Namespace("ns2").Append(…).Append(…)…

Hywan added 2 commits June 4, 2019 13:37
…ace.

Basically, this patch allows to define imported function in any
namepace. The `Imports.Namespace` sets the current namespce for the
next defined imported functions:

```go
wasm.NewImports().Namespace("ns").Append("f", f, C.f)
```

By default, the namespace is `env`, so both statements are identical:

```go
wasm.NewImports().Namespace("env").Append(…)
wasm.NewImports().Append(…)
```

To register imported functions in different namespaces, one writes:

```go
wasm.NewImports().Namespace("ns1").Append(…).Append(…).Namespace("ns2").Append(…).Append(…)…
```
@Hywan Hywan added 🎉 enhancement New feature or request 📦 component-extension About the Go extension 🧪 tests I love tests labels Jun 4, 2019
@Hywan Hywan self-assigned this Jun 4, 2019
@Hywan
Copy link
Contributor Author

Hywan commented Jun 4, 2019

bors r+

bors bot added a commit that referenced this pull request Jun 4, 2019
29: feat(import) Add `Imports.Namespace` to set the current import namespace r=Hywan a=Hywan

Fix #25.

Basically, this patch allows to define imported function in any
namepace. The `Imports.Namespace` sets the current namespce for the
next defined imported functions:

```go
wasm.NewImports().Namespace("ns").Append("f", f, C.f)
```

By default, the namespace is `env`, so both statements are identical:

```go
wasm.NewImports().Namespace("env").Append(…)
wasm.NewImports().Append(…)
```

To register imported functions in different namespaces, one writes:

```go
wasm.NewImports().Namespace("ns1").Append(…).Append(…).Namespace("ns2").Append(…).Append(…)…
```

Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
@bors
Copy link
Contributor

bors bot commented Jun 4, 2019

@bors bors bot merged commit 0f7e593 into wasmerio:master Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 component-extension About the Go extension 🎉 enhancement New feature or request 🧪 tests I love tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure the namespace of the imports functions
1 participant