python-on-a-chip online compiler

Dependencies:   mbed TSI

Embed: (wiki syntax)

« Back to documentation index

obj.c File Reference

obj.c File Reference

Object Type. More...

Go to the source code of this file.

Functions

PmReturn_t obj_loadFromImg (PmMemSpace_t memspace, uint8_t const **paddr, pPmObj_t *r_pobj)
 Loads an object from an image in memory.
PmReturn_t obj_loadFromImgObj (pPmObj_t pimg, pPmObj_t *r_pobj)
 Loads a code object from a code image object.
int8_t obj_isFalse (pPmObj_t pobj)
 Finds the boolean value of the given object.
PmReturn_t obj_isIn (pPmObj_t pobj, pPmObj_t pitem)
 Returns the boolean true if the item is in the object.
int8_t obj_compare (pPmObj_t pobj1, pPmObj_t pobj2)
 Compares two objects for equality.
PmReturn_t obj_print (pPmObj_t pobj, uint8_t is_expr_repr, uint8_t is_nested)
 Print an object, thereby using objects helpers.
PmReturn_t obj_repr (pPmObj_t pobj, pPmObj_t *r_pstr)
 Returns by reference a string object that is the human-readable representation of the object.

Detailed Description

Object Type.

Object type operations.

Definition in file obj.c.


Function Documentation

int8_t obj_compare ( pPmObj_t  pobj1,
pPmObj_t  pobj2 
)

Compares two objects for equality.

Parameters:
pobj1Ptr to first object.
pobj2Ptr to second object.
Returns:
C_SAME if the items are equivalent, C_DIFFER otherwise.

Definition at line 247 of file obj.c.

int8_t obj_isFalse ( pPmObj_t  pobj )

Finds the boolean value of the given object.

Parameters:
pobjPtr to object to test.
Returns:
Nonzero value if object is False.

Definition at line 104 of file obj.c.

PmReturn_t obj_isIn ( pPmObj_t  pobj,
pPmObj_t  pitem 
)

Returns the boolean true if the item is in the object.

Parameters:
pobjPtr to container object
pitemPtr to item

Definition at line 157 of file obj.c.

PmReturn_t obj_loadFromImg ( PmMemSpace_t  memspace,
uint8_t const **  paddr,
pPmObj_t r_pobj 
)

Loads an object from an image in memory.

Return pointer to object. Leave add pointing one byte past end of obj.

The following lists the simple object types and their image structures: -None: -type: int8_t - OBJ_TYPE_NON

-Int: -type: int8_t - OBJ_TYPE_INT -value: int32_t - signed integer value

-Float: -type: int8_t - OBJ_TYPE_FLOAT -value: float32_t - 32-bit floating point value

-Slice (is this allowed in img?): -type: int8_t - OBJ_TYPE_SLICE -index1: int16_t - first index. -index2: int16_t - second index.

Parameters:
memspacememory space/type
paddrptr to ptr to obj return by reference: paddr pts to first byte after obj
r_pobjReturn arg, the loaded object.
Returns:
Return status

Definition at line 25 of file obj.c.

PmReturn_t obj_loadFromImgObj ( pPmObj_t  pimg,
pPmObj_t r_pobj 
)

Loads a code object from a code image object.

Parameters:
pimgPtr to a code image object
r_pobjReturn arg, the loaded object
Returns:
Returns status

Definition at line 83 of file obj.c.

PmReturn_t obj_print ( pPmObj_t  pobj,
uint8_t  is_expr_repr,
uint8_t  is_nested 
)

Print an object, thereby using objects helpers.

Parameters:
pobjPtr to object for printing.
is_expr_reprInfluences the way None and strings are printed. If 0, None is printed, strings are printed. If 1, None is not printed and strings are printed surrounded with single quotes and unprintable characters are escaped.
is_nestedInfluences the way None and strings are printed. If 1, None will be printed and strings will be surrounded with single quotes and escaped. This argument overrides the is_expr_repr argument.
Returns:
Return status

Definition at line 339 of file obj.c.

PmReturn_t obj_repr ( pPmObj_t  pobj,
pPmObj_t r_pstr 
)

Returns by reference a string object that is the human-readable representation of the object.

Used by the backtick operation (UNARY_CONVERT).

Parameters:
pobjPtr to object to represent
r_pstrReturn arg, the string object
Returns:
Return status

Definition at line 438 of file obj.c.