Macro for creating statically initialized argument lists
#define Pt_ARG( _type, _value, _len ) { ... }
This macro lets you have statically initialized argument lists as an alternative to using PtSetArg(). For example, instead of:
PhPoint_t pos; PtArg_t args[ 2 ]; pos.x = 100; pos.y = 150; PtSetArg( &args[0], Pt_ARG_POS, &pos, 0 ); PtSetArg( &args[1], Pt_ARG_TEXT_STRING, "Blah", 0 ); PtCreateWidget( PtLabel, NULL, 2, args );
you can write:
static const PhPoint_t pos = { 100, 150 }; static const PtArg_t args[] = { Pt_ARG( Pt_ARG_POS, &pos, 0 ), Pt_ARG( Pt_ARG_TEXT_STRING, "Blah", 0 ) }; PtCreateWidget( PtLabel, NULL, sizeof(args) / sizeof(args[0]), args );
This makes adding or removing items easier and safer because the compiler counts the items in the array for you. And as a bonus, it generates less code than the first version.
If you have to calculate some of the values at runtime, you'll need to use PtSetArg() to intialize the argument list. |
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
Pt_ARG() is a macro.
PtArg_t, PtGetResources(), PtSetArg(), PtSetResources()
Manipulating Resources in Application Code chapter of the Photon Programmer's Guide.