changeset 320:5c6455c4889b signals

remove rubbish
author eldar_ins@eldar-laptop
date Fri, 25 Dec 2009 22:08:25 +0500
parents 894d40eb89b6
children d458ed66e871
files generator/dgenerator.cpp qt/d2/qt/Signal.d qt/qtd/MOC.d qt/qtd/Meta.d
diffstat 4 files changed, 20 insertions(+), 300 deletions(-) [+]
line wrap: on
line diff
--- a/generator/dgenerator.cpp	Fri Dec 25 21:48:32 2009 +0500
+++ b/generator/dgenerator.cpp	Fri Dec 25 22:08:25 2009 +0500
@@ -2951,12 +2951,13 @@
 void DGenerator::writeSignal(QTextStream &s, const AbstractMetaFunction *d_function)
 {
     Q_ASSERT(d_function->isSignal());
-
+/*
     s << INDENT << "mixin BindQtSignal!(\"" << d_function->name() << "(";
 
     writeMetaMethodArguments(s, d_function);
 
     s << ")\");" << endl;
+    */
 }
 
 void DGenerator::writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *d_function,
--- a/qt/d2/qt/Signal.d	Fri Dec 25 21:48:32 2009 +0500
+++ b/qt/d2/qt/Signal.d	Fri Dec 25 22:08:25 2009 +0500
@@ -30,29 +30,6 @@
     std.metastrings;
 
    
-/* returns name, arguments or tuple of the function depending on type parameter
-    foo(int, float)
-    _Name:  "foo"
-    _Tuple: "(int, float)"
-    _Args:  "int, float"
-*/
-enum {_Name, _Tuple, _Args}
-string getFunc(int type)(string fullName)
-{
-    int pos = 0;
-    foreach(i, c; fullName)
-        if (c == '(')
-            static if (type == _Tuple)
-                return fullName[i..$];
-            else static if (type == _Name)
-                return fullName[0..i];
-            else static if (type == _Args)
-                for(int j = fullName.length-1; ; j--)
-                    if(fullName[j] == ')')
-                        return fullName[i+1 .. j];
-    return null;
-}
-
 /** The beast that takes string representation of function arguments
   * and returns an array of default values it doesn't check if arguments
   * without default values follow the arguments with default values for
@@ -121,11 +98,6 @@
     return defVals.length;
 }
 
-/**
-    New implementation.
-*/
-
-
 
 // templates for extracting data from static meta-information of signals, slots or properties
 // public alias TypeTuple!("name", index, OwnerClass, ArgTypes) __signal
@@ -147,180 +119,6 @@
 
 template TupleWrapper(A...) { alias A at; }
 
