Commits

ariovistus  committed 5de7890

fixes for pending 2.061
there is a std.typetuple.Filter
override enforcement is stricter
__traits(compiles, Type.fun( <stuff> )) is no longer true
PydInputRange is a struct, if value is copied, iter's refcount must be incremented

  • Participants
  • Parent commits 90fa006

Comments (0)

Files changed (5)

File examples/pyd_unittests/makefile

 	     -L-lpython3.2mu
 DC = dmd -unittest -property -debug -gc
 
-all: pydobject.x pydobject3.x make_object.x make_object3.x embedded.x embedded3.x func_wrap.x func_wrap3.x class_wrap.x class_wrap3.x def.x def3.x struct_wrap.x buffer.x threading.x
+all: pydobject.x pydobject3.x make_object.x make_object3.x embedded.x embedded3.x func_wrap.x func_wrap3.x class_wrap.x class_wrap3.x def.x def3.x struct_wrap.x threading.x
 	./pydobject.x
 	./pydobject3.x
 	./make_object.x
 	./struct_wrap.x
 	./def.x
 	./def3.x
-	./buffer.x
 	./threading.x
 
 clean:

File infrastructure/pyd/class_wrap.d

     template shim(size_t i, T) {
         enum shim = Replace!(q{    
             alias Params[$i] __pyd_p$i;
-            ReturnType!(__pyd_p$i.func_t) $realname(ParameterTypeTuple!(__pyd_p$i.func_t) t) {
+            $override ReturnType!(__pyd_p$i.func_t) $realname(ParameterTypeTuple!(__pyd_p$i.func_t) t) {
                 return __pyd_get_overload!("$realname", __pyd_p$i.func_t).func("$name", t);
             }
             alias T.$realname $realname;
-        }, "$i",i,"$realname",realname, "$name", name);
+        }, "$i",i,"$realname",realname, "$name", name, "$override", 
+        // todo: figure out what's going on here
+        (variadicFunctionStyle!func == Variadic.no ? "override":""));
     }
 }
 
         template shim(size_t i, T) {
             static if(countUntil(parts.mode, "r") != -1) {
                 enum getter = Replace!(q{
-                ReturnType!(__pyd_p$i.get_t) $realname() {
+                override ReturnType!(__pyd_p$i.get_t) $realname() {
                     return __pyd_get_overload!("$realname", __pyd_p$i.get_t).func("$name");
                 }
                 } , "$i",i,"$realname",realname, "$name", pyname);

File infrastructure/pyd/func_wrap.d

     }
     alias variadicFunctionStyle!fn vstyle;
     alias ParameterTypeTuple!fn ps;
+    alias ParameterDefaultValueTuple!fn defaults;
     static if(vstyle == Variadic.no) {
-        if(n > ps.length) return false;
-        if(n == 0 && __traits(compiles, fn())) return true;
-        foreach(i,_p; ps) {
-            if(__traits(compiles, fn(ps[0 .. i+1].init)) && i+1 == n) {
-                return true;
-            }
-        }
-        return false;
+        return (n >= minArgs!(fn,fn_t) && n <= maxArgs!(fn,fn_t).max);
     }else static if(vstyle == Variadic.c) {
         return true;
     }else static if(vstyle == Variadic.d) {

File infrastructure/pyd/pydobject.d

     /**
      * Exposes Python object comparison to D. Equivalent to cmp(this, rhs) in Python.
      */
-    int opCmp(Object o) {
+    override int opCmp(Object o) {
         PydObject rhs = cast(PydObject) o;
         if (!rhs) return -1;
         version(Python_3_0_Or_Later) {
         return new PydObject(PyObject_Str(m_ptr));
     }
     /// Allows use of PydObject in writeln via %s
-    string toString() {
+    override string toString() {
         return python_to_d!(string)(m_ptr);
     }
     
         }
         popFront();
     }
+    this(this) {
+        Py_INCREF(iter);
+    }
     ~this() {
         Py_XDECREF(iter);
     }

File infrastructure/util/typelist.d

 module util.typelist;
 
-
 import std.algorithm;
 import std.typetuple;
 
-// from std.typecons:
-
-// this would be deprecated by std.typelist.Filter
-// emn: std.typelist DOESNT EXIST
-template Filter(alias pred, lst...)
-{
-    static if (lst.length > 0)
+static if(__traits(hasMember,std.typetuple, "Filter")) {
+    public import std.typetuple: Filter;
+}else{
+    // functionality added in 2.061
+    template Filter(alias pred, lst...)
     {
-        alias Filter!(pred, lst[1 .. $]) tail;
-        //
-        static if (pred!(lst[0]))
-            alias TypeTuple!(lst[0], tail) Filter;
+        static if (lst.length > 0)
+        {
+            alias Filter!(pred, lst[1 .. $]) tail;
+            //
+            static if (pred!(lst[0]))
+                alias TypeTuple!(lst[0], tail) Filter;
+            else
+                alias tail Filter;
+        }
         else
-            alias tail Filter;
+            alias TypeTuple!() Filter;
     }
-    else
-        alias TypeTuple!() Filter;
 }
 
 template Join(string delimit, T...) {