Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (25 sloc) 600 Bytes
package v8go
// #include <stdlib.h>
// #include "v8go.h"
import "C"
import (
"runtime"
"unsafe"
)
// Value represents all Javascript values and objects
type Value struct {
ptr C.ValuePtr
}
// String will return the string representation of the value. Primitive values
// are returned as-is, objects will return `[object Object]` and functions will
// print their definition.
func (v *Value) String() string {
s := C.ValueToString(v.ptr)
defer C.free(unsafe.Pointer(s))
return C.GoString(s)
}
func (v *Value) finalizer() {
C.ValueDispose(v.ptr)
v.ptr = nil
runtime.SetFinalizer(v, nil)
}
You can’t perform that action at this time.