1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
################################################################################
#
# $Project: /Convert-Binary-C $
# $Author: mhx $
# $Date: 2009/03/15 04:10:44 +0100 $
# $Revision: 5 $
# $Source: /xsubs/arg.xs $
#
################################################################################
#
# Copyright (c) 2002-2009 Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################
################################################################################
#
# METHOD: arg
#
# WRITTEN BY: Marcus Holland-Moritz ON: Jun 2004
# CHANGED BY: ON:
#
################################################################################
#
# DESCRIPTION: Turn string arguments into blessed object, so we can recognize
# them later on.
#
################################################################################
void
CBC::arg(...)
PREINIT:
CBC_METHOD(arg);
int i;
PPCODE:
CT_DEBUG_METHOD;
CHECK_VOID_CONTEXT;
for (i = 1; i < items; i++)
{
const char *argstr;
STRLEN len;
HookArgType type;
SV *sv;
argstr = SvPV(ST(i), len);
if (strEQ(argstr, "SELF"))
type = HOOK_ARG_SELF;
else if (strEQ(argstr, "TYPE"))
type = HOOK_ARG_TYPE;
else if (strEQ(argstr, "DATA"))
type = HOOK_ARG_DATA;
else if (strEQ(argstr, "HOOK"))
type = HOOK_ARG_HOOK;
else
Perl_croak(aTHX_ "Unknown argument type '%s' in %s", argstr, method);
sv = newRV_noinc(newSViv(type));
sv_bless(sv, gv_stashpv(ARGTYPE_PACKAGE, 1));
ST(i-1) = sv_2mortal(sv);
}
XSRETURN(items-1);
|