Closed JerryKwan closed 6 years ago
When defining a function in script, if the function has not parameter, it will introduce an error such as "runtime error: index out of range", and after review the codes, i think it was introduced in the following snippets
func (e *Element) CallFunction(functionName string, args ...*Value) (retval *Value, err error) { retval = NewValue() argc := len(args) argv := make([]Value, argc) for i := 0; i < argc; i++ { argv[i] = *args[i] } // args cfn := C.LPCSTR(unsafe.Pointer(StringToBytePtr(functionName))) cargc := C.UINT(argc) cargv := (*C.SCITER_VALUE)(unsafe.Pointer(&argv[0])) cretval := (*C.SCITER_VALUE)(unsafe.Pointer(retval)) // cgo call r := C.SciterCallScriptingFunction(e.handle, cfn, cargv, cargc, cretval) err = wrapDomResult(r, "SciterCallScriptingFunction") return }
The error was introduced by __cargv := (*C.SCITER_VALUE)(unsafe.Pointer(&argv[0]))__
True, thank you for the catch. Care to send a fix?
@pravic , Yes, absolutely, the pull request has been sent, please take some time to review, thank you
https://github.com/sciter-sdk/go-sciter/pull/176
Thanks!
When defining a function in script, if the function has not parameter, it will introduce an error such as "runtime error: index out of range", and after review the codes, i think it was introduced in the following snippets
The error was introduced by __cargv := (*C.SCITER_VALUE)(unsafe.Pointer(&argv[0]))__