value.h

Go to the documentation of this file.
00001 /*      Value.h - metaclass system  MAXScript values
00002  *
00003  *  All MAXScript-specific C++ objects are subclasses of a single root class, Value, 
00004  *  and allocated & automatically freed in a specially maintained heap.  There is also
00005  *  a metaclass system to provide a runtime type calculus for the scripter.  Value subclasses
00006  *  are divided into those that are scripter-visible, (ie, may wind up as objects that the
00007  *  scripter may pass around or store in variables, etc.), and those that are entirely
00008  *  internal to the scripter operation (such as thunks, etc.).  The scripter-visible
00009  *  classes (the majority) are represented in the metasystem by instances of separate
00010  *  metaclasses.  The metaclasses are all subclasses of ValueMetaClass, the metaclass of
00011  *  a class X is named XClass and its sole instance is X_class. The class instances are
00012  *  made visible in globals (usually) named X.  
00013  *
00014  *  Each Value instance has a tag word that either contains a pointer to the instance's
00015  *  class instance (in the case of scripter-visible classes) or the reserved value INTERNAL_CLASS_TAG.
00016  *  This value is used in performing runtimne type tests and for yielding results to classOf 
00017  *  methods.
00018  *
00019  *  The metaclass, its instance and some of the class calculus methods are usually defined via
00020  *  a bunch of macros defined here (see visible_class, visible_class_instance, etc.)
00021  *
00022  *  Some of the classes are can be instanced directly as literals in a script, such as strings, 
00023  *  Point3s, arrays, etc.  Some others are instantiable directly by applying the class value
00024  *  to a set of initializing parameters, ie, using the class as a function in a function call,
00025  *  for example, ray, quat, interval, etc.  These are defined via a variant macro: applyable_class().
00026  *  A special case of this is provided in the MAXWrapper subsytem for creatable MAX objects, such as
00027  *  boxes, lights, camera, etc..  These are represnted by instances of the class MAXClass, and again, thses
00028  *  instances are exposed in globals to be applied to creation paramters.  These instances
00029  *  contain a lot of property metadata and are defined in MAX_classes.cpp.  See MAXObject.h for more
00030  *  info.
00031  *  
00032  *      Copyright (c) John Wainwright, 1996
00033  *
00034  */
00035 
00036 #pragma once
00037 
00038 #include "..\ScripterExport.h"
00039 #include "collectable.h"
00040 #include "interupts.h"
00041 #include "MAXScript_TLS.h"
00042 #include "..\macros\value_locals.h"
00043 #include "MaxscriptTypedefs.h"
00044 #include "..\..\matrix3.h"
00045 #include "..\..\box2.h"
00046 #include "..\..\acolor.h"
00047 #include "..\..\interval.h"
00048 #include "..\..\quat.h"
00049 #include "..\..\ifnpub.h"
00050 
00051 // forward declarations
00052 class BitArray;
00053 class CharStream;
00054 class Name;
00055 class PathName;
00056 class Undefined;
00057 class UserProp;
00058 class UserGeneric;
00059 class CallContext;
00060 class ValueMetaClass;
00061 struct node_map;
00062 class Mtl;
00063 class Texmap;
00064 class MtlBase;
00065 class Modifier;
00066 class Control;
00067 class Atmospheric;
00068 class Effect;
00069 class IMultiPassCameraEffect;
00070 class ShadowType;
00071 class FPInterfaceDesc;
00072 class FilterKernel;
00073 class ITrackViewNode;
00074 class NURBSIndependentPoint;
00075 class NURBSPoint;
00076 class NURBSObject;
00077 class NURBSControlVertex;
00078 class NURBSCurve;
00079 class NURBSCVCurve;
00080 class NURBSSurface;
00081 class NURBSTexturePoint;
00082 class NURBSSet;
00083 class ReferenceTarget;
00084 class Mesh;
00085 class Thunk;
00086 class Renderer;
00087 class NURBSTextureSurface;
00088 class NURBSDisplay;
00089 class TessApprox;
00090 class SelectionIterator;
00091 
00092 #include "..\macros\define_external_functions.h"
00093 #   include "..\protocols\corenames.inl"
00094 
00095 // forward declarations...
00096 
00097 
00098 extern ScripterExport Undefined undefined;
00099 extern ScripterExport bool dontThrowAccessorError;
00100 
00101 
00102 // the root MAXScript class
00103 class Value : public Collectable
00104 {
00105 private:
00106     ScripterExport static Matrix3  s_error_matrix;
00107     ScripterExport static Box2  s_error_box2;
00108 public:
00109     #pragma warning(push)
00110     #pragma warning(disable:4100)
00111     ValueMetaClass* tag;        // runtime type tag; filled in by subclasses
00112 
00113     ScripterExport virtual BOOL is_kind_of(ValueMetaClass* c);
00114     ScripterExport virtual ValueMetaClass* local_base_class(); // local base class in this class's plug-in
00115     virtual Value*  eval() { check_interrupts(); return this; }
00116     virtual Value*  eval_no_wrapper() { check_interrupts(); return this; }
00117     ScripterExport virtual Value*  apply(Value** arglist, int count, CallContext* cc=NULL);
00118     ScripterExport virtual Value*  apply_no_alloc_frame(Value** arglist, int count, CallContext* cc=NULL);
00119     virtual void    export_to_scripter() { }
00120 
00121     virtual Value*  map(node_map& m) { unimplemented(_M("map"), this) ; return this; }
00122     virtual Value*  map_path(PathName* path, node_map& m) { unimplemented(_M("map_path"), this) ; return this; }
00123     virtual Value*  find_first(BOOL (*test_fn)(INode* node, int level, void* arg), void* test_arg) { unimplemented(_M("find_first"), this) ; return this; }
00124     virtual Value*  get_path(PathName* path) { unimplemented(_M("get"), this) ; return this; }
00125 
00126     ScripterExport virtual void sprin1(CharStream* stream);
00127     ScripterExport virtual void sprint(CharStream* stream);
00128 
00129     virtual void    prin1() { sprin1(thread_local(current_stdout)); }
00130     virtual void    print() { sprint(thread_local(current_stdout)); }
00131     
00132     /* include all the protocol declarations */
00133 
00134 #include "..\macros\define_abstract_functions.h"
00135 #   include "..\protocols\math.inl"
00136 #   include "..\protocols\vector.inl"
00137 #   include "..\protocols\matrix.inl"
00138 #   include "..\protocols\quat.inl"
00139 #   include "..\protocols\arrays.inl"
00140 #   include "..\protocols\streams.inl"
00141 #   include "..\protocols\strings.inl"
00142 #   include "..\protocols\time.inl"
00143 #   include "..\protocols\color.inl"
00144 #   include "..\protocols\node.inl"
00145 #   include "..\protocols\controller.inl"
00146 #   include "..\protocols\primitives.inl"
00147 #   include "..\protocols\generics.inl"
00148 #   include "..\protocols\bitmaps.inl"
00149 #   include "..\protocols\textures.inl"
00150 #   include "..\protocols\atmospherics.inl"
00151 #   // Moved to ..\maxwrapper\mxsnurbs.h into class NURBSObjectValue
00152 #   include "..\protocols\cameratracker.inl"
00153 #   include "..\protocols\bigmatrix.inl"
00154 #   include "..\protocols\box.inl"
00155 #   include "..\protocols\physiqueblend.inl"
00156 #   include "..\protocols\physiquemod.inl"
00157 #   include "..\protocols\biped.inl"
00158 #   include "..\protocols\notekey.inl"
00159 #   include "..\protocols\xrefs.inl"
00160 
00161     ScripterExport virtual Class_ID get_max_class_id() { return Class_ID(0, 0); }
00162     ScripterExport virtual Value* delete_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("delete"), this, Value*); }    
00163     ScripterExport virtual Value* clearSelection_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("clearSelection"), this, Value*); }    
00164 
00165 #undef def_generic
00166 #define def_generic(fn, name) ScripterExport virtual Value* fn##_vf(Value** arglist, int arg_count);
00167 #   include "..\protocols\kernel.inl"
00168     
00169     virtual float       to_float() { ABSTRACT_CONVERTER(float, Float); }
00170     virtual double      to_double() { ABSTRACT_CONVERTER(double, Double); }
00171     virtual MCHAR*      to_string() { ABSTRACT_CONVERTER(MCHAR*, String); }
00172     virtual MSTR        to_filename() { ABSTRACT_CONVERTER(MCHAR*, FileName); }
00173     virtual int         to_int() { ABSTRACT_CONVERTER(int, Integer); }
00174     virtual INT64       to_int64() { ABSTRACT_CONVERTER(INT64, Integer64); }    
00175     virtual INT_PTR     to_intptr() { ABSTRACT_CONVERTER(INT_PTR, IntegerPtr); }    
00176     virtual BOOL        to_bool() { ABSTRACT_CONVERTER(BOOL, Boolean); }
00177     virtual BitArray&   to_bitarray() { throw ConversionError (this, _M("BitArray")); return *(BitArray*)NULL; }
00178     virtual Point4      to_point4() { ABSTRACT_CONVERTER(Point4, Point4); }
00179     virtual Point3      to_point3() { ABSTRACT_CONVERTER(Point3, Point3); }
00180     virtual Point2      to_point2() { ABSTRACT_CONVERTER(Point2, Point2); }
00181     virtual AColor      to_acolor() { throw ConversionError (this, _M("Color")); return AColor(0,0,0); }
00182     virtual COLORREF    to_colorref() { throw ConversionError (this, _M("Color")); return RGB(0,0,0); }
00183     virtual INode*      to_node() { ABSTRACT_CONVERTER(INode*, <node>); }
00184     virtual Ray         to_ray() { throw ConversionError (this, _M("Ray")); return Ray(); }
00185     virtual Interval    to_interval() { throw ConversionError (this, _M("Interval")); return Interval();  }
00186     virtual Quat        to_quat() { throw ConversionError (this, _M("Quaternion")); return Quat();  }
00187     virtual AngAxis     to_angaxis() { throw ConversionError (this, _M("AngleAxis")); return AngAxis();  }
00188     virtual Matrix3&    to_matrix3() { throw ConversionError (this, _M("Matrix")); return s_error_matrix;  }
00189     virtual float*      to_eulerangles() { ABSTRACT_CONVERTER(float*, Float); }
00190     virtual Mtl*        to_mtl() { ABSTRACT_CONVERTER(Mtl*, Material); }
00191     virtual Texmap*     to_texmap() { ABSTRACT_CONVERTER(Texmap*, TextureMap); }
00192     virtual MtlBase*    to_mtlbase() { ABSTRACT_CONVERTER(MtlBase*, MtlBase); }
00193     virtual Modifier*   to_modifier() { ABSTRACT_CONVERTER(Modifier*, Modifier); }
00194     virtual TimeValue   to_timevalue() { ABSTRACT_CONVERTER(TimeValue, Time); }
00195     virtual Control*    to_controller() { ABSTRACT_CONVERTER(Control*, Controller); }
00196     virtual Atmospheric* to_atmospheric() { ABSTRACT_CONVERTER(Atmospheric*, Atmospheric); }
00197     virtual Effect*     to_effect() { ABSTRACT_CONVERTER(Effect*, Effect); }                        // RK: Added this
00198     virtual IMultiPassCameraEffect* to_mpassCamEffect() { ABSTRACT_CONVERTER(IMultiPassCameraEffect*, Effect); }    // LAM: Added this
00199     virtual ShadowType* to_shadowtype() { ABSTRACT_CONVERTER(ShadowType*, ShadowType); }            // RK: Added this
00200     virtual FilterKernel*   to_filter() { ABSTRACT_CONVERTER(FilterKernel*, FilterKernel); }        // RK: Added this
00201     virtual INode*      to_rootnode() { ABSTRACT_CONVERTER(INode*, <root>); }                       // RK: Added this
00202     virtual ITrackViewNode* to_trackviewnode() { ABSTRACT_CONVERTER(ITrackViewNode*, TrackViewNode); }
00203     virtual NURBSIndependentPoint* to_nurbsindependentpoint() { throw ConversionError (this, _M("NURBSIndependentPoint")); return (NURBSIndependentPoint*)0;  }
00204     virtual NURBSPoint* to_nurbspoint() { throw ConversionError (this, _M("NURBSPoint")); return (NURBSPoint*)0;  }
00205     virtual NURBSObject* to_nurbsobject() { throw ConversionError (this, _M("NURBSObject")); return (NURBSObject*)0;  }
00206     virtual NURBSControlVertex* to_nurbscontrolvertex() { throw ConversionError (this, _M("NURBSControlVertex")); return (NURBSControlVertex*)0;  }
00207     virtual NURBSCurve* to_nurbscurve() { throw ConversionError (this, _M("NURBSCurve")); return (NURBSCurve*)0;  }
00208     virtual NURBSCVCurve* to_nurbscvcurve() { throw ConversionError (this, _M("NURBSCVCurve")); return (NURBSCVCurve*)0;  }
00209     virtual NURBSSurface* to_nurbssurface() { throw ConversionError (this, _M("NURBSSurface")); return (NURBSSurface*)0;  }
00210     virtual NURBSTexturePoint* to_nurbstexturepoint() { throw ConversionError (this, _M("NURBSTexturePoint")); return (NURBSTexturePoint*)0;  }
00211     virtual NURBSSet*   to_nurbsset() { throw ConversionError (this, _M("NURBSSet")); return (NURBSSet*)0;  }
00212     virtual ReferenceTarget* to_reftarg() { ABSTRACT_CONVERTER(ReferenceTarget*, MaxObject); }
00213     virtual Mesh*       to_mesh() { ABSTRACT_CONVERTER(Mesh*, Mesh); }
00214     virtual Thunk*      to_thunk() { ABSTRACT_CONVERTER(Thunk*, &-reference); }
00215     virtual void        to_fpvalue(FPValue& v) { throw ConversionError (this, _M("FPValue")); }
00216 
00217     virtual Renderer*   to_renderer() { ABSTRACT_CONVERTER(Renderer*, Renderer); }  // LAM: Added this 9/15/01
00218 
00219     virtual Box2&   to_box2() { throw ConversionError (this, _M("Box2")); return s_error_box2;  }
00220     virtual NURBSTextureSurface* to_nurbstexturesurface() { throw ConversionError (this, _M("NURBSTextureSurface")); return (NURBSTextureSurface*)0;  }
00221     virtual NURBSDisplay* to_nurbsdisplay() { throw ConversionError (this, _M("NURBSDisplay")); return (NURBSDisplay*)0;  }
00222     virtual TessApprox*  to_tessapprox() { throw ConversionError (this, _M("TessApprox")); return (TessApprox*)0;  }
00223 
00224     virtual Value*  widen_to(Value* arg, Value** arg_list) { ABSTRACT_WIDENER(arg); }
00225     virtual BOOL    comparable(Value* arg) { return (tag == arg->tag); }
00226     virtual BOOL    is_const() { return FALSE; }
00227     // LAM - 7/8/03 - defect 504956 - following identifies classes that derive from MAXWrapper. Only other implementation is in MAXWrapper
00228     // used by garbage collector to prevent collection of MAXWrapper-derived values while doing light collection
00229     virtual BOOL    derives_from_MAXWrapper()  { return FALSE; } 
00230 
00231     ScripterExport virtual Value*   get_property(Value** arg_list, int count);
00232     ScripterExport virtual Value*   set_property(Value** arg_list, int count);
00233     ScripterExport         Value*   _get_property(Value* prop);
00234     ScripterExport virtual Value*   _set_property(Value* prop, Value* val);
00235     virtual Value*  get_container_property(Value* prop, Value* cur_prop) { if (!dontThrowAccessorError) throw AccessorError (cur_prop, prop); return NULL; }
00236     virtual Value*  set_container_property(Value* prop, Value* val, Value* cur_prop) { throw AccessorError (cur_prop, prop); return NULL;}
00237 
00238     // polymorphic default type predicates - abstracted over by is_x(v) macros as needed
00239     virtual BOOL    _is_collection() { return FALSE; }
00240     virtual BOOL    _is_charstream() { return FALSE; }
00241     virtual BOOL    _is_rolloutcontrol() { return FALSE; }
00242     virtual BOOL    _is_rolloutthunk() { return FALSE; }
00243     virtual BOOL    _is_function()   { return FALSE; }
00244     virtual BOOL    _is_selection()  { return FALSE; }
00245     virtual BOOL    _is_thunk()     { return FALSE; }
00246     virtual BOOL    _is_indirect_thunk() { return FALSE; }
00247 
00248     // yield selection set iterator if you can
00249     virtual SelectionIterator* selection_iterator() { throw RuntimeError (_M("Operation requires a selection (Array or BitArray)")); return NULL; }
00250 
00251     // scene persistence functions
00252     ScripterExport virtual IOResult Save(ISave* isave);
00253     // the Load fn is a static method on loadbale classes, see SceneIO.cpp & .h and each loadable class
00254 
00255     // called during MAX exit to have all MAXScript-side refs dropped (main implementation in MAXWrapper)
00256     virtual void drop_MAX_refs() { }
00257 
00258     // access ID'd FPInterface if supported
00259     virtual BaseInterface* GetInterface(Interface_ID id) { return NULL; }
00260 
00261 
00262     // stack allocation routines
00263     ScripterExport Value* make_heap_permanent();
00264     ScripterExport Value* make_heap_static() { Value* v = make_heap_permanent(); v->flags |= GC_STATIC; return v; }
00265 
00266     ScripterExport Value* get_heap_ptr() { if (!has_heap_copy()) return migrate_to_heap(); return is_on_stack() ? get_stack_heap_ptr() : this; } 
00267     ScripterExport Value* get_stack_heap_ptr() { return (Value*)next; }
00268     ScripterExport Value* migrate_to_heap();
00269     ScripterExport Value* get_live_ptr() { return is_on_stack() && has_heap_copy() ? get_stack_heap_ptr() : this; } 
00270     #pragma warning(pop)
00271 };
00272 
00273 inline Value* heap_ptr(Value* v) { return v ? v->get_heap_ptr() : NULL; }   // ensure v is in heap, migrate if not, return heap pointer
00274 inline Value* live_ptr(Value* v) { return  v->get_live_ptr(); }             // get live pointer, if on stack & migrated, heap copy is live
00275 
00276 /* ---------- the base class for all metaclasses  ---------- */
00277 
00278 class MetaClassClass;
00279 extern MetaClassClass value_metaclass;  // the metaclass class
00280 
00281 class ValueMetaClass : public Value
00282 {
00283 // Whether the generic functions and property setters of class instances can be called from debugger thread stored 
00284 // in Collectable::flags3 - bit 0. Default is false.
00285 public:
00286     MCHAR*          name;
00287     UserProp*       user_props;     // additional, user defined property accessors
00288     short           uprop_count;
00289     UserGeneric*    user_gens;      //     "        "      "    generic fns
00290     short           ugen_count;
00291     Tab<FPInterfaceDesc*> prop_interfaces;  // static interfaces who methods appear as properties on instances of the class
00292 
00293                     ValueMetaClass() { }
00294     ScripterExport  ValueMetaClass(MCHAR* iname);
00295     ScripterExport  ~ValueMetaClass();
00296 
00297     ScripterExport BOOL is_kind_of(ValueMetaClass* c);
00298 #   define      is_valueclass(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == (ValueMetaClass*)&value_metaclass)
00299     ScripterExport void sprin1(CharStream* s);
00300     ScripterExport void export_to_scripter();
00301     ScripterExport void add_user_prop(MCHAR* prop, value_cf getter, value_cf setter);
00302     ScripterExport void add_user_generic(MCHAR* name, value_cf fn);
00303     ScripterExport UserGeneric* find_user_gen(Value* name);
00304     ScripterExport UserProp* find_user_prop(Value* prop);
00305 
00306     // static property interfaces
00307     ScripterExport void add_prop_interface(FPInterfaceDesc* fpd) { prop_interfaces.Append(1, &fpd); }
00308     ScripterExport int num_prop_interfaces() { return prop_interfaces.Count(); }
00309     ScripterExport FPInterfaceDesc* get_prop_interface(int i) { return prop_interfaces[i]; }
00310 };
00311 #define CHECK_ARG_COUNT(fn, w, g)   if ((w) != (g)) throw ArgCountError (_M(#fn), w, g)
00312 
00313 #define classof_methods(_cls, _super)                   \
00314     Value* classOf_vf(Value** arg_list, int count)      \
00315     {                                                   \
00316         UNUSED_PARAM(arg_list);                         \
00317         CHECK_ARG_COUNT(classOf, 1, count + 1);         \
00318         return &_cls##_class;                           \
00319     }                                                   \
00320     Value* superClassOf_vf(Value** arg_list, int count) \
00321     {                                                   \
00322         UNUSED_PARAM(arg_list);                         \
00323         CHECK_ARG_COUNT(superClassOf, 1, count + 1);    \
00324         return &_super##_class;                         \
00325     }                                                   \
00326     Value* isKindOf_vf(Value** arg_list, int count)     \
00327     {                                                   \
00328         CHECK_ARG_COUNT(isKindOf, 2, count + 1);        \
00329         return (arg_list[0] == &_cls##_class) ?         \
00330             &true_value :                               \
00331             _super::isKindOf_vf(arg_list, count);       \
00332     }                                                   \
00333     BOOL is_kind_of(ValueMetaClass* c)                  \
00334     {                                                   \
00335         return (c == &_cls##_class) ? 1                 \
00336                     : _super::is_kind_of(c);            \
00337     }
00338 
00339 #define visible_class(_cls)                                             \
00340     class _cls##Class : public ValueMetaClass                           \
00341     {                                                                   \
00342     public:                                                             \
00343                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { }    \
00344         void        collect() { delete this; }                          \
00345     };                                                                  \
00346     extern ScripterExport _cls##Class _cls##_class;
00347 
00348 #define visible_class_debug_ok(_cls)                                    \
00349     class _cls##Class : public ValueMetaClass                           \
00350     {                                                                   \
00351     public:                                                             \
00352                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { flags3 |= VALUE_FLAGBIT_0; } \
00353         void        collect() { delete this; }                          \
00354     };                                                                  \
00355     extern ScripterExport _cls##Class _cls##_class;
00356 
00357 #define visible_class_s(_cls, _super)                                   \
00358     class _cls##Class : public ValueMetaClass                           \
00359     {                                                                   \
00360     public:                                                             \
00361                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { }    \
00362         void        collect() { delete this; }                          \
00363         Value*      classOf_vf(Value** arg_list, int count)             \
00364         {                                                               \
00365             UNUSED_PARAM(arg_list);                                     \
00366             CHECK_ARG_COUNT(classOf, 1, count + 1);                     \
00367             return &_super##_class;                                     \
00368         }                                                               \
00369         Value*      superClassOf_vf(Value** arg_list, int count)        \
00370         {                                                               \
00371             UNUSED_PARAM(arg_list);                                     \
00372             UNUSED_PARAM(count);                                        \
00373             return _super##_class.classOf_vf(NULL, 0);                  \
00374         }                                                               \
00375     };                                                                  \
00376     extern ScripterExport _cls##Class _cls##_class;
00377 
00378 #define applyable_class(_cls)                                           \
00379     class _cls##Class : public ValueMetaClass                           \
00380     {                                                                   \
00381     public:                                                             \
00382                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { }\
00383         void        collect() { delete this; }                          \
00384         ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
00385     };                                                                  \
00386     extern ScripterExport _cls##Class _cls##_class;
00387 
00388 #define applyable_class_debug_ok(_cls)                                  \
00389     class _cls##Class : public ValueMetaClass                           \
00390     {                                                                   \
00391     public:                                                             \
00392                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { flags3 |= VALUE_FLAGBIT_0; }\
00393         void        collect() { delete this; }                          \
00394         ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
00395     };                                                                  \
00396     extern ScripterExport _cls##Class _cls##_class;
00397 
00398 #define applyable_class_s(_cls, _super)                                 \
00399     class _cls##Class : public ValueMetaClass                           \
00400     {                                                                   \
00401     public:                                                             \
00402                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { }\
00403         Value*      classOf_vf(Value** arg_list, int count)             \
00404         {                                                               \
00405             UNUSED_PARAM(arg_list);                                     \
00406             CHECK_ARG_COUNT(classOf, 1, count + 1);                     \
00407             return &_super##_class;                                     \
00408         }                                                               \
00409         Value*      superClassOf_vf(Value** arg_list, int count)        \
00410         {                                                               \
00411             UNUSED_PARAM(arg_list);                                     \
00412             UNUSED_PARAM(count);                                        \
00413             return _super##_class.classOf_vf(NULL, 0);                  \
00414         }                                                               \
00415         void        collect() { delete this; }                          \
00416         ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
00417     };                                                                  \
00418     extern ScripterExport _cls##Class _cls##_class;
00419 
00420 #define visible_class_instance(_cls, _name)             \
00421     ScripterExport _cls##Class _cls##_class (_M(_name));
00422 
00423 #define invisible_class(_cls)                                           \
00424     class _cls##Class : public ValueMetaClass                           \
00425     {                                                                   \
00426     public:                                                             \
00427                     _cls##Class(MCHAR* name) : ValueMetaClass (name) { }    \
00428         void        collect() { delete this; }                          \
00429         void        export_to_scripter() { }                            \
00430     };                                                                  \
00431     extern ScripterExport _cls##Class _cls##_class;
00432 
00433 #define invisible_class_instance(_cls, _name)               \
00434     ScripterExport _cls##Class _cls##_class (_M(_name));
00435 
00436 
00437 #define class_tag(_cls)             &_cls##_class
00438 
00439 #define INTERNAL_CLASS_TAG              ((ValueMetaClass*)0L)
00440 #define INTERNAL_INDEX_THUNK_TAG        ((ValueMetaClass*)1L)
00441 #define INTERNAL_PROP_THUNK_TAG         ((ValueMetaClass*)2L)
00442 #define INTERNAL_LOCAL_THUNK_TAG        ((ValueMetaClass*)3L)
00443 #define INTERNAL_FREE_THUNK_TAG         ((ValueMetaClass*)4L)
00444 #define INTERNAL_RO_LOCAL_THUNK_TAG     ((ValueMetaClass*)5L)
00445 #define INTERNAL_CODE_TAG               ((ValueMetaClass*)6L)
00446 #define INTERNAL_SOURCEFILEWRAPPER_TAG  ((ValueMetaClass*)7L)
00447 #define INTERNAL_PIPE_TAG               ((ValueMetaClass*)8L)
00448 #define INTERNAL_TOOL_LOCAL_THUNK_TAG   ((ValueMetaClass*)9L)
00449 #define INTERNAL_GLOBAL_THUNK_TAG       ((ValueMetaClass*)10L)
00450 #define INTERNAL_CONST_GLOBAL_THUNK_TAG ((ValueMetaClass*)11L)
00451 #define INTERNAL_SYS_GLOBAL_THUNK_TAG   ((ValueMetaClass*)12L)
00452 #define INTERNAL_PLUGIN_LOCAL_THUNK_TAG ((ValueMetaClass*)13L)
00453 #define INTERNAL_PLUGIN_PARAM_THUNK_TAG ((ValueMetaClass*)14L)
00454 #define INTERNAL_RCMENU_LOCAL_THUNK_TAG ((ValueMetaClass*)15L)
00455 #define INTERNAL_STRUCT_MEM_THUNK_TAG   ((ValueMetaClass*)16L)
00456 #define INTERNAL_MSPLUGIN_TAG           ((ValueMetaClass*)17L)
00457 #define INTERNAL_STRUCT_TAG             ((ValueMetaClass*)18L)
00458 #define INTERNAL_MAKER_TAG              ((ValueMetaClass*)19L)
00459 #define INTERNAL_CODEBLOCK_LOCAL_TAG    ((ValueMetaClass*)20L)
00460 #define INTERNAL_CODEBLOCK_TAG          ((ValueMetaClass*)21L)
00461 #define INTERNAL_THUNK_REF_TAG          ((ValueMetaClass*)22L)
00462 #define INTERNAL_THUNK_DEREF_TAG        ((ValueMetaClass*)23L)
00463 #define INTERNAL_STRUCT_METHOD_TAG      ((ValueMetaClass*)24L) // LAM - defect 307069
00464 #define INTERNAL_MSPLUGIN_METHOD_TAG    ((ValueMetaClass*)25L) // LAM - 9/6/02 - defect 291499
00465 #define INTERNAL_CONTEXT_THUNK_TAG      ((ValueMetaClass*)26L) // LAM - 2/8/05
00466 #define INTERNAL_OWNER_THUNK_TAG        ((ValueMetaClass*)27L) // LAM - 2/28/05
00467 #define INTERNAL_RCMENU_ITEM_THUNK_TAG  ((ValueMetaClass*)28L) // LAM - 3/21/05
00468 #define INTERNAL_STANDINMSPLUGINCLASS_TAG   ((ValueMetaClass*)29L) // LAM - 8/29/06
00469 #define INTERNAL_SOURCEPOSWRAPPER_TAG       ((ValueMetaClass*)30L) // LAM - 9/4/08
00470 
00471 #define INTERNAL_TAGS                   ((ValueMetaClass*)100L)  // must be higher than all internal tags
00472 
00473 visible_class_debug_ok (Value)
00474 
00475 #define is_sourcepositionwrapper(v) ((v)->tag == INTERNAL_SOURCEPOSWRAPPER_TAG)
00476 
00477 /* ---------- the distinguished value subclasses ---------- */
00478 
00479 visible_class_debug_ok (Boolean)
00480 
00481 class Boolean;
00482 class ValueLoader;
00483 extern ScripterExport Boolean true_value;
00484 extern ScripterExport Boolean false_value;
00485 #pragma warning(push)
00486 #pragma warning(disable:4100)
00487 
00488 class Boolean : public Value
00489 {
00490 public:
00491             Boolean() { tag = &Boolean_class; }
00492             classof_methods (Boolean, Value);
00493     void    collect() { delete this; }
00494     void    sprin1(CharStream* s);
00495 
00496 #   define  is_bool(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == &Boolean_class)
00497     Value*  not_vf(Value**arg_list, int count);
00498     Value*  copy_vf(Value** arg_list, int count) { return this; }
00499     BOOL    to_bool() { return this == &true_value; }
00500     void    to_fpvalue(FPValue& v) { v.i = (this == &true_value) ? 1 : 0; v.type = (ParamType2)TYPE_BOOL; }
00501 
00502     // scene I/O 
00503     IOResult Save(ISave* isave);
00504     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00505 };
00506 
00507 /* ----- */
00508 
00509 visible_class_debug_ok (Undefined)
00510 
00511 class Undefined : public Value
00512 {
00513 public:
00514             Undefined() { tag = &Undefined_class; }
00515             classof_methods (Undefined, Value);
00516     void    collect() { delete this; }
00517     ScripterExport void sprin1(CharStream* s);
00518     Value*  copy_vf(Value** arg_list, int count) { return this; }
00519 
00520     // scene I/O 
00521     IOResult Save(ISave* isave);
00522     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00523     Mtl*    to_mtl() { return NULL; }       // undefined is a NULL material
00524     void    to_fpvalue(FPValue& v);
00525 };
00526 
00527 extern ScripterExport Undefined undefined;
00528 extern ScripterExport Undefined dontCollect;
00529 extern ScripterExport Undefined loopExit;
00530 
00531 /* ----- */
00532 
00533 visible_class_debug_ok (Ok)
00534 
00535 class Ok : public Value
00536 {
00537 public:
00538             Ok() { tag = &Ok_class; }
00539             classof_methods (Ok, Value);
00540     void    collect() { delete this; }
00541     ScripterExport void sprin1(CharStream* s);
00542     Value*  copy_vf(Value** arg_list, int count) { return this; }
00543 
00544     // scene I/O 
00545     IOResult Save(ISave* isave);
00546     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00547     void    to_fpvalue(FPValue& v);
00548 };
00549 
00550 extern ScripterExport Ok ok;
00551 
00552 /* ----- */
00553 
00554 visible_class_debug_ok (Empty)
00555 
00556 class Empty : public Value
00557 {
00558 public:
00559             Empty() { tag = &Empty_class; }
00560             classof_methods (Empty, Value);
00561     void    collect() { delete this; }
00562     ScripterExport void sprin1(CharStream* s);
00563     Value*  copy_vf(Value** arg_list, int count) { return this; }
00564 
00565     // scene I/O 
00566     IOResult Save(ISave* isave);
00567     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00568     void    to_fpvalue(FPValue& v);
00569 };
00570 
00571 extern ScripterExport Empty empty;
00572 
00573 /* ----- */
00574 
00575 visible_class_debug_ok (Unsupplied)
00576 
00577 class Unsupplied : public Value
00578 {
00579 public:
00580             Unsupplied() { tag = &Unsupplied_class; }
00581             classof_methods (Unsupplied, Value);
00582     void    collect() { delete this; }
00583     ScripterExport void sprin1(CharStream* s);
00584     Value*  copy_vf(Value** arg_list, int count) { return this; }
00585 
00586     // scene I/O 
00587     IOResult Save(ISave* isave);
00588     static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
00589     void    to_fpvalue(FPValue& v);
00590 };
00591 #pragma warning(pop)
00592 extern ScripterExport Unsupplied unsupplied;