Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Deep Macro parsing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

zakker
New Member

2 Posts

Posted - Sep 21 2010 :  06:01:22 AM  Show Profile  Reply with Quote
example 1:

file: classes.inl
DECLARE_ATOM_CLASS( AC_STATIC, static )
DECLARE_ATOM_CLASS( AC_DYNAMIC, dynamic )
DECLARE_ATOM_CLASS( AC_MULTISTATE, multistate )

and now use it:
enum atom_class_e
{
    AC_FIRST_LIST           = 0,

#define DECLARE_ATOM_CLASS( e, a ) e,
#include "classes.inl"
#undef DECLARE_ATOM_CLASS
    
    ATOM_CLASSES_COUNT,
    AC_UNDEFINED,
};

atom_c::atom_definition_s atom_c::g_classes[ ATOM_CLASSES_COUNT ] = 
{
#define DECLARE_ATOM_CLASS( e, a ) { #a, atom_##a##_c::instance },
#include "classes.inl"
#undef DECLARE_ATOM_CLASS
};


example 2:
#define LOGICPARAMS \    LPRM( CUSTOMVAR1,   prm_word ) \    LPRM( CUSTOMVAR2,   prm_word ) \    LPRM( MTYPE,        prm_mtype ) \    LPRM( LOCTYPE,      prm_loctype ) \    LPRM( SURFTYPE,     prm_surftype )

and now use it:
// types
#define LPRM(x, y) typedef y::TYPE typeof_##x;
    LOGICPARAMS
#undef LPRM

// enum : LP_CUSTOMVAR1, LP_CUSTOMVAR2 ... LP_max
#define LPRM(x, y) LP_##x,
enum lp_e { LOGICPARAMS LP_max };
#undef LPRM

// sizeof : LPSZ_CUSTOMVAR1, LPSZ_CUSTOMVAR2 ...
#define LPRM(x, y) LPSZ_##x = sizeof(y::TYPE),
enum lpsz_e { LOGICPARAMS };
#undef LPRM

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Sep 21 2010 :  7:49:36 PM  Show Profile  Reply with Quote
Unfortunately VA's parser does not understand the ## command inside macros for generating names:

case=729

Which is why you are going to be having problems with this code. If you only use macro's that use ## occasionally you might be able to add dummy helper macro's to help VA's parser that give the generated names.

zen is the art of being at one with the two'ness
Go to Top of Page

zakker
New Member

2 Posts

Posted - Sep 22 2010 :  02:21:01 AM  Show Profile  Reply with Quote
enum atom_class_e does not use any ## command, but AC_STATIC, for example, VA's parser can't handle too. I understand that multiple #include of the same file is hack, but compiler allows it :)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Sep 24 2010 :  11:13:43 AM  Show Profile  Reply with Quote
I am not sure I understand the problem with "AC_STATIC". If I understand your code correctly then you are giving DECLARE_ATOM_CLASS different definitions at different points in the same file. This is going to confuse VA's parser, especially when some of the definitions use ##

Since you are using DECLARE_ATOM_CLASS to mean different things at different points, I am not sure how to try and work around this either. Any simple hack to try and help VA's parser is never going to capture what you are doing here.

It might be possible to use VA's StdAfx.h file here, if there was a single simple definition of DECLARE_ATOM_CLASS that would help a bit:

http://docs.wholetomato.com?W302

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000