Fl

 view release on metacpan or  search on metacpan

xs/Fl_cxx.template  view on Meta::CPAN

XS_EUPXS({{cpp.function.name}}) {
    dVAR; dXSARGS;{%for definition in method.definitions %}
{%
    assign size.req  = definition.required | size %}{%
    assign size.opt  = definition.optional | size %}{%
    unless class.package == 'Fl' %}{%
        assign is_method = 1 %}{% else %}{%
        assign is_method = 0 %}{%
    endunless%}
    {%if is_method%}{%assign size.req = size.req | plus:1 %}{%endif%}
 // is_method   = {{is_method}}
 // size.req    = {{size.req}}
 // st.position = {{st.position}}

    {%unless forloop.first%}else {%endunless%}if (items {%if size.opt%}>{%else%}={%endif%}= {{ size.req }}{% if size.opt %} && items < {{ size.req | plus: size.opt | plus: is_method }}{% endif %}{%if definition.andif %} && {{definition.andif}}{% endi...
        {%if definition.required %}
        // Required
        {% for arg in definition.required %}
        {%if is_method%}{%assign st.position = forloop.index%}{%else%}{%assign st.position = forloop.index0%}{%endif%}
        // st.position = {{st.position}}
        // .index       = {{forloop.index}}
        // .index0      = {{forloop.index0}}
        // {{arg | join:' '}}
        {%case arg.0%}
        {%when 'uchar'                          %}{{arg | join: ' '}} = (unsigned char)SvUV(ST({{st.position}}));
        {%when 'const char *'                   %}{{arg | join: ' '}} = ({{arg.0}})SvPV_nolen(ST({{st.position}}));
        {%when 'SV *'                           %}{{arg | join: ' '}} = (SV *)ST({{st.position}});
        {%when 'CV *'                           %}{{arg | join: ' '}}; 	STMT_START {
                HV *st; GV *gvp;
                SV * const xsub_tmp_sv = ST({{st.position}});
                SvGETMAGIC(xsub_tmp_sv);
                {{arg.1}} = sv_2cv(xsub_tmp_sv, &st, &gvp, 0);
                if (!{{arg.1}})
                    croak("We were expecting {{arg.1}} to be a CODE reference!");
        } STMT_END;
        {%when 'AV *'                           %}{{arg | join: ' '}}; STMT_START {
            SV* const xsub_tmp_sv = ST({{st.position}});
            SvGETMAGIC(xsub_tmp_sv);
            if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV)
                {{arg.0}} = (AV*)SvRV(xsub_tmp_sv);
            else
                croak("{{arg.0}} is not an ARRAY reference");
            }
        } STMT_END;
        {%when 'HV *'               %}{{arg | join: ' '}}; STMT_START {
            SV* const xsub_tmp_sv = ST({{st.position}});
            SvGETMAGIC(xsub_tmp_sv);
            if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV)
                {{arg.0}} = (HV*)SvRV(xsub_tmp_sv);
            else
                croak("{{arg.0}} is not an HASH reference");
            }
        } STMT_END;
        {%when 'Fl_Widget *' %}CTX * /*{{arg.0 | split: ' ' | first | replace: '_', '__'}}*/ {{arg.1}};
        if ( sv_isobject( ST({{st.position}}) ) || ( SvTYPE( SvRV( ST({{st.position}}) ) ) == SVt_PVMG ) ) {
            IV tmp = SvIV((SV*)SvRV(ST({{st.position}})));
            {{arg.1}} = INT2PTR(CTX * /*{{ arg.0 | split:' ' | first | replace:'_', '__'}}*/, tmp);
        }
        else
            croak("Expected object. Got a non-object?!");
        {%when 'Fl_Menu_Item *' %}CTX * /*{{arg.0 | replace: '_', | replace_first: 'Fl', 'Fl__' | replace: '\*',}}*/ {{arg.1}};
        if ( sv_isobject( ST({{st.position}}) ) || ( SvTYPE( SvRV( ST({{st.position}}) ) ) == SVt_PVMG ) ) {
            IV tmp = SvIV((SV*)SvRV(ST({{st.position}})));
            {{arg.1}} = INT2PTR(CTX */*{{ arg.0 | split:' ' | first | replace: '_', | replace_first: 'Fl', 'Fl__'}}*/, tmp);
        }
        else
            croak("Expected object. Got a non-object?!");
        {%when 'int'         %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'short'       %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'float'       %}{{arg | join: ' '}} = ({{arg.0}})SvNV(ST({{st.position}}));
        {%when 'double'      %}{{arg | join: ' '}} = ({{arg.0}})SvNV(ST({{st.position}}));
        {%when 'FILE'        %}{{arg | join: ' '}} = PerlIO_findFILE(IoIFP(sv_2io(ST({{st.position}}))));
        {%when 'PerlIO *'    %}{{arg | join: ' '}} = IoIFP(sv_2io(ST({{st.position}})));
        {%when 'Fl_Fontsize' %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Font'     %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Color'    %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Align'    %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Char'     %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_When'     %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Labeltype'  %}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%when 'Fl_Boxtype'%}{{arg | join: ' '}} = ({{arg.0}})SvIV(ST({{st.position}}));
        {%endcase%}{% endfor %}{% endif %}
    {%if size.opt %}
        // Optional{% for arg in definition.optional %}
        {%assign position = forloop.index0 %}
        // position  = {{position}}            | {{position}} + {{size.req}} = {{ position | plus: size.req}} {{ 99 | plus : 30000000 }}
        // .index       = {{forloop.index}}
        // .index0      = {{forloop.index0}}
        // size.req     = {{size.req }}
        // {{size.req | plus: position | minus:1}}
        // {{arg}}

        {{arg.0}} {{arg.1}}; // {{size.req}} | {{position}}
        if (items > {{size.req | plus: position}}) // OY! {{ size.req | plus: position | minus: 1 }}
            {{arg.1}} = {%case arg.0%}
            {%when 'bool'           %}({{arg.0}}) SvTRUE(ST({{    size.req | plus: position }}));
            {%when 'uchar'          %}(unsigned char) SvUV(ST({{  size.req | plus: position }}));
            {%when 'unsigned int'   %}(unsigned int) SvUV(ST({{   size.req | plus: position }}));
            {%when 'const char *'   %}({{arg.0}}) SvPV_nolen(ST({{size.req | plus: position }}));
            {%when 'int'            %}({{arg.0}}) SvIV(ST({{      size.req | plus: position }}));
            {%when 'short'          %}({{arg.0}}) SvIV(ST({{      size.req | plus: position }}));
            {%when 'double'         %}({{arg.0}}) SvNV(ST({{      size.req | plus: position }}));
            {%when 'float'          %}({{arg.0}}) SvNV(ST({{      size.req | plus: position }}));
            {%when 'FILE'           %} PerlIO_findFILE(IoIFP(sv_2io(ST({{size.req | plus: position }}))));
            {%when 'Fl_Color'       %}({{arg.0}}) SvIV(ST({{      size.req | plus: position }}));
            {%when 'Fl_Char'        %}({{arg.0}}) SvIV(ST({{      size.req | plus: position }}));
            {%when 'Fl_Labeltype'   %}({{arg.0}}) SvIV(ST({{      size.req | plus: position }}));
            {%else                  %}({{arg.0}}) (ST({{          size.req | plus: position }}));
            {%endcase%}
        {%if arg.2%}else
            {{arg.1}} = {{arg.2}};{%endif%}{%
    endfor %}{%endif%}
{%comment%}/standard init{%endcomment%}
        {% case function %}
            {% when 'new' %}
            {%assign class.widget_type = definition.returns | split:' ' | first %}
        CTX * ctx;
        Newx(ctx, 1, CTX);

        const char * package = (const char *) SvPV_nolen(ST(0));
        {{assignments}}

