p2  0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PNString Struct Reference

strings are immutable UTF-8, the ID is incremental and they may be garbage collected. More...

#include <potion.h>

Public Member Functions

#define PN_STR_LEN(x)   ((struct PNString *)(x))->len
 
static PN potion_str_length (Potion *P, PN cl, PN self)
 
static PN potion_str_eval (Potion *P, PN cl, PN self)
 
static PN potion_str_number (Potion *P, PN cl, PN self)
 
static PN potion_str_string (Potion *P, PN cl, PN self)
 
static PN potion_str_clone (Potion *P, PN cl, PN self)
 
static PN potion_str_print (Potion *P, PN cl, PN self)
 
static PN potion_str_slice (Potion *P, PN cl, PN self, PN start, PN end)
 
static PN potion_str_bytes (Potion *P, PN cl, PN self)
 
PN potion_str_add (Potion *P, PN cl, PN self, PN x)
 
static PN potion_str_at (Potion *P, PN cl, PN self, PN index)
 
static PN potion_str_cmp (Potion *P, PN cl, PN self, PN str)
 

Data Fields

 PN_OBJECT_HEADER
 PNType vt; PNUniq uniq. More...
 
PN_SIZE len
 
char chars []
 

Detailed Description

strings are immutable UTF-8, the ID is incremental and they may be garbage collected.

(non-volatile)

Definition at line 337 of file potion.h.

Member Function Documentation

static PN potion_str_length ( Potion P,
PN  cl,
PN  self 
)

"length" method. number of chars

Definition at line 100 of file string.c.

static PN potion_str_eval ( Potion P,
PN  cl,
PN  self 
)

"eval" a string.

Definition at line 106 of file string.c.

static PN potion_str_number ( Potion P,
PN  cl,
PN  self 
)

"number" method. as atoi/atof

Definition at line 112 of file string.c.

static PN potion_str_string ( Potion P,
PN  cl,
PN  self 
)

"string" method. Returns self

Definition at line 133 of file string.c.

static PN potion_str_clone ( Potion P,
PN  cl,
PN  self 
)

"clone" method. Returns self, strings are immutable.

Definition at line 139 of file string.c.

static PN potion_str_print ( Potion P,
PN  cl,
PN  self 
)

"print" method. fwrite to stdout

Returns
nil

Definition at line 146 of file string.c.

static PN potion_str_slice ( Potion P,
PN  cl,
PN  self,
PN  start,
PN  end 
)

"slice" method. supports negative indices, and end<start

Parameters
startPNInteger
endPNInteger
Returns
PNString substring

Definition at line 243 of file string.c.

static PN potion_str_bytes ( Potion P,
PN  cl,
PN  self 
)

"bytes" method. Convert PNString to PNBytes

Definition at line 271 of file string.c.

PN potion_str_add ( Potion P,
PN  cl,
PN  self,
PN  x 
)

"+" method.

Parameters
xPNString
Returns
concat PNString

Definition at line 279 of file string.c.

static PN potion_str_at ( Potion P,
PN  cl,
PN  self,
PN  index 
)

default function type_call_is for PNString, returning the character at the given position.

Parameters
indexPNInteger
Returns
PNString substring index .. index+1

Definition at line 295 of file string.c.

static PN potion_str_cmp ( Potion P,
PN  cl,
PN  self,
PN  str 
)

"cmp" a string to argument str, casted to a string

"a" cmp "b" #=> -1
"a" cmp "a" #=> 0
"z" cmp "a" #=> 1
Parameters
strPN string compared to
Returns
PNInteger (positive, negative or 0)
See also
potion_tuple_sort.

Definition at line 479 of file string.c.

Field Documentation

PNString::PN_OBJECT_HEADER

PNType vt; PNUniq uniq.

Definition at line 338 of file potion.h.

PN_SIZE PNString::len

Definition at line 339 of file potion.h.

char PNString::chars[]

Definition at line 340 of file potion.h.


The documentation for this struct was generated from the following files: