From 88d9210237d6a86f48a5420fa5139afe57acdf26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Mon, 8 Jun 2020 18:13:11 +0200 Subject: [PATCH] try to autodeclare member functions --- autogen/generator.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autogen/generator.py b/autogen/generator.py index 048adce..c5cee55 100644 --- a/autogen/generator.py +++ b/autogen/generator.py @@ -98,6 +98,8 @@ def can_handle_function(self, function, cname="", **kwds): False >>> G.can_handle_function("bnfinit", "bnfinit0", **{"class":"hard"}) False + >>> G.can_handle_function("_.cyc", "member_cyc", **{"class":"basic"}) + True """ if not cname: # No corresponding C function => must be specific to GP or GP2C @@ -105,6 +107,9 @@ def can_handle_function(self, function, cname="", **kwds): if function in function_blacklist: # Blacklist specific troublesome functions return False + if function.startswith("_."): + # for member functions + function = "member_" + function[2:] if not function_re.match(function): # Not a legal function name, like "!_" return False @@ -235,6 +240,10 @@ def polredord(self, x): self.write_declaration(cname, args, ret, self.decl_file) + if function.startswith("_."): + # for member functions + function = "member_" + function[2:] + if len(args) > 0 and isinstance(args[0], PariArgumentGEN): # If the first argument is a GEN, write a method of the # Gen class.