Skip to content

Commit

Permalink
Replace long obsolete sub native trick
Browse files Browse the repository at this point in the history
Ever since we got support for %?RESOURCES, there has not been a need for a
"native" sub containing logic to find the library. Perl 6 finds it for us :)
  • Loading branch information
niner committed Jan 29, 2017
1 parent 1ecd114 commit fdf275b
Showing 1 changed file with 46 additions and 52 deletions.
98 changes: 46 additions & 52 deletions lib/Inline/Python.pm6
Expand Up @@ -7,13 +7,7 @@ has &!call_method;

use NativeCall;

sub native(Sub $sub) {
my Str $path = %?RESOURCES<libraries/pyhelper>.Str;
unless $path {
die "unable to find pyhelper library";
}
trait_mod:<is>($sub, :native($path));
}
my constant $pyhelper = %?RESOURCES<libraries/pyhelper>.Str;

class PythonObject { ... }
role PythonParent { ... }
Expand Down Expand Up @@ -46,141 +40,141 @@ class ObjectKeeper {
}

sub py_init_python(&call_object (int32, Pointer, Pointer --> Pointer), &call_method (int32, Str, Pointer, Pointer --> Pointer))
is native($pyhelper)
{ ... }
native(&py_init_python);
sub py_init_perl6object()
is native($pyhelper)
{ ... }
native(&py_init_perl6object);
sub py_eval(Str, int32)
is native($pyhelper)
returns Pointer { ... }
native(&py_eval);
sub py_import(Str)
returns Pointer
is native($pyhelper)
{ ... }
native(&py_import);
sub py_instance_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_instance_check);
sub py_is_instance(Pointer, Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_is_instance);
sub py_int_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_int_check);
sub py_float_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_float_check);
sub py_unicode_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_unicode_check);
sub py_ascii_string_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_ascii_string_check);
sub py_string_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_string_check);
sub py_sequence_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_sequence_check);
sub py_mapping_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_mapping_check);
sub py_callable_check(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_callable_check);
sub py_is_none(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_is_none);
sub py_int_as_long(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_int_as_long);
sub py_int_to_py(int32)
is native($pyhelper)
returns Pointer { ... }
native(&py_int_to_py);
sub py_float_as_double(Pointer)
is native($pyhelper)
returns num64 { ... }
native(&py_float_as_double);
sub py_float_to_py(num64)
is native($pyhelper)
returns Pointer { ... }
native(&py_float_to_py);
sub py_unicode_as_utf8_string(Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_unicode_as_utf8_string);
sub py_string_as_string(Pointer)
is native($pyhelper)
returns Str { ... }
native(&py_string_as_string);
sub py_string_to_buf(Pointer, CArray[CArray[int8]])
is native($pyhelper)
returns int32 { ... }
native(&py_string_to_buf);
sub py_str_to_py(int32, Str)
is native($pyhelper)
returns Pointer { ... }
native(&py_str_to_py);
sub py_buf_to_py(int32, Blob)
is native($pyhelper)
returns Pointer { ... }
native(&py_buf_to_py);
sub py_tuple_new(int32)
is native($pyhelper)
returns Pointer { ... }
native(&py_tuple_new);
sub py_tuple_set_item(Pointer, int32, Pointer)
is native($pyhelper)
{ ... }
native(&py_tuple_set_item);
sub py_list_new(int32)
is native($pyhelper)
returns Pointer { ... }
native(&py_list_new);
sub py_list_set_item(Pointer, int32, Pointer)
is native($pyhelper)
{ ... }
native(&py_list_set_item);
sub py_dict_new()
is native($pyhelper)
returns Pointer { ... }
native(&py_dict_new);
sub py_dict_set_item(Pointer, Pointer, Pointer)
is native($pyhelper)
{ ... }
native(&py_dict_set_item);
sub py_call_function(Str, Str, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_function);
sub py_call_function_kw(Str, Str, Pointer, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_function_kw);
sub py_call_static_method(Str, Str, Str, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_static_method);
sub py_call_static_method_kw(Str, Str, Str, Pointer, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_static_method_kw);
sub py_call_method(Pointer, Str, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_method);
sub py_call_method_kw(Pointer, Str, Pointer, Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_call_method_kw);
sub py_sequence_length(Pointer)
is native($pyhelper)
returns int32 { ... }
native(&py_sequence_length);
sub py_sequence_get_item(Pointer, int32)
is native($pyhelper)
returns Pointer { ... }
native(&py_sequence_get_item);
sub py_mapping_items(Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_mapping_items);
sub py_none()
is native($pyhelper)
returns Pointer { ... }
native(&py_none);
sub py_dec_ref(Pointer)
is native($pyhelper)
{ ... }
native(&py_dec_ref);
sub py_inc_ref(Pointer)
is native($pyhelper)
{ ... }
native(&py_inc_ref);
sub py_getattr(Pointer, Str)
is native($pyhelper)
returns Pointer { ... }
native(&py_getattr);
sub py_dir(Pointer)
is native($pyhelper)
returns Pointer { ... }
native(&py_dir);
sub py_fetch_error(CArray[Pointer])
is native($pyhelper)
{ ... }
native(&py_fetch_error);

method py_dec_ref(Pointer $obj) {
py_dec_ref($obj);
Expand Down

0 comments on commit fdf275b

Please sign in to comment.