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

js,parser: Allow declaring methods on JS interfaces for easier FFI #12447

Merged
merged 1 commit into from
Nov 13, 2021
Merged

Conversation

playXE
Copy link
Contributor

@playXE playXE commented Nov 13, 2021

This PR allows to declare methods on JS interfaces, this allows to create high-level wrappers without wrapping interfaces in another V struct. For example:

pub interface JS.CanvasRenderingContext2D {
	setLineDash(JS.Array)
}

pub fn (ctx JS.CanvasRenderingContext2D) set_line_dash(arr []f64) {
	tmp := JS.Array.prototype.constructor()

	for x in arr {
		tmp.push(JS.Number(x))
	}
	ctx.setLineDash(tmp)
}

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

Successfully merging this pull request may close these issues.

None yet

2 participants