Compare commits

..

3 Commits

2 changed files with 55 additions and 42 deletions

View File

@@ -32,9 +32,9 @@ and run UPIWIN successfully. This document describes the process.
## Installing Libraries for UPIWIN ## Installing Libraries for UPIWIN
1. Use `sudo -i` to get a root command prompt. 1. Use `sudo -i` to get a root command prompt.
2. Execute the command to install packaged libraries: 2. Execute the command to install packaged libraries and utilities:
apt install python3-dev libfreetype6-dev libpng-dev ttf-mscorefonts-installer apt install python3-dev libfreetype6-dev libpng-dev libzip-dev ttf-mscorefonts-installer zip
3. Execute the commands to install the BCM2835 library: 3. Execute the commands to install the BCM2835 library:

View File

@@ -27,12 +27,34 @@
#include "ep_init.h" #include "ep_init.h"
#include "ep_types.h" #include "ep_types.h"
static PyObject *wrap_resource_file_handle(HRESFILE handle)
static PyObject *resfile_load_classmethod(ResFileType *cls, PyObject *args)
{ {
const char *filename;
PyObject *rc = NULL, *args, *kwargs; PyObject *rc = NULL, *args, *kwargs;
ResFileObject *presfile; ResFileObject *presfile;
args = PyTuple_New(0);
if (args)
{
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&ResFileType, args, kwargs);
if (rc)
{
presfile = (ResFileObject *)rc;
presfile->hresfile = handle;
}
Py_DECREF(kwargs);
}
Py_DECREF(args);
}
return rc;
}
static PyObject *resfile_load_classmethod(PyTypeObject *cls, PyObject *args)
{
const char *filename;
PyObject *rc = NULL;
HRESULT hr; HRESULT hr;
HRESFILE handle; HRESFILE handle;
@@ -41,23 +63,7 @@ static PyObject *resfile_load_classmethod(ResFileType *cls, PyObject *args)
hr = Rsrc_load_file((PCSTR)filename, &handle); hr = Rsrc_load_file((PCSTR)filename, &handle);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
args = PyTuple_New(0); rc = wrap_resource_file_handle(handle);
if (args)
{
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&ResFileType, args, kwargs);
if (rc)
{
presfile = (ResFileObject *)rc;
presfile->hresfile = handle;
}
Py_DECREF(kwargs);
}
Py_DECREF(args);
}
if (!rc) if (!rc)
{ {
Rsrc_close_file(handle); Rsrc_close_file(handle);
@@ -77,11 +83,34 @@ static PyObject *resfile_close(ResFileObject *self, PyObject *args)
return NULL; return NULL;
} }
static PyObject *wrap_resource_handle(HRSRC hrsrc)
{
PyObject *rc = NULL, *args, *kwargs;
ResourceObject *pres;
args = PyTuple_New(0);
if (args)
{
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&ResourceType, args, kwargs);
if (rc)
{
pres = (ResourceObject *)rc;
pres->hrsrc = hrsrc;
}
Py_DECREF(kwargs);
}
Py_DECREF(args);
}
return rc;
}
static PyObject *resfile_find_resource(ResFileObject *self, PyObject *args) static PyObject *resfile_find_resource(ResFileObject *self, PyObject *args)
{ {
const char *name; const char *name;
PyObject *rc = NULL, *args, *kwargs; PyObject *rc = NULL;
ResourceObject *pres;
HRSRC hrsrc; HRSRC hrsrc;
HRESULT hr; HRESULT hr;
@@ -90,23 +119,7 @@ static PyObject *resfile_find_resource(ResFileObject *self, PyObject *args)
hr = Rsrc_find_resource(self->hresfile, (PCSTR)name, NULL, &hrsrc); hr = Rsrc_find_resource(self->hresfile, (PCSTR)name, NULL, &hrsrc);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
args = PyTuple_New(0); rc = wrap_resource_handle(hrsrc);
if (args)
{
kwargs = PyDict_New();
if (kwargs)
{
rc = PyType_GenericNew(&ResourceType, args, kwargs);
if (rc)
{
pres = (ResourceObject *)rc;
pres->hrsrc = hrsrc;
}
Py_DECREF(kwargs);
}
Py_DECREF(args);
}
if (!rc) if (!rc)
{ {
Rsrc_free_resource(hrsrc); Rsrc_free_resource(hrsrc);
@@ -114,7 +127,7 @@ static PyObject *resfile_find_resource(ResFileObject *self, PyObject *args)
} }
} }
else else
PyErr_Format(PyExc_RuntimeError, "unable to load resource file '%s' (%08x)", filename, hr); PyErr_Format(PyExc_RuntimeError, "unable to load resource ''%s' (%08x)", name, hr);
return rc; return rc;
} }