Created
July 3, 2011 20:39
-
-
Save crazy2be/1062583 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (ctx *Context) newCValueArray(val []*Value) (*C.JSValueRef, C.size_t) { | |
if len(val) == 0 { | |
return nil, 0 | |
} | |
arr := make([]C.JSValueRef, len(val)) | |
for i := 0; i < len(val); i++ { | |
arr[i] = val[i].ref | |
} | |
return &arr[0], C.size_t(len(arr)) | |
} | |
func (ctx *Context) newGoValueArray(ptr unsafe.Pointer, size uint) ([]*Value) { | |
if uintptr(ptr) == 0x00000000 { | |
return nil | |
} | |
goarr := make([]*Value, size) | |
for i := uint(0); i < size; i++ { | |
goarr[i] = ctx.newValue(C.JSValueRef(ptr)) | |
ptr = unsafe.Pointer(4+uintptr(ptr)) | |
} | |
return goarr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment