22 #ifndef DIRECTOR_LINGO_OBJECT_H 23 #define DIRECTOR_LINGO_OBJECT_H 25 #include "director/lingo/lingo.h" 47 virtual ObjectType getObjType()
const = 0;
48 virtual bool isDisposed()
const = 0;
49 virtual int *getRefCount()
const = 0;
50 virtual void incRefCount() = 0;
51 virtual void decRefCount() = 0;
52 virtual int getInheritanceLevel()
const = 0;
55 virtual void dispose() = 0;
63 virtual uint32 getPropCount() = 0;
64 virtual bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false) = 0;
65 virtual bool hasField(
int field) = 0;
66 virtual Datum getField(
int field) = 0;
67 virtual bool setField(
int field,
const Datum &value) = 0;
70 template <
typename Derived>
80 _inheritanceLevel = 1;
87 _objType = obj._objType;
88 _disposed = obj._disposed;
89 _inheritanceLevel = obj._inheritanceLevel + 1;
97 warning(
"Object::initMethods: Methods already initialized");
102 for (
MethodProto *mtd = protos; mtd->name; mtd++) {
103 if (mtd->version > g_lingo->_vm->getVersion())
109 sym.nargs = mtd->minArgs;
110 sym.maxArgs = mtd->maxArgs;
111 sym.u.bltin = mtd->func;
112 (*_methods)[mtd->name] = sym;
116 static void cleanupMethods() {
126 ObjectType getObjType()
const override {
return _objType; };
127 bool isDisposed()
const override {
return _disposed; };
128 int *getRefCount()
const override {
return _refCount; };
129 void incRefCount()
override { *_refCount += 1; };
130 virtual void decRefCount()
override {
135 int getInheritanceLevel()
const override {
return _inheritanceLevel; };
137 void setName(
const Common::String &name)
override { _name = name; };
138 void dispose()
override { _disposed =
true; };
145 return new Derived(static_cast<Derived const &>(*
this));
152 warning(
"Method '%s' called on disposed object <%s>, returning VOID", methodName.c_str(), asString().c_str());
157 if ((_objType & (kFactoryObj | kXObj)) && methodName.hasPrefixIgnoreCase(
"m")) {
158 methodId = methodName.
substr(1);
160 methodId = methodName;
163 if (_methods && _methods->contains(methodId)) {
164 sym = (*_methods)[methodId];
168 if (g_lingo->_methods.
contains(methodId) && (g_lingo->_methods[methodId].targetType & _objType)) {
169 sym = g_lingo->_methods[methodId];
186 uint32 getPropCount()
override {
189 bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false)
override {
192 bool hasField(
int field)
override {
195 Datum getField(
int field)
override {
198 bool setField(
int field,
const Datum &value)
override {
207 int _inheritanceLevel;
210 template<
typename Derived>
215 ScriptType _scriptType;
229 bool _onlyInLctxContexts =
false;
236 bool isFactory()
const {
return _objType == kFactoryObj; };
237 void setFactory(
bool flag) { _objType = flag ? kFactoryObj : kScriptObj; }
239 void setOnlyInLctxContexts() { _onlyInLctxContexts =
true; }
240 bool getOnlyInLctxContexts() {
return _onlyInLctxContexts; }
247 uint32 getPropCount()
override;
248 bool setProp(
const Common::String &propName,
const Datum &value,
bool force =
false)
override;
258 void m_describe(
int nargs);
259 void m_dispose(
int nargs);
260 void m_get(
int nargs);
261 void m_instanceRespondsTo(
int nargs);
262 void m_messageList(
int nargs);
263 void m_name(
int nargs);
264 void m_new(
int nargs);
265 void m_perform(
int nargs);
266 void m_put(
int nargs);
267 void m_respondsTo(
int nargs);
270 void m_close(
int nargs);
271 void m_forget(
int nargs);
272 void m_moveToBack(
int nargs);
273 void m_moveToFront(
int nargs);
274 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:37
Definition: lingo-object.h:71
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:594
Definition: lingo-object.h:42
Definition: lingo-object.h:213