annotate dstep/internal/Traits.d @ 17:c2fba45df857

Fixed: indexOf didn't compile
author Jacob Carlborg <doob@me.com>
date Sun, 10 Jan 2010 13:22:58 +0100
parents 19885b43130e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
1 /**
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
3 * Authors: Jacob Carlborg
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
4 * Version: Initial created: Apr 28, 2009
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
6 */
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
7 module dstep.internal.Traits;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
8
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
9 import dstep.objc.bridge.Bridge;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
10 import dstep.internal.String;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
11
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
12 /**
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
13 * Returns the name of the given function
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
14 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
15 * Params:
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
16 * func = the function alias to get the name of
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
17 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
18 * Returns: the name of the function
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
19 */
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
20 template functionNameOf (alias func)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
21 {
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
22 version(LDC)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
23 const functionNameOf = (&func).stringof[1 .. $];
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
24
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
25 else
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
26 const functionNameOf = (&func).stringof[2 .. $];
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
27 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
28
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
29 /**
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
30 * Returns the parameter names of the given function
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
31 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
32 * Params:
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
33 * func = the function alias to get the parameter names of
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
34 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
35 * Returns: an array of strings containing the parameter names
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
36 */
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
37 template parameterNamesOf (alias func)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
38 {
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
39 const parameterNamesOf = parameterNamesOfImpl!(func);
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
40 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
41
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
42 private string[] parameterNamesOfImpl (alias func) ()
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
43 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
44 string funcStr = typeof(&func).stringof;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
45
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
46 auto start = funcStr.indexOf('(');
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
47 auto end = funcStr.indexOf(')');
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
48
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
49 const firstPattern = ' ';
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
50 const secondPattern = ',';
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
51
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
52 funcStr = funcStr[start + 1 .. end];
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
53
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
54 if (funcStr == "")
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
55 return null;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
56
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
57 funcStr ~= secondPattern;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
58
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
59 string token;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
60 string[] arr;
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
61
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
62 foreach (c ; funcStr)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
63 {
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
64 if (c != firstPattern && c != secondPattern)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
65 token ~= c;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
66
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
67 else
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
68 {
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
69 if (token)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
70 arr ~= token;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
71
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
72 token = null;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
73 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
74 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
75
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
76 if (arr.length == 1)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
77 return arr;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
78
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
79 string[] result;
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
80 bool skip = false;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
81
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
82 foreach (str ; arr)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
83 {
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
84 skip = !skip;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
85
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
86 if (skip)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
87 continue;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
88
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
89 result ~= str;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
90 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
91
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
92 return result;
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
93 }
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
94
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
95 /**
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
96 * Compile-time function to get the index of the give element.
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
97 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
98 * Performs a linear scan, returning the index of the first occurrence
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
99 * of the specified element in the array, or U.max if the array does
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
100 * not contain the element.
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
101 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
102 * Params:
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
103 * arr = the array to get the index of the element from
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
104 * element = the element to find
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
105 *
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
106 * Returns: the index of the element or size_t.max if the element was not found.
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
107 */
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
108 private size_t indexOf (T) (T[] arr, T element)
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
109 {
17
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
110 foreach (i, e ; arr)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
111 if (e == element)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
112 return i;
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
113
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
114 return size_t.max;
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
115 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
116
17
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
117 //FIXME fix this when http://d.puremagic.com/issues/show_bug.cgi?id=3512 is fixed
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
118 version (none)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
119 {
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
120
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
121 /**
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
122 * Compile-time function to get the index of the give element.
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
123 *
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
124 * Performs a linear scan, returning the index of the first occurrence
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
125 * of the specified element in the array, or U.max if the array does
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
126 * not contain the element.
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
127 *
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
128 * Params:
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
129 * arr = the array to get the index of the element from
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
130 * element = the element to find
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
131 *
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
132 * Returns: the index of the element or size_t.max if the element was not found.
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
133 */
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
134 private size_t indexOf (T) (T[] arr, dchar element)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
135 {
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
136 static assert(is(T == char) || is(T == wchar) || is(T == dchar), `dstep.internal.Traits.indexOf: The given type "` ~ T.stringof ~ `" is not valid, it has to be char, wchar or dchar`);
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
137
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
138 foreach (i, dchar e ; arr)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
139 if (e == element)
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
140 return i;
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
141
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
142 return size_t.max;
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
143 }
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
144 }
c2fba45df857 Fixed: indexOf didn't compile
Jacob Carlborg <doob@me.com>
parents: 16
diff changeset
145
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
146 /**
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
147 * Evaluates to true if $(D_PARAM T) has a instance method with the given name
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
148 *
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
149 * Params:
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
150 * T = the type of the class/struct
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
151 * method = the name of the method
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
152 */
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
153 template hasInstanceMethod (T, string method)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
154 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
155 const hasInstanceMethod = is(typeof({
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
156 T t;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
157 mixin("auto f = &t." ~ method ~ ";");
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
158 }));
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
159 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
160
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
161 /**
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
162 * Evaluates to true if $(D_PARAM T) has a class method with the given name
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
163 *
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
164 * Params:
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
165 * T = the type of the class/struct
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
166 * method = the name of the method
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
167 */
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
168 template hasClassMethod (T, string method)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
169 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
170 const hasClassMethod = is(typeof({
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
171 mixin("auto f = &T." ~ method ~ ";");
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
172 }));
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
173 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
174
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
175 /**
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
176 * Evaluates to true if $(D_PARAM T) has a either a class method or a instance method
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
177 * with the given name.
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
178 *
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
179 * Params:
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
180 * T = the type of the class/struct
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
181 * method = the name of the method
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
182 */
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
183 template hasMethod (T, string method)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
184 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
185 const hasMethod = hasClassMethod!(T, method) || hasInstanceMethod!(T, method);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
186 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
187
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
188 /**
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
189 * Evaluates to true if $(D_PARAM T) has a field with the given name
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
190 *
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
191 * Params:
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
192 * T = the type of the class/struct
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
193 * field = the name of the field
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
194 */
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
195 template hasField (T, string field)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
196 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
197 const hasField = is(typeof({
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
198 T t;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
199 mixin("auto f = t." ~ field ~ ";");
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
200 }));
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
201 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
202
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
203 /// Evaluates to true if $(D_PARAM T) has binded methods
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
204 template hasBindedMethods (T)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
205 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 1
diff changeset
206 const bool hasBindedMethods = hasField!(T, Bridge.objcClassMethodDeclarationVar) || hasField!(T, Bridge.objcMethodDeclarationVar);
1
033d260cfc9b First upload of the bridge
Jacob Carlborg <doob@me.com>
parents:
diff changeset
207 }