Skip to content

Instantly share code, notes, and snippets.

package MyRect;
use base 'SDL::Rect';
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
unless (ref $self) {
require Carp;
Carp::croak SDL::GetError();
}
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 723914c..69677bb 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -145,6 +145,26 @@ XXX
=item *
+L<ExtUtils::ParseXS> has been upgraded from version XXX to version XXX.
+
diff --git a/pod/perlxs.pod b/pod/perlxs.pod
index 1eccb49..e5077a8 100644
--- a/pod/perlxs.pod
+++ b/pod/perlxs.pod
@@ -540,6 +540,25 @@ not care about its initial contents.
OUTPUT:
timep
+=head2 The TYPEMAP: Keyword
+
use strict; use warnings;
use Math::SimpleHisto::XS;
use SOOT qw/:all/;
my $nbins = 10000;
my $starttime = -7200.;
my $endtime = 0.;
my $hs = Math::SimpleHisto::XS->new(nbins => $nbins, min => $starttime, max => $endtime);
my @data = (
use strict;
use warnings;
my @data = (
{end => 1000, duration => 100, records => 100},
{end => 1600, duration => 300, records => 400},
{end => 1200, duration => 150, records => 50},
{end => 1300, duration => 500, records => 900},
);
my $time_start = 500;
use strict;
use warnings;
use Data::Dumper;
use List::Util qw(min max);
my $code = do {local $/; <DATA>};
my %data_hash = eval $code;
my $data = $data_hash{SessionVisitor};
# simple preprocessing step, so we can easily plugin different source data
=head2 Sharing typemaps Between CPAN Distributions
Starting with ExtUtils::ParseXS version 3.12 (comes with perl 5.16
and better), it is rather easy to share typemap code between multiple
CPAN distributions. The general idea is to share it as a module that
offers a certain API and have the dependent modules declare that as a
built-time requirement and import the typemap into the XS. An example
of such a typemap-sharing module on CPAN is
C<ExtUtils::Typemaps::Basic>. Two steps to getting that module's
typemaps available in your code:
PERL_DL_NONLAZY=1 /usr/local/booking-perl/5.8.5/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/001_load.........ok
t/002_constants....ok
t/003_ptable.......ok
t/010_desperate....
# Failed test '(plain) correct: blessed regexp with reuse'
# at t/010_desperate.t line 47.
# got: '"=srl\1\0B,cbar(\245)\r"'
# expected: '"=srl\1\0B,cbar(\261cfoobix)\r"'
@tsee
tsee / terrain.h
Created April 25, 2013 17:53
terrain.h - a naive C implementation
#define NW 0
#define NE 1
#define SW 2
#define SE 3
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <EXTERN.h>
#!perl
# Large data structure results
# $ perl bench.pl
# 2902
# 2653
# 3941
# Benchmark: timing 500000 iterations of json decode, json encode, mp decode, mp encode, sereal decode, sereal encode...
# json decode: 22 wallclock secs (22.31 usr + 0.00 sys = 22.31 CPU) @ 22411.47/s (n=500000)
# json encode: 12 wallclock secs (10.96 usr + 0.00 sys = 10.96 CPU) @ 45620.44/s (n=500000)