Пример #1
0
//export gone_hello
func gone_hello(perl *C.PerlInterpreter, cv *C.CV) {
	var stack C.ouroboros_stack_t
	C.ouroboros_stack_init(perl, &stack)

	var hello = "Hello from Go"
	var hello_c = C.CString(hello)
	C.ouroboros_stack_prepush(perl, &stack)
	C.ouroboros_stack_xpush_pv(perl, &stack, hello_c, C.STRLEN(len(hello)))
	C.ouroboros_stack_putback(perl, &stack)

	C.free(unsafe.Pointer(hello_c))
}
Пример #2
0
//export boot_Gone
func boot_Gone(perl *C.PerlInterpreter, cv *C.CV) {
	var stack C.ouroboros_stack_t
	C.ouroboros_stack_init(perl, &stack)

	var hello = C.CString("Gone::hello")
	C.Perl_newXS(perl, hello,
		(*[0]byte)(unsafe.Pointer(C.gone_hello)),
		(*C.char)(unsafe.Pointer(&file[0])))
	C.free(unsafe.Pointer(hello))

	C.ouroboros_stack_prepush(perl, &stack)
	C.ouroboros_stack_xpush_iv(perl, &stack, C.IV(1))
	C.ouroboros_stack_putback(perl, &stack)
}