Name

SPVM::Native::MethodCall - Method Call

Description

The Native::MethodCall class of SPVM has methods to call methods.

Usage

use Native::MethodCall;

my $class_method_call = Native::MethodCall->new_class_method("Point", "new");

my $point = (Point)$class_method_call->call([(object)1, 2]);

say $point->x;

say $point->y;

Class Methods

new_class_method

static method new_class_method : Native::MethodCall ($basic_type_name : string, $method_name : string);

Create a class method call given the basic type name $basic_type_name and the method name $method_name and returns it.

new_instance_method_static

static method new_instance_method_static : Native::MethodCall ($basic_type_name : string, $method_name : string);

Create a instance method call given the basic type name $basic_type_name and the method name $method_name, and returns it.

new_instance_method

static method new_instance_method : Native::MethodCall ($instance : object, $method_name : string);

Create a instance method call given the instance $instance and the method name $method_name, and returns it.

call_callback

static method call_callback : void ($callback : Callback, $error_id : int*, $stack = undef : Native::Stack);

Calls a callback with a stack. If $stack is not defined, the current stack is used.

The stack is a Native::Stack object.

The callback is a Callback object.

If the callback throw exception, the error id is set to $error_id. Otherwise 0 is set to $error_id.

call_class_method_for_env

static method call_class_method_for_env : void ($basic_type_name : string, $method_name : string, $error_id : int*, $stack : Native::Stack = undef, $env : Native::Env = undef);

Calls a class method with an environment and a stack without arguments. If the environment is not given, the current environment is used.

The stack is a Native::Stack object.

The environment is a Native::Env object.

If $stack is not defined, the current stackt is used.

If $environment is not defined, the current environment is used.

get_exception

static method get_exception : string ($stack : Native::Stack = undef, $env : Native::Env = undef);

Copies an excetpion on a stack, and returns it.

The stack is a Native::Stack object.

The environment is a Native::Env object.

If $stack is not defined, the current stackt is used.

If $environment is not defined, the current environment is used.

set_exception

static method set_exception : void ($exception : string, $stack : Native::Stack = undef, $env : Native::Env = undef);

Copies an excetpion on a stack using an enviroment, and sets it to the stack.

The stack is a Native::Stack object.

The environment is a Native::Env object.

If $stack is not defined, the current stackt is used.

If $environment is not defined, the current environment is used.

call_class_method

static method call_class_method : void ($basic_type_name : string, $method_name : string, $args : object[] = undef);

Calls a class method given the basic type name $basic_type_name, the method name $method_name, and the arguments $args.

call_instance_method_static

static method call_instance_method_static : object ($basic_type_name : string, $method_name : string, $args : object[] = undef);

Calls a instance method given the basic type name $basic_type_name, the method name $method_name, and the arguments $args.

call_instance_method

static method call_instance_method : object ($method_name : string, $args : object[] = undef);

Calls a instance method given the method name $method_name, and the arguments $args. The first argument in $args must be an instance.

Instance Methods

call

method call : object ($args : object[] = undef);

Calls a method with arguments and returns the return value.

Arguments

Each argument must be an object type. The following conversion is perfromed.

# Numeric types
Byte -> byte
Short -> short
Int -> int
Long -> long
Float -> float
Double -> double

# Multi-Numeric types
byte[] -> multi-numeric byte
short[] -> multi-numeric short
int[] -> multi-numeric int
long[] -> multi-numeric long
float[] -> multi-numeric float
double[] -> multi-numeric double

# Numeric reference types
byte[] -> byte*
short[] -> short*
int[] -> int*
long[] -> long*
float[] -> float*
double[] -> double*

# Multi-Numeric reference types
byte[] -> multi-numeric byte reference
short[] -> multi-numeric short reference
int[] -> multi-numeric int reference
long[] -> multi-numeric long reference
float[] -> multi-numeric float reference
double[] -> multi-numeric double reference

If the type of an argument cannot be assigned, an exception is thrown.

Return Value

If the type of the return value is a numeric type, it is converted to a numeric object.

byte -> Byte
short -> Short
int -> Int
long -> Long
float -> Float
double -> Double

If the type of the return value is a multi-numeric type, it is converted to a numeric array.

multi-numeric byte type -> byte[]
multi-numeric short type -> short[]
multi-numeric int type -> int[]
multi-numeric long type -> long[]
multi-numeric float type -> float[]
multi-numeric double type -> double[]

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License