On 18 February 2012 00:37, Kirk Wallace <[email protected]> wrote:

>        FOR_ALL_INSTS() {    // <-- I have no idea what FOR_ALL_INSTS () is or 
> does, or where it lives, but it seems to work

It is briefly mentioned here:
http://linuxcnc.org/docs/html/hal_comp.html#r1_8
It is a macro[1] that expands to loop through all instances of a
component. It would probably be unusual to run multiple instances of a
userspace component, but comp assumes that you want to make it
possible, and creates copies of all pins for all instances.

[1] All-caps in C-code typically means that the code expands to say
something quite different at compile time. As I understand it this is
a simple textual replacement. As a very simple example you might
#define PI = 4.0 and then any time "PI" appears in the code, it is
replaced by the string-literal "4.0". comp takes this to extremes, for
example every pin_name is #defined to be inst->pin_name so that the
C-code can iterate through all instances of the component.

Looking at the python code, comp inserts
#define FOR_ALL_INSTS() for(inst = first_inst; inst; inst = inst->_next)
and then the C-compiler does the substitution. It saves you having to
know what the internal representation of the instance structure is in
the auto-generated C-code (though sometimes it can be useful to know
that, when you are "stretching" comp.

-- 
atp
The idea that there is no such thing as objective truth is, quite simply, wrong.

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to