ScummVM API documentation
luascript.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This code is based on Broken Sword 2.5 engine
24 *
25 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26 *
27 * Licensed under GNU GPL v2
28 *
29 */
30
31#ifndef SWORD25_LUASCRIPT_H
32#define SWORD25_LUASCRIPT_H
33
34#include "common/str.h"
35#include "common/str-array.h"
36#include "sword25/kernel/common.h"
37#include "sword25/script/script.h"
38
39struct lua_State;
40
41namespace Sword25 {
42
43class Kernel;
44
46public:
47 LuaScriptEngine(Kernel *KernelPtr);
48 ~LuaScriptEngine() override;
49
54 bool init() override;
55
61 bool executeFile(const Common::String &fileName) override;
62
68 bool executeString(const Common::String &code) override;
69
74 void *getScriptObject() override {
75 return _state;
76 }
77
84 void setCommandLine(const Common::StringArray &commandLineParameters) override;
85
89 bool persist(OutputPersistenceBlock &writer) override;
93 bool unpersist(InputPersistenceBlock &reader) override;
94
95private:
96 lua_State *_state;
97 int _pcallErrorhandlerRegistryIndex;
98
99 bool registerStandardLibs();
100 bool registerStandardLibExtensions();
101 bool executeBuffer(const byte *data, uint size, const Common::String &name) const;
102};
103
104} // End of namespace Sword25
105
106#endif
Definition: str.h:59
Definition: inputpersistenceblock.h:40
Definition: kernel.h:72
Definition: luascript.h:45
bool executeString(const Common::String &code) override
bool unpersist(InputPersistenceBlock &reader) override
void * getScriptObject() override
Definition: luascript.h:74
bool init() override
bool executeFile(const Common::String &fileName) override
void setCommandLine(const Common::StringArray &commandLineParameters) override
bool persist(OutputPersistenceBlock &writer) override
Definition: outputpersistenceblock.h:39
Definition: script.h:46
Definition: console.h:27
Definition: lstate.h:100