/* * This file was generated automatically by ExtUtils::ParseXS version 2.18 from the * contents of C.xs. Do not edit this file, edit C.xs instead. * * ANY CHANGES MADE HERE WILL BE LOST! * */ #line 1 "C.xs" /******************************************************************************* * * MODULE: C.xs * ******************************************************************************** * * DESCRIPTION: XS Interface for Convert::Binary::C Perl extension module * ******************************************************************************** * * $Project: /Convert-Binary-C $ * $Author: mhx $ * $Date: 2006/08/26 13:33:44 +0200 $ * $Revision: 160 $ * $Source: /C.xs $ * ******************************************************************************** * * Copyright (c) 2002-2006 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. * ******************************************************************************** * * "All you have to do is to decide what you are going to do * with the time that is given to you." -- Gandalf * *******************************************************************************/ /*===== GLOBAL INCLUDES ======================================================*/ #define PERL_NO_GET_CONTEXT #include #include #define NO_XSLOCKS #include #define NEED_newRV_noinc_GLOBAL #define NEED_sv_2pv_nolen_GLOBAL #include "ppport.h" /*===== LOCAL INCLUDES =======================================================*/ #include "util/ccattr.h" #include "util/list.h" #include "util/hash.h" #include "ctlib/cterror.h" #include "ctlib/fileinfo.h" #include "ctlib/parser.h" #include "cbc/cbc.h" #include "cbc/debug.h" #include "cbc/hook.h" #include "cbc/init.h" #include "cbc/macros.h" #include "cbc/member.h" #include "cbc/object.h" #include "cbc/option.h" #include "cbc/pack.h" #include "cbc/sourcify.h" #include "cbc/tag.h" #include "cbc/type.h" #include "cbc/typeinfo.h" #include "cbc/util.h" /*===== DEFINES ==============================================================*/ #ifndef PerlEnv_getenv # define PerlEnv_getenv getenv #endif #ifdef CBC_DEBUGGING #define DBG_CTXT_FMT "%s" #define DBG_CTXT_ARG (GIMME_V == G_VOID ? "0=" : \ (GIMME_V == G_SCALAR ? "$=" : \ (GIMME_V == G_ARRAY ? "@=" : \ "?=" \ ))) #endif #define CBC_METHOD(name) const char * const method PERL_UNUSED_DECL = #name #define CBC_METHOD_VAR const char * method PERL_UNUSED_DECL = "" #define CBC_METHOD_SET(string) method = string #define CT_DEBUG_METHOD \ CT_DEBUG(MAIN, (DBG_CTXT_FMT XSCLASS "::%s", DBG_CTXT_ARG, method)) #define CT_DEBUG_METHOD1(fmt, arg1) \ CT_DEBUG(MAIN, (DBG_CTXT_FMT XSCLASS "::%s( " fmt " )", \ DBG_CTXT_ARG, method, arg1)) #define CT_DEBUG_METHOD2(fmt, arg1, arg2) \ CT_DEBUG(MAIN, (DBG_CTXT_FMT XSCLASS "::%s( " fmt " )", \ DBG_CTXT_ARG, method, arg1, arg2) ) #define CHECK_PARSE_DATA \ STMT_START { \ if (!THIS->cpi.available) \ Perl_croak(aTHX_ "Call to %s without parse data", method); \ } STMT_END #define NEED_PARSE_DATA \ STMT_START { \ if (THIS->cpi.available) \ { \ if (!THIS->cpi.ready) \ update_parse_info(&THIS->cpi, &THIS->cfg); \ assert(THIS->cpi.ready); \ } \ } STMT_END #define WARN_VOID_CONTEXT \ WARN((aTHX_ "Useless use of %s in void context", method)) #define CHECK_VOID_CONTEXT \ STMT_START { \ if (GIMME_V == G_VOID) \ { \ WARN_VOID_CONTEXT; \ XSRETURN_EMPTY; \ } \ } STMT_END /*===== TYPEDEFS =============================================================*/ /*===== STATIC FUNCTION PROTOTYPES ===========================================*/ static void *ct_newstr(void); static void ct_scatf(void *p, const char *f, ...); static void ct_vscatf(void *p, const char *f, va_list *l); static const char *ct_cstring(void *p, size_t *len); static void ct_fatal(void *p) __attribute__((__noreturn__)); static void handle_parse_errors(pTHX_ LinkedList stack); /*===== EXTERNAL VARIABLES ===================================================*/ /*===== GLOBAL VARIABLES =====================================================*/ /*===== STATIC VARIABLES =====================================================*/ static int gs_DisableParser; static int gs_OrderMembers; /*===== GLOBAL FUNCTIONS =====================================================*/ /******************************************************************************* * * ROUTINE: CBC_malloc, CBC_calloc, CBC_realloc, CBC_free * * WRITTEN BY: Marcus Holland-Moritz ON: Feb 2005 * CHANGED BY: ON: * ******************************************************************************** * * DESCRIPTION: Memory allocation routines for ucpp and util libs. * *******************************************************************************/ void *CBC_malloc(size_t size) { void *p; New(0, p, size, char); return p; } void *CBC_calloc(size_t count, size_t size) { void *p; Newz(0, p, count*size, char); return p; } void *CBC_realloc(void *p, size_t size) { Renew(p, size, char); return p; } void CBC_free(void *p) { Safefree(p); } /*===== STATIC FUNCTIONS =====================================================*/ /******************************************************************************* * * ROUTINE: ct_* * * WRITTEN BY: Marcus Holland-Moritz ON: Mar 2002 * CHANGED BY: ON: * ******************************************************************************** * * DESCRIPTION: These functions are used to build arbitrary strings within the * ctlib routines and to provide an interface to perl's warn(). * *******************************************************************************/ static void *ct_newstr(void) { dTHX; return (void *) newSVpvn("", 0); } static void ct_destroy(void *p) { dTHX; SvREFCNT_dec((SV*)p); } static void ct_scatf(void *p, const char *f, ...) { dTHX; va_list l; va_start(l, f); sv_vcatpvf((SV*)p, f, &l); va_end(l); } static void ct_vscatf(void *p, const char *f, va_list *l) { dTHX; sv_vcatpvf((SV*)p, f, l); } static const char *ct_cstring(void *p, size_t *len) { dTHX; STRLEN l; const char *s = SvPV((SV*)p, l); if (len) *len = (size_t) l; return s; } static void ct_fatal(void *p) { dTHX; sv_2mortal((SV*)p); fatal("%s", SvPV_nolen((SV*)p)); } /******************************************************************************* * * ROUTINE: handle_parse_errors * * WRITTEN BY: Marcus Holland-Moritz ON: Nov 2003 * CHANGED BY: ON: * ******************************************************************************** * * DESCRIPTION: * * ARGUMENTS: * * RETURNS: * *******************************************************************************/ static void handle_parse_errors(pTHX_ LinkedList stack) { ListIterator ei; CTLibError *perr; LL_foreach(perr, ei, stack) { switch (perr->severity) { case CTES_ERROR: Perl_croak(aTHX_ "%s", perr->string); break; case CTES_WARNING: if( PERL_WARNINGS_ON ) Perl_warn(aTHX_ "%s", perr->string); break; default: Perl_croak(aTHX_ "unknown severity [%d] for error: %s", perr->severity, perr->string); } } } /*===== XS FUNCTIONS =========================================================*/ #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(var) if (0) var = var #endif #line 315 "C.c" /* INCLUDE: Including 'xsubs/cbc.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_new); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_new) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::new", "CLASS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/cbc.xs" CBC_METHOD(new); #line 337 "C.c" char * CLASS = (char *)SvPV_nolen(ST(0)); #line 33 "xsubs/cbc.xs" CT_DEBUG_METHOD; if (items % 2 == 0) Perl_croak(aTHX_ "Number of configuration arguments " "to %s must be even", method); else { int i; CBC *THIS = cbc_new(aTHX); if (gs_DisableParser) { Perl_warn(aTHX_ XSCLASS " parser is DISABLED"); THIS->cfg.disable_parser = 1; } /* Only preset the option here, user may explicitly */ /* disable OrderMembers in the constructor */ if (gs_OrderMembers) THIS->order_members = 1; /* * bless the new object here, because handle_option() * may croak and DESTROY would not be called to free * the memory that has been allocated */ ST(0) = sv_2mortal(cbc_bless(aTHX_ THIS, CLASS)); for (i = 1; i < items; i += 2) handle_option(aTHX_ THIS, ST(i), ST(i+1), NULL, NULL); if (gs_OrderMembers && THIS->order_members) load_indexed_hash_module(aTHX_ THIS); XSRETURN(1); } #line 376 "C.c" PUTBACK; return; } } XS(XS_Convert__Binary__C_DESTROY); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_DESTROY) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::DESTROY", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { #line 83 "xsubs/cbc.xs" CBC_METHOD(DESTROY); #line 398 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::DESTROY(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::DESTROY(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::DESTROY(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::DESTROY(): THIS is not a blessed hash reference"); #line 86 "xsubs/cbc.xs" CT_DEBUG_METHOD; cbc_delete(aTHX_ THIS); #line 421 "C.c" } XSRETURN_EMPTY; } /* INCLUDE: Returning to 'C.xs' from 'xsubs/cbc.xs' */ /* INCLUDE: Including 'xsubs/clone.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_clone); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_clone) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::clone", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/clone.xs" CBC_METHOD(clone); CBC *clone; const char *class; #line 452 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::clone(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::clone(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::clone(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::clone(): THIS is not a blessed hash reference"); #line 35 "xsubs/clone.xs" CT_DEBUG_METHOD; CHECK_VOID_CONTEXT; class = HvNAME(SvSTASH(SvRV(ST(0)))); clone = cbc_clone(aTHX_ THIS); ST(0) = sv_2mortal(cbc_bless(aTHX_ clone, class)); XSRETURN(1); #line 482 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/clone.xs' */ /* INCLUDE: Including 'xsubs/clean.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_clean); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_clean) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::clean", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ { #line 30 "xsubs/clean.xs" CBC_METHOD(clean); #line 510 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::clean(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::clean(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::clean(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::clean(): THIS is not a blessed hash reference"); #line 33 "xsubs/clean.xs" CT_DEBUG_METHOD; free_parse_info(&THIS->cpi); if (GIMME_V != G_VOID) XSRETURN(1); #line 536 "C.c" } XSRETURN_EMPTY; } /* INCLUDE: Returning to 'C.xs' from 'xsubs/clean.xs' */ /* INCLUDE: Including 'xsubs/configure.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_configure); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_configure) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::configure", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ { #line 30 "xsubs/configure.xs" CBC_METHOD(configure); #line 563 "C.c" CBC * THIS; SV * RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::configure(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::configure(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::configure(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::configure(): THIS is not a blessed hash reference"); #line 33 "xsubs/configure.xs" CT_DEBUG_METHOD; if (items <= 2 && GIMME_V == G_VOID) { WARN_VOID_CONTEXT; XSRETURN_EMPTY; } else if (items == 1) RETVAL = get_configuration(aTHX_ THIS); else if (items == 2) handle_option(aTHX_ THIS, ST(1), NULL, &RETVAL, NULL); else if (items % 2) { int i, changes = 0, layout = 0, preproc = 0; HandleOptionResult res; for (i = 1; i < items; i += 2) { handle_option(aTHX_ THIS, ST(i), ST(i+1), NULL, &res); if (res.option_modified) changes = 1; if (res.impacts_layout) layout = 1; if (res.impacts_preproc) preproc = 1; } if (changes) { if (layout) { basic_types_reset(THIS->basic); if (THIS->cpi.available && THIS->cpi.ready) reset_parse_info(&THIS->cpi); } if (preproc) { reset_preprocessor(&THIS->cpi); } } XSRETURN(1); } else Perl_croak(aTHX_ "Invalid number of arguments to %s", method); #line 632 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/configure.xs' */ /* INCLUDE: Including 'xsubs/include.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_Include); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_Include) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif dXSI32; if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 34 "xsubs/include.xs" CBC_METHOD_VAR; LinkedList list; int hasRval; SV *rval, *inval; #line 667 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::Include(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::Include(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::Include(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::Include(): THIS is not a blessed hash reference"); #line 40 "xsubs/include.xs" switch (ix) { case 1: /* Define */ CBC_METHOD_SET("Define"); list = THIS->cfg.defines; break; case 2: /* Assert */ CBC_METHOD_SET("Assert"); list = THIS->cfg.assertions; break; default: /* Include */ CBC_METHOD_SET("Include"); list = THIS->cfg.includes; break; } CT_DEBUG_METHOD; hasRval = GIMME_V != G_VOID && items <= 1; if (GIMME_V == G_VOID && items <= 1) { WARN_VOID_CONTEXT; XSRETURN_EMPTY; } if (items > 1 && !SvROK(ST(1))) { int i; inval = NULL; for (i = 1; i < items; i++) { if (SvROK(ST(i))) Perl_croak(aTHX_ "Argument %d to %s must not be a reference", i, method); LL_push(list, string_new_fromSV(aTHX_ ST(i))); } } else { if (items > 2) Perl_croak(aTHX_ "Invalid number of arguments to %s", method); inval = items == 2 ? ST(1) : NULL; } if (inval != NULL || hasRval) handle_string_list(aTHX_ method, list, inval, hasRval ? &rval : NULL); if (hasRval) ST(0) = sv_2mortal(rval); reset_preprocessor(&THIS->cpi); XSRETURN(1); #line 743 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/include.xs' */ /* INCLUDE: Including 'xsubs/parse.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_parse); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_parse) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::parse", "THIS, code"); PERL_UNUSED_VAR(cv); /* -W */ { SV * code = ST(1); #line 32 "xsubs/parse.xs" CBC_METHOD(parse); SV *temp = NULL; STRLEN len; Buffer buf; #line 775 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::parse(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::parse(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::parse(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::parse(): THIS is not a blessed hash reference"); #line 38 "xsubs/parse.xs" CT_DEBUG_METHOD; buf.buffer = SvPV(code, len); if (!((len == 0) || (len >= 1 && (buf.buffer[len-1] == '\n' || buf.buffer[len-1] == '\r')))) { /* append a newline to a temporary copy */ temp = newSVsv(code); sv_catpvn(temp, "\n", 1); buf.buffer = SvPV(temp, len); } buf.length = len; buf.pos = 0; (void) parse_buffer(NULL, &buf, &THIS->cfg, &THIS->cpi); if (temp) SvREFCNT_dec(temp); handle_parse_errors(aTHX_ THIS->cpi.errorStack); if (GIMME_V != G_VOID) XSRETURN(1); #line 820 "C.c" } XSRETURN_EMPTY; } XS(XS_Convert__Binary__C_parse_file); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_parse_file) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::parse_file", "THIS, file"); PERL_UNUSED_VAR(cv); /* -W */ { const char * file = (const char *)SvPV_nolen(ST(1)); #line 79 "xsubs/parse.xs" CBC_METHOD(parse_file); #line 842 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::parse_file(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::parse_file(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::parse_file(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::parse_file(): THIS is not a blessed hash reference"); #line 82 "xsubs/parse.xs" CT_DEBUG_METHOD1("'%s'", file); (void) parse_buffer(file, NULL, &THIS->cfg, &THIS->cpi); handle_parse_errors(aTHX_ THIS->cpi.errorStack); if (GIMME_V != G_VOID) XSRETURN(1); #line 870 "C.c" } XSRETURN_EMPTY; } /* INCLUDE: Returning to 'C.xs' from 'xsubs/parse.xs' */ /* INCLUDE: Including 'xsubs/def.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_def); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_def) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::def", "THIS, type"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); #line 32 "xsubs/def.xs" CBC_METHOD(def); MemberInfo mi; const char *member = NULL; #line 900 "C.c" CBC * THIS; char * RETVAL; dXSTARG; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::def(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::def(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::def(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::def(): THIS is not a blessed hash reference"); #line 37 "xsubs/def.xs" CT_DEBUG_METHOD1("'%s'", type); CHECK_VOID_CONTEXT; if (get_type_spec(THIS, type, &member, &mi.type) == 0) XSRETURN_UNDEF; if (mi.type.ptr == NULL) RETVAL = "basic"; else { void *ptr = mi.type.ptr; switch (GET_CTYPE(ptr)) { case TYP_TYPEDEF: RETVAL = is_typedef_defined((Typedef *) ptr) ? "typedef" : ""; break; case TYP_STRUCT: if (((Struct *) ptr)->declarations) RETVAL = ((Struct *) ptr)->tflags & T_STRUCT ? "struct" : "union"; else RETVAL = ""; break; case TYP_ENUM: RETVAL = ((EnumSpecifier *) ptr)->enumerators ? "enum" : ""; break; default: fatal("Invalid type (%d) in " XSCLASS "::%s( '%s' )", GET_CTYPE(ptr), method, type); break; } if (member && *member != '\0' && *RETVAL != '\0') { mi.pDecl = NULL; mi.level = 0; RETVAL = get_member(aTHX_ &mi, member, NULL, CBC_GM_DONT_CROAK | CBC_GM_NO_OFFSET_SIZE_CALC) ? "member" : ""; } } #line 965 "C.c" sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG; } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/def.xs' */ /* INCLUDE: Including 'xsubs/pack.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_pack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_pack) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 2 || items > 4) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::pack", "THIS, type, data = &PL_sv_undef, string = NULL"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); SV * data; SV * string; #line 34 "xsubs/pack.xs" CBC_METHOD(pack); char *buffer; MemberInfo mi; PackHandle pack; SV *rv; dXCPT; #line 1001 "C.c" CBC * THIS; if (items < 3) data = &PL_sv_undef; else { data = ST(2); } if (items < 4) string = NULL; else { string = ST(3); } if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::pack(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::pack(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::pack(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::pack(): THIS is not a blessed hash reference"); #line 42 "xsubs/pack.xs" CT_DEBUG_METHOD1("'%s'", type); if (string == NULL && GIMME_V == G_VOID) { WARN_VOID_CONTEXT; XSRETURN_EMPTY; } if (string != NULL) { SvGETMAGIC(string); if ((SvFLAGS(string) & (SVf_POK|SVp_POK)) == 0) Perl_croak(aTHX_ "Type of arg 3 to pack must be string"); if (GIMME_V == G_VOID && SvREADONLY(string)) Perl_croak(aTHX_ "Modification of a read-only value attempted"); } NEED_PARSE_DATA; if (!get_member_info(aTHX_ THIS, type, &mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); if (mi.flags) WARN_FLAGS(type, mi.flags); if (string == NULL) { rv = newSV(mi.size); /* force rv into a PV when mi.size is zero (bug #3753) */ if (mi.size == 0) sv_grow(rv, 1); SvPOK_only(rv); SvCUR_set(rv, mi.size); buffer = SvPVX(rv); /* We get an mi.size+1 buffer from newSV. So the following */ /* call will properly \0-terminate our return value. */ Zero(buffer, mi.size+1, char); } else { STRLEN len = SvCUR(string); STRLEN max = mi.size > len ? mi.size : len; if (GIMME_V == G_VOID) { rv = NULL; buffer = SvGROW(string, max+1); SvCUR_set(string, max); } else { rv = newSV(max); SvPOK_only(rv); buffer = SvPVX(rv); SvCUR_set(rv, max); Copy(SvPVX(string), buffer, len, char); } if(max > len) Zero(buffer+len, max+1-len, char); } pack = pk_create(THIS, ST(0)); pk_set_type(pack, type); pk_set_buffer(pack, rv ? rv : string, buffer, mi.size); SvGETMAGIC(data); XCPT_TRY_START { pk_pack(aTHX_ pack, &mi.type, mi.pDecl, mi.level, data); } XCPT_TRY_END pk_delete(pack); XCPT_CATCH { if (rv) SvREFCNT_dec(rv); XCPT_RETHROW; } /* this makes substr() as third argument work */ if (string) SvSETMAGIC(string); if (rv == NULL) XSRETURN_EMPTY; ST(0) = sv_2mortal(rv); XSRETURN(1); #line 1131 "C.c" } XSRETURN(1); } XS(XS_Convert__Binary__C_unpack); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_unpack) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 3) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::unpack", "THIS, type, string"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { const char * type = (const char *)SvPV_nolen(ST(1)); SV * string = ST(2); #line 157 "xsubs/pack.xs" CBC_METHOD(unpack); char *buf; STRLEN len; MemberInfo mi; unsigned long count; #line 1160 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::unpack(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::unpack(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::unpack(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::unpack(): THIS is not a blessed hash reference"); #line 164 "xsubs/pack.xs" CT_DEBUG_METHOD1("'%s'", type); CHECK_VOID_CONTEXT; SvGETMAGIC(string); if ((SvFLAGS(string) & (SVf_POK|SVp_POK)) == 0) Perl_croak(aTHX_ "Type of arg 2 to unpack must be string"); NEED_PARSE_DATA; if (!get_member_info(aTHX_ THIS, type, &mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); if (mi.flags) WARN_FLAGS(type, mi.flags); buf = SvPV(string, len); if (GIMME_V == G_SCALAR) { if (mi.size > len) WARN((aTHX_ "Data too short")); count = 1; } else count = mi.size == 0 ? 1 : len / mi.size; if (count > 0) { dXCPT; unsigned long i; PackHandle pack; SV **sva; /* newHV_indexed() messes with the stack, so we cannot * store the return values on the stack immediately... */ Newz(0, sva, count, SV *); pack = pk_create(THIS, ST(0)); pk_set_buffer(pack, NULL, buf, len); XCPT_TRY_START { for (i = 0; i < count; i++) { pk_set_buffer_pos(pack, i*mi.size); sva[i] = pk_unpack(aTHX_ pack, &mi.type, mi.pDecl, mi.level); } } XCPT_TRY_END pk_delete(pack); XCPT_CATCH { for (i = 0; i < count; i++) if (sva[i]) SvREFCNT_dec(sva[i]); Safefree(sva); XCPT_RETHROW; } EXTEND(SP, count); for (i = 0; i < count; i++) PUSHs(sv_2mortal(sva[i])); Safefree(sva); } XSRETURN(count); #line 1258 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/pack.xs' */ /* INCLUDE: Including 'xsubs/sizeof.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_sizeof); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_sizeof) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::sizeof", "THIS, type"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); #line 32 "xsubs/sizeof.xs" CBC_METHOD(sizeof); MemberInfo mi; #line 1288 "C.c" CBC * THIS; SV * RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::sizeof(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::sizeof(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::sizeof(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::sizeof(): THIS is not a blessed hash reference"); #line 36 "xsubs/sizeof.xs" CT_DEBUG_METHOD1("'%s'", type); CHECK_VOID_CONTEXT; NEED_PARSE_DATA; if (!get_member_info(aTHX_ THIS, type, &mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); if (mi.pDecl && mi.pDecl->bitfield_flag) Perl_croak(aTHX_ "Cannot use %s on bitfields", method); if (mi.flags) WARN_FLAGS(type, mi.flags); RETVAL = newSVuv(mi.size); #line 1326 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/sizeof.xs' */ /* INCLUDE: Including 'xsubs/typeof.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_typeof); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_typeof) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::typeof", "THIS, type"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); #line 32 "xsubs/typeof.xs" CBC_METHOD(typeof); MemberInfo mi; #line 1357 "C.c" CBC * THIS; SV * RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::typeof(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::typeof(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typeof(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typeof(): THIS is not a blessed hash reference"); #line 36 "xsubs/typeof.xs" CT_DEBUG_METHOD1("'%s'", type); CHECK_VOID_CONTEXT; if (!get_member_info(aTHX_ THIS, type, &mi, CBC_GMI_NO_CALC)) Perl_croak(aTHX_ "Cannot find '%s'", type); RETVAL = get_type_name_string(aTHX_ &mi); #line 1387 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/typeof.xs' */ /* INCLUDE: Including 'xsubs/offsetof.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_offsetof); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_offsetof) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 3) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::offsetof", "THIS, type, member"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); const char * member = (const char *)SvPV_nolen(ST(2)); #line 33 "xsubs/offsetof.xs" CBC_METHOD(offsetof); MemberInfo mi, mi2; const char *m = member; #line 1420 "C.c" CBC * THIS; SV * RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::offsetof(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::offsetof(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::offsetof(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::offsetof(): THIS is not a blessed hash reference"); #line 38 "xsubs/offsetof.xs" CT_DEBUG_METHOD2("'%s', '%s'", type, member); CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; while (isSPACE(*m)) m++; if (*m == '\0') WARN((aTHX_ "Empty string passed as member expression")); NEED_PARSE_DATA; if (!get_member_info(aTHX_ THIS, type, &mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); (void) get_member(aTHX_ &mi, member, &mi2, CBC_GM_ACCEPT_DOTLESS_MEMBER); if (mi2.pDecl && mi2.pDecl->bitfield_flag) Perl_croak(aTHX_ "Cannot use %s on bitfields", method); if (mi.flags) WARN_FLAGS(type, mi.flags); RETVAL = newSViv(mi2.offset); #line 1467 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/offsetof.xs' */ /* INCLUDE: Including 'xsubs/member.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_member); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_member) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 2 || items > 3) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::member", "THIS, type, offset = NULL"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { const char * type = (const char *)SvPV_nolen(ST(1)); SV * offset; #line 33 "xsubs/member.xs" CBC_METHOD(member); MemberInfo mi; int have_offset, off; #line 1502 "C.c" CBC * THIS; if (items < 3) offset = NULL; else { offset = ST(2); } if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::member(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::member(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::member(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::member(): THIS is not a blessed hash reference"); #line 38 "xsubs/member.xs" off = (have_offset = DEFINED(offset)) ? SvIV(offset) : 0; CT_DEBUG_METHOD2("'%s', %d", type, off); CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; NEED_PARSE_DATA; if (!get_member_info(aTHX_ THIS, type, &mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); check_allowed_types(aTHX_ &mi, method, ALLOW_STRUCTS | ALLOW_UNIONS | ALLOW_ARRAYS); if (mi.flags) { u_32 flags = mi.flags; /* bitfields are not a problem without offset given */ if (!have_offset) flags &= ~T_HASBITFIELD; WARN_FLAGS(type, flags); } if (have_offset) { if (off < 0 || off >= (int) mi.size) Perl_croak(aTHX_ "Offset %d out of range (0 <= offset < %d)", off, mi.size); if (GIMME_V == G_ARRAY) { ListIterator li; GMSInfo info; SV *member; int count; info.hit = LL_new(); info.off = LL_new(); info.pad = LL_new(); (void) get_member_string(aTHX_ &mi, off, &info); count = LL_count(info.hit) + LL_count(info.off) + LL_count(info.pad); EXTEND(SP, count); LL_foreach(member, li, info.hit) PUSHs(member); LL_foreach(member, li, info.off) PUSHs(member); LL_foreach(member, li, info.pad) PUSHs(member); LL_destroy(info.hit, NULL); LL_destroy(info.off, NULL); LL_destroy(info.pad, NULL); XSRETURN(count); } else { SV *member = get_member_string(aTHX_ &mi, off, NULL); PUSHs(member); XSRETURN(1); } } else { LinkedList list; SV *member; int count; list = GIMME_V == G_ARRAY ? LL_new() : NULL; count = get_all_member_strings(aTHX_ &mi, list); if (GIMME_V == G_ARRAY) { ListIterator li; EXTEND(SP, count); LL_foreach(member, li, list) PUSHs(member); LL_destroy(list, NULL); XSRETURN(count); } else XSRETURN_IV(count); } #line 1626 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/member.xs' */ /* INCLUDE: Including 'xsubs/tag.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_tag); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_tag) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif dXSI32; if (items < 2) Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS, type, ..."); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); #line 35 "xsubs/tag.xs" CBC_METHOD_VAR; TagTypeInfo tti; CtTagList *taglist; #line 1658 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::tag(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::tag(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::tag(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::tag(): THIS is not a blessed hash reference"); #line 40 "xsubs/tag.xs" switch (ix) { case 0: CBC_METHOD_SET("tag"); break; case 1: CBC_METHOD_SET("untag"); break; default: fatal("Invalid alias (%d) for tag method", ix); break; } CT_DEBUG_METHOD1("'%s'", type); if (ix == 0 && items <= 3 && GIMME_V == G_VOID) { WARN_VOID_CONTEXT; XSRETURN_EMPTY; } NEED_PARSE_DATA; tti.type = type; if (!get_member_info(aTHX_ THIS, type, &tti.mi, 0)) Perl_croak(aTHX_ "Cannot find '%s'", type); if (tti.mi.level != 0) Perl_croak(aTHX_ "Cannot tag array members"); taglist = tti.mi.pDecl ? &tti.mi.pDecl->tags : find_taglist_ptr(tti.mi.type.ptr); assert(taglist != NULL); if (ix == 0) /* tag */ { if (items == 2) ST(0) = get_tags(aTHX_ &tti, *taglist); else if (items == 3) handle_tag(aTHX_ &tti, taglist, ST(2), NULL, &ST(0)); else if (items % 2 == 0) { int i; for (i = 2; i < items; i += 2) handle_tag(aTHX_ &tti, taglist, ST(i), ST(i+1), NULL); } else Perl_croak(aTHX_ "Invalid number of arguments to %s", method); } else /* untag */ { if (items == 2) delete_all_tags(taglist); else { int i; for (i = 2; i < items; i++) handle_tag(aTHX_ &tti, taglist, ST(i), &PL_sv_undef, NULL); } } XSRETURN(1); #line 1744 "C.c" } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/tag.xs' */ /* INCLUDE: Including 'xsubs/enum.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_enum_names); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_enum_names) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::enum_names", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/enum.xs" CBC_METHOD(enum_names); ListIterator li; EnumSpecifier *pEnumSpec; int count = 0; U32 context; #line 1777 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::enum_names(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::enum_names(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::enum_names(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::enum_names(): THIS is not a blessed hash reference"); #line 37 "xsubs/enum.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; LL_foreach(pEnumSpec, li, THIS->cpi.enums) if (pEnumSpec->identifier[0] && pEnumSpec->enumerators) { if (context == G_ARRAY) XPUSHs(sv_2mortal(newSVpv(pEnumSpec->identifier, 0))); count++; } if (context == G_ARRAY) XSRETURN(count); else XSRETURN_IV(count); #line 1816 "C.c" PUTBACK; return; } } XS(XS_Convert__Binary__C_enum); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_enum) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::enum", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 70 "xsubs/enum.xs" CBC_METHOD(enum); EnumSpecifier *pEnumSpec; U32 context; #line 1842 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::enum(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::enum(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::enum(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::enum(): THIS is not a blessed hash reference"); #line 75 "xsubs/enum.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; if (context == G_SCALAR && items != 2) XSRETURN_IV(items > 1 ? items-1 : LL_count(THIS->cpi.enums)); if (items > 1) { int i; for (i = 1; i < items; i++) { const char *name = SvPV_nolen(ST(i)); /* skip optional enum */ if (name[0] == 'e' && name[1] == 'n' && name[2] == 'u' && name[3] == 'm' && isSPACE(name[4])) name += 5; while (isSPACE(*name)) name++; pEnumSpec = HT_get(THIS->cpi.htEnums, name, 0, 0); if (pEnumSpec) PUSHs(sv_2mortal(get_enum_spec_def(aTHX_ &THIS->cfg, pEnumSpec))); else PUSHs(&PL_sv_undef); } XSRETURN(items-1); } else { ListIterator li; int size = LL_count(THIS->cpi.enums); if (size <= 0) XSRETURN_EMPTY; EXTEND(SP, size); LL_foreach(pEnumSpec, li, THIS->cpi.enums) PUSHs(sv_2mortal(get_enum_spec_def(aTHX_ &THIS->cfg, pEnumSpec))); XSRETURN(size); } #line 1916 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/enum.xs' */ /* INCLUDE: Including 'xsubs/compound.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_compound_names); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_compound_names) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif dXSI32; if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 34 "xsubs/compound.xs" CBC_METHOD_VAR; ListIterator li; Struct *pStruct; int count = 0; U32 context; u_32 mask; #line 1952 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::compound_names(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::compound_names(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::compound_names(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::compound_names(): THIS is not a blessed hash reference"); #line 42 "xsubs/compound.xs" switch (ix) { case 1: /* struct_names */ CBC_METHOD_SET("struct_names"); mask = T_STRUCT; break; case 2: /* union_names */ CBC_METHOD_SET("union_names"); mask = T_UNION; break; default: /* compound_names */ CBC_METHOD_SET("compound_names"); mask = T_STRUCT | T_UNION; break; } CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; LL_foreach(pStruct, li, THIS->cpi.structs) if (pStruct->identifier[0] && pStruct->declarations && pStruct->tflags & mask) { if (context == G_ARRAY) XPUSHs(sv_2mortal(newSVpv(pStruct->identifier, 0))); count++; } if (context == G_ARRAY) XSRETURN(count); else XSRETURN_IV(count); #line 2009 "C.c" PUTBACK; return; } } XS(XS_Convert__Binary__C_compound); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_compound) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif dXSI32; if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", GvNAME(CvGV(cv)), "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 97 "xsubs/compound.xs" CBC_METHOD_VAR; Struct *pStruct; U32 context; u_32 mask; #line 2037 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::compound(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::compound(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::compound(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::compound(): THIS is not a blessed hash reference"); #line 103 "xsubs/compound.xs" switch(ix) { case 1: /* struct */ CBC_METHOD_SET("struct"); mask = T_STRUCT; break; case 2: /* union */ CBC_METHOD_SET("union"); mask = T_UNION; break; default: /* compound */ CBC_METHOD_SET("compound"); mask = T_STRUCT | T_UNION; break; } CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; if (context == G_SCALAR && items != 2) { if (items > 1) XSRETURN_IV(items-1); else if (mask == (T_STRUCT|T_UNION)) XSRETURN_IV(LL_count(THIS->cpi.structs)); else { ListIterator li; int count = 0; LL_foreach(pStruct, li, THIS->cpi.structs) if (pStruct->tflags & mask) count++; XSRETURN_IV(count); } } NEED_PARSE_DATA; if (items > 1) { int i; for (i = 1; i < items; i++) { const char *name; u_32 limit = mask; name = SvPV_nolen(ST(i)); /* skip optional union/struct */ if(mask & T_UNION && name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'o' && name[4] == 'n' && isSPACE(name[5])) { name += 6; limit = T_UNION; } else if(mask & T_STRUCT && name[0] == 's' && name[1] == 't' && name[2] == 'r' && name[3] == 'u' && name[4] == 'c' && name[5] == 't' && isSPACE(name[6])) { name += 7; limit = T_STRUCT; } while (isSPACE(*name)) name++; pStruct = HT_get(THIS->cpi.htStructs, name, 0, 0); if (pStruct && pStruct->tflags & limit) PUSHs(sv_2mortal(get_struct_spec_def(aTHX_ &THIS->cfg, pStruct))); else PUSHs(&PL_sv_undef); } XSRETURN(items-1); } else { ListIterator li; int count = 0; LL_foreach(pStruct, li, THIS->cpi.structs) if (pStruct->tflags & mask) { XPUSHs(sv_2mortal(get_struct_spec_def(aTHX_ &THIS->cfg, pStruct))); count++; } XSRETURN(count); } #line 2165 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/compound.xs' */ /* INCLUDE: Including 'xsubs/typedef.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_typedef_names); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_typedef_names) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::typedef_names", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/typedef.xs" CBC_METHOD(typedef_names); ListIterator tli, ti; TypedefList *pTDL; Typedef *pTypedef; int count = 0; U32 context; #line 2200 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::typedef_names(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::typedef_names(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typedef_names(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typedef_names(): THIS is not a blessed hash reference"); #line 38 "xsubs/typedef.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; LL_foreach(pTDL, tli, THIS->cpi.typedef_lists) LL_foreach(pTypedef, ti, pTDL->typedefs) if (is_typedef_defined(pTypedef)) { if (context == G_ARRAY) XPUSHs(sv_2mortal(newSVpv(pTypedef->pDecl->identifier, 0))); count++; } if (context == G_ARRAY) XSRETURN(count); else XSRETURN_IV(count); #line 2240 "C.c" PUTBACK; return; } } XS(XS_Convert__Binary__C_typedef); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_typedef) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::typedef", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 72 "xsubs/typedef.xs" CBC_METHOD(typedef); Typedef *pTypedef; U32 context; #line 2266 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::typedef(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::typedef(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typedef(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::typedef(): THIS is not a blessed hash reference"); #line 77 "xsubs/typedef.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; context = GIMME_V; if (context == G_SCALAR && items != 2) XSRETURN_IV(items > 1 ? items-1 : HT_count(THIS->cpi.htTypedefs)); NEED_PARSE_DATA; if (items > 1) { int i; for (i = 1; i < items; i++) { const char *name = SvPV_nolen(ST(i)); pTypedef = HT_get(THIS->cpi.htTypedefs, name, 0, 0); if (pTypedef) PUSHs(sv_2mortal(get_typedef_def(aTHX_ &THIS->cfg, pTypedef))); else PUSHs(&PL_sv_undef); } XSRETURN(items-1); } else { ListIterator tli, ti; TypedefList *pTDL; int size = HT_count(THIS->cpi.htTypedefs); if (size <= 0) XSRETURN_EMPTY; EXTEND(SP, size); LL_foreach(pTDL, tli, THIS->cpi.typedef_lists) LL_foreach(pTypedef, ti, pTDL->typedefs) PUSHs(sv_2mortal(get_typedef_def(aTHX_ &THIS->cfg, pTypedef))); XSRETURN(size); } #line 2333 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/typedef.xs' */ /* INCLUDE: Including 'xsubs/sourcify.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_sourcify); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_sourcify) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::sourcify", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ { #line 30 "xsubs/sourcify.xs" CBC_METHOD(sourcify); SourcifyConfig sc; #line 2362 "C.c" CBC * THIS; SV * RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::sourcify(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::sourcify(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::sourcify(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::sourcify(): THIS is not a blessed hash reference"); #line 34 "xsubs/sourcify.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; /* preset with defaults */ sc.context = 0; sc.defines = 0; if (items == 2 && SvROK(ST(1))) { SV *sv = SvRV(ST(1)); if (SvTYPE(sv) == SVt_PVHV) get_sourcify_config(aTHX_ (HV *) sv, &sc); else Perl_croak(aTHX_ "Need a hash reference for configuration options"); } else if (items >= 2) Perl_croak(aTHX_ "Sourcification of individual types is not yet supported"); RETVAL = get_parsed_definitions_string(aTHX_ &THIS->cpi, &sc); #line 2406 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/sourcify.xs' */ /* INCLUDE: Including 'xsubs/initializer.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_initializer); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_initializer) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 2 || items > 3) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::initializer", "THIS, type, init = &PL_sv_undef"); PERL_UNUSED_VAR(cv); /* -W */ { const char * type = (const char *)SvPV_nolen(ST(1)); SV * init; #line 33 "xsubs/initializer.xs" CBC_METHOD(initializer); MemberInfo mi; #line 2438 "C.c" CBC * THIS; SV * RETVAL; if (items < 3) init = &PL_sv_undef; else { init = ST(2); } if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::initializer(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::initializer(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::initializer(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::initializer(): THIS is not a blessed hash reference"); #line 37 "xsubs/initializer.xs" CT_DEBUG_METHOD1("'%s'", type); CHECK_VOID_CONTEXT; if (!get_member_info(aTHX_ THIS, type, &mi, CBC_GMI_NO_CALC)) Perl_croak(aTHX_ "Cannot find '%s'", type); SvGETMAGIC(init); RETVAL = get_initializer_string(aTHX_ THIS, &mi, init, type); #line 2476 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/initializer.xs' */ /* INCLUDE: Including 'xsubs/dependencies.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_dependencies); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_dependencies) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::dependencies", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/dependencies.xs" CBC_METHOD(dependencies); HashIterator hi; const char *pKey; FileInfo *pFI; #line 2510 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::dependencies(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::dependencies(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::dependencies(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::dependencies(): THIS is not a blessed hash reference"); #line 36 "xsubs/dependencies.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; if (GIMME_V == G_SCALAR) { HV *hv = newHV(); HT_foreach(pKey, pFI, hi, THIS->cpi.htFiles) { if (pFI && pFI->valid) { SV *attr; HV *hattr = newHV(); HV_STORE_CONST(hattr, "size", newSVuv(pFI->size)); HV_STORE_CONST(hattr, "mtime", newSViv(pFI->modify_time)); HV_STORE_CONST(hattr, "ctime", newSViv(pFI->change_time)); attr = newRV_noinc((SV *) hattr); if (hv_store(hv, pFI->name, strlen(pFI->name), attr, 0) == NULL) SvREFCNT_dec(attr); } } XPUSHs(sv_2mortal(newRV_noinc((SV *) hv))); XSRETURN(1); } else { int keylen, count = 0; HI_init(&hi, THIS->cpi.htFiles); while (HI_next(&hi, &pKey, &keylen, (void **) &pFI)) if (pFI && pFI->valid) { XPUSHs(sv_2mortal(newSVpvn(CONST_CHAR(pKey), keylen))); count++; } XSRETURN(count); } #line 2574 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/dependencies.xs' */ /* INCLUDE: Including 'xsubs/defined.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_defined); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_defined) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 2) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::defined", "THIS, name"); PERL_UNUSED_VAR(cv); /* -W */ { const char * name = (const char *)SvPV_nolen(ST(1)); #line 32 "xsubs/defined.xs" CBC_METHOD(defined); #line 2603 "C.c" CBC * THIS; bool RETVAL; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::defined(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::defined(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::defined(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::defined(): THIS is not a blessed hash reference"); #line 35 "xsubs/defined.xs" CT_DEBUG_METHOD; /* TODO: probably we can do without parse data (would require special handling of the pp object) */ CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; RETVAL = macro_is_defined(&THIS->cpi, name); #line 2632 "C.c" ST(0) = boolSV(RETVAL); sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/defined.xs' */ /* INCLUDE: Including 'xsubs/macro.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_macro_names); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_macro_names) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::macro_names", "THIS"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 30 "xsubs/macro.xs" CBC_METHOD(macro_names); #line 2663 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::macro_names(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::macro_names(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::macro_names(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::macro_names(): THIS is not a blessed hash reference"); #line 33 "xsubs/macro.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; if (GIMME_V == G_ARRAY) { LinkedList ll = macros_get_names(aTHX_ &THIS->cpi, NULL); int count = LL_count(ll); SV *sv; EXTEND(SP, count); while ((sv = LL_pop(ll)) != NULL) PUSHs(sv_2mortal(sv)); assert(LL_count(ll) == 0); LL_delete(ll); XSRETURN(count); } else { size_t count; (void) macros_get_names(aTHX_ &THIS->cpi, &count); XSRETURN_IV((int)count); } #line 2709 "C.c" PUTBACK; return; } } XS(XS_Convert__Binary__C_macro); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_macro) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::macro", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 72 "xsubs/macro.xs" CBC_METHOD(macro); #line 2733 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::macro(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::macro(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::macro(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::macro(): THIS is not a blessed hash reference"); #line 75 "xsubs/macro.xs" CT_DEBUG_METHOD; CHECK_PARSE_DATA; CHECK_VOID_CONTEXT; if (GIMME_V == G_SCALAR && items != 2) { if (items > 1) { XSRETURN_IV(items-1); } else { size_t count; (void) macros_get_names(aTHX_ &THIS->cpi, &count); XSRETURN_IV((int)count); } } if (items > 1) { int i; for (i = 1; i < items; i++) { const char *name = SvPV_nolen(ST(i)); size_t len; char *def = macro_get_def(&THIS->cpi, name, &len); if (def) { PUSHs(sv_2mortal(newSVpvn(def, len))); macro_free_def(def); } else PUSHs(&PL_sv_undef); } XSRETURN(items-1); } else { LinkedList ll = macros_get_definitions(aTHX_ &THIS->cpi); int count = LL_count(ll); SV *sv; EXTEND(SP, count); while ((sv = LL_pop(ll)) != NULL) PUSHs(sv_2mortal(sv)); assert(LL_count(ll) == 0); LL_delete(ll); XSRETURN(count); } #line 2808 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/macro.xs' */ /* INCLUDE: Including 'xsubs/arg.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_arg); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_arg) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::arg", "THIS, ..."); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 35 "xsubs/arg.xs" CBC_METHOD(arg); int i; #line 2839 "C.c" CBC * THIS; if (sv_isobject(ST(0)) && SvTYPE(SvRV(ST(0))) == SVt_PVHV) { HV *hv = (HV *) SvRV(ST(0)); SV **sv = hv_fetch(hv, "", 0, 0); if (sv) { IV tmp = SvIV(*sv); THIS = INT2PTR(CBC *, tmp); if (THIS == NULL) Perl_croak(aTHX_ "Convert::Binary::C::arg(): THIS is NULL"); if (THIS->hv != hv) Perl_croak(aTHX_ "Convert::Binary::C::arg(): THIS->hv is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::arg(): THIS is corrupt"); } else Perl_croak(aTHX_ "Convert::Binary::C::arg(): THIS is not a blessed hash reference"); #line 39 "xsubs/arg.xs" 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); #line 2889 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/arg.xs' */ /* INCLUDE: Including 'xsubs/feature.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_feature); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_feature) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { #line 34 "xsubs/feature.xs" CBC_METHOD(feature); int method_call; const char *feat; #line 2919 "C.c" #line 39 "xsubs/feature.xs" method_call = items > 0 && sv_isobject(ST(0)); if (items != (method_call ? 2 : 1)) Perl_croak(aTHX_ "Usage: Convert::Binary::C::feature(feat)"); CHECK_VOID_CONTEXT; feat = (const char *)SvPV_nolen(ST(items-1)); switch (*feat) { case 'd': if (strEQ(feat, "debug")) #ifdef CBC_DEBUGGING XSRETURN_YES; #else XSRETURN_NO; #endif break; case 'i': if (strEQ(feat, "ieeefp")) #ifdef CBC_HAVE_IEEE_FP XSRETURN_YES; #else XSRETURN_NO; #endif break; case 't': if (strEQ(feat, "threads")) #ifdef CBC_THREAD_SAFE XSRETURN_YES; #else XSRETURN_NO; #endif break; } XSRETURN_UNDEF; #line 2961 "C.c" PUTBACK; return; } } /* INCLUDE: Returning to 'C.xs' from 'xsubs/feature.xs' */ /* INCLUDE: Including 'xsubs/native.xs' from 'C.xs' */ XS(XS_Convert__Binary__C_native); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_native) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif PERL_UNUSED_VAR(cv); /* -W */ { #line 34 "xsubs/native.xs" CBC_METHOD(native); int method_call; #line 2988 "C.c" SV * RETVAL; #line 38 "xsubs/native.xs" method_call = items > 0 && sv_isobject(ST(0)); if (items > (method_call ? 2 : 1)) Perl_croak(aTHX_ "Usage: Convert::Binary::C::native(property)"); CHECK_VOID_CONTEXT; if (items == (method_call ? 1 : 0)) { RETVAL = get_native_property(aTHX_ NULL); } else { const char *property = (const char *)SvPV_nolen(ST(items-1)); RETVAL = get_native_property(aTHX_ property); if (RETVAL == NULL) Perl_croak(aTHX_ "Invalid property '%s'", property); } #line 3012 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } /* INCLUDE: Returning to 'C.xs' from 'xsubs/native.xs' */ #define WARN_NO_DEBUGGING 0x00000001 XS(XS_Convert__Binary__C_import); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C_import) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif PERL_UNUSED_VAR(cv); /* -W */ { #line 376 "C.xs" int i; U32 wflags; #line 3038 "C.c" #line 380 "C.xs" wflags = 0; if (items % 2 == 0) Perl_croak(aTHX_ "You must pass an even number of module arguments"); else { for (i = 1; i < items; i += 2) { const char *opt = SvPV_nolen(ST(i)); #ifdef CBC_DEBUGGING const char *arg = SvPV_nolen(ST(i+1)); #endif if (strEQ(opt, "debug")) { #ifdef CBC_DEBUGGING set_debug_options(aTHX_ arg); #else wflags |= WARN_NO_DEBUGGING; #endif } else if (strEQ(opt, "debugfile")) { #ifdef CBC_DEBUGGING set_debug_file(aTHX_ arg); #else wflags |= WARN_NO_DEBUGGING; #endif } else Perl_croak(aTHX_ "Invalid module option '%s'", opt); } if (wflags & WARN_NO_DEBUGGING) Perl_warn(aTHX_ XSCLASS " not compiled with debugging support"); } #line 3075 "C.c" } XSRETURN_EMPTY; } #undef WARN_NO_DEBUGGING XS(XS_Convert__Binary__C___DUMP__); /* prototype to pass -Wmissing-prototypes */ XS(XS_Convert__Binary__C___DUMP__) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 1) Perl_croak(aTHX_ "Usage: %s(%s)", "Convert::Binary::C::__DUMP__", "val"); PERL_UNUSED_VAR(cv); /* -W */ { SV * val = ST(0); SV * RETVAL; #line 441 "C.xs" RETVAL = newSVpvn("", 0); #ifdef CBC_DEBUGGING dump_sv(aTHX_ RETVAL, 0, val); #else (void) val; Perl_croak(aTHX_ "__DUMP__ not enabled in non-debug version"); #endif #line 3105 "C.c" ST(0) = RETVAL; sv_2mortal(ST(0)); } XSRETURN(1); } #ifdef __cplusplus extern "C" #endif XS(boot_Convert__Binary__C); /* prototype to pass -Wmissing-prototypes */ XS(boot_Convert__Binary__C) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif char* file = __FILE__; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XS_VERSION_BOOTCHECK ; { CV * cv ; newXSproto("Convert::Binary::C::new", XS_Convert__Binary__C_new, file, "$;@"); newXSproto("Convert::Binary::C::DESTROY", XS_Convert__Binary__C_DESTROY, file, "$"); newXSproto("Convert::Binary::C::clone", XS_Convert__Binary__C_clone, file, "$"); newXSproto("Convert::Binary::C::clean", XS_Convert__Binary__C_clean, file, "$"); newXSproto("Convert::Binary::C::configure", XS_Convert__Binary__C_configure, file, "$;@"); cv = newXS("Convert::Binary::C::Define", XS_Convert__Binary__C_Include, file); XSANY.any_i32 = 1 ; sv_setpv((SV*)cv, "$;@") ; cv = newXS("Convert::Binary::C::Include", XS_Convert__Binary__C_Include, file); XSANY.any_i32 = 0 ; sv_setpv((SV*)cv, "$;@") ; cv = newXS("Convert::Binary::C::Assert", XS_Convert__Binary__C_Include, file); XSANY.any_i32 = 2 ; sv_setpv((SV*)cv, "$;@") ; newXSproto("Convert::Binary::C::parse", XS_Convert__Binary__C_parse, file, "$$"); newXSproto("Convert::Binary::C::parse_file", XS_Convert__Binary__C_parse_file, file, "$$"); newXSproto("Convert::Binary::C::def", XS_Convert__Binary__C_def, file, "$$"); newXSproto("Convert::Binary::C::pack", XS_Convert__Binary__C_pack, file, "$$;$$"); newXSproto("Convert::Binary::C::unpack", XS_Convert__Binary__C_unpack, file, "$$$"); newXSproto("Convert::Binary::C::sizeof", XS_Convert__Binary__C_sizeof, file, "$$"); newXSproto("Convert::Binary::C::typeof", XS_Convert__Binary__C_typeof, file, "$$"); newXSproto("Convert::Binary::C::offsetof", XS_Convert__Binary__C_offsetof, file, "$$$"); newXSproto("Convert::Binary::C::member", XS_Convert__Binary__C_member, file, "$$;$"); cv = newXS("Convert::Binary::C::tag", XS_Convert__Binary__C_tag, file); XSANY.any_i32 = 0 ; sv_setpv((SV*)cv, "$$;@") ; cv = newXS("Convert::Binary::C::untag", XS_Convert__Binary__C_tag, file); XSANY.any_i32 = 1 ; sv_setpv((SV*)cv, "$$;@") ; newXSproto("Convert::Binary::C::enum_names", XS_Convert__Binary__C_enum_names, file, "$"); newXSproto("Convert::Binary::C::enum", XS_Convert__Binary__C_enum, file, "$;@"); cv = newXS("Convert::Binary::C::compound_names", XS_Convert__Binary__C_compound_names, file); XSANY.any_i32 = 0 ; sv_setpv((SV*)cv, "$") ; cv = newXS("Convert::Binary::C::struct_names", XS_Convert__Binary__C_compound_names, file); XSANY.any_i32 = 1 ; sv_setpv((SV*)cv, "$") ; cv = newXS("Convert::Binary::C::union_names", XS_Convert__Binary__C_compound_names, file); XSANY.any_i32 = 2 ; sv_setpv((SV*)cv, "$") ; cv = newXS("Convert::Binary::C::compound", XS_Convert__Binary__C_compound, file); XSANY.any_i32 = 0 ; sv_setpv((SV*)cv, "$;@") ; cv = newXS("Convert::Binary::C::union", XS_Convert__Binary__C_compound, file); XSANY.any_i32 = 2 ; sv_setpv((SV*)cv, "$;@") ; cv = newXS("Convert::Binary::C::struct", XS_Convert__Binary__C_compound, file); XSANY.any_i32 = 1 ; sv_setpv((SV*)cv, "$;@") ; newXSproto("Convert::Binary::C::typedef_names", XS_Convert__Binary__C_typedef_names, file, "$"); newXSproto("Convert::Binary::C::typedef", XS_Convert__Binary__C_typedef, file, "$;@"); newXSproto("Convert::Binary::C::sourcify", XS_Convert__Binary__C_sourcify, file, "$;@"); newXSproto("Convert::Binary::C::initializer", XS_Convert__Binary__C_initializer, file, "$$;$"); newXSproto("Convert::Binary::C::dependencies", XS_Convert__Binary__C_dependencies, file, "$"); newXSproto("Convert::Binary::C::defined", XS_Convert__Binary__C_defined, file, "$$"); newXSproto("Convert::Binary::C::macro_names", XS_Convert__Binary__C_macro_names, file, "$"); newXSproto("Convert::Binary::C::macro", XS_Convert__Binary__C_macro, file, "$;@"); newXSproto("Convert::Binary::C::arg", XS_Convert__Binary__C_arg, file, "$;@"); newXSproto("Convert::Binary::C::feature", XS_Convert__Binary__C_feature, file, ";@"); newXSproto("Convert::Binary::C::native", XS_Convert__Binary__C_native, file, ";@"); newXSproto("Convert::Binary::C::import", XS_Convert__Binary__C_import, file, ";@"); newXSproto("Convert::Binary::C::__DUMP__", XS_Convert__Binary__C___DUMP__, file, "$"); } /* Initialisation Section */ #line 463 "C.xs" { const char *str; PrintFunctions f; f.newstr = ct_newstr; f.destroy = ct_destroy; f.scatf = ct_scatf; f.vscatf = ct_vscatf; f.cstring = ct_cstring; f.fatalerr = ct_fatal; set_print_functions(&f); #ifdef CBC_DEBUGGING init_debugging(aTHX); if ((str = PerlEnv_getenv("CBC_DEBUG_OPT")) != NULL) set_debug_options(aTHX_ str); if ((str = PerlEnv_getenv("CBC_DEBUG_FILE")) != NULL) set_debug_file(aTHX_ str); #endif gs_DisableParser = 0; if ((str = PerlEnv_getenv("CBC_DISABLE_PARSER")) != NULL) gs_DisableParser = atoi(str); gs_OrderMembers = 0; if ((str = PerlEnv_getenv("CBC_ORDER_MEMBERS")) != NULL) { if (isDIGIT(str[0])) gs_OrderMembers = atoi(str); else if (isALPHA(str[0])) { gs_OrderMembers = 1; set_preferred_indexed_hash_module(str); } } } #line 3232 "C.c" /* End of Initialisation Section */ XSRETURN_YES; }