SOOT

 view release on metacpan or  search on metacpan

ROOT_XSP/TExec.xsp  view on Meta::CPAN

      else {
        RETVAL = new TExec(name, SvPV_nolen(command));
      }
    %};

%{

void
TExec::DESTROY(self)
    SV* self
  PPCODE:
    TObject* obj = SOOT::LobotomizeObject(aTHX_ self);
    if (SOOT::UnregisterObject(aTHX_ self)) {
      SOOT::ClearStoredPerlCallback(aTHX_ (unsigned long int)obj);
    }

%}

  void Exec(SV* command = NULL)
    %code{%
      if (command == NULL || command == &PL_sv_undef) {

ROOT_XSP/TF1.xsp  view on Meta::CPAN


class TF1 {
  TFormulaFloatArray GetParErrors();

// GetRandom optimization
%{

void
GetRandom(self, ...)
    SV* self;
  PPCODE:
    dXSTARG;
    TF1* fun = (TF1*)SOOT::LobotomizeObject(aTHX_ self); // note: could check classname...
    if (items == 1) {
      PUSHn(fun->GetRandom());
    }
    else if (items == 3) {
      PUSHn(fun->GetRandom(SvNV(ST(1)), SvNV(ST(2))));
    }
    else {
      croak("TF1::GetRandom takes either two or no arguments");

ROOT_XSP/TRandom.xsp  view on Meta::CPAN

  Double_t PoissonD(Double_t mean);
  Double_t Rndm(Int_t i = 0);

%{

void
Rannor(self)
    TRandom* self
  PREINIT:
    Double_t x, y;
  PPCODE:
    self->Rannor(x, y);
    mXPUSHn(x);
    mXPUSHn(y);
    XSRETURN(2);

%}

};

RunTimeXS/SOOT_RTXS_array.xs  view on Meta::CPAN

MODULE = SOOT        PACKAGE = SOOT::RTXS
PROTOTYPES: DISABLE


void
access_struct_array_Bool_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_IntegerConversion(Bool_t)

void
access_struct_array_Char_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_RTXS_CALCADDRESS_ARRAY
    if (items > 1) {
      // FIXME investigate null-padding issues. In general the Char_t[5] thingies might not need it
      size_t len;
      char* buf = SvPV(ST(1), len);
      if (idxdata.maxIndex < len)
        len = idxdata.maxIndex;
      strncpy( (char*)dataAddr, buf, len );
      ((char*)dataAddr)[len] = '\0'; // FIXME is this right?
    } else {

RunTimeXS/SOOT_RTXS_array.xs  view on Meta::CPAN

      ));
    }


void
access_struct_array_UChar_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_UIntegerConversion(UChar_t)

void
access_struct_array_Short_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_IntegerConversion(Short_t)

void
access_struct_array_UShort_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_UIntegerConversion(UShort_t)

void
access_struct_array_Int_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_IntegerConversion(Int_t)

void
access_struct_array_UInt_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_UIntegerConversion(UInt_t)

void
access_struct_array_Long_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_IntegerConversion(Long_t)

void
access_struct_array_ULong_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_UIntegerConversion(ULong_t)

void
access_struct_array_Long64_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_IntegerConversion(Long64_t)

void
access_struct_array_ULong64_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_UIntegerConversion(ULong64_t)

void
access_struct_array_Float_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_FloatConversion(Float_t)

void
access_struct_array_Double_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT_ARRAY
  PPCODE:
    SOOT_FloatConversion(Double_t)

#undef SOOT_ToFloatAV
#undef SOOT_ToUIntegerAV
#undef SOOT_ToIntegerAV
#undef SOOT_AVToIntegerAry
#undef SOOT_AVToUIntegerAry
#undef SOOT_AVToFloatAry
#undef SOOT_IntegerConversion
#undef SOOT_UIntegerConversion

RunTimeXS/SOOT_RTXS_scalar.xs  view on Meta::CPAN


MODULE = SOOT        PACKAGE = SOOT::RTXS
PROTOTYPES: DISABLE

void
access_struct_Bool_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Bool_t*)dataAddr) = (Bool_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Bool_t*)dataAddr))
      ));
    }

void
access_struct_Char_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Char_t*)dataAddr) = (Char_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Char_t*)dataAddr))
      ));
    }

void
access_struct_UChar_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((UChar_t*)dataAddr) = (UChar_t)SvUV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVuv((UV) *((UChar_t*)dataAddr))
      ));
    }

void
access_struct_Short_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Short_t*)dataAddr) = (Short_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Short_t*)dataAddr))
      ));
    }

void
access_struct_UShort_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((UShort_t*)dataAddr) = (UShort_t)SvUV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVuv((UV) *((UShort_t*)dataAddr))
      ));
    }

void
access_struct_Int_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Int_t*)dataAddr) = (Int_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Int_t*)dataAddr))
      ));
    }

void
access_struct_UInt_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((UInt_t*)dataAddr) = (UInt_t)SvUV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVuv((UV) *((UInt_t*)dataAddr))
      ));
    }

void
access_struct_Long_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Long_t*)dataAddr) = (Long_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Long_t*)dataAddr))
      ));
    }

void
access_struct_ULong_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((ULong_t*)dataAddr) = (ULong_t)SvUV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVuv((UV) *((ULong_t*)dataAddr))
      ));
    }

void
access_struct_Long64_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Long64_t*)dataAddr) = (Long64_t)SvIV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSViv((IV) *((Long64_t*)dataAddr))
      ));
    }

void
access_struct_ULong64_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((ULong64_t*)dataAddr) = (ULong64_t)SvUV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVuv((UV) *((ULong64_t*)dataAddr))
      ));
    }

void
access_struct_Float_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Float_t*)dataAddr) = (Float_t)SvNV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVnv((NV) *((Float_t*)dataAddr))
      ));
    }

void
access_struct_Double_t(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      SV* src = ST(1);
      *((Double_t*)dataAddr) = (Double_t)SvNV(src);
    } else {
      XPUSHs(sv_2mortal(
        newSVnv((NV) *((Double_t*)dataAddr))
      ));
    }

