Author: nickg
Date: Mon Jan 16 15:19:22 2006
New Revision: 11219
Modified:
branches/nci/include/parrot/nci.h
branches/nci/src/nci.c
branches/nci/src/nci_ffcall.c
Log:
NCI #13. Some miscellaneous changes from the other night.
Use parrot's memory allocation routines, and fix NCI ffcall clone.
Modified: branches/nci/include/parrot/nci.h
==============================================================================
--- branches/nci/include/parrot/nci.h (original)
+++ branches/nci/include/parrot/nci.h Mon Jan 16 15:19:22 2006
@@ -16,6 +16,8 @@
#include "parrot/parrot.h"
#include "parrot/method_util.h"
+/* Declare types for the vtable entries */
+
typedef void (*nci_new_method_t)(Interp* interpreter, PMC* pmc,
STRING* signature, Parrot_csub_t func);
typedef void (*nci_clone_method_t)(Interp* interpreter, PMC* pmc1, PMC* pmc2);
@@ -27,6 +29,7 @@ typedef void (*nci_new_callback_method_t
STRING *cb_signature,
PMC* user_data);
+/* Declare the NCI vtable structure */
struct nci_vtable {
@@ -52,6 +55,7 @@ extern struct nci_vtable nci_builtin_vta
extern struct nci_vtable nci_ffcall_vtable;
extern struct nci_vtable nci_libffi_vtable;
+/* Declare routines for getting and setting arguments */
INTVAL Parrot_get_nci_I(Interp *interpreter, struct call_state *st, int n);
FLOATVAL Parrot_get_nci_N(Interp *interpreter, struct call_state *st, int n);
STRING* Parrot_get_nci_S(Interp *interpreter, struct call_state *st, int n);
Modified: branches/nci/src/nci.c
==============================================================================
--- branches/nci/src/nci.c (original)
+++ branches/nci/src/nci.c Mon Jan 16 15:19:22 2006
@@ -1,4 +1,12 @@
-/* Convenience routines for fetching values */
+/*
+Copyright: 2006 The Perl Foundation. All Rights Reserved.
+$Id$
+
+=head1 NAME
+
+src/nci.c - Convenience routines for handling arguments in NCI implementations
+
+*/
#include "parrot/nci.h"
@@ -95,7 +103,7 @@ char *Parrot_convert_signature (const ch
{
int i, length = strlen (signature);
- char *signature_parrot = (char *) malloc (length);
+ char *signature_parrot = (char *) mem_sys_allocate (length);
for (i = 0 ; i < length+1 ; i++)
{
Modified: branches/nci/src/nci_ffcall.c
==============================================================================
--- branches/nci/src/nci_ffcall.c (original)
+++ branches/nci/src/nci_ffcall.c Mon Jan 16 15:19:22 2006
@@ -99,43 +99,38 @@ static void nci_ffcall_clone (Interp * i
{
NCIArgs* nci_args = PMC_data(pmc2);
- /* XXX: Fix signature passed */
nci_ffcall_new (interpreter, pmc1,
- 0,
+ string_from_cstring (interpreter,
+ nci_args->signature, 0),
nci_args->func);
}
static void nci_ffcall_free (Interp *interpreter, PMC *pmc)
{
-#if 0
- NCIArgs* nci_args = args;
+ NCIArgs* nci_args = (NCIArgs *) PMC_data(pmc);
- if (nci_args)
- {
- mem_sys_free (nci_args->signature);
- mem_sys_free (nci_args->signature_parrot);
-
- mem_sys_free (nci_args);
- }
-#endif
+ if (nci_args)
+ {
+ mem_sys_free (nci_args->signature);
+ mem_sys_free (nci_args->signature_parrot);
+
+ mem_sys_free (nci_args);
+ }
}
static void nci_ffcall_invoke (Interp *interpreter, PMC * pmc)
{
PMC *temp;
+ av_alist alist;
unsigned int i, length;
struct call_state st;
- char *signature;
- __VA_function pointer;
-
- av_alist alist;
NCIArgs* nci_args = (NCIArgs *) PMC_data(pmc);
- signature = nci_args->signature;
- pointer = (__VA_function) nci_args->func;
+ char* signature = nci_args->signature;
+ __VA_function pointer = (__VA_function) nci_args->func;
/* Set up return type for function */
switch (signature[0])