diff --git a/find-modules/sip_generator.py b/find-modules/sip_generator.py old mode 100644 new mode 100755 --- a/find-modules/sip_generator.py +++ b/find-modules/sip_generator.py @@ -51,6 +51,10 @@ logger = logging.getLogger(__name__) gettext.install(__name__) +# Keep PyCharm happy. +_ = _ + + EXPR_KINDS = [ CursorKind.UNEXPOSED_EXPR, CursorKind.CONDITIONAL_OPERATOR, CursorKind.UNARY_OPERATOR, CursorKind.BINARY_OPERATOR, @@ -165,6 +169,9 @@ :param member: The attribute. :param text: The raw source corresponding to the region of member. """ + if member.kind == CursorKind.UNEXPOSED_ATTR and text.find("_DEPRECATED") != -1: + sip["annotations"].add("Deprecated") + return True if member.kind != CursorKind.VISIBILITY_ATTR: return False if member.spelling == "hidden": @@ -448,6 +455,7 @@ sip = { "name": function.spelling, + "annotations": set(), } parameters = [] parameter_modifying_rules = [] @@ -529,6 +537,8 @@ decl = pad + sip["prefix"] + decl + sip["suffix"] if sip["template_parameters"]: decl = pad + "template <" + ", ".join(sip["template_parameters"]) + ">\n" + decl + if sip["annotations"]: + decl += " /" + ",".join(sip["annotations"]) + "/" decl += ";\n" decl += sip["code"] else: @@ -691,7 +701,8 @@ """ sip = { - "name": variable.spelling + "name": variable.spelling, + "annotations": set(), } for child in variable.get_children(): if child.kind in TEMPLATE_KINDS + [CursorKind.STRUCT_DECL, CursorKind.UNION_DECL]: diff --git a/tests/GenerateSipBindings/cpplib.h b/tests/GenerateSipBindings/cpplib.h --- a/tests/GenerateSipBindings/cpplib.h +++ b/tests/GenerateSipBindings/cpplib.h @@ -239,3 +239,10 @@ protected: void virtualInterface() override; }; + +#define TEST_DEPRECATED __attribute__((__deprecated__)) +class TEST_DEPRECATED DeprecatedClass +{ +public: + TEST_DEPRECATED void deprecatedFn(int bar) {}; +};