NAME
SPVM::Document::ExchangeAPI - Exchange API
What is Exchange API
Exchange API is perl functions to exchange Perl data to SPVM data, and reverse.
use SPVM 'SomeModule';
# Convert Perl array reference to SPVM int array
my $spvm_nums = SPVM::new_int_array([1, 2, 3]);
# Convert SPVM int array to Perl array reference
my $nums = $spvm_nums->to_elements;
# Create SPVM object(SomeModule need to define new method)
my $spvm_object = SomeModule->new;
Functions
new_byte_array
my $spvm_array = SPVM::new_byte_array([1, 2, 3]);
Convert Perl array reference to SPVM byte array.
Return value is SPVM::Data::Array object.
new_short_array
my $spvm_array = SPVM::new_short_array([1, 2, 3]);
Convert Perl array reference to SPVM short array.
Return value is SPVM::Data::Array object.
new_int_array
my $spvm_array = SPVM::new_int_array([1, 2, 3]);
Convert Perl array reference to SPVM int array.
Return value is SPVM::Data::Array object.
new_long_array
my $spvm_array = SPVM::new_long_array([1, 2, 3]);
Convert Perl array reference to SPVM long array.
Return value is SPVM::Data::Array object.
new_float_array
my $spvm_array = SPVM::new_float_array([0.5, 0.1, 0.3]);
Convert Perl array reference to SPVM float array.
Return value is SPVM::Data::Array object.
new_double_array
my $spvm_array = SPVM::new_double_array([0.5, 0.1, 0.3]);
Return value is SPVM::Data::Array object.
new_object_array
my $array = SPVM::new_object_array("TestCase", [$object1, $object2]);
Convert Perl array reference which contains SPVM object to SPVM object array.
Return value is SPVM::Data::Array object.
An example:
use SPVM 'Point';
my $spvm_point1 = Point->new(0, 1);
my $spvm_point2 = Point->new(3, 4);
my $spvm_points = SPVM::new_object_array("Point", [$spvm_point1, $spvm_point2]);