Starlink-AST
view release on metacpan or search on metacpan
src/astTypemap.c view on Meta::CPAN
/*
* astTypemap.c
* Purpose:
* Helper code for AST object typemap processing and object handling
* Description:
* This file implements functions useful for converting AST C structs
* to Perl objects and Perl objects back to the corresponding C struct.
* Mainly used in the typemap file but can be used to simplify processing
* of PPCODE return arguments.
*
* In order to use these functions in a typemap file, declare each
* AST struct as a T_ASTOBJ and define the following INPUT and OUTPUT
* entries:
*
* TYPEMAP
* AstObject * T_ASTOBJ
*
* INPUT
* T_ASTOBJ
* if (sv_derived_from($arg, ntypeToClass(\"${ntype}\"))) {
* IV tmp = extractAstIntPointer( $arg );
* $var = INT2PTR($type,tmp);
* }
* else
* Perl_croak(aTHX_ \"$var is not of class %s\",ntypeToClass(\"${ntype}\"))
*
* OUTPUT
* T_ASTOBJ
* $arg = createPerlObject(\"${ntype}\", (void*)$var);
* Copyright:
* Copyright (C) 2004-2005 Tim Jenness.
* All Rights Reserved.
* Authors:
* TIMJ: Tim Jenness (JAC)
* History:
* 24-FEB-2004 (TIMJ):
* Original version
*
*/
/* prototypes */
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h" /* std perl include */
#include "perl.h" /* std perl include */
#include "XSUB.h" /* XSUB include */
#include "ppport.h"
#ifdef __cplusplus
}
#endif
#include "ast.h"
#include "astTypemap.h"
/* The name of the attribute in the perl object that handles the
IV representation of a pointer. */
static char pntrAttrib[9] = "_pointer";
/* The root namespace we are dealing with */
static char NAMESPACE[14] = "Starlink::AST";
/*
Given the XS version of the class name (which is directly related
to the struct name - AstObject * maps to AstObjectPtr), and a
pointer to an ast object, return an a reference to a Perl hash
( run in 0.474 second using v1.01-cache-2.11-cpan-5511b514fd6 )