SPVM::Native::MethodCall − Method Call
The Native::MethodCall class of SPVM has methods to call methods.
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;
"static method new_class_method_with_env_stack : Native::MethodCall ($env : Native::Env, $stack : Native::Stack, $basic_type_name : string, $method_name : string);" Creates a class method call given the runtime environment $env, the runtime stck $stack, the basic type name $basic_type_name and the method name $method_name and returns it.
If $env is not given, $env is set to the current runtime environment.
If $stack is not given, $stack is set to the current runtime environment.
"static method new_instance_method_static_with_env_stack : Native::MethodCall ($env : Native::Env, $stack : Native::Stack, $basic_type_name : string, $method_name : string);"
Creates a instance method call given the runtime environment $env, the runtime stck $stack, the basic type name $basic_type_name and the method name $method_name, and returns it.
If $env is not given, $env is set to the current runtime environment.
If $stack is not given, $stack is set to the current runtime environment.
"static method new_instance_method_with_env_stack : Native::MethodCall ($env : Native::Env, $stack : Native::Stack, $instance : object, $method_name : string);"
Creates a instance method call given the runtime environment $env, the runtime stck $stack, the instance $instance and the method name $method_name, and returns it.
If $env is not given, $env is set to the current runtime environment.
If $stack is not given, $stack is set to the current runtime environment.
"static method new_class_method : Native::MethodCall ($basic_type_name : string, $method_name : string);"
Calls "new_class_method_with_env_stack" method given $env to undef and $stack to undef, and returns its return value.
Creates a class method call given the basic type name $basic_type_name and the method name $method_name and returns it.
"static method new_instance_method_static : Native::MethodCall ($basic_type_name : string, $method_name : string);"
Calls "new_instance_method_static_with_env_stack" method given $env to undef and $stack to undef, and returns its return value.
"static method new_instance_method : Native::MethodCall ($instance : object, $method_name : string);"
Calls "new_instance_method_with_env_stack" method given $env to undef and $stack to undef, and returns its return value.
"static method call_class_method : void ($basic_type_name : string, $method_name : string, $args : object[] = undef, $error_id_ref : int[] = undef);"
Calls a class method given the basic type name $basic_type_name, the method name $method_name, and the arguments $args.
"static method call_instance_method_static : object ($basic_type_name : string, $method_name : string, $args : object[] = undef, $error_id_ref : int[] = undef);"
Calls a instance method given the basic type name $basic_type_name, the method name $method_name, and the arguments $args.
"static method call_instance_method : object ($method_name : string, $args : object[] = undef, $error_id_ref : int[] = undef);"
Calls a instance method given the method name $method_name, and the arguments $args. The first argument in $args must be an instance.
"static method new_proto_with_method_name : object ($proto : object, $method_name : string, $args : object[] = undef, $error_id_ref : int[] = undef)"
Calls "call_class_method" method given the class name of $proto, the method name $method_name, $args, and $error_id_ref and its return value.
Exceptions:
The prototype object $proto must be defined. Otherwise an exception is thrown.
Exceptions thrown by "call_class_method" method could be thrown.
"static method new_proto : object ($proto : object, $args : object[] = undef, $error_id_ref : int[] = undef);"
Same as "new_proto_with_method_name" method, but $method_name is set to "new".
"method call : object ($args : object[] = undef, $error_id_ref : int[] = undef);"
Calls a method with arguments and returns the return value.
"method get_exception : string ();"
Gets the excetpion on the runtime enviroment and runtime stack owned by this instance.
"method set_exception : void ($exception : string);"
Sets the excetpion on the runtime enviroment and runtime stack owned by this instance to the string $exception.
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 (c) 2023 Yuki Kimoto
MIT License