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 and returns it. It is a Native::MethodCall.

call_callback

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

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

The stack is a Native::Stack object.

The callback is a Native::MethodCall::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

static method call_class_method : 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 the $stack is not defined, the current stackt is used.

If the $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 the $stack is not defined, the current stackt is used.

If the $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 the $stack is not defined, the current stackt is used.

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

Instance Methods

call

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

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