AI-TensorFlow-Libtensorflow
view release on metacpan or search on metacpan
lib/AI/TensorFlow/Libtensorflow/TString.pm view on Meta::CPAN
package AI::TensorFlow::Libtensorflow::TString;
# ABSTRACT: A variable-capacity string type
$AI::TensorFlow::Libtensorflow::TString::VERSION = '0.0.7';
use strict;
use warnings;
use namespace::autoclean;
use AI::TensorFlow::Libtensorflow::Lib qw(arg);
use FFI::Platypus::Memory qw(malloc free);
my $ffi = AI::TensorFlow::Libtensorflow::Lib->ffi;
$ffi->mangler(AI::TensorFlow::Libtensorflow::Lib->mangler_default);
### From <tensorflow/tsl/platform/ctstring_internal.h>
#// _Static_assert(sizeof(TF_TString) == 24);
use constant SIZEOF_TF_TString => 24;
### From <tensorflow/tsl/platform/ctstring_internal.h>
# typedef enum TF_TString_Type { // NOLINT
# TF_TSTR_SMALL = 0x00,
# TF_TSTR_LARGE = 0x01,
# TF_TSTR_OFFSET = 0x02,
# TF_TSTR_VIEW = 0x03,
# TF_TSTR_TYPE_MASK = 0x03
# } TF_TString_Type;
sub _CREATE {
my ($class) = @_;
my $pointer = malloc SIZEOF_TF_TString;
my $obj = bless { ptr => $pointer }, $class;
}
$ffi->attach( [ 'StringInit' => 'Init' ] => [
arg 'TF_TString' => 'tstr'
] => 'void' => sub {
my ($xs, $invoc) = @_;
my $obj = ref $invoc ? $invoc : $invoc->_CREATE();
$xs->($obj);
$obj;
});
$ffi->attach( [ 'StringCopy' => 'Copy' ] => [
arg TF_TString => 'dst',
arg tf_text_buffer => [ qw( src size ) ],
] => 'void' );
$ffi->attach( [ 'StringAssignView' => 'AssignView' ] => [
arg TF_TString => 'dst',
arg tf_text_buffer => [ qw( src size ) ],
] => 'void' );
$ffi->attach( [ 'StringGetDataPointer' => 'GetDataPointer' ] => [
arg TF_TString => 'tstr',
] => 'opaque' );
$ffi->attach( [ 'StringGetType' => 'GetType' ] => [
arg TF_TString => 'str'
] => 'int' );
$ffi->attach( [ 'StringGetSize' => 'GetSize' ] => [
arg TF_TString => 'tstr'
] => 'size_t' );
$ffi->attach( [ 'StringGetCapacity' => 'GetCapacity' ] => [
arg TF_TString => 'str'
] => 'size_t' );
( run in 0.475 second using v1.01-cache-2.11-cpan-39bf76dae61 )