Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 8

Pt_ARG()

Macro for creating statically initialized argument lists

Synopsis:

#define Pt_ARG( type, value, len ) { ... }

Library:

ph

Description:

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.


Note: If you have to calculate some of the values at runtime, you'll need to use PtSetArg() to initialize the argument list.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

Caveats:

Pt_ARG() is a macro.

See also:

PtArg_t, PtGetResource(), PtGetResources(), PtSetArg(), PtSetResource(), PtSetResources()

Manipulating Resources in Application Code chapter of the Photon Programmer's Guide.


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 138

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/pt/pt_arg.html on line 138