void
access_struct_CharStar(self, ...)
    SV* self;
  ALIAS:
  INIT:
    SOOT_RTXS_INIT
  PPCODE:
    SOOT_RTXS_CALCADDRESS
    if (items > 1) {
      // FIXME investigate null-padding issues. In general the Char_t[5] thingies might not need it
      char* buf = strdup(SvPV_nolen(ST(1)));
      free(*((char**)dataAddr));
      dataAddr = (void*)&buf;
    } else {
      XPUSHs(sv_2mortal(
        newSVpvn(*((char**)dataAddr), strlen(*((char**)dataAddr)))
      ));

SOOT.xs  view on Meta::CPAN

#include <vector>
#include <cstring>

using namespace SOOT;
using namespace std;

/*
// Broken due to bug in perl.
void
AUTOLOAD(...)
  PPCODE:
    SV* fullname = get_sv("AUTOLOAD", 0);
    if (fullname == 0 || !SvOK(fullname))
      croak("$AUTOLOAD undefined in AUTOLOAD");
    STRLEN len;
    char* strptr = SvPV(fullname, len);
    if (len < 2)
      croak("$AUTOLOAD is empty string in AUTOLOAD");
    char* lastcolon = strptr+len;
    for (; lastcolon != strptr; --lastcolon) {
      if (*lastcolon == ':')

SOOT.xs  view on Meta::CPAN

      const unsigned int len = classes.size();
      av_extend(av, len-1);
      for (unsigned int i = 0; i < len; ++i)
        av_store(av, i, newSVpv(classes[i].Data(), classes[i].Length()));
    }
  OUTPUT: RETVAL


void
GenerateClassStubs()
  PPCODE:
    SOOT::GenerateClassStubs(aTHX);


XS/SOOTAPI.xs  view on Meta::CPAN


MODULE = SOOT		PACKAGE = SOOT::API

void
type(sv)
    SV* sv
  INIT:
    SOOT::BasicType type;
  PPCODE:
    dXSTARG;
    type = GuessType(aTHX_ sv);
    const char* type_str = SOOT::gBasicTypeStrings[type];
    XPUSHp(type_str, strlen(type_str));


void
cproto(sv)
    SV* sv
  INIT:
    SOOT::BasicType type;
  PPCODE:
    dXSTARG;
    type = GuessType(aTHX_ sv);
    string cproto = CProtoFromType(aTHX_ sv, type);
    if (cproto.length() == 0)
      XPUSHs(&PL_sv_undef);
    else
      XPUSHp(cproto.c_str(), cproto.length());


void
is_same_object(obj1, obj2)
    SV* obj1
    SV* obj2
  PPCODE:
    if (SOOT::IsSameTObject(aTHX_ obj1, obj2))
      XSRETURN_YES;
    else
      XSRETURN_NO;


void
prevent_destruction(rootObject)
    SV* rootObject
  PPCODE:
    SOOT::PreventDestruction(aTHX_ rootObject);


void
print_ptrtable_state()
  PPCODE:
    gSOOTObjects->PrintStats();

void
is_soot_class(className)
    char* className
  PPCODE:
    string isROOTName = string(className) + string("isROOT");
    SV* isROOT = get_sv(isROOTName.c_str(), 0);
    if (isROOT == NULL)
      XSRETURN_NO;
    else
      XSRETURN_YES;


void
Cleanup()
  PPCODE:
    PtrTable* tmp = SOOT::gSOOTObjects;
    SOOT::gSOOTObjects = NULL;
    tmp->Clear();
    delete tmp;


XS/SOOTBOOT.xs  view on Meta::CPAN

  gSystem->Load("libPhysics");
  SOOT::gSOOTObjects = new SOOT::PtrTable(aTHX_ (UV)1024, &SOOT::ClearAnnotation);
  SOOT::GenerateClassStubs(aTHX);
  SOOT::InitializePerlGlobals(aTHX);

void
Init(int eval_macros = 0)
  INIT:
    static bool initialized = false;
    static bool initialized_macros = false;
  PPCODE:
    if (!initialized) {
      gROOT->ProcessLine("#include <iostream>");
      gROOT->ProcessLine("#include <iomanip>");
      gROOT->ProcessLine("#include <sstream>");
      gROOT->ProcessLine("#include <vector>");
      gROOT->ProcessLine("#include <map>");
      gROOT->ProcessLine("#include <string>");
      gROOT->ProcessLine("using namespace std;");
      initialized = true;
    }

XS/TObject.xs  view on Meta::CPAN

### NOTE: Any stuff you want to have all SOOT classes needs to be added to ClassGenerator, too

MODULE = SOOT		PACKAGE = TObject

void
DESTROY(self)
    SV* self
  PPCODE:
    SOOT::UnregisterObject(aTHX_ self);


SV*
as(self, newType)
    SV* self
    const char* newType
  CODE:
    RETVAL = SOOT::RegisterObject(aTHX_ self, newType);
  OUTPUT: RETVAL

XS/TObject.xs  view on Meta::CPAN

  CODE:
    SOOT::PreventDestruction(aTHX_ self);
    SvREFCNT_inc(self);
    RETVAL = self;
  OUTPUT: RETVAL


void
delete(self)
    SV* self
  PPCODE:
    SOOT::MarkForDestruction(aTHX_ self);
    SvREFCNT_dec(self);



####### FIXME The following is a super-evil workaround for the "type enum" bug, so that users can at least do GetXaxis()->as("TAxis")!

MODULE = SOOT		PACKAGE = enum

void
DESTROY(self)
    SV* self
  PPCODE:
    SOOT::UnregisterObject(aTHX_ self);


SV*
as(self, newType)
    SV* self
    const char* newType
  CODE:
    RETVAL = SOOT::RegisterObject(aTHX_ self, newType);
  OUTPUT: RETVAL

XS/TObject.xs  view on Meta::CPAN

  CODE:
    SOOT::PreventDestruction(aTHX_ self);
    SvREFCNT_inc(self);
    RETVAL = self;
  OUTPUT: RETVAL


void
delete(self)
    SV* self
  PPCODE:
    SOOT::MarkForDestruction(aTHX_ self);
    SvREFCNT_dec(self);

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS.pm  view on Meta::CPAN

        $self->{defaults}->{$args[$i]} =~ s/"/\\"/g;
      }
      $self->{proto_arg}->[$i+1] = '$';
    }
    my $min_args = $num_args - $extra_args;
    $report_args =~ s/"/\\"/g;
    $report_args =~ s/^,\s+//;
    $self->{func_args} = assign_func_args($self, \@args, $class);
    @{ $self->{args_match} }{@args} = @args_num;

    my $PPCODE = grep(/^\s*PPCODE\s*:/, @{ $self->{line} });
    my $CODE = grep(/^\s*CODE\s*:/, @{ $self->{line} });
    # Detect CODE: blocks which use ST(n)= or XST_m*(n,v)
    # to set explicit return values.
    my $EXPLICIT_RETURN = ($CODE &&
            ("@{ $self->{line} }" =~ /(\bST\s*\([^;]*=) | (\bXST_m\w+\s*\()/x ));

    # The $ALIAS which follows is only explicitly called within the scope of
    # process_file().  In principle, it ought to be a lexical, i.e., 'my
    # $ALIAS' like the other nearby variables.  However, implementing that
    # change produced a slight difference in the resulting .c output in at

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS.pm  view on Meta::CPAN

#       croak_xs_usage(cv,  "$report_args");
EOF
    }
    else {
    # cv likely to be unused
    print Q(<<"EOF");
#    PERL_UNUSED_VAR(cv); /* -W */
EOF
    }

    #gcc -Wall: if an xsub has PPCODE is used
    #it is possible none of ST, XSRETURN or XSprePUSH macros are used
    #hence `ax' (setup by dXSARGS) is unused
    #XXX: could breakup the dXSARGS; into dSP;dMARK;dITEMS
    #but such a move could break third-party extensions
    print Q(<<"EOF") if $PPCODE;
#    PERL_UNUSED_VAR(ax); /* -Wall */
EOF

    print Q(<<"EOF") if $PPCODE;
