-
Notifications
You must be signed in to change notification settings - Fork 230
Expand file tree
/
Copy pathPythonEngine.hpp
More file actions
66 lines (47 loc) · 2.07 KB
/
PythonEngine.hpp
File metadata and controls
66 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
* See also https://openstudio.net/license
***********************************************************************************************************************/
#ifndef PYTHONENGINE_included
#define PYTHONENGINE_included
#include <ScriptEngine.hpp>
#include <ScriptEngineAPI.hpp>
#ifndef PyObject_HEAD
struct _object;
using PyObject = _object;
#endif
namespace openstudio {
class PythonEngine final : public ScriptEngine
{
public:
PythonEngine(int argc, char* argv[]);
~PythonEngine() override;
PythonEngine(const PythonEngine&) = delete;
PythonEngine(PythonEngine&&) = delete;
PythonEngine& operator=(const PythonEngine&) = delete;
PythonEngine& operator=(PythonEngine&&) = delete;
ScriptObject eval(std::string_view sv) override;
void exec(std::string_view sv) override;
virtual void setupPythonPath(const std::vector<openstudio::path>& includeDirs) override;
virtual std::string inferMeasureClassName(const openstudio::path& measureScriptPath) override;
virtual ScriptObject loadMeasure(const openstudio::path& measureScriptPath, std::string_view className) override;
virtual int numberOfArguments(ScriptObject& methodObject, std::string_view methodName) override;
virtual bool hasMethod(ScriptObject& methodObject, std::string_view methodName, bool overriden_only) override;
protected:
void* getAs_impl(ScriptObject& obj, const std::type_info&) override;
bool getAs_impl_bool(ScriptObject& obj) override;
int getAs_impl_int(ScriptObject& obj) override;
double getAs_impl_double(ScriptObject& obj) override;
std::string getAs_impl_string(ScriptObject& obj) override;
void importOpenStudio();
void pyimport(const std::string& importName, const std::string& includePath);
private:
wchar_t* program;
PyObject* m_globalDict;
};
} // namespace openstudio
extern "C"
{
SCRIPTENGINE_API openstudio::ScriptEngine* makeScriptEngine(int argc, char* argv[]);
}
#endif