3ds Max C++ API Reference
Loading...
Searching...
No Matches
generic_class.h File Reference

Macros

#define DECLARE_LOCAL_GENERIC_CLASS(_rootclass, _cls)
#define DEFINE_LOCAL_GENERIC_CLASS(_rootClass, _cls)
#define DEFINE_LOCAL_GENERIC_CLASS_DEBUG_OK(_rootClass, _cls)

Macro Definition Documentation

◆ DECLARE_LOCAL_GENERIC_CLASS

#define DECLARE_LOCAL_GENERIC_CLASS ( _rootclass,
_cls )
Value:
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name); \
void collect(); \
}; \
extern _cls##Class _cls##_class; \
class _rootclass; \
typedef Value* (_rootclass::*local_value_vf)(Value**, int); \
class _cls : public Generic \
{ \
public: \
local_value_vf fn_ptr; \
_cls(); \
_cls(const MCHAR* name, local_value_vf fn); \
classof_methods (_cls, Generic); \
void collect(); \
Value* apply(Value** arglist, int count, CallContext* cc = NULL); \
};
#define NULL
Definition autoptr.h:18
Definition functions.h:56
Definition functions.h:86
Definition value.h:107
Definition value.h:433
const MCHAR * name
Definition value.h:437
Value *(MS_LOCAL_ROOT_CLASS::*)(Value **, int) local_value_vf
Definition local_class.h:71
#define MCHAR
MBCS/Unicode helper defines std::wofstream doesn't mix well with Unicode.
Definition strbasic.h:42
14#define DECLARE_LOCAL_GENERIC_CLASS( _rootclass, _cls ) \
15 class _cls##Class : public ValueMetaClass \
16 { \
17 public: \
18 _cls##Class(const MCHAR* name); \
19 void collect(); \
20 }; \
21 extern _cls##Class _cls##_class; \
22 class _rootclass; \
23 typedef Value* (_rootclass::*local_value_vf)(Value**, int); \
24 class _cls : public Generic \
25 { \
26 public: \
27 local_value_vf fn_ptr; \
28 _cls(); \
29 _cls(const MCHAR* name, local_value_vf fn); \
30 classof_methods (_cls, Generic); \
31 void collect(); \
32 Value* apply(Value** arglist, int count, CallContext* cc = NULL); \
33 };

◆ DEFINE_LOCAL_GENERIC_CLASS

#define DEFINE_LOCAL_GENERIC_CLASS ( _rootClass,
_cls )
35#define DEFINE_LOCAL_GENERIC_CLASS( _rootClass, _cls ) \
36 _cls##Class::_cls##Class(const MCHAR* name) \
37 : ValueMetaClass (name) \
38 { \
39 } \
40 void _cls##Class::collect() \
41 { \
42 delete this; \
43 } \
44 \
45 _cls::_cls() \
46 { \
47 } \
48 _cls::_cls(const MCHAR*fn_name, local_value_vf fn) \
49 { \
50 tag = &(_cls##_class); \
51 fn_ptr = fn; \
52 name = save_string(fn_name); \
53 } \
54 Value* _cls::apply(Value** arg_list, int count, CallContext* cc) \
55 { \
56 if (thread_local(is_dubugger_thread) && !theMXSDebugger->GetAllowUnsafeMethods()) \
57 throw DebuggerRuntimeError(_M("Method not available from debugger: "),name); \
58 Value* result = NULL; \
59 Value** evald_args; \
60 if (count < 1) \
61 throw ArgCountError(_M("Generic apply"), 1, count); \
62 value_local_array(evald_args, count); \
63 Value** ap = arg_list; \
64 Value** eap = evald_args; \
65 for (int i = count; i > 0; i--) \
66 { \
67 *eap = (*ap)->eval(); \
68 eap++; \
69 ap++; \
70 } \
71 if (evald_args[0]->local_base_class() == &_rootClass##_class) \
72 result = (((_rootClass*)evald_args[0])->*fn_ptr)(&evald_args[1], count - 1); \
73 else \
74 throw NoMethodError (name, evald_args[0]); \
75 return result; \
76 } \
77 void _cls::collect() \
78 { \
79 delete this; \
80 } \
81 _cls##Class _cls##_class (_M(#_cls));

◆ DEFINE_LOCAL_GENERIC_CLASS_DEBUG_OK

#define DEFINE_LOCAL_GENERIC_CLASS_DEBUG_OK ( _rootClass,
_cls )
84#define DEFINE_LOCAL_GENERIC_CLASS_DEBUG_OK( _rootClass, _cls ) \
85 _cls##Class::_cls##Class(const MCHAR* name) \
86 : ValueMetaClass (name) \
87 { \
88 } \
89 void _cls##Class::collect() \
90 { \
91 delete this; \
92 } \
93 \
94 _cls::_cls() \
95 { \
96 } \
97 _cls::_cls(const MCHAR*fn_name, local_value_vf fn) \
98 { \
99 tag = &(_cls##_class); \
100 fn_ptr = fn; \
101 name = save_string(fn_name); \
102 flags3 |= VALUE_FLAGBIT_0; \
103 } \
104 Value* _cls::apply(Value** arg_list, int count, CallContext* ) \
105 { \
106 Value* result = NULL; \
107 Value** evald_args; \
108 if (count < 1) \
109 throw ArgCountError(_M("Generic apply"), 1, count); \
110 value_local_array(evald_args, count); \
111 Value** ap = arg_list; \
112 Value** eap = evald_args; \
113 for (int i = count; i > 0; i--) \
114 { \
115 *eap = (*ap)->eval(); \
116 eap++; \
117 ap++; \
118 } \
119 if (evald_args[0]->local_base_class() == &_rootClass##_class) \
120 result = (((_rootClass*)evald_args[0])->*fn_ptr)(&evald_args[1], count - 1); \
121 else \
122 throw NoMethodError (name, evald_args[0]); \
123 return result; \
124 } \
125 void _cls::collect() \
126 { \
127 delete this; \
128 } \
129 _cls##Class _cls##_class (_M(#_cls));