local_class.h

Go to the documentation of this file.
00001 /*      local_class.h - macros for defining local classes and generics in a MAXScript extension .dlx
00002  *
00003  *
00004  *      Copyright (c) Autodesk, Inc.  1988.  John Wainwright.
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "ClassCfg.h"
00011 class Value;
00012 
00013 #define local_visible_class(_cls)                                       \
00014     class _cls##Class : public ValueMetaClass                           \
00015     {                                                           \
00016     public:                                                     \
00017         _cls##Class(MCHAR* name) : ValueMetaClass (name) { }                \
00018         void    collect() { delete this; }                              \
00019     };                                                          \
00020     extern _cls##Class _cls##_class;
00021 
00022 #define local_applyable_class(_cls)                                 \
00023     class _cls##Class : public ValueMetaClass                           \
00024     {                                                           \
00025     public:                                                     \
00026         _cls##Class(MCHAR* name) : ValueMetaClass (name) { }                \
00027         void    collect() { delete this; }                              \
00028         Value* apply(Value** arglist, int count, CallContext* cc = NULL);   \
00029     };                                                          \
00030     extern _cls##Class _cls##_class;
00031 
00032 #define local_visible_class_instance(_cls, _name)                           \
00033     _cls##Class _cls##_class (_M(_name));
00034 
00035 class MS_LOCAL_ROOT_CLASS;
00036 typedef Value* (MS_LOCAL_ROOT_CLASS::*local_value_vf)(Value**, int);
00037 // confusing macros. Do not use them.
00038 #define cat0(_a) _a
00039 #define cat1(_a) cat0(_a)
00040 #define cat2(_a, _b) cat0(_a)##cat0(_b)
00041 #define str0(_c) #_c
00042 #define str1(_c) str0(_c)
00043 
00050 
00051 #define CONCATENATE_HELPER(x,y) x##y
00052 
00053 #define CONCATENATE(x,y) CONCATENATE_HELPER(x,y)
00054 
00055 
00056 #define MS_LOCAL_ROOT_CLASS_TAG     &CONCATENATE(MS_LOCAL_ROOT_CLASS, _class)
00057 #define MS_LOCAL_GENERIC_CLASS_TAG  &CONCATENATE(MS_LOCAL_GENERIC_CLASS, _class)
00058 #define MS_LOCAL_GENERIC_CLASS_CLASS CONCATENATE(MS_LOCAL_GENERIC_CLASS, Class)
00059 #define MS_LOCAL_GENERIC_CLASS_class CONCATENATE(MS_LOCAL_GENERIC_CLASS, _class)