++ed by:
KES SKOLYCHEV FAYLAND ILUX BEROV

8 PAUSE users
5 non-PAUSE users.

Yuki Kimoto

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_iarray([1, 2, 3]);
  
  # Convert SPVM int array to Perl array reference
  my $nums = $spvm_nums->to_elems;
  
  # Create SPVM object(SomeModule need to define new method)
  my $spvm_object = SomeModule->new;

Functions

new_barray

  my $spvm_array = SPVM::new_barray([1, 2, 3]);

Convert Perl array reference to SPVM byte array.

Return value is SPVM::Data::Array object.

new_sarray

  my $spvm_array = SPVM::new_sarray([1, 2, 3]);

Convert Perl array reference to SPVM short array.

Return value is SPVM::Data::Array object.

new_iarray

  my $spvm_array = SPVM::new_iarray([1, 2, 3]);

Convert Perl array reference to SPVM int array.

Return value is SPVM::Data::Array object.

new_larray

  my $spvm_array = SPVM::new_larray([1, 2, 3]);

Convert Perl array reference to SPVM long array.

Return value is SPVM::Data::Array object.

new_farray

  my $spvm_array = SPVM::new_farray([0.5, 0.1, 0.3]);

Convert Perl array reference to SPVM float array.

Return value is SPVM::Data::Array object.

new_darray

  my $spvm_array = SPVM::new_darray([0.5, 0.1, 0.3]);

Return value is SPVM::Data::Array object.

new_oarray

  my $array = SPVM::new_oarray("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_oarray("Point", [$spvm_point1, $spvm_point2]);