pyToC.h File Reference
This file implements Python functions defined in main.py.
More...
#include "pm.h"
Go to the source code of this file.
|
Defines |
#define | EXCEPTION_UNLESS(expr, prReturn,...) |
#define | PM_CHECK_FUNCTION(func) |
#define | PM_ARG_CHECK_FUNCTION(func, u8_ndx) |
#define | GET_UINT16_ARG(u8_ndx, pu16_val) PM_ARG_CHECK_FUNCTION( getUint16(NATIVE_GET_LOCAL(u8_ndx), pu16_val), u8_ndx ) |
#define | GET_INT16_ARG(u8_ndx, pi16_val) PM_ARG_CHECK_FUNCTION( getInt16(NATIVE_GET_LOCAL(u8_ndx), pi16_val), u8_ndx ) |
#define | GET_INT32_ARG(u8_ndx, pi32_val) PM_ARG_CHECK_FUNCTION( getInt32(NATIVE_GET_LOCAL(u8_ndx), pi32_val), u8_ndx ) |
#define | GET_UINT32_ARG(u8_ndx, pu32_val) PM_ARG_CHECK_FUNCTION( getUint32(NATIVE_GET_LOCAL(u8_ndx), pu32_val), u8_ndx ) |
#define | GET_BOOL_ARG(u8_ndx, pb_bool) PM_ARG_CHECK_FUNCTION( getBool(NATIVE_GET_LOCAL(u8_ndx), pb_bool), u8_ndx ) |
#define | GET_FLOAT_ARG(u8_ndx, pf_val) PM_ARG_CHECK_FUNCTION( getFloat(NATIVE_GET_LOCAL(u8_ndx), pf_val), u8_ndx ) |
#define | CHECK_NUM_ARGS(u8_numArgs) |
Functions |
PmReturn_t | getRangedInt (pPmObj_t ppo, int32_t i32_min, int32_t i32_max, int32_t *pi32_val) |
PmReturn_t | getUint16 (pPmObj_t ppo, uint16_t *pu16_val) |
PmReturn_t | getInt16 (pPmObj_t ppo, int16_t *pi16_val) |
PmReturn_t | getInt32 (pPmObj_t ppo, int32_t *pi32_val) |
PmReturn_t | getUint32 (pPmObj_t ppo, uint32_t *pu32_val) |
PmReturn_t | getBool (pPmObj_t ppo, bool_t *pb_bool) |
PmReturn_t | getFloat (pPmObj_t ppo, float *pf_val) |
Detailed Description
This file implements Python functions defined in main.py.
Definition in file pyToC.h.
Define Documentation
#define CHECK_NUM_ARGS |
( |
u8_numArgs |
|
) |
|
Value:
Check the number of arguments passed to a Python function. Report an exception if the number is incorrect. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_numArgs | Number of arguemnts expected. |
Definition at line 137 of file pyToC.h.
#define EXCEPTION_UNLESS |
( |
expr, |
|
|
prReturn, |
|
|
... |
|
) |
|
Value:
do { \
if (!(expr)) { \
printf("Error: " __VA_ARGS__); \
PM_RAISE(retval, prReturn); \
return retval; \
} \
} while (C_FALSE)
Raise an exception unless the given expression is true. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of
- PmReturn_t retval Optional arguments are a string to describe the cause of the exception, optionally containing printf-style formatting codes, followed by arguments matching the printf codes.
- Parameters:
-
| expr | Expression to evaluate. |
| prReturn | If expression is false, exception to raise. Must be of type PmReturn_t and typically is in the PmReturn_e enum. |
Definition at line 19 of file pyToC.h.
#define GET_BOOL_ARG |
( |
u8_ndx, |
|
|
pb_bool |
|
) |
PM_ARG_CHECK_FUNCTION( getBool(NATIVE_GET_LOCAL(u8_ndx), pb_bool), u8_ndx ) |
Macro to ease calling the getBool function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pb_bool | Resulting boolean value extracted. |
- Returns:
- Standard Python return value.
Definition at line 114 of file pyToC.h.
#define GET_FLOAT_ARG |
( |
u8_ndx, |
|
|
pf_val |
|
) |
PM_ARG_CHECK_FUNCTION( getFloat(NATIVE_GET_LOCAL(u8_ndx), pf_val), u8_ndx ) |
Macro to ease calling the getFloat function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pf_val | Resulting floating-point value extracted. |
- Returns:
- Standard Python return value.
Definition at line 126 of file pyToC.h.
#define GET_INT16_ARG |
( |
u8_ndx, |
|
|
pi16_val |
|
) |
PM_ARG_CHECK_FUNCTION( getInt16(NATIVE_GET_LOCAL(u8_ndx), pi16_val), u8_ndx ) |
Macro to ease calling the getInt16 function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pi16_val | Resulting value extracted. |
- Returns:
- Standard Python return value.
Definition at line 78 of file pyToC.h.
#define GET_INT32_ARG |
( |
u8_ndx, |
|
|
pi32_val |
|
) |
PM_ARG_CHECK_FUNCTION( getInt32(NATIVE_GET_LOCAL(u8_ndx), pi32_val), u8_ndx ) |
Macro to ease calling the getInt32 function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pi32_val | Resulting value extracted. |
- Returns:
- Standard Python return value.
Definition at line 90 of file pyToC.h.
#define GET_UINT16_ARG |
( |
u8_ndx, |
|
|
pu16_val |
|
) |
PM_ARG_CHECK_FUNCTION( getUint16(NATIVE_GET_LOCAL(u8_ndx), pu16_val), u8_ndx ) |
Macro to ease calling the getUint16 function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pu16_val | Resulting value extracted. |
- Returns:
- Standard Python return value.
Definition at line 65 of file pyToC.h.
#define GET_UINT32_ARG |
( |
u8_ndx, |
|
|
pu32_val |
|
) |
PM_ARG_CHECK_FUNCTION( getUint32(NATIVE_GET_LOCAL(u8_ndx), pu32_val), u8_ndx ) |
Macro to ease calling the getUint32 function. This MUST be called from the C implementation of a Python function, becuase it assumes the existance of:
- PmReturn_t retval
- pPmFrame_t* ppframe
- Parameters:
-
| u8_ndx | Zero-based index of the desired parameter to extract. |
| pu32_val | Resulting value extracted. |
- Returns:
- Standard Python return value.
Definition at line 102 of file pyToC.h.
#define PM_ARG_CHECK_FUNCTION |
( |
func, |
|
|
u8_ndx |
|
) |
|
Value:
Call a C function, then print argument-based errors on failure.
- Parameters:
-
| func | Call to a C function, not just the name of the function. Its return value will be tested. |
| u8_ndx | Zero-based index of the desired parameter to extract. |
Definition at line 48 of file pyToC.h.
#define PM_CHECK_FUNCTION |
( |
func |
|
) |
|
Value:
Call a C function which implements a Python routine. If the return value indicates an error, return. Because this macro assumes execution within the C implementation of a Python routine, is requires the existance of the variable
PmReturn_t retval
. The C function called must return
PmReturn_t retval
.
- Parameters:
-
| func | Call to a C function, not just the name of the function. Its return value will be tested. |
Definition at line 37 of file pyToC.h.
Function Documentation
Get a boolean value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pb_bool | Pointer to resulting boolean value extracted. |
- Returns:
- Standard Python return value.
Definition at line 100 of file pyToC.c.
Get a floating-point value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pf_val | Pointer to resulting floating-point value extracted. |
- Returns:
- Standard Python return value.
Definition at line 28 of file pyToC.c.
Get an signed, 16-bit value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pi16_val | Pointer to resulting int16 value extracted. |
- Returns:
- Standard Python return value.
Definition at line 89 of file pyToC.c.
Get a signed, 32-bit value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pi32_val | Pointer to resulting int32 value extracted. |
- Returns:
- Standard Python return value.
Definition at line 13 of file pyToC.c.
Get an integer from a Python object, requiring that the integer lie winin a minimum and minimum value. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| i32_min | Minimum allowable value. |
| i32_max | Maximum allowable value. |
| pi32_val | Pointer to resulting int32 value extracted. |
- Returns:
- Standard Python return value.
Definition at line 60 of file pyToC.c.
Get an unsigned, 16-bit value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pu16_val | Pointer to resulting uint16 value extracted. |
- Returns:
- Standard Python return value.
Definition at line 78 of file pyToC.c.
Get an unsigned, 32-bit value from a Python object. Raises errors as necessary.
- Parameters:
-
| ppo | A Python object. |
| pu32_val | Pointer to resulting int32 value extracted. |
- Returns:
- Standard Python return value.
Definition at line 43 of file pyToC.c.