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

Pointers to scalar values (*string, *int, *bool) fail ValueOf #6

Closed
thegrumpylion opened this issue Oct 21, 2019 · 1 comment
Closed

Comments

@thegrumpylion
Copy link

thegrumpylion commented Oct 21, 2019

Functions that get a pointer to a string/int/bool should dereference the pointers before passing them to any js functions

For example

// SetTextContent setting attribute 'textContent' with
// type string (idl: DOMString).
func (_this *Node) SetTextContent(value *string) {
	input := value
	_this.Value_JS.Set("textContent", input)
}

could be

// SetTextContent setting attribute 'textContent' with
// type string (idl: DOMString).
func (_this *Node) SetTextContent(value *string) {
	if value != nil {
		input := *value
		_this.Value_JS.Set("textContent", input)
	}
}

otherwise it panics panic: ValueOf: invalid value

Similar,

func (_this *Node) CloneNode(deep *bool) (_result *Node) {
	var (
		_args [1]interface{}
		_end  int
	)
	if deep != nil {
		_p0 := deep
		_args[0] = _p0
		_end++
	}
	_returned := _this.Value_JS.Call("cloneNode", _args[0:_end]...)
	var (
		_converted *Node // javascript: Node _what_return_name
	)
	_converted = NodeFromJS(_returned)
	_result = _converted
	return
}

could be

func (_this *Node) CloneNode(deep *bool) (_result *Node) {
	var (
		_args [1]interface{}
		_end  int
	)
	if deep != nil {
		_p0 := *deep
		_args[0] = _p0
		_end++
	}
	_returned := _this.Value_JS.Call("cloneNode", _args[0:_end]...)
	var (
		_converted *Node // javascript: Node _what_return_name
	)
	_converted = NodeFromJS(_returned)
	_result = _converted
	return
}
@martin-juhlin
Copy link
Contributor

I think this issue is now fixed. Thank for the feedback!

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

2 participants