Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2019-01-27 20:44:05 +01:00
7 changed files with 145 additions and 124 deletions

27
PyInt.h
View File

@@ -28,18 +28,35 @@ http://mozilla.org/MPL/2.0/.
#include "Classes.h"
#include "utilities.h"
#define PyGetFloat(param) PyFloat_FromDouble(param >= 0 ? param : -param)
#define PyGetFloatS(param) PyFloat_FromDouble(param)
#define PyGetFloat(param) PyFloat_FromDouble(param)
#define PyGetInt(param) PyInt_FromLong(param)
#define PyGetBool(param) param ? Py_True : Py_False
#define PyGetString(param) PyString_FromString(param)
// collection of keyword-value pairs
// NOTE: since our python dictionary operates on a few types, most of the class was hardcoded for simplicity
struct dictionary_source {
// types
template <typename Type_>
using keyvaluepair_sequence = std::vector<std::pair<std::string, Type_>>;
// members
keyvaluepair_sequence<double> floats;
keyvaluepair_sequence<int> integers;
keyvaluepair_sequence<bool> bools;
keyvaluepair_sequence<std::string> strings;
// methods
inline void insert( std::string const &Key, double const Value ) { floats.emplace_back( Key, Value ); }
inline void insert( std::string const &Key, int const Value ) { integers.emplace_back( Key, Value ); }
inline void insert( std::string const &Key, bool const Value ) { bools.emplace_back( Key, Value ); }
inline void insert( std::string const &Key, std::string const Value ) { strings.emplace_back( Key, Value ); }
};
// TODO: extract common base and inherit specialization from it
class render_task {
public:
// constructors
render_task( PyObject *Renderer, PyObject *Input, GLuint Target ) :
render_task( PyObject *Renderer, dictionary_source *Input, GLuint Target ) :
m_renderer( Renderer ), m_input( Input ), m_target( Target )
{}
// methods
@@ -50,7 +67,7 @@ public:
private:
// members
PyObject *m_renderer {nullptr};
PyObject *m_input { nullptr };
dictionary_source *m_input { nullptr };
GLuint m_target { 0 };
};
@@ -63,7 +80,7 @@ public:
struct task_request {
std::string const &renderer;
PyObject *input;
dictionary_source *input;
GLuint target;
};
// constructors