22 #ifndef DIRECTOR_LINGO_OBJECT_H 23 #define DIRECTOR_LINGO_OBJECT_H 25 #include "director/lingo/lingo.h" 42 virtual ObjectType getObjType()
const = 0;
43 virtual bool isDisposed()
const = 0;
44 virtual int *getRefCount()
const = 0;
45 virtual void incRefCount() = 0;
46 virtual void decRefCount() = 0;
47 virtual int getInheritanceLevel()
const = 0;
50 virtual void dispose() = 0;
58 virtual uint32 getPropCount() = 0;
59 virtual bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false) = 0;
60 virtual bool hasField(
int field) = 0;
61 virtual Datum getField(
int field) = 0;
62 virtual bool setField(
int field,
const Datum &value) = 0;
65 template <
typename Derived>
75 _inheritanceLevel = 1;
82 _objType = obj._objType;
83 _disposed = obj._disposed;
84 _inheritanceLevel = obj._inheritanceLevel + 1;
92 warning(
"Object::initMethods: Methods already initialized");
98 if (mtd->version > g_lingo->_vm->getVersion())
104 sym.nargs = mtd->minArgs;
105 sym.maxArgs = mtd->maxArgs;
106 sym.u.bltin = mtd->func;
107 (*_methods)[mtd->name] = sym;
111 static void cleanupMethods() {
121 ObjectType getObjType()
const override {
return _objType; };
122 bool isDisposed()
const override {
return _disposed; };
123 int *getRefCount()
const override {
return _refCount; };
124 void incRefCount()
override { *_refCount += 1; };
125 virtual void decRefCount()
override {
130 int getInheritanceLevel()
const override {
return _inheritanceLevel; };
132 void setName(
const Common::String &name)
override { _name = name; };
133 void dispose()
override { _disposed =
true; };
140 return new Derived(static_cast<Derived const &>(*
this));
147 warning(
"Method '%s' called on disposed object <%s>, returning VOID", methodName.c_str(), asString().c_str());
152 if ((_objType & (kFactoryObj | kXObj)) && methodName.hasPrefixIgnoreCase(
"m")) {
153 methodId = methodName.
substr(1);
155 methodId = methodName;
158 if (_methods && _methods->contains(methodId)) {
159 sym = (*_methods)[methodId];
163 if (g_lingo->_methods.
contains(methodId) && (g_lingo->_methods[methodId].targetType & _objType)) {
164 sym = g_lingo->_methods[methodId];
181 uint32 getPropCount()
override {
184 bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false)
override {
187 bool hasField(
int field)
override {
190 Datum getField(
int field)
override {
193 bool setField(
int field,
const Datum &value)
override {
202 int _inheritanceLevel;
205 template<
typename Derived>
210 ScriptType _scriptType;
222 bool _onlyInLctxContexts =
false;
229 bool isFactory()
const {
return _objType == kFactoryObj; };
230 void setFactory(
bool flag) { _objType = flag ? kFactoryObj : kScriptObj; }
232 void setOnlyInLctxContexts() { _onlyInLctxContexts =
true; }
233 bool getOnlyInLctxContexts() {
return _onlyInLctxContexts; }
240 uint32 getPropCount()
override;
241 bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false)
override;
251 void m_describe(
int nargs);
252 void m_dispose(
int nargs);
253 void m_get(
int nargs);
254 void m_instanceRespondsTo(
int nargs);
255 void m_messageList(
int nargs);
256 void m_name(
int nargs);
257 void m_new(
int nargs);
258 void m_perform(
int nargs);
259 void m_put(
int nargs);
260 void m_respondsTo(
int nargs);
263 void m_close(
int nargs);
264 void m_forget(
int nargs);
265 void m_moveToBack(
int nargs);
266 void m_moveToFront(
int nargs);
267 void m_open(
int nargs);
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: lingo-object.h:66
Definition: lingo-object.h:29
String substr(size_t pos=0, size_t len=npos) const
bool contains(const Key &key) const
Definition: hashmap.h:592
Definition: lingo-object.h:37
Definition: lingo-object.h:208