Re: m4 question

David Bélanger <[email protected]> Wed, 16 Feb 2005 15:37:43 -0500
Newsgroups gmane.comp.java.vm.sablevm.devel
Message-ID <[email protected]>
On Wed, Feb 16, 2005 at 11:35:19AM -0500, Jennifer LHOTAK wrote:
> Hi,
> 
> I've been working on project in sablevm and I'm trying to read in a code
> attribute
> that is very similar to the LineNumberTable attribute. I noticed there is
> a macro that expands to the if/else statements which process the
> attributes based on there names. This macro generates methods with part of
> the id as the name giving to the macro. The problem I am having is that
> the name of my attribute has a bunch of dots in it, so when it expands the
> macro creates method ids with dots which is not allowed.
> 
> So my question is should I not use the macro or should I fix it to change
> dots to underscrores? And where can find more information about how these
> macros work?
> 
> Thanks
> Jennifer
> 

Hi Jennifer,

Try this quick untested patch as attachment.

Patch adds 2nd (optionnal) argument for textual comparison.
First arg used for function names etc. as before.

David

---

David Bélanger
Web page:   http://www.cs.mcgill.ca/~dbelan2/
Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt

_______________________________________________
SableVM-devel mailing list
[email protected]
http://sablevm.org/lists/control/listinfo/sablevm-devel
dot.patch (text/plain, 1.1 KB)
Index: src/libsablevm/class_file_parser.m4.c
===================================================================
--- src/libsablevm/class_file_parser.m4.c	(revision 3406)
+++ src/libsablevm/class_file_parser.m4.c	(working copy)
@@ -146,7 +146,7 @@
 {
   m4svm_define_begin v = ":], [:m4svm_parse_attribute_if:])";
 
-  if (strcmp (name, "$1") == 0)
+  if (strcmp (name, "m4_ifelse($2,,$1,$2)") == 0)
     {
       /* m4svm_comment_define([:m4svm_parse_attribute_1:],
        * [:[:m4svm_parse_attribute($:][:1):][::]m4_dnl:]) */
@@ -167,7 +167,7 @@
 {
   if (dummy)
     m4svm_define_begin = ":], [:m4svm_parse_attribute_elseif:])";
-  else if (strcmp (name, "$1") == 0)
+  else if (strcmp (name, "m4_ifelse($2,,$1,$2)") == 0)
     {
       /* m4svm_comment_define([:m4svm_parse_attribute_1:],
        * [:[:m4svm_parse_attribute($:][:1):][::]m4_dnl:]) */
@@ -1343,6 +1343,7 @@
      m4svm_parse_attribute_if(ConstantValue)
      m4svm_parse_attribute_elseif(Synthetic)
      m4svm_parse_attribute_elseif(Deprecated)
+     m4svm_parse_attribute_elseif(ADot,A.Dot)
      m4svm_parse_attribute_else(unknown)
 
      m4svm_on(0)m4_dnl */