aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2019-06-18 13:21:05 +1000
committerNeil <nyamatongwe@gmail.com>2019-06-18 13:21:05 +1000
commitab38beeb9a31a5df65b6e2a41251ca36574065f3 (patch)
tree12f052b289b42751c2f4aa93e52e85fd35ad9569
parentef5c1c95756e22cd8244c04f90d388fd122e76d6 (diff)
downloadscintilla-mirror-ab38beeb9a31a5df65b6e2a41251ca36574065f3.tar.gz
Feature [feature-requests:#1297] 6: Support enumerated types in APIs.
-rw-r--r--qt/ScintillaEdit/WidgetGen.py11
-rw-r--r--scripts/CheckMentioned.py4
-rw-r--r--scripts/Face.py3
-rw-r--r--test/ScintillaCallable.py8
4 files changed, 21 insertions, 5 deletions
diff --git a/qt/ScintillaEdit/WidgetGen.py b/qt/ScintillaEdit/WidgetGen.py
index 2fa63279e..44349a90b 100644
--- a/qt/ScintillaEdit/WidgetGen.py
+++ b/qt/ScintillaEdit/WidgetGen.py
@@ -51,21 +51,26 @@ typeAliases = {
def cppAlias(s):
if s in typeAliases:
return typeAliases[s]
+ elif Face.IsEnumeration(s):
+ return "int"
else:
return s
understoodTypes = ["", "void", "int", "bool", "position", "line", "pointer",
"colour", "keymod", "string", "stringresult", "cells"]
+def understoodType(t):
+ return t in understoodTypes or Face.IsEnumeration(t)
+
def checkTypes(name, v):
understandAllTypes = True
- if v["ReturnType"] not in understoodTypes:
+ if not understoodType(v["ReturnType"]):
#~ print("Do not understand", v["ReturnType"], "for", name)
understandAllTypes = False
- if v["Param1Type"] not in understoodTypes:
+ if not understoodType(v["Param1Type"]):
#~ print("Do not understand", v["Param1Type"], "for", name)
understandAllTypes = False
- if v["Param2Type"] not in understoodTypes:
+ if not understoodType(v["Param2Type"]):
#~ print("Do not understand", v["Param2Type"], "for", name)
understandAllTypes = False
return understandAllTypes
diff --git a/scripts/CheckMentioned.py b/scripts/CheckMentioned.py
index 2694b7a49..379225fe1 100644
--- a/scripts/CheckMentioned.py
+++ b/scripts/CheckMentioned.py
@@ -65,6 +65,8 @@ def convertIFaceTypeToC(t):
return "Sci_TextToFind *"
elif t == "formatrange":
return "Sci_RangeToFormat *"
+ elif Face.IsEnumeration(t):
+ return "int "
return t + " "
def makeParm(t, n, v):
@@ -86,6 +88,8 @@ def makeSig(params):
retType = params["ReturnType"]
if retType in ["void", "string", "stringresult"]:
retType = ""
+ elif Face.IsEnumeration(retType):
+ retType = "int"
if retType:
retType = " &rarr; " + retType
diff --git a/scripts/Face.py b/scripts/Face.py
index e4001e47d..22c2943e6 100644
--- a/scripts/Face.py
+++ b/scripts/Face.py
@@ -37,6 +37,9 @@ def decodeParam(p):
name = nv
return type, name, value
+def IsEnumeration(t):
+ return t[:1].isupper()
+
class Face:
def __init__(self):
diff --git a/test/ScintillaCallable.py b/test/ScintillaCallable.py
index 05cc5f671..6d97eb25a 100644
--- a/test/ScintillaCallable.py
+++ b/test/ScintillaCallable.py
@@ -6,6 +6,9 @@ import ctypes, os, sys
from ctypes import c_int, c_ulong, c_char_p, c_wchar_p, c_ushort, c_uint, c_long, c_ssize_t
+def IsEnumeration(t):
+ return t[:1].isupper()
+
class TEXTRANGE(ctypes.Structure):
_fields_= (\
('cpMin', c_long),
@@ -83,7 +86,8 @@ class ScintillaCallable:
not name.startswith("Get") and \
not feature["Param1Type"] and \
not feature["Param2Type"] and \
- feature["ReturnType"] in ["bool", "int", "position", "line", "pointer"]:
+ (feature["ReturnType"] in ["bool", "int", "position", "line", "pointer"] or \
+ IsEnumeration(feature["ReturnType"])):
#~ print("property", feature)
return self._scifn(self._sciptr, value, None, None)
elif name.startswith("SCN_") and name in self.k:
@@ -101,7 +105,7 @@ class ScintillaCallable:
value = int(feature["Value"], 0)
#~ print("setproperty", feature)
if feature["FeatureType"] == "set" and not name.startswith("Set"):
- if feature["Param1Type"] in ["bool", "int", "position", "line"]:
+ if feature["Param1Type"] in ["bool", "int", "position", "line"] or IsEnumeration(feature["Param1Type"]):
return self._scifn(self._sciptr, value, c_char_p(val), None)
elif feature["Param2Type"] in ["string"]:
return self._scifn(self._sciptr, value, None, c_char_p(val))