For advanced users and applications, it can still be useful in that many people find C++-style declarations easier to read than their MMXX counterparts. For those situations where twentifier is unable to cope with a particular situation or construct, escape sequences can be used to force it to produce the correct output: the #quote { ... #} construct bypasses the translation and places the enclosed text directly into the output MMXX header, and the %inhibit { ... } construct forces twentifier to witness the enclosed declarations (usually typedefs and simplified forward declarations whose true declarations are present in other headers) without sending them to output.
Here are some of the major restrictions on what may be in a twentifier input file. Many of these restrictions reflect what is and isn't expressible in MMXX's header grammar, however occasionally twentifier will allow constructs that are indeed not allowed or reccomendable. Please note that this list is not exhaustive:
Because of all these restrictions, the best way to use twentifier is to either refrain from using it for sophisticated classes, or to closely monitor its output to make sure the it's correct, while availing oneself of the #quote and %inhibit constructs to fix any problems along the way.
Here are the special twentifier directives:
twentifier's input files use the .mxh suffix by convention, and its output files default to the classic .h suffix.
Here are example input and output files:
%header MyHeader;
template <class Z> class Vector;
%include BingoHeader;
%inhibit {
typedef Vector<int> IntVector;
class Bingo;
}
#quote {
typedef char *vodzilla;
#}
class MyClass : public Bingo {
public:
struct stuff {
int elem1;
void *elem2;
char elem3[256];
};
enum famous_mafiosi {
oprah,
cher,
bill = 1000,
hillary,
gates = 0x23842UL,
ballmer,
herman = pee_wee
};
inline MyClass(int, double);
virtual ~MyClass();
static void Compute(const char *foo, Vector<float> &bar, double &aardvark) throw();
/* we'll get a warning here, and this will be made private
(temporarily, till the next MMXX release) */
inline MyClass & operator = (const MyClass &);
protected:
virtual int hello() const;
const int *&adriatic, mediterranean[2], *baltic;
virtual int pure_indeed() = 0;
private:
char *mycstring;
IntVector myintvector;
};
#if !defined(__MYHEADER__) || defined(_MMXX_BREWING_)
#define __MYHEADER__ 1
#ifndef _MMXX_BREWING_
#ifndef __BINGOHEADER__
#include "BingoHeader.h"
#endif /* #ifndef __BINGOHEADER__ */
template <class Z > class Vector;
/* =-= begin quote: =-= */
typedef char *vodzilla;
/* =-= end quote =-= */
#include "mmxxapi.h"
#endif /* #ifndef _MMXX_BREWING_ */
MMXX_CLASS_1_0(MyClass,public,Bingo)
MMXX_STRUCT_START(MyClass,stuff)
MMXX_STRUCT_FIELD(MyClass,stuff, int,elem1)
MMXX_STRUCT_FIELD(MyClass,stuff, void*,elem2)
MMXX_STRUCT_ARRAY(MyClass,stuff, char,elem3,256)
MMXX_STRUCT_END(MyClass,stuff)
MMXX_ENUM_START(MyClass,famous_mafiosi)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, oprah,0)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, cher,1)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, bill,1000)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, hillary,1001)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, gates,0x23842UL)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, ballmer,0x23842UL+1)
MMXX_ENUM_TUPLE(MyClass,famous_mafiosi, herman,pee_wee)
MMXX_ENUM_END(MyClass,famous_mafiosi)
// Warning: dropping 'inline' from MyClass::MyClass
MMXX_CONS_2( Pub, MyClass,Req,
1,(Bingo), int,p33892634,
double,pa86fc21c)
// public: inline MyClass(int, double);
// Warning: public virtual destructor is always implicitly declared
// public: virtual ~MyClass();
MMXX_STATIC_3N( Pub, MyClass,Req,
Compute, const char*,foo,
Vector< float >&,bar,
double&,aardvark)
// public: static void Compute(const char* foo, Vector< float >& bar, double& aardvark) throw();
// Warning: making typedef/operator temporarily private
MMXX_METHOD_0RC(ProtV, MyClass,Req,
int, hello )
// protected: virtual int hello()const ;
// Warning: making MyClass::adriatic private
// Warning: making MyClass::mediterranean private
// Warning: making MyClass::baltic private
MMXX_METHOD_0R( ProtPV, MyClass,Req,
int, pure_indeed )
// protected: virtual int pure_indeed() = 0;
#if !defined(_MMXX_BREWING_) && defined(_MMXX_SHADOW_MyClass) && _MMXX_SHADOW_MyClass==0
private:
inline MyClass& operator = (const MyClass&);
/* we'll get a warning here, and this will be made private
(temporarily, till the next MMXX release) */
const int*& adriatic;
const int mediterranean[2];
const int* baltic;
char* mycstring;
IntVector myintvector;
#endif /* #if !defined(_MMXX_BREWING_) && defined(_MMXX_SHADOW_MyClass) && _MMXX_SHADOW_MyClass==0 */
MMXX_CLASS_END(MyClass)
#endif /* #if !defined(__MYHEADER__) || defined(_MMXX_BREWING_) */