On Sat, 2012-02-18 at 01:08 +0000, andy pugh wrote: > 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.
Okay, that explains a lot. That keeps me from having to provide a loop for each instance and it does it on the fly. or rather when the component is loaded. I had envisioned something more complicated. > [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. I looked in some of the include files and didn't see where FOR_ALL_INSTS was defined, but gave up after a while. > 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. Thank you Andy. This gets me to the next level of misunderstanding. -- Kirk Wallace http://www.wallacecompany.com/machine_shop/ http://www.wallacecompany.com/E45/index.html California, USA ------------------------------------------------------------------------------ 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
