Skip to content

Commit

Permalink
More OO Changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpalmer committed Oct 3, 2010
1 parent b526638 commit baff871
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
27 changes: 19 additions & 8 deletions Julia.xs
Expand Up @@ -69,17 +69,28 @@ julia_DESTROY(j)
free(j);

unsigned int
julia_set_max_iter(myclass, max_iter)
julia_set_max_iter(self, max_iter)
SV * self
unsigned int max_iter
PREINIT:
char* CLASS = "Math::Fractal::Julia";
INIT:
Math_Fractal_Julia *j;

if (sv_isobject(self) && sv_derived_from(self, CLASS)) {
j = self;
} else {
dMY_CXT;
j = &MY_CXT.julia;
}
CODE:
dMY_CXT;
MY_CXT.julia.max_iter = max_iter;
RETVAL = MY_CXT.julia.max_iter;
j->max_iter = max_iter;
RETVAL = j->max_iter;
OUTPUT:
RETVAL

double
julia_set_limit(myclass, limit)
julia_set_limit(self, limit)
double limit
CODE:
dMY_CXT;
Expand All @@ -89,7 +100,7 @@ julia_set_limit(myclass, limit)
RETVAL

void
julia_set_bounds(myclass, x_min, y_min, x_max, y_max, width, height)
julia_set_bounds(self, x_min, y_min, x_max, y_max, width, height)
double x_min
double y_min
double x_max
Expand All @@ -106,7 +117,7 @@ julia_set_bounds(myclass, x_min, y_min, x_max, y_max, width, height)
MY_CXT.julia.height = height;

void
julia_set_constant(myclass, x, y)
julia_set_constant(self, x, y)
double x
double y
CODE:
Expand All @@ -115,7 +126,7 @@ julia_set_constant(myclass, x, y)
MY_CXT.julia.y_const = y;

unsigned int
julia_point(myclass, x, y)
julia_point(self, x, y)
unsigned int x
unsigned int y
INIT:
Expand Down
9 changes: 8 additions & 1 deletion t/Math-Fractal-Julia.t
@@ -1,7 +1,7 @@
use strict;
use warnings;

use Test::More tests => 3;
use Test::More tests => 5;
BEGIN { use_ok('Math::Fractal::Julia') }

can_ok( 'Math::Fractal::Julia',
Expand All @@ -14,3 +14,10 @@ eval {
if ($@) {
fail('Math::Fractal::Julia->new()');
}

my $julia = Math::Fractal::Julia->new();

isa_ok($julia, 'Math::Fractal::Julia');

is($julia->set_max_iter(4), 4);

15 changes: 14 additions & 1 deletion typemap
@@ -1,2 +1,15 @@
TYPEMAP
Math_Fractal_Julia * T_PTROBJ
Math_Fractal_Julia * T_PTROBJ_SPECIAL

INPUT
T_PTROBJ_SPECIAL
if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\")

OUTPUT
T_PTROBJ_SPECIAL
sv_setref_pv($arg, CLASS, (void*)$var);

0 comments on commit baff871

Please sign in to comment.