#    SP -= items;
EOF

    # Now do a block of some sort.

    $self->{condnum} = 0;
    $self->{cond} = '';            # last CASE: conditional
    push(@{ $self->{line} }, "$END:");
    push(@{ $self->{line_no} }, $self->{line_no}->[-1]);
    $_ = '';

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS.pm  view on Meta::CPAN

        if (@fake_INPUT or @fake_INPUT_pre) {
          unshift @{ $self->{line} }, @fake_INPUT_pre, @fake_INPUT, $_;
          $_ = "";
          $self->{processing_arg_with_types} = 1;
          $self->INPUT_handler($_);
        }
        print $self->{deferred};

        $self->process_keyword("INIT|ALIAS|ATTRS|PROTOTYPE|INTERFACE_MACRO|INTERFACE|C_ARGS|OVERLOAD");

        if ($self->check_keyword("PPCODE")) {
          $self->print_section();
          $self->death("PPCODE must be last thing") if @{ $self->{line} };
          print "\tLEAVE;\n" if $self->{ScopeThisXSUB};
          print "\tPUTBACK;\n\treturn;\n";
        }
        elsif ($self->check_keyword("CODE")) {
          $self->print_section();
        }
        elsif (defined($class) and $func_name eq "DESTROY") {
          print "\n\t";
          print "delete THIS;\n";
        }

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS.pm  view on Meta::CPAN

        do_setmagic => 0,
        do_push     => 1,
      } ) for @{ $outlist_ref };

      # do cleanup
      $self->process_keyword("CLEANUP|ALIAS|ATTRS|PROTOTYPE|OVERLOAD");

      print Q(<<"EOF") if $self->{ScopeThisXSUB};
#   ]]
EOF
      print Q(<<"EOF") if $self->{ScopeThisXSUB} and not $PPCODE;
#   LEAVE;
EOF

      # print function trailer
      print Q(<<"EOF");
#    ]]
EOF
      print Q(<<"EOF") if $self->{except};
#    BEGHANDLERS
#    CATCHALL

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS.pm  view on Meta::CPAN

      last if $_ eq "$END:";
      $self->death(/^$self->{BLOCK_re}/o ? "Misplaced `$1:'" : "Junk at end of function ($_)");
    }

    print Q(<<"EOF") if $self->{except};
#    if (errbuf[0])
#    Perl_croak(aTHX_ errbuf);
EOF

    if ($xsreturn) {
      print Q(<<"EOF") unless $PPCODE;
#    XSRETURN($xsreturn);
EOF
    }
    else {
      print Q(<<"EOF") unless $PPCODE;
#    XSRETURN_EMPTY;
EOF
    }

    print Q(<<"EOF");
#]]
#
EOF

    $self->{newXS} = "newXS";

inc/inc_ExtUtils-ParseXS/ExtUtils/ParseXS/Constants.pm  view on Meta::CPAN


=cut

# FIXME: THESE ARE NOT CONSTANTS!
our @InitFileCode;

# Note that to reduce maintenance, $PrototypeRegexp is used
# by ExtUtils::Typemaps, too!
our $PrototypeRegexp = "[" . quotemeta('\$%&*@;[]_') . "]";
our @XSKeywords      = qw( 
  REQUIRE BOOT CASE PREINIT INPUT INIT CODE PPCODE
  OUTPUT CLEANUP ALIAS ATTRS PROTOTYPES PROTOTYPE
  VERSIONCHECK INCLUDE INCLUDE_COMMAND SCOPE INTERFACE
  INTERFACE_MACRO C_ARGS POSTCALL OVERLOAD FALLBACK
);

1;

inc/inc_ExtUtils-XSpp/ExtUtils/XSpp/Node/Function.pm  view on Meta::CPAN

  # special case: constructors with name different from 'new'
  # need to be declared 'static' in XS
  if( $this->isa( 'ExtUtils::XSpp::Node::Constructor' ) &&
      $this->perl_name ne $this->cpp_name ) {
    $retstr = "static $retstr";
  }

  my $has_ret = $ret_typemap && !$ret_typemap->type->is_void;

  my $ppcode = $has_ret && $ret_typemap->output_list( '' ) ? 1 : 0;
  my $code_type = $ppcode ? "PPCODE" : "CODE";
  my $ccode = $this->_call_code( $call_arg_list );
  if ($this->isa('ExtUtils::XSpp::Node::Destructor')) {
    $ccode = 'delete THIS';
    $has_ret = 0;
  } elsif( $has_ret && defined $ret_typemap->call_function_code( '', '' ) ) {
    $ccode = $ret_typemap->call_function_code( $ccode, 'RETVAL' );
  } elsif( $has_ret ) {
    $ccode = "RETVAL = $ccode";
  }



( run in 1.364 second using v1.01-cache-2.11-cpan-5511b514fd6 )