mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
Instead of passing sipIsErr into custom functions made for CppMethodDefs and etc. just check PyErr_Occurred after the function returns and then set sipIsErr there.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@69400 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -50,7 +50,6 @@ def run():
|
||||
self->SetColour(wxColour(wxMacCreateCGColorFromHITheme(macThemeBrushID)));
|
||||
#else
|
||||
wxPyRaiseNotImplemented();
|
||||
_isErr = 1;
|
||||
#endif
|
||||
""")
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ def run():
|
||||
return new wxColour(wxMacCreateCGColorFromHITheme(themeBrushID));
|
||||
#else
|
||||
wxPyRaiseNotImplemented();
|
||||
_isErr = 1;
|
||||
return NULL;
|
||||
#endif
|
||||
""", factory=True)
|
||||
@@ -148,9 +147,9 @@ def run():
|
||||
alpha = self->Alpha();
|
||||
}
|
||||
if (includeAlpha)
|
||||
return sipBuildResult(&_isErr, "(iiii)", red, green, blue, alpha);
|
||||
return sipBuildResult(0, "(iiii)", red, green, blue, alpha);
|
||||
else
|
||||
return sipBuildResult(&_isErr, "(iii)", red, green, blue);
|
||||
return sipBuildResult(0, "(iii)", red, green, blue);
|
||||
""", briefDoc="""\
|
||||
Get(includeAlpha=False) -> (r,g,b) or (r,g,b,a)\n
|
||||
Returns the RGB intensity values as a tuple, optionally the alpha value as well.""")
|
||||
|
||||
@@ -156,7 +156,6 @@ def run():
|
||||
return (long)((wxMSWDCImpl*)self->GetImpl())->GetHDC();
|
||||
#else
|
||||
wxPyRaiseNotImplemented();
|
||||
_isErr = 1;
|
||||
return 0;
|
||||
#endif""")
|
||||
c.addCppMethod('void*', 'GetCGContext', '()', """\
|
||||
@@ -169,7 +168,6 @@ def run():
|
||||
return cgctx;
|
||||
#else
|
||||
wxPyRaiseNotImplemented();
|
||||
_isErr = 1;
|
||||
return NULL;
|
||||
#endif""")
|
||||
c.addCppMethod('void*', 'GetGdkDrawable', '()', """\
|
||||
@@ -180,7 +178,6 @@ def run():
|
||||
return ((wxGTKDCImpl*)self->GetImpl())->GetGDKWindow();
|
||||
#else
|
||||
wxPyRaiseNotImplemented();
|
||||
_isErr = 1;
|
||||
return NULL;
|
||||
#endif""")
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ def run():
|
||||
&wxPyCallback::EventThunker);
|
||||
}
|
||||
else {
|
||||
_isErr = 1;
|
||||
PyErr_SetString(PyExc_TypeError, "Expected callable object or None.");
|
||||
}
|
||||
""")
|
||||
@@ -354,7 +353,6 @@ def run():
|
||||
if (!list) {
|
||||
PyErr_SetString(PyExc_MemoryError, "Can't allocate list of files!");
|
||||
wxPyEndBlockThreads(blocked);
|
||||
_isErr = 1;
|
||||
return NULL;
|
||||
}
|
||||
for (int i=0; i<count; i++) {
|
||||
|
||||
@@ -103,7 +103,7 @@ def run():
|
||||
c.convertFromPyObject = tools.convertTwoIntegersTemplate('wxPoint')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(ii)", self->x, self->y);
|
||||
return sipBuildResult(0, "(ii)", self->x, self->y);
|
||||
""", briefDoc="""\
|
||||
Get() -> (x,y)\n
|
||||
Return the x and y properties as a tuple.""")
|
||||
@@ -161,7 +161,7 @@ def run():
|
||||
c.convertFromPyObject = tools.convertTwoIntegersTemplate('wxSize')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(ii)", self->GetWidth(), self->GetHeight());
|
||||
return sipBuildResult(0, "(ii)", self->GetWidth(), self->GetHeight());
|
||||
""", briefDoc="""\
|
||||
Get() -> (width, height)\n
|
||||
Return the width and height properties as a tuple.""")
|
||||
@@ -233,7 +233,7 @@ def run():
|
||||
c.convertFromPyObject = tools.convertFourIntegersTemplate('wxRect')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(iiii)",
|
||||
return sipBuildResult(0, "(iiii)",
|
||||
self->x, self->y, self->width, self->height);
|
||||
""", briefDoc="""\
|
||||
Get() -> (x, y, width, height)\n
|
||||
@@ -282,7 +282,7 @@ def run():
|
||||
c.convertFromPyObject = tools.convertTwoDoublesTemplate('wxRealPoint')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(dd)", self->x, self->y);
|
||||
return sipBuildResult(0, "(dd)", self->x, self->y);
|
||||
""", briefDoc="""\
|
||||
Get() -> (x, y, width, height)\n
|
||||
Return the rectangle's properties as a tuple.""")
|
||||
|
||||
@@ -60,8 +60,9 @@ def run():
|
||||
c.convertFromPyObject = tools.convertTwoDoublesTemplate('wxPoint2DDouble')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(dd)", self->m_x, self->m_y);
|
||||
""", briefDoc="""\
|
||||
return sipBuildResult(0, "(dd)", self->m_x, self->m_y);
|
||||
""",
|
||||
briefDoc="""\
|
||||
Get() -> (x,y)\n
|
||||
Return the x and y properties as a tuple.""")
|
||||
|
||||
@@ -103,9 +104,10 @@ def run():
|
||||
c.convertFromPyObject = tools.convertFourDoublesTemplate('wxRect2DDouble')
|
||||
|
||||
c.addCppMethod('PyObject*', 'Get', '()', """\
|
||||
return sipBuildResult(&_isErr, "(dddd)",
|
||||
return sipBuildResult(0, "(dddd)",
|
||||
self->m_x, self->m_y, self->m_width, self->m_height);
|
||||
""", briefDoc="""\
|
||||
""",
|
||||
briefDoc="""\
|
||||
Get() -> (x, y, width, height)\n
|
||||
Return the rectangle's properties as a tuple.""")
|
||||
|
||||
|
||||
@@ -520,8 +520,6 @@ from %s import *
|
||||
name = re.split(r'[ \*\&]+', name)[-1]
|
||||
pnames[idx] = name
|
||||
pnames = ', '.join(pnames)
|
||||
if pnames:
|
||||
pnames = ', ' + pnames
|
||||
typ = method.type
|
||||
|
||||
if not skipDeclaration:
|
||||
@@ -553,11 +551,9 @@ from %s import *
|
||||
arg = arg.replace('&', '*') # SIP will always want to use pointers for parameters
|
||||
fargs[idx] = arg
|
||||
fargs = ', '.join(fargs)
|
||||
if fargs:
|
||||
fargs = ', ' + fargs
|
||||
if method.isCtor:
|
||||
fname = '_%s_newCtor' % klass.name
|
||||
fargs = '(int& _isErr%s)' % fargs
|
||||
fargs = '(%s)' % fargs
|
||||
fstream.write('%s%%TypeCode\n' % indent)
|
||||
typ = klass.name
|
||||
if method.useDerivedName:
|
||||
@@ -574,13 +570,15 @@ from %s import *
|
||||
if method.isStatic:
|
||||
# If the method is static then there is no sipCpp to send to
|
||||
# the new function, so it should not have a self parameter.
|
||||
fargs = '(int& _isErr%s)' % fargs
|
||||
fargs = '(%s)' % fargs
|
||||
else:
|
||||
fargs = '(%s* self, int& _isErr%s)' % (klass.name, fargs)
|
||||
if fargs:
|
||||
fargs = ', ' + fargs
|
||||
fargs = '(%s* self%s)' % (klass.name, fargs)
|
||||
fstream.write('%s%%TypeCode\n' % indent)
|
||||
else:
|
||||
fname = '_%s_function' % method.name
|
||||
fargs = '(int& _isErr%s)' % fargs
|
||||
fargs = '(%s)' % fargs
|
||||
fstream.write('%s%%ModuleCode\n' % indent)
|
||||
|
||||
# If the return type is in the forcePtrTypes list then make sure
|
||||
@@ -603,7 +601,7 @@ from %s import *
|
||||
stream.write('%s%%MethodCode\n' % indent)
|
||||
stream.write(indent+' '*4)
|
||||
if method.isCtor:
|
||||
stream.write('sipCpp = %s(sipIsErr%s);\n' % (fname, pnames))
|
||||
stream.write('sipCpp = %s(%s);\n' % (fname, pnames))
|
||||
else:
|
||||
if method.type != 'void':
|
||||
stream.write('sipRes = ')
|
||||
@@ -611,11 +609,15 @@ from %s import *
|
||||
if method.isStatic:
|
||||
# If the method is static then there is no sipCpp to send to
|
||||
# the new function, so it should not have a self parameter.
|
||||
stream.write('%s(sipIsErr%s);\n' % (fname, pnames))
|
||||
stream.write('%s(%s);\n' % (fname, pnames))
|
||||
else:
|
||||
stream.write('%s(sipCpp, sipIsErr%s);\n' % (fname, pnames))
|
||||
if pnames:
|
||||
pnames = ', ' + pnames
|
||||
stream.write('%s(sipCpp%s);\n' % (fname, pnames))
|
||||
else:
|
||||
stream.write('%s(sipIsErr%s);\n' % (fname, pnames))
|
||||
stream.write('%s(%s);\n' % (fname, pnames))
|
||||
stream.write(indent+' '*4)
|
||||
stream.write('if (PyErr_Occurred()) sipIsErr = 1;\n')
|
||||
stream.write('%s%%End\n' % indent)
|
||||
|
||||
# and finally, add the new function itself
|
||||
@@ -640,7 +642,6 @@ from %s import *
|
||||
stream.write('%s%%MethodCode\n' % indent)
|
||||
stream.write(nci(method.body, len(indent)+4))
|
||||
stream.write('%s%%End\n\n' % indent)
|
||||
# TODO: add the %Docstring...
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user