xs/Fl_cxx.template  view on Meta::CPAN

            ((WidgetSubclass<{%if class.widget_type%}{{class.widget_type}}{%else%}{{class.package | replace:'::','_'}}{%endif%}> *)self->cp_ctx)->draw( TRUE );
                {% when 'handle' %}
                    {%assign xs.return = 'XSRETURN(1);' %}
        if (self->cp_ctx != NULL)
            RETVAL = ((WidgetSubclass<{%if class.widget_type%}{{class.widget_type}}{%else%}{{class.package | replace:'::','_'}}{%endif%}> *)self->cp_ctx)->handle( TRUE, {{args}} );
                {%else%}
                    {%unless definition.returns %}
                         {%assign xs.return = 'XSRETURN_EMPTY' %}
                    {%else%}
                        {%assign xs.return = 'XSRETURN(1);' %}
                    {%endunless%}
            {% if definition.code %}
                { {{definition.code}} }
            {% else %}
                {% if definition.returns and definition.returns != 'void' %}RETVAL = {%endif%} // {{ class.package }} | {{ class.widget_type }}
                {%if is_method%}((WidgetSubclass<{%if class.widget_type%}{{class.widget_type}}{%else%}{{class.package | replace:'::','_'}}{%endif%}> *)self->cp_ctx)->{{ function }}{%
                else        %}{{ function }}{%
                endif%}( {{args}} );
            {%endif%}
            {% endcase %}
                {% if definition.returns %}
                {%case definition.returns %}
                    {%when 'void'              %}{% assign xs.return = 'XSRETURN_EMPTY;' %}
                    {%when 'double'            %}XSprePUSH; PUSHn((double)RETVAL);
                    {%when 'char *'            %}PUSHp(RETVAL, STRLEN);
                    {%when 'const char *'      %}sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
                    {%when 'unsigned int'      %}XSprePUSH; PUSHu((UV)RETVAL);
                    {%when 'bool'              %}boolSV(RETVAL);
                    {%when 'int'               %}XSprePUSH; PUSHi((IV)RETVAL);
                    {%when 'short'             %}XSprePUSH; PUSHi((IV)RETVAL);
                    {%when 'Fl_Widget *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'Fl_Group *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'Fl_Window *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'Fl_Menu_Button *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;
                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'const Fl_Menu_Item *' %}
                        CTX * ctx;
                        Newx(ctx, 1, CTX);
                        ctx->cp_ctx    = (Fl_Widget *) RETVAL;

                        {
                            SV * RETVALSV;
                            RETVALSV = sv_newmortal();
                            sv_setref_pv(RETVALSV, object2package(ctx), (void*)ctx);
                            ST(0) = RETVALSV;
                        }
                    {%when 'CV *'     %}SV * RETVALSV; RETVALSV = newRV((SV*)RETVAL); RETVALSV = sv_2mortal(RETVALSV); ST(0) = RETVALSV;
                    {%when 'AV *'     %}SV * RETVALSV; RETVALSV = newRV((SV*)RETVAL); RETVALSV = sv_2mortal(RETVALSV); ST(0) = RETVALSV;
                    {%when 'HV *'     %}SV * RETVALSV; RETVALSV = newRV((SV*)RETVAL); RETVALSV = sv_2mortal(RETVALSV); ST(0) = RETVALSV;
                    {%else %}XSprePUSH; PUSHi((IV)RETVAL); // {{definition.returns}}
                {%endcase%}
                {%endif%}
        {% endcase %}
        {{definition.cleanup}}
        {{ xs.return }};
    }{%endfor%}
    else
        croak("TODO: Improve usage info! {%if is_method%}{%if function == 'new'%}{{ class.package }}{%else%}${{class.package | split:'::' | last | downcase }}{%endif%}->{%endif%}{{ function }}( ... );");
}
{% endfor %}
#undef PKG_{{ class.package | replace: "::", "_" | upcase }}
/* /package {{class.package}};  */
{%endfor%}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Fl); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Fl)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
    char* file = (char *) __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

    /* Initialisation Section */

    /* Setup! */
    Fl_stash  = gv_stashpv( "Fl", TRUE );



( run in 0.529 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )