2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
2012-12-18 00:51:25 +00:00
|
|
|
*/
|
2010-07-26 01:23:27 +00:00
|
|
|
|
|
|
|
|
#include "../stroke/StyleModule.h"
|
|
|
|
|
#include "../system/PythonInterpreter.h"
|
|
|
|
|
|
2014-07-19 15:38:56 +09:00
|
|
|
#include "BLI_utildefines.h" // BLI_assert()
|
2014-07-16 00:21:27 +09:00
|
|
|
|
2014-07-19 15:38:56 +09:00
|
|
|
struct Text;
|
2010-07-26 01:23:27 +00:00
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2015-04-28 23:18:32 +09:00
|
|
|
class BufferedStyleModule : public StyleModule {
|
|
|
|
|
public:
|
|
|
|
|
BufferedStyleModule(const string &buffer, const string &file_name, Interpreter *inter)
|
|
|
|
|
: StyleModule(file_name, inter)
|
|
|
|
|
{
|
|
|
|
|
_buffer = buffer;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
virtual ~BufferedStyleModule() {}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-28 23:18:32 +09:00
|
|
|
protected:
|
|
|
|
|
virtual int interpret()
|
|
|
|
|
{
|
|
|
|
|
PythonInterpreter *py_inter = dynamic_cast<PythonInterpreter *>(_inter);
|
|
|
|
|
BLI_assert(py_inter != 0);
|
|
|
|
|
return py_inter->interpretString(_buffer, getFileName());
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-28 23:18:32 +09:00
|
|
|
private:
|
|
|
|
|
string _buffer;
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BufferedStyleModule")
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
2010-07-26 01:23:27 +00:00
|
|
|
class BlenderStyleModule : public StyleModule {
|
2012-12-18 00:51:25 +00:00
|
|
|
public:
|
2014-07-19 18:52:32 +09:00
|
|
|
BlenderStyleModule(struct Text *text, const string &name, Interpreter *inter)
|
|
|
|
|
: StyleModule(name, inter)
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2010-07-26 01:23:27 +00:00
|
|
|
_text = text;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
virtual ~BlenderStyleModule() {}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-26 01:23:27 +00:00
|
|
|
protected:
|
2012-12-18 00:51:25 +00:00
|
|
|
virtual int interpret()
|
|
|
|
|
{
|
2013-03-07 23:17:23 +00:00
|
|
|
PythonInterpreter *py_inter = dynamic_cast<PythonInterpreter *>(_inter);
|
2014-04-17 12:55:17 +09:00
|
|
|
BLI_assert(py_inter != 0);
|
2010-07-26 01:23:27 +00:00
|
|
|
return py_inter->interpretText(_text, getFileName());
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-07-26 01:23:27 +00:00
|
|
|
private:
|
|
|
|
|
struct Text *_text;
|
2013-08-04 18:50:00 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:BlenderStyleModule")
|
|
|
|
|
#endif
|
2010-07-26 01:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|