1111*/
1212module foundation.nsarray ;
1313import foundation;
14- import objc.utils;
1514import objc;
1615
1716import core.attribute : selector, optional;
17+ import numem.core.exception ;
1818
1919private alias iter_func (T) = int delegate (T);
2020private alias iter_i_func (T) = int delegate (size_t , T);
2121
22+ private
23+ int iter_func_t (T)(T item, scope iter_func! T dg) @nogc {
24+ return assumeNoThrowNoGC (dg, item);
25+ }
26+
27+ private
28+ int iter_i_func_t (T)(size_t idx, T item, scope iter_i_func! T dg) @nogc {
29+ return assumeNoThrowNoGC (dg, idx, item);
30+ }
31+
2232nothrow @nogc :
2333version (D_ObjectiveC ):
2434
@@ -58,7 +68,7 @@ public:
5868 extern (D )
5969 final // @suppress(dscanner.useless.final)
6070 static NSArray! T create (T[] objects) {
61- return typeof ( this ) .create(objects.ptr, objects.length);
71+ return NSArray ! T .create(objects.ptr, objects.length);
6272 }
6373
6474 /**
@@ -165,10 +175,8 @@ public:
165175 extern (D )
166176 final
167177 int opApply (scope iter_func! T dg) {
168- auto ngc_dg = assumeNothrowNoGC! (iter_func! T)(dg);
169-
170178 foreach (i; 0 .. length) {
171- int result = ngc_dg (this [i]);
179+ int result = iter_func_t ! T (this [i], dg );
172180 if (result)
173181 return result;
174182 }
@@ -181,9 +189,8 @@ public:
181189 extern (D )
182190 final
183191 int opApplyReverse (scope iter_func! T dg) {
184- auto ngc_dg = assumeNothrowNoGC! (iter_func! T)(dg);
185192 foreach (i; 0 .. length) {
186- int result = ngc_dg (this [i]);
193+ int result = iter_func_t ! T (this [i], dg );
187194 if (result)
188195 return result;
189196 }
@@ -196,9 +203,8 @@ public:
196203 extern (D )
197204 final
198205 int opApply (scope iter_i_func! T dg) {
199- auto ngc_dg = assumeNothrowNoGC! (iter_i_func! T)(dg);
200206 foreach (i; 0 .. length) {
201- int result = ngc_dg (i, this [i]);
207+ int result = iter_i_func_t ! T (i, this [i], dg );
202208 if (result)
203209 return result;
204210 }
@@ -211,9 +217,8 @@ public:
211217 extern (D )
212218 final
213219 int opApplyReverse (scope iter_i_func! T dg) {
214- auto ngc_dg = assumeNothrowNoGC! (iter_i_func! T)(dg);
215220 foreach (i; 0 .. length) {
216- int result = ngc_dg (i, this [i]);
221+ int result = iter_i_func_t ! T (i, this [i], dg );
217222 if (result)
218223 return result;
219224 }
0 commit comments