Script takes halui_str structure and parses types from it.
For every variable it creates list entry with its size.
For array variables list of sizes is added.

Makefile rule is added to generate halui_size.h

Signed-off-by: Pavel Shramov <[email protected]>
---
 src/emc/usr_intf/Submakefile |    3 ++
 src/emc/usr_intf/halui.awk   |   45 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
 create mode 100644 src/emc/usr_intf/halui.awk

diff --git a/src/emc/usr_intf/Submakefile b/src/emc/usr_intf/Submakefile
index 3244705..62c2619 100644
--- a/src/emc/usr_intf/Submakefile
+++ b/src/emc/usr_intf/Submakefile
@@ -74,6 +74,9 @@ TARGETS += ../bin/emclcd
        $(CXX) $(LDFLAGS) -o $@ $(ULFLAGS) $^
 TARGETS += ../bin/usrmot
 
+emc/usr_intf/halui_size.h: emc/usr_intf/halui.awk emc/usr_intf/halui.cc
+       awk -f $^ > $@
+
 ../bin/halui: $(call TOOBJS, $(HALUISRCS)) ../lib/libemc.a 
../lib/libemcini.so.0 ../lib/libnml.so.0 ../lib/libemchal.so.0
        $(ECHO) Linking $(notdir $@)
        $(CXX) $(LDFLAGS) -o $@ $(ULFLAGS) $^ 
diff --git a/src/emc/usr_intf/halui.awk b/src/emc/usr_intf/halui.awk
new file mode 100644
index 0000000..e8a6528
--- /dev/null
+++ b/src/emc/usr_intf/halui.awk
@@ -0,0 +1,45 @@
+BEGIN {
+       flag=0; MDI_MAX=64; EMCMOT_MAX_JOINTS=9; EMCMOT_MAX_AXIS=9;
+       printf("static unsigned char halui_data_size[] = {\n");
+}
+
+END { printf("};\n"); }
+
+/^struct halui_str {/ { flag=1; }
+/} \* halui_data;/ { flag=0; }
+($1 ~ /hal_.*_t/) {
+       if (flag == 1) { flag = 2; }
+       else if (flag > 1) { process(); }
+}
+
+function process() {
+       size = 0;
+       if      ($1 == "hal_bit_t")   { size = 1; }
+       else if ($1 == "hal_s32_t")   { size = 4; }
+       else if ($1 == "hal_u32_t")   { size = 4; }
+       else if ($1 == "hal_float_t") { size = 8; }
+
+       if (!size) return;
+
+       count = 0;
+       if ($2 ~ /];$/) {
+               tmp = $2;
+               sub(".*\\[", "", tmp);
+               sub("].*", "", tmp);
+               if (tmp ~ /+1$/) {
+                       sub("+1$", "", tmp);
+                       count = 1;
+               } else
+                       count = 0;
+               if (tmp == "EMCMOT_MAX_JOINTS")    count += EMCMOT_MAX_JOINTS;
+               else if (tmp == "EMCMOT_MAX_AXIS") count += EMCMOT_MAX_AXIS;
+               else if (tmp == "MDI_MAX")         count += MDI_MAX;
+               else {
+                       exit 1;
+               }
+       } else
+               count = 1;
+       printf("\t");
+       while (count) { printf("%d, ", size); count -= 1; };
+       printf("// %s\n", $0);
+}
-- 
1.7.1

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to