Convert-Binary-C
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
PACK->order = CBO_LITTLE_ENDIAN; \
break; \
\
default: \
fatal("Unknown byte order (%d)", BOtag->flags); \
break; \
} \
} STMT_END
#define RESTORE_BYTEORDER PACK->order = old_byte_order
/*------------*/
/* some flags */
/*------------*/
#define PACK_FLEXIBLE 0x00000001
/*===== TYPEDEFS =============================================================*/
struct PackInfo {
Buffer buf;
IDList idl;
const CBC *THIS;
SV *bufsv;
SV *self;
CByteOrder order;
HV *parent;
};
typedef enum {
FPT_UNKNOWN,
FPT_FLOAT,
FPT_DOUBLE,
FPT_LONG_DOUBLE
} FPType;
/*===== STATIC FUNCTION PROTOTYPES ===========================================*/
static FPType get_fp_type(u_32 flags);
static void store_float_sv(pPACKARGS, unsigned size, u_32 flags, SV *sv);
static SV *fetch_float_sv(pPACKARGS, unsigned size, u_32 flags);
static void store_int_sv(pPACKARGS, unsigned size, unsigned sign, const BitfieldInfo *pBI, SV *sv);
static SV *fetch_int_sv(pPACKARGS, unsigned size, unsigned sign, const BitfieldInfo *pBI);
static unsigned load_size(const CParseConfig *pCfg, u_32 *pFlags, const BitfieldInfo *pBI);
static void prepare_pack_format(pPACKARGS, const Declarator *pDecl, const CtTag *dimtag,
int *pSize, u_32 *pFlags);
static void pack_pointer(pPACKARGS, SV *sv);
static void pack_struct(pPACKARGS, const Struct *pStruct, SV *sv, int inlined);
static void pack_enum(pPACKARGS, const EnumSpecifier *pEnumSpec, const BitfieldInfo *pBI, SV *sv);
static void pack_basic(pPACKARGS, u_32 flags, const BitfieldInfo *pBI, SV *sv);
static void pack_format(pPACKARGS, const CtTag *format, unsigned size, u_32 flags, SV *sv);
static void pack_type(pPACKARGS, const TypeSpec *pTS, const Declarator *pDecl, int dimension,
const BitfieldInfo *pBI, SV *sv);
static SV *unpack_pointer(pPACKARGS);
static SV *unpack_struct(pPACKARGS, const Struct *pStruct, HV *hash);
static SV *unpack_enum(pPACKARGS, const EnumSpecifier *pEnumSpec, const BitfieldInfo *pBI);
static SV *unpack_basic(pPACKARGS, u_32 flags, const BitfieldInfo *pBI);
static SV *unpack_format(pPACKARGS, const CtTag *format, unsigned size, u_32 flags);
static SV *unpack_type(pPACKARGS, const TypeSpec *pTS, const Declarator *pDecl, int dimension,
const BitfieldInfo *pBI);
static SV *hook_call_typespec(pTHX_ SV *self, const TypeSpec *pTS,
enum HookId hook_id, SV *in, int mortal);
/*===== EXTERNAL VARIABLES ===================================================*/
/*===== GLOBAL VARIABLES =====================================================*/
/*===== STATIC VARIABLES =====================================================*/
/*===== STATIC FUNCTIONS =====================================================*/
/*******************************************************************************
*
* ROUTINE: get_fp_type
*
* WRITTEN BY: Marcus Holland-Moritz ON: Jun 2003
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
*
* RETURNS:
*
*******************************************************************************/
static FPType get_fp_type(u_32 flags)
{
/* mask out irrelevant flags */
flags &= T_VOID | T_CHAR | T_SHORT | T_INT
| T_LONG | T_FLOAT | T_DOUBLE | T_SIGNED
| T_UNSIGNED | T_LONGLONG;
/* only a couple of types are supported */
switch (flags)
{
case T_LONG | T_DOUBLE: return FPT_LONG_DOUBLE;
case T_DOUBLE : return FPT_DOUBLE;
case T_FLOAT : return FPT_FLOAT;
}
return FPT_UNKNOWN;
}
/*******************************************************************************
*
* ROUTINE: store_float_sv
*
* WRITTEN BY: Marcus Holland-Moritz ON: Jun 2003
* CHANGED BY: ON:
*
********************************************************************************
*
* DESCRIPTION:
*
* ARGUMENTS:
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.670 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )