hackathon-dev #1
|
@ -1,25 +1,16 @@
|
||||||
# Initial test script
|
# Initial test script
|
||||||
import upiwin_tmp
|
import upiwin_tmp
|
||||||
|
|
||||||
FBPRIMCLR_BLACK = 0x0000
|
upiwin_tmp.filled_rectangle(10, 10, 50, 50, upiwin_tmp.FBPRIMCLR_RED, False)
|
||||||
FBPRIMCLR_RED = 0xF800
|
upiwin_tmp.filled_rectangle(60, 10, 100, 50, upiwin_tmp.FBPRIMCLR_GREEN, False)
|
||||||
FBPRIMCLR_GREEN = 0x07E0
|
upiwin_tmp.filled_rectangle(110, 10, 150, 50, upiwin_tmp.FBPRIMCLR_BLUE, False)
|
||||||
FBPRIMCLR_BLUE = 0x001F
|
upiwin_tmp.filled_rectangle(10, 60, 50, 100, upiwin_tmp.FBPRIMCLR_CYAN, False)
|
||||||
FBPRIMCLR_YELLOW = 0xFFE0
|
upiwin_tmp.filled_rectangle(60, 60, 100, 100, upiwin_tmp.FBPRIMCLR_MAGENTA, False)
|
||||||
FBPRIMCLR_CYAN = 0x07FF
|
upiwin_tmp.filled_rectangle(110, 60, 150, 100, upiwin_tmp.FBPRIMCLR_YELLOW, False)
|
||||||
FBPRIMCLR_MAGENTA = 0xF81F
|
upiwin_tmp.rectangle(10, 110, 150, 150, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
||||||
FBPRIMCLR_WHITE = 0xFFFF
|
upiwin_tmp.line(10, 110, 150, 150, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
||||||
|
upiwin_tmp.line(10, 150, 150, 110, upiwin_tmp.FBPRIMCLR_WHITE, False)
|
||||||
|
|
||||||
upiwin_tmp.filled_rectangle(10, 10, 50, 50, FBPRIMCLR_RED, False)
|
upiwin_tmp.line(0, 180, 319, 180, upiwin_tmp.FBPRIMCLR_RED, False);
|
||||||
upiwin_tmp.filled_rectangle(60, 10, 100, 50, FBPRIMCLR_GREEN, False)
|
upiwin_tmp.line(0, 196, 319, 196, upiwin_tmp.FBPRIMCLR_RED, False);
|
||||||
upiwin_tmp.filled_rectangle(110, 10, 150, 50, FBPRIMCLR_BLUE, False)
|
|
||||||
upiwin_tmp.filled_rectangle(10, 60, 50, 100, FBPRIMCLR_CYAN, False)
|
|
||||||
upiwin_tmp.filled_rectangle(60, 60, 100, 100, FBPRIMCLR_MAGENTA, False)
|
|
||||||
upiwin_tmp.filled_rectangle(110, 60, 150, 100, FBPRIMCLR_YELLOW, False)
|
|
||||||
upiwin_tmp.rectangle(10, 110, 150, 150, FBPRIMCLR_WHITE, False)
|
|
||||||
upiwin_tmp.line(10, 110, 150, 150, FBPRIMCLR_WHITE, False)
|
|
||||||
upiwin_tmp.line(10, 150, 150, 110, FBPRIMCLR_WHITE, False)
|
|
||||||
|
|
||||||
upiwin_tmp.line(0, 180, 319, 180, FBPRIMCLR_RED, False);
|
|
||||||
upiwin_tmp.line(0, 196, 319, 196, FBPRIMCLR_RED, False);
|
|
||||||
upiwin_tmp.textout(10, 180, 'Amy was here!!!')
|
upiwin_tmp.textout(10, 180, 'Amy was here!!!')
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "scode.h"
|
#include "scode.h"
|
||||||
#include "fbprimitive.h"
|
#include "fbprimitive.h"
|
||||||
#include "ep_init.h"
|
#include "ep_init.h"
|
||||||
|
#include "ep_util.h"
|
||||||
|
|
||||||
static PyObject *do_setpixel(PyObject *self, PyObject *args)
|
static PyObject *do_setpixel(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -84,10 +85,30 @@ static PyModuleDef DefUPIWIN_tmp = {
|
||||||
NULL /* no free function */
|
NULL /* no free function */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BEGIN_CONSTANT_TABLE(UPIWIN_tmpConstants)
|
||||||
|
/* primitive color values */
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_BLACK)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_RED)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_GREEN)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_BLUE)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_YELLOW)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_CYAN)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_MAGENTA)
|
||||||
|
CONSTANT_INT_MACRO(FBPRIMCLR_WHITE)
|
||||||
|
END_CONSTANT_TABLE
|
||||||
|
|
||||||
PyObject *Epython_init_upiwin_tmp_module(void)
|
PyObject *Epython_init_upiwin_tmp_module(void)
|
||||||
{
|
{
|
||||||
PyObject *module;
|
PyObject *module;
|
||||||
|
|
||||||
module = PyModule_Create(&DefUPIWIN_tmp);
|
module = PyModule_Create(&DefUPIWIN_tmp);
|
||||||
|
if (module)
|
||||||
|
{
|
||||||
|
if (FAILED(Epython_register_constants(module, UPIWIN_tmpConstants)))
|
||||||
|
{
|
||||||
|
Py_DECREF(module);
|
||||||
|
module = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,3 +42,33 @@ HRESULT Epython_trace_exception(void)
|
||||||
Py_DECREF(traceback);
|
Py_DECREF(traceback);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT Epython_register_constants(PyObject *module, PCREGCONSTANT const_table)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
int i = 0, rc;
|
||||||
|
|
||||||
|
while (const_table[i].name)
|
||||||
|
{
|
||||||
|
switch (const_table[i].regtype)
|
||||||
|
{
|
||||||
|
case 'i':
|
||||||
|
rc = PyModule_AddIntConstant(module, const_table[i].name, const_table[i].value.ival);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
rc = PyModule_AddStringConstant(module, const_table[i].name, const_table[i].value.sval);
|
||||||
|
break;
|
||||||
|
default;
|
||||||
|
Log(LERROR, "register_constants type '%c' unknown", const_table[i].regtype);
|
||||||
|
return E_UNEXPECTED;
|
||||||
|
}
|
||||||
|
if (!rc)
|
||||||
|
{
|
||||||
|
hr = E_FAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,26 @@
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include "wintype.h"
|
#include "wintype.h"
|
||||||
|
|
||||||
|
typedef struct tagREGCONSTANT {
|
||||||
|
CHAR regtype;
|
||||||
|
PCSTR name;
|
||||||
|
union {
|
||||||
|
LONG ival;
|
||||||
|
PCSTR sval;
|
||||||
|
} value;
|
||||||
|
} REGCONSTANT, *PREGCONSTANT;
|
||||||
|
|
||||||
|
typedef const REGCONSTANT *PCREGCONSTANT;
|
||||||
|
|
||||||
extern void Epython_log_object(int level, const char *label, PyObject *object);
|
extern void Epython_log_object(int level, const char *label, PyObject *object);
|
||||||
extern HRESULT Epython_trace_exception(void);
|
extern HRESULT Epython_trace_exception(void);
|
||||||
|
extern HRESULT Epython_register_constants(PyObject *module, PCREGCONSTANT const_table);
|
||||||
|
|
||||||
|
#define BEGIN_CONSTANT_TABLE(name) static const REGCONSTANT name[] = {
|
||||||
|
#define CONSTANT_INT(name, value) { 'i', name, { .ival = value } },
|
||||||
|
#define CONSTANT_INT_MACRO(mac) CONSTANT_INT(#mac, mac)
|
||||||
|
#define CONSTANT_STRING(name, value) { 's', name, { .sval = value } },
|
||||||
|
#define CONSTANT_STRING_MACRO(mac) CONSTANT_STRING(#mac, mac)
|
||||||
|
#define END_CONSTANT_TABLE { 0, NULL, { .sval = NULL } } };
|
||||||
|
|
||||||
#endif /* __EP_UTIL_H_INCLUDED */
|
#endif /* __EP_UTIL_H_INCLUDED */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user