python-on-a-chip online compiler

Dependencies:   mbed TSI

Embed: (wiki syntax)

« Back to documentation index

class.c File Reference

class.c File Reference

Class Object Type. More...

Go to the source code of this file.

Functions

PmReturn_t class_new (pPmObj_t pattrs, pPmObj_t pbases, pPmObj_t pname, pPmObj_t *r_pclass)
 Creates a new Class object from the methods dict, bases tuple, and name string.
PmReturn_t class_instantiate (pPmObj_t pclass, pPmObj_t *r_pobj)
 Returns an instance of the given class.
PmReturn_t class_autobox (pPmObj_t *pobj)
 Autoboxes an object in place.
PmReturn_t class_method (pPmObj_t pinstance, pPmObj_t pfunc, pPmObj_t *r_pmeth)
 Returns a method based on the given inputs.
PmReturn_t class_getAttr (pPmObj_t pobj, pPmObj_t pname, pPmObj_t *r_pobj)
 Returns the first attribute named __init__ in the class' inheritance tree.
uint8_t class_isSubclass (pPmObj_t ptest_class, pPmObj_t pbase_class)
 Returns a C boolean if the base class is found in the inheritance tree of the test class.

Detailed Description

Class Object Type.

Class object type operations.

Definition in file class.c.


Function Documentation

PmReturn_t class_autobox ( pPmObj_t pobj )

Autoboxes an object in place.

Parameters:
pclassPointer to object
Returns:
Return status

first, try to get the module from the cache

replace old object with new instance in place

Definition at line 100 of file class.c.

PmReturn_t class_getAttr ( pPmObj_t  pobj,
pPmObj_t  pname,
pPmObj_t r_pobj 
)

Returns the first attribute named __init__ in the class' inheritance tree.

Parameters:
pobjptr to class or instance to search
pnameptr to name of attr to find
r_pobjReturn by ref, ptr to attr if found, or undetermined
Returns:
Return status

Definition at line 198 of file class.c.

PmReturn_t class_instantiate ( pPmObj_t  pclass,
pPmObj_t r_pobj 
)

Returns an instance of the given class.

Parameters:
pclassPointer to class object
r_pobjReturn by ref, instance object
Returns:
Return status

Definition at line 67 of file class.c.

uint8_t class_isSubclass ( pPmObj_t  ptest_class,
pPmObj_t  pbase_class 
)

Returns a C boolean if the base class is found in the inheritance tree of the test class.

NOTE: This function is recursive.

Parameters:
ptest_classptr to class whose inheritance tree is searched
pbase_classptr to class to look for
Returns:
Returns C_TRUE if pbase_class is found in the inheritance tree; C_FALSE otherwise.

Definition at line 242 of file class.c.

PmReturn_t class_method ( pPmObj_t  pinstance,
pPmObj_t  pfunc,
pPmObj_t r_pmeth 
)

Returns a method based on the given inputs.

Parameters:
pinstanceptr to instance
pfuncptr to func
r_pmethReturn by ref, ptr to new method
Returns:
Return status

Definition at line 167 of file class.c.

PmReturn_t class_new ( pPmObj_t  pmeths,
pPmObj_t  pbases,
pPmObj_t  pname,
pPmObj_t r_pclass 
)

Creates a new Class object from the methods dict, bases tuple, and name string.

Parameters:
pmethsptr to methods dict.
pbasesptr to bases tuple.
pnameptr to name string.
r_pclassReturn by ref, ptr to new class
Returns:
Return status

Definition at line 34 of file class.c.