Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
repair mangling tests and add one
  • Loading branch information
sergot committed Feb 24, 2015
1 parent 5057b18 commit dd53c36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 2 additions & 5 deletions lib/NativeCall.pm
Expand Up @@ -474,12 +474,9 @@ sub cpp_param_letter($type, :$R = '', :$P = '', :$K = '') {
#~ $R ~ 'e'
#~ }
when Str {
'Rc'
'Pc'
}
when CArray {
'R' ~ $K ~ cpp_param_letter(.of);
}
when Pointer {
when CArray | Pointer {
'P' ~ $K ~ cpp_param_letter(.of);
}
default {
Expand Down
3 changes: 2 additions & 1 deletion t/04-nativecall/13-cpp-mangling.cpp
Expand Up @@ -20,7 +20,8 @@ class Foo {
virtual int TakeAFloat(float i) { return 7; }
virtual int TakeADouble(double i) { return 8; }
virtual int TakeAString(char *i) { return 9; }
virtual int TakeAnArray(int *i) { return 10; }
virtual int TakeAnArray(int i[]) { return 10; }
virtual int TakeAPointer(void *i) { return 11; }
};

Foo::Foo(){};
Expand Down
8 changes: 5 additions & 3 deletions t/04-nativecall/13-cpp-mangling.t
Expand Up @@ -2,7 +2,7 @@ use v6;
use NativeCall;
use Test;

plan 8;
plan 11;

shell 'g++ --shared -fPIC -o 13-cpp-mangling.so t/04-nativecall/13-cpp-mangling.cpp';

Expand All @@ -21,6 +21,7 @@ class Foo is repr<CPPStruct> {
method TakeADouble(num64) returns int32 is native("./13-cpp-mangling") { * };
method TakeAString(Str) returns int32 is native("./13-cpp-mangling") { * };
method TakeAnArray(CArray[int32]) returns int32 is native("./13-cpp-mangling") { * };
method TakeAPointer(Pointer) returns int32 is native("./13-cpp-mangling") { * };
}

my $foo = Foo.new;
Expand All @@ -34,6 +35,7 @@ is $foo.TakeALong(1), 5, 'long mangling';
is $foo.TakeALongLong(1), 6, 'long long mangling';
is $foo.TakeAFloat(5e0), 7, 'float mangling';
is $foo.TakeADouble(6e0), 8, 'double mangling';
#is $foo.TakeAString("1"), 9, 'string mangling';
#is $foo.TakeAnArray(CArray[int32].new), 10, 'CArray mangling';
is $foo.TakeAString("1"), 9, 'string mangling';
is $foo.TakeAnArray(CArray[int32].new), 10, 'CArray mangling';
is $foo.TakeAPointer, 11, 'Pointer mangling';
# TODO : add more

0 comments on commit dd53c36

Please sign in to comment.