7878
7979}
8080
81- exclusions = [ 'FormatRange' , 'GetCharacterPointer' , 'GetRangePointer' ]
82-
83- def Contains (s ,sub ):
84- return s .find (sub ) != - 1
81+ exclusions = [ 'FormatRange' ,]
8582
8683
8784def symbolName (v ):
@@ -317,6 +314,56 @@ def annotationSetTextBody(v, out):
317314''' .format (v ["Param2Name" ], v ["Param2Name" ], symbolName (v ), v ["Param1Name" ]))
318315
319316
317+ def getSetDocPointerBody (v , out ):
318+ traceCall (v , out )
319+ checkDisallowedInCallback (v , out )
320+ out .write (
321+ ''' callScintilla({0}, 0, {1});
322+ ''' .format (symbolName (v ), v ["Param2Name" ]))
323+
324+
325+ def getAddRefDocumentBody (v , out ):
326+ traceCall (v , out )
327+ checkDisallowedInCallback (v , out )
328+ out .write (
329+ ''' callScintilla({0}, 0, {1});
330+ ''' .format (symbolName (v ), v ["Param2Name" ]))
331+
332+
333+ def getReleaseDocumentBody (v , out ):
334+ traceCall (v , out )
335+ checkDisallowedInCallback (v , out )
336+ out .write (
337+ ''' callScintilla({0}, 0, {1});
338+ ''' .format (symbolName (v ), v ["Param2Name" ]))
339+
340+
341+ def getPrivateLexerCallBody (v , out ):
342+ traceCall (v , out )
343+ checkDisallowedInCallback (v , out )
344+ out .write (
345+ ''' return callScintilla({0}, {1}, {2});
346+ ''' .format (symbolName (v ), v ["Param1Name" ], v ["Param2Name" ]))
347+
348+
349+ def getGetRangePointerBody (v , out ):
350+ out .write (
351+ ''' GILRelease release;
352+ const char *charPtr = reinterpret_cast<const char*>(callScintilla({0}, {2}, {3}));
353+ release.reacquire();
354+ return {1}(charPtr, charPtr + {3});
355+ ''' .format (symbolName (v ), v ["ReturnType" ], v ["Param1Name" ], v ["Param2Name" ]))
356+
357+
358+ def getGetCharacterPointerBody (v , out ):
359+ out .write (
360+ ''' GILRelease release;
361+ const char *charPtr = reinterpret_cast<const char*>(callScintilla({0}));
362+ release.reacquire();
363+ return {1}(charPtr);
364+ ''' .format (symbolName (v ), v ["ReturnType" ]))
365+
366+
320367def standardBody (v , out ):
321368 # We always release the GIL. For standard getters, this shouldn't really be necessary.
322369 # However, it doesn't appear to affect performance to dramatically (yet!), so we'll leave it in until
@@ -409,7 +456,13 @@ def getPythonParamNamesQuoted(param1Type, param1Name, param2Type, param2Name):
409456specialCases = {
410457 'GetStyledText' : ('boost::python::tuple' , 'int' , 'start' , 'int' , 'end' , getStyledTextBody ),
411458 'GetLine' : ('boost::python::str' , 'int' , 'line' , '' , '' , getLineBody ),
412- 'AnnotationSetText' : ('void' , 'int' , 'line' , 'boost::python::object' , 'text' , annotationSetTextBody )
459+ 'AnnotationSetText' : ('void' , 'int' , 'line' , 'boost::python::object' , 'text' , annotationSetTextBody ),
460+ 'SetDocPointer' :('void' , '' ,'' ,'intptr_t' , 'pointer' , getSetDocPointerBody ),
461+ 'AddRefDocument' :('void' , '' ,'' , 'intptr_t' , 'doc' , getAddRefDocumentBody ),
462+ 'ReleaseDocument' :('void' , '' ,'' , 'intptr_t' , 'doc' , getReleaseDocumentBody ),
463+ 'PrivateLexerCall' :('intptr_t' , 'intptr_t' ,'operation' ,'intptr_t' , 'pointer' , getPrivateLexerCallBody ),
464+ 'GetCharacterPointer' :('boost::python::str' , '' ,'' ,'' , '' , getGetCharacterPointerBody ),
465+ 'GetRangePointer' :('boost::python::str' , 'int' ,'position' ,'int' , 'rangeLength' , getGetRangePointerBody )
413466}
414467
415468
@@ -496,16 +549,14 @@ class PythonCompatibleStrBuffer
496549 sig = mapSignature ((v ["Param1Type" ], v ["Param1Name" ], v ["Param2Type" ], v ["Param2Name" ]))
497550
498551 if sig is not None :
499- # print '{:<45} {} ==>> {}'.format(v["Name"], v["ReturnType"], sig[0])
500- v ["ReturnType" ] = 'intptr_t' if sig [0 ] == 'int' else sig [0 ]
552+ v ["ReturnType" ] = 'intptr_t' if sig [0 ] in ['int' , 'int pointer' ] else sig [0 ]
501553 v ["Param1Type" ] = sig [1 ]
502554 v ["Param2Type" ] = sig [2 ]
555+
503556 body = sig [3 ]
504557 else :
505- # print '{:<45} {} -->> {}'.format(v["Name"], v["ReturnType"], mapType(v["ReturnType"]))
506558 #if !checkStandardTypeIsKnown(v["ReturnType", v["Param1Type"], v["Param1Name"], v["Param2Type"], v["Param2Name"]):
507559 # print("Warning: unrecognised parameter combination for {0}({1} {2}, {3} {4})".format(v["Name"], v["Param1Type"], v["Param1Name"], v["Param2Type"], v["Param2Name"]))
508-
509560 v ["ReturnType" ] = 'intptr_t' if v ["ReturnType" ] in ['int' , 'position' ] else mapType (v ["ReturnType" ])
510561 v ["Param1Type" ] = mapType (v ["Param1Type" ])
511562 v ["Param2Type" ] = mapType (v ["Param2Type" ])
@@ -568,7 +619,7 @@ def writeHFile(f,out):
568619
569620 out .write ("\t /** " + "\n \t * " .join (v ["Comment" ]) + "\n */\n " )
570621
571- out .write ("\t " );
622+ out .write ("\t " )
572623 out .write (getSignature (v ).replace (' ScintillaWrapper::' , ' ' ))
573624 out .write (";\n \n " )
574625
@@ -659,7 +710,7 @@ def writeEnumsWrapperFile(f, out):
659710 out .write ('\n \t \t .value("{0}", PYSCR_{1})' .format (val [0 ][takeEnumValueFromPosition :].upper (), val [0 ]))
660711 out .write (';\n \n ' )
661712
662- out .write ('\t boost::python::enum_<ScintillaNotification>("SCINTILLANOTIFICATION")' .format (name , name .upper ()))
713+ out .write ('\t boost::python::enum_<ScintillaNotification>("SCINTILLANOTIFICATION")' ) # .format(name, name.upper()))
663714
664715 for name in f .order :
665716 v = f .features [name ]
@@ -668,7 +719,7 @@ def writeEnumsWrapperFile(f, out):
668719 out .write ('\n \t \t .value("{0}", PYSCR_SCN_{1})' .format (name .upper (), name .upper ()))
669720 out .write (';\n \n ' )
670721
671- out .write ('\t boost::python::enum_<ScintillaMessage>("SCINTILLAMESSAGE")' .format (name , name .upper ()))
722+ out .write ('\t boost::python::enum_<ScintillaMessage>("SCINTILLAMESSAGE")' ) # .format(name, name.upper()))
672723 for name in f .order :
673724 v = f .features [name ]
674725 if v ["Category" ] != "Deprecated" :
@@ -688,7 +739,7 @@ def writeScintillaDoc(f, out):
688739 continue
689740
690741 if v ["Name" ] in specialCases :
691- (v ["ReturnType" ], v ["Param1Type" ], v ["Param1Name" ], v ["Param2Type" ], v ["Param2Name" ], body ) = specialCases [v ["Name" ]]
742+ (v ["ReturnType" ], v ["Param1Type" ], v ["Param1Name" ], v ["Param2Type" ], v ["Param2Name" ], _ ) = specialCases [v ["Name" ]]
692743 else :
693744 sig = mapSignature ((v ["Param1Type" ], v ["Param1Name" ], v ["Param2Type" ], v ["Param2Name" ]))
694745
@@ -765,10 +816,10 @@ def CopyWithInsertion(input, output, genfn, definition):
765816 for line in input .readlines ():
766817 if copying :
767818 output .write (line )
768- if Contains ( line , "/* ++Autogenerated" ) :
819+ if "/* ++Autogenerated" in line :
769820 copying = 0
770821 genfn (definition , output )
771- if Contains ( line , "/* --Autogenerated" ) :
822+ if "/* --Autogenerated" in line :
772823 copying = 1
773824 output .write (line )
774825
0 commit comments