1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 /*
24  * This file is based on WME Lite.
25  * http://dead-code.org/redir.php?target=wmelite
26  * Copyright (c) 2011 Jan Nedoma
27  */
28 
29 #ifndef WINTERMUTE_BASE_SCRIPTABLE_H
30 #define WINTERMUTE_BASE_SCRIPTABLE_H
31 
32 
33 #include "engines/wintermute/base/base_named_object.h"
34 #include "engines/wintermute/persistent.h"
35 
36 namespace Wintermute {
37 
38 class ScValue;
39 class ScStack;
40 class ScScript;
41 
42 class BaseScriptable : public BaseNamedObject {
43 public:
44 	virtual ScScript *invokeMethodThread(const char *methodName);
45 	DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject)
46 
47 	BaseScriptable(BaseGame *inGame, bool noValue = false, bool persistable = true);
48 	~BaseScriptable() override;
49 
50 	// high level scripting interface
51 	virtual bool canHandleMethod(const char *eventMethod) const;
52 	virtual bool scSetProperty(const char *name, ScValue *value);
53 	virtual ScValue *scGetProperty(const Common::String &name);
54 	virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name);
55 	virtual const char *scToString();
56 	virtual void *scToMemBuffer();
57 	virtual int scToInt();
58 	virtual double scToFloat();
59 	virtual bool scToBool();
60 	virtual void scSetString(const char *val);
61 	virtual void scSetInt(int val);
62 	virtual void scSetFloat(double val);
63 	virtual void scSetBool(bool val);
64 	virtual int scCompare(BaseScriptable *val);
65 	virtual void scDebuggerDesc(char *buf, int bufSize);
66 	virtual Common::String debuggerToString() const;
67 	int32 _refCount;
68 	ScValue *_scValue;
69 	ScValue *_scProp;
70 };
71 
72 // Implemented in their respective .cpp-files
73 BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack);
74 BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack);
75 BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack);
76 BaseScriptable *makeSXDirectory(BaseGame *inGame);
77 BaseScriptable *makeSXMath(BaseGame *inGame);
78 BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack);
79 BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack);
80 BaseScriptable *makeSXStore(BaseGame *inGame);
81 BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack);
82 
83 } // End of namespace Wintermute
84 
85 #endif
86