5252
5353castsRet = {
5454 'bool' : lambda val : 'return 0 != (' + val + ')' ,
55- 'boost::python::tuple' : lambda val : 'int retVal = (int)' + val + ';\n ' + reacquireGIL () + '\t return boost::python::make_tuple(COLOUR_RED(retVal), COLOUR_GREEN(retVal), COLOUR_BLUE(retVal))'
55+ 'boost::python::tuple' : lambda val : 'int retVal = (int)' + val + ';\n ' + '\t return boost::python::make_tuple(COLOUR_RED(retVal), COLOUR_GREEN(retVal), COLOUR_BLUE(retVal))'
5656}
5757
5858# Must be kept in sync with pythonTypeExplosions
8686def Contains (s ,sub ):
8787 return s .find (sub ) != - 1
8888
89- def releaseGIL ():
90- return "\t GILRelease gilRelease;\n "
91-
92- def reacquireGIL ():
93- return "\t gilRelease.reacquire();\n "
94-
9589def symbolName (v ):
9690 return "SCI_" + v ["Name" ].upper ()
9791
@@ -118,32 +112,27 @@ def traceCall(v, out):
118112def cellsBody (v , out ):
119113 traceCall (v , out )
120114 checkDisallowedInCallback (v , out )
121- out .write (releaseGIL ())
122115 out .write ("\t return callScintilla(" + symbolName (v ) + ", " + v ["Param2Name" ] + ".length(), reinterpret_cast<LPARAM>(" + v ["Param2Name" ] + ".cells()));\n " )
123116
124117def constString (v , out ):
125118 #out.write("\tconst char *raw = boost::python::extract<const char *>(" + v["Param2Name"] + ".attr(\"__str__\")());\n")
126119 traceCall (v , out )
127120 checkDisallowedInCallback (v , out )
128121 out .write ("\t std::string s = getStringFromObject({0});\n " .format (v ["Param2Name" ]))
129- out .write (releaseGIL ())
130122 out .write ("\t return callScintilla(" + symbolName (v ) + ", s.size(), reinterpret_cast<LPARAM>(s.c_str()));\n " );
131123
132124def retString (v , out ):
133125 traceCall (v , out )
134126 checkDisallowedInCallback (v , out )
135- out .write (releaseGIL ())
136127 out .write ("\t PythonCompatibleStrBuffer result(callScintilla(" + symbolName (v ) + ") + 1);\n " )
137128 out .write ("\t // result.size() does not depend on the order of evaluation here\n " )
138129 out .write ("\t //lint -e{864}\n " )
139130 out .write ("\t callScintilla(" + symbolName (v ) + ", result.size(), reinterpret_cast<LPARAM>(*result));\n " )
140- out .write (reacquireGIL ())
141131 out .write ("\t return boost::python::str(result.c_str());\n " )
142132
143133def getLineBody (v , out ):
144134 traceCall (v , out )
145135 checkDisallowedInCallback (v , out )
146- out .write (releaseGIL ())
147136 out .write ("\t int lineCount = callScintilla(SCI_GETLINECOUNT);\n " )
148137 out .write ("\t if (line >= lineCount)\n " )
149138 out .write ("\t {\n " )
@@ -153,14 +142,12 @@ def getLineBody(v, out):
153142 out .write ("\t {\n " )
154143 out .write ("\t \t PythonCompatibleStrBuffer result(callScintilla(SCI_LINELENGTH, line));\n " )
155144 out .write ("\t \t callScintilla(" + symbolName (v ) + ", line, reinterpret_cast<LPARAM>(*result));\n " )
156- out .write (reacquireGIL ())
157145 out .write ("\t \t return boost::python::str(result.c_str());\n " )
158146 out .write ("\t }\n " )
159147
160148def retStringNoLength (v , out ):
161149 traceCall (v , out )
162150 checkDisallowedInCallback (v , out )
163- out .write (releaseGIL ())
164151 out .write ("\t PythonCompatibleStrBuffer result(callScintilla(" + symbolName (v ))
165152 if v ["Param1Type" ] != '' or v ["Param2Type" ] != '' :
166153 out .write (", " )
@@ -183,7 +170,6 @@ def retStringNoLength(v, out):
183170 out .write ("0" );
184171
185172 out .write (", reinterpret_cast<LPARAM>(*result));\n " )
186- out .write (reacquireGIL ())
187173 out .write ("\t return boost::python::str(result.c_str());\n " )
188174
189175
@@ -192,35 +178,30 @@ def retStringFromKey(v, out):
192178 checkDisallowedInCallback (v , out )
193179 out .write ('\t std::string keyString = getStringFromObject({0});\n ' .format (v ["Param1Name" ]))
194180
195- out .write (releaseGIL ())
196181 out .write ("\t PythonCompatibleStrBuffer result(callScintilla({0}, reinterpret_cast<WPARAM>(keyString.c_str()), 0));\n " .format (symbolName (v )))
197182
198183 out .write ("\t callScintilla({0}, reinterpret_cast<WPARAM>(keyString.c_str()), reinterpret_cast<LPARAM>(*result));\n " .format (symbolName (v )))
199184
200- out .write (reacquireGIL ())
201185 out .write ("\t return boost::python::str(result.c_str());\n " )
202186
203187
204188def findTextBody (v , out ):
205189 traceCall (v , out )
206190 checkDisallowedInCallback (v , out )
207191 out .write ('\t std::string search = getStringFromObject({0});\n ' .format (v ['Param2Name' ]))
208- out .write (releaseGIL ())
209192 out .write ('\t Sci_TextToFind src;\n ' )
210193 out .write ('\t src.chrg.cpMin = start;\n ' )
211194 out .write ('\t src.chrg.cpMax = end;\n ' )
212195 out .write ('\t // We assume findText won\' t write to this buffer - it should be const\n ' )
213196 out .write ('\t src.lpstrText = const_cast<char*>(search.c_str());\n ' )
214197 out .write ('\t int result = callScintilla({0}, {1}, reinterpret_cast<LPARAM>(&src));\n ' .format (symbolName (v ), v ["Param1Name" ]))
215- out .write (reacquireGIL ())
216198 out .write ('\t if (-1 == result)\n ' )
217199 out .write ('\t {\n \t \t return boost::python::object();\n \t }\n ' )
218200 out .write ('\t else\n \t {\n \t \t return boost::python::make_tuple(src.chrgText.cpMin, src.chrgText.cpMax);\n \t }\n ' )
219201
220202def getTextRangeBody (v , out ):
221203 traceCall (v , out )
222204 checkDisallowedInCallback (v , out )
223- out .write (releaseGIL ())
224205 out .write ('\t Sci_TextRange src;\n ' )
225206 out .write ('\t if (end == -1)\n ' )
226207 out .write ('\t {\n ' )
@@ -238,13 +219,11 @@ def getTextRangeBody(v, out):
238219 out .write ('\t src.chrg.cpMax = end;\n ' )
239220 out .write ('\t src.lpstrText = *result;\n ' )
240221 out .write ('\t callScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n ' .format (symbolName (v )))
241- out .write (reacquireGIL ())
242222 out .write ('\t return boost::python::str(result.c_str());\n ' )
243223
244224def getStyledTextBody (v , out ):
245225 traceCall (v , out )
246226 checkDisallowedInCallback (v , out )
247- out .write (releaseGIL ())
248227 out .write ('\t Sci_TextRange src;\n ' )
249228 out .write ('\t if (end < start)\n ' )
250229 out .write ('\t {\n ' )
@@ -256,7 +235,6 @@ def getStyledTextBody(v, out):
256235 out .write ('\t src.chrg.cpMax = end;\n ' )
257236 out .write ('\t src.lpstrText = new char[size_t(((end-start) * 2) + 2)];\n ' )
258237 out .write ('\t callScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n ' .format (symbolName (v )))
259- out .write (reacquireGIL ())
260238 out .write ('\t boost::python::list styles;\n ' )
261239 out .write ("\t PythonCompatibleStrBuffer result(end-start);\n " )
262240 out .write ('\t for(idx_t pos = 0; pos < result.size() - 1; pos++)\n ' )
@@ -282,7 +260,6 @@ def annotationSetTextBody(v, out):
282260 out .write ("\t \t s = getStringFromObject({0});\n " .format (v ["Param2Name" ]))
283261 out .write ('\t \t newText = s.c_str();\n ' )
284262 out .write ('\t }\n ' )
285- out .write (releaseGIL ())
286263 out .write ("\t callScintilla({0}, static_cast<WPARAM>({1}), reinterpret_cast<LPARAM>(newText));\n " .format (symbolName (v ), v ["Param1Name" ]));
287264
288265def standardBody (v , out ):
@@ -293,7 +270,6 @@ def standardBody(v, out):
293270 checkDisallowedInCallback (v , out )
294271 withGilParam (out , v ['Param1Type' ], v ['Param1Name' ])
295272 withGilParam (out , v ['Param2Type' ], v ['Param2Name' ])
296- out .write (releaseGIL ())
297273
298274 call = 'callScintilla(' + symbolName (v )
299275
0 commit comments