-template isDg(Dg)
-{
-    enum isDg = is(Dg == delegate);
-}
-
-template isFn(Fn)
-{
-    enum isFn = is(typeof(*Fn.init) == function);
-}
-
-template isFnOrDg(Dg)
-{
-    enum isFnOrDg = isFn!(Dg) || isDg!(Dg);
-}
-
-string joinArgs(A...)()
-{
-    string res = "";
-    static if(A.length)
-    {
-        res = A[0].stringof;
-        foreach(k; A[1..$])
-            res ~= "," ~ k.stringof;
-    }
-    return res;
-}
-
-template SlotPred(T1, T2)
-{
-    enum SlotPred = is(T1 : T2);
-}
-
-template CheckSlot(alias Needle, alias Source)
-{
-    static if(Needle.at.length <= Source.at.length)
-        enum CheckSlot = CheckArgs!(Needle, Source, SlotPred, 0).value;
-    else
-        enum CheckSlot = false;
-}
-
-template SignalPred(T1, T2)
-{
-    enum SignalPred = is(T1 == T2);
-}
-
-template CheckSignal(alias Needle, alias Source)
-{
-    static if(Needle.at.length == Source.at.length)
-        enum CheckSignal = CheckArgs!(Needle, Source, SignalPred, 0).value;
-    else
-        enum CheckSignal = false;
-}
-
-template CheckArgs(alias Needle, alias Source, alias pred, int i)
-{
-    static if (i < Needle.at.length)
-    {
-        static if (pred!(Needle.at[i], Source.at[i]))
-            enum value = CheckArgs!(Needle, Source, pred, i + 1).value;
-        else
-            enum value = false;
-    }
-    else
-    {
-        enum value = true;
-    }
-}
-
-template SigByNamePred(string name, SlotArgs...)
-{
-    template SigByNamePred(source...)
-    {
-        static if (source[0] == name) // only instantiate CheckSlot if names match
-            enum SigByNamePred = CheckSlot!(TupleWrapper!(SlotArgs), TupleWrapper!(source[2 .. $]));
-        else
-            enum SigByNamePred = false;
-    }
-}
-
-template SigBySignPred(string name, SigArgs...)
-{
-    template SigBySignPred(source...)
-    {
-        static if (source[0] == name) // only instantiate CheckSignal if names match
-            enum SigBySignPred = CheckSignal!(TupleWrapper!(SigArgs), TupleWrapper!(source[2 .. $]));
-        else
-            enum SigBySignPred = false;
-    }
-}
-
-template ByOwner(Owner)
-{
-    template ByOwner(source...)
-    {
-        enum ByOwner = is(MetaEntryOwner!source == Owner);
-    }
-}
-
-template staticSymbolName(string prefix, int id)
-{
-    const string staticSymbolName = prefix ~ ToString!(id);
-}
-
-template signatureString(string name, A...)
-{
-    const string signatureString = name ~ "(" ~ joinArgs!(A) ~ ")";
-}
-
-// recursive search in the static meta-information
-template findSymbolImpl(string prefix, C, int id, alias pred)
-{
-    static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
-    {
-        mixin ("alias C." ~ staticSymbolName!(prefix, id) ~ " current;");
-        static if (pred!current)
-            alias current result;
-        else
-            alias findSymbolImpl!(prefix, C, id + 1, pred).result result;
-    }
-    else
-    {
-        alias void result;
-    }
-}
-
-template findSymbol(string prefix, C, alias pred)
-{
-    alias findSymbolImpl!(prefix, C, 0, pred).result findSymbol;
-}
-
-template findSignal(C, string name, Receiver, SigArgs...)
-{
-    alias TupleWrapper!(ParameterTypeTuple!Receiver) SlotArgsWr;
-    static if (SigArgs.length > 0)
-    {
-        alias findSymbol!(signalPrefix, C, SigBySignPred!(name, SigArgs)) result;
-        static if (is(result == void))
-            static assert(0, "Signal " ~ name ~ "(" ~ joinArgs!SigArgs() ~ ") was not found.");
-        else
-            static if (!CheckSlot!(SlotArgsWr, TupleWrapper!(result[2 .. $])))
-                static assert(0, "Signature of slot is incompatible with signal " ~ name ~ ".");
-    }
-    else
-    {
-        alias findSymbol!(signalPrefix, C, SigByNamePred!(name, SlotArgsWr.at)) result;
-        static if (is(result == void))
-            static assert(0, "Signal " ~ name ~ " was not found.");
-    }
-}
-
-// recursive search in the static meta-information
-template findSymbolsImpl(string prefix, C, int id, alias pred)
-{
-    static if ( is(typeof(mixin("C." ~ staticSymbolName!(prefix, id)))) )
-    {
-        mixin ("alias C." ~ staticSymbolName!(prefix, id) ~ " current;");
-        static if (pred!current) {
-            alias TupleWrapper!current subres;
-//                    pragma(msg, toStringNow!id ~ " " ~ subres.stringof);
-        } else
-            alias TypeTuple!() subres;
-        alias TypeTuple!(subres, findSymbolsImpl!(prefix, C, id + 1, pred).result) result;
-    }
-    else
-    {
-        alias TypeTuple!() result;
-    }
-}
-
-template findSymbols(string prefix, C, alias pred)
-{
-    alias findSymbolsImpl!(prefix, C, 0, pred).result findSymbols;
-}
-
 string convertSignalArguments(Args...)()
 {
 //        void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
@@ -388,80 +186,6 @@
     NewSlot
 }
 
-template BindQtSignal(string fullName)
-{
-    mixin MetaMethodImpl!(signalPrefix, 0, fullName, SignalType.BindQtSignal);
-}
-
-template Signal(string fullName)
-{
-    mixin MetaMethodImpl!(signalPrefix, 0, fullName, SignalType.NewSignal);
-}
-
-template Slot(string fullName)
-{
-    mixin MetaMethodImpl!(slotPrefix, 0, fullName, SignalType.NewSlot);
-}
-
-template SignalImpl(int index, string fullName, SignalType signalType)
-{
-    static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ signalPrefix ~ ToString!(index)))))
-        mixin SignalImpl!(index + 1, fullName, signalType);
-    else
-    {
-//        pragma(msg, "alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
-        mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
-        alias ParameterTypeTuple!(Dg) ArgTypes;
-        enum args = getFunc!_Args(fullName);
-        enum defVals = defaultValues(args);
-        enum defValsLength = defaultValuesLength(defVals);
-
-//        pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, index));
-        mixin InsertMetaSignal!(fullName, index, defValsLength, ArgTypes);
-//        pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
-    }
-}
-template MetaMethodImpl(string metaPrefix, int index, string fullName, SignalType signalType)
-{
-    static if (is(typeof(mixin(typeof(this).stringof ~ "." ~ metaPrefix ~ toStringNow!(index)))))
-    {
-        mixin MetaMethodImpl!(metaPrefix, index + 1, fullName, signalType);
-    }
-    else
-    {
-        mixin("alias void delegate" ~ getFunc!_Tuple(fullName) ~ " Dg;");
-        alias ParameterTypeTuple!(Dg) ArgTypes;
-        enum args = getFunc!_Args(fullName);
-        enum defVals = defaultValues(args);
-        enum defValsLength = defaultValuesLength(defVals);
-        
-        static if (metaPrefix == signalPrefix)
-        {
-            // calculating local index of the signal
-            static if (typeof(this).stringof == "QObject")
-                enum localIndex = index;
-            else
-                mixin ("enum localIndex = index - 1 - lastSignalIndex_" ~ (typeof(super)).stringof ~ ";");
-            
-            static if (signalType == SignalType.NewSignal)
-            {
-                pragma (msg, SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
-                mixin (SignalEmitter!(ArgTypes)(SignalType.NewSignal, getFunc!_Name(fullName), defVals, localIndex));
-            }
-        }
-        mixin InsertMetaMethod!(fullName, metaPrefix, index, defValsLength, ArgTypes);
-//        pragma (msg, ctfe_meta_signal!(ArgTypes)(fullName, index, defValsLength));
-    }
-}
-template InsertMetaMethod(string fullName, string metaPrefix, int index, int defValsCount, ArgTypes...)
-{
-    static if(defValsCount >= 0)
-        mixin("public alias TypeTuple!(\"" ~ getFunc!_Name(fullName) ~ "\", index, typeof(this), ArgTypes) " ~ metaPrefix ~ toStringNow!(index) ~ ";");
-    static if(defValsCount > 0)
-        mixin InsertMetaMethod!(fullName, metaPrefix, index+1, defValsCount-1, ArgTypes[0..$-1]);
-}
-
-
 string signature_impl(T...)(string name)
 {
     string res = name ~ "(";
@@ -553,7 +277,7 @@
     alias findSymbols2!(C, "slot_").result findSlots;
 }
 
-
+/* commented out for future when we will implement default arguments
 template metaMethods(alias func, int index, int defValsCount)
 {
     static if(defValsCount >= 0) {
@@ -567,12 +291,14 @@
         alias TypeTuple!() result;
     }
 }
+*/
 
 template toMetaEntriesImpl(int id, Methods...)
 {
     static if (Methods.length > id)
     {
         alias typeof(&Methods[id]) Fn;
+//    commented out for future when we will implement default arguments
 //        enum defValsLength = 0; //ParameterTypeTuple!(Fn).length - requiredArgCount!(Methods[id])();
 //        pragma(msg, __traits(identifier, Methods[id]) ~ " " ~ typeof(&Methods[id]).stringof);
 //        alias metaMethods!(Methods[id], 0, defValsLength).result subres;
@@ -588,25 +314,4 @@
 template toMetaEntries(Methods...)
 {
     alias TupleWrapper!(toMetaEntriesImpl!(0, Methods).result) toMetaEntries;
-}
-
-
-bool printRawFuncs(T...)()
-{
-    pragma(msg, "---Raw---");
-    foreach(i, _; T)
-        pragma(msg, __traits(identifier, T[i]) ~ " " ~ typeof(&T[i]).stringof);
-    return true;
-}
-
-
-bool printFuncs(alias T)()
-{
-    pragma(msg, "---MetaEntries---");
-    alias T.at tuple;
-    enum num = tuple.length;
-    foreach(i, _; Repeat!(void, num))
-        pragma(msg, tuple[i].at[0] ~ " " ~ tuple[i].at[1].stringof);
-//        pragma(msg, typeof(&tuple[i].at[0]).stringof ~ " " ~ __toString(tuple[i].at[1]));
-    return true;
 }
\ No newline at end of file
--- a/qt/qtd/MOC.d	Fri Dec 25 21:48:32 2009 +0500
+++ b/qt/qtd/MOC.d	Fri Dec 25 22:08:25 2009 +0500
@@ -504,7 +504,6 @@
 
 template Q_OBJECT_BIND()
 {
-    mixin ("enum lastSignalIndex_" ~ typeof(this).stringof ~ " = " ~ toStringNow!(lastSignalIndex!(typeof(this))) ~ ";");
 }
 /*
 template Q_OBJECT()
--- a/qt/qtd/Meta.d	Fri Dec 25 21:48:32 2009 +0500
+++ b/qt/qtd/Meta.d	Fri Dec 25 22:08:25 2009 +0500
@@ -65,4 +65,19 @@
         }
     }
     return 0;
+}
+
+template isDg(Dg)
+{
+    enum isDg = is(Dg == delegate);
+}
+
+template isFn(Fn)
+{
+    enum isFn = is(typeof(*Fn.init) == function);
+}
+
+template isFnOrDg(Dg)
+{
+    enum isFnOrDg = isFn!(Dg) || isDg!(Dg);
 }
\ No newline at end of file