Skip to content

Instantly share code, notes, and snippets.

@pghalliday
Created June 27, 2012 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pghalliday/3005134 to your computer and use it in GitHub Desktop.
Save pghalliday/3005134 to your computer and use it in GitHub Desktop.
Blog - OOOCode - Part 2 - Gist 2
#include "MyClass.h"
#define OOOClass MyClass
OOOPrivateData
int nMyField;
OOOPrivateDataEnd
OOODestructor
{
}
OOODestructorEnd
OOOMethod(int, getMyField)
{
return OOOF(nMyField);
}
OOOMethodEnd
OOOMethod(int, getData)
{
return OOOC(getMyField);
}
OOOMethodEnd
OOOConstructor(int nMyField)
{
#define OOOInterface IMyInterface
OOOMapVirtuals
OOOVirtualMapping(getData)
OOOMapVirtualsEnd
#undef OOOInterface
OOOMapMethods
OOOMethodMapping(getMyField)
OOOMapMethodsEnd
OOOF(nMyField) = nMyField;
}
OOOConstructorEnd
#undef OOOClass
#ifndef MYCLASS_H_
#define MYCLASS_H_
#include "OOOCode.h"
#include "IMyInterface.h"
#define OOOClass MyClass
OOODeclare(int nMyField)
OOOImplements
OOOImplement(IMyInterface);
OOOImplementsEnd
OOOExports
OOOExport(int, getMyField);
OOOExportsEnd
OOODeclareEnd
#undef OOOClass
#endif
#include "OOOUnitTestDefines.h"
#include "MyClass.h"
OOOTest(MyClass)
{
MyClass * pMyClass = OOOConstruct(MyClass, 5);
MyClass * pMyClassCopy = OOOCall(pMyClass, copy);
/* Check stuff here */
OOOCheck(OOOCall(pMyClass, getMyField) == 5);
OOOCheck(OOOICall(OOOCast(IMyInterface, pMyClass), getData) == 5);
OOOCheck(OOOCall(pMyClassCopy, isEqual, pMyClass));
OOOCheck(OOOCall(pMyClassCopy , getMyField) == 5);
OOOCheck(pMyClassCopy != pMyClass);
OOODestroy(pMyClass);
OOODestroy(pMyClassCopy);
}
#include "MyClass.h"
#define OOOClass MyClass
OOOPrivateData
int nMyField;
OOOPrivateDataEnd
OOODestructor
{
}
OOODestructorEnd
OOOMethod(int, getMyField)
{
return OOOF(nMyField);
}
OOOMethodEnd
OOOMethod(MyClass *, copy)
{
return OOOConstruct(MyClass, OOOF(nMyField));
}
OOOMethodEnd
OOOMethod(bool, isEqual, MyClass * pCompare)
{
return (OOOF(nMyField) == OOOPCall(pCompare, getMyField));
}
OOOMethodEnd
OOOMethod(int, getData)
{
return OOOC(getMyField);
}
OOOMethodEnd
OOOConstructor(int nMyField)
{
#define OOOInterface IMyInterface
OOOMapVirtuals
OOOVirtualMapping(getData)
OOOMapVirtualsEnd
#undef OOOInterface
OOOMapMethods
OOOMethodMapping(getMyField),
OOOMethodMapping(copy),
OOOMethodMapping(isEqual)
OOOMapMethodsEnd
OOOF(nMyField) = nMyField;
}
OOOConstructorEnd
#undef OOOClass
#ifndef MYCLASS_H_
#define MYCLASS_H_
#include "OOOCode.h"
#include "IMyInterface.h"
#define OOOClass MyClass
OOODeclare(int nMyField)
OOOImplements
OOOImplement(IMyInterface);
OOOImplementsEnd
OOOExports
OOOExport(int, getMyField);
OOOExport(MyClass *, copy);
OOOExport(bool, isEqual, MyClass * pCompare);
OOOExportsEnd
OOODeclareEnd
#undef OOOClass
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment