Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r110:0bfe3f8ba02d
Date: 2014-11-29 10:04 +0100
http://bitbucket.org/cffi/creflect/changeset/0bfe3f8ba02d/

Log:    ellipsis in function types

diff --git a/creflect/src/c_decl_parser.c b/creflect/src/c_decl_parser.c
--- a/creflect/src/c_decl_parser.c
+++ b/creflect/src/c_decl_parser.c
@@ -17,6 +17,7 @@
     TOK_ERROR,
     TOK_IDENTIFIER,
     TOK_INTEGER,
+    TOK_DOTDOTDOT,
 
     /* keywords */
     TOK__BOOL,
@@ -95,6 +96,12 @@
                 tok->size++;
             return;
         }
+        else if (p[0] == '.' && p[1] == '.' && p[2] == '.') {
+            tok->kind = TOK_DOTDOTDOT;
+            tok->p = p;
+            tok->size = 3;
+            return;
+        }
         else if (*p) {
             tok->kind = *p;
             tok->p = p;
@@ -195,6 +202,11 @@
             }
             if (tok->kind != TOK_CLOSE_PAREN) {
                 while (1) {
+                    if (tok->kind == TOK_DOTDOTDOT) {
+                        ds[0] = TOK_DOTDOTDOT;
+                        next_token(tok);
+                        break;
+                    }
                     crx_type_t *t1 = parse_complete(tok);
                     intptr_t *ds_type = alloc_ds(tok, 1);
                     assert(ds_type == ds + 2 + ds[1]);
@@ -277,6 +289,15 @@
                                                 nbargs, NULL);
                 break;
             }
+            case TOK_DOTDOTDOT:   /* function ending with a '...' */
+            {
+                intptr_t nbargs = *delay_slot++;
+                crx_type_t **argtypes = (crx_type_t **)delay_slot;
+                delay_slot += nbargs;
+                t1 = tok->cb->get_ellipsis_function_type(tok->cb, t1,
+                                                         argtypes, nbargs);
+                break;
+            }
             default:
                 abort();
             }
diff --git a/test/test_c_decl_parser.py b/test/test_c_decl_parser.py
--- a/test/test_c_decl_parser.py
+++ b/test/test_c_decl_parser.py
@@ -77,8 +77,8 @@
     parse("int[]", "ARRAY[] int")
     parse("foo_t", "foo_t")
     parse("foo_t*", "PTR foo_t")
+    parse("int(int, ...)", "FUNC( int -> ... -> int )")
     import py; py.test.skip("in-progress")
-    parse("int(int, ...)")
     parse("int(int[])")
     parse("int(long(char))")
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to