2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								USING: kernel cocoa cocoa.types alien.c-types locals math sequences
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								vectors fry libc ;
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								IN: cocoa.enumeration
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: NS-EACH-BUFFER-SIZE 16 ; inline
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: (with-enumeration-buffers) ( quot -- )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    "NSFastEnumerationState" heap-size swap '[
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        NS-EACH-BUFFER-SIZE "id" heap-size * [
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            NS-EACH-BUFFER-SIZE @
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        ] with-malloc
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] with-malloc ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-18 20:22:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:: (NSFastEnumeration-each) ( object quot: ( elt -- ) state stackbuf count -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    object state stackbuf count -> countByEnumeratingWithState:objects:count:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    dup zero? [ drop ] [
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        state NSFastEnumerationState-itemsPtr [ stackbuf ] unless*
							 | 
						
					
						
							
								
									
										
										
										
											2008-09-10 23:11:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        '[ _ void*-nth quot call ] each
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        object quot state stackbuf count (NSFastEnumeration-each)
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-18 20:22:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ] if ; inline recursive
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: NSFastEnumeration-each ( object quot -- )
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ (NSFastEnumeration-each) ] (with-enumeration-buffers) ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: NSFastEnumeration-map ( object quot -- vector )
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 15:48:59 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    NS-EACH-BUFFER-SIZE <vector>
							 | 
						
					
						
							
								
									
										
										
										
											2008-09-10 23:11:40 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    [ '[ @ _ push ] NSFastEnumeration-each ] keep ; inline
							 | 
						
					
						
							
								
									
										
										
										
											2008-07-13 13:42:35 -04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								: NSFastEnumeration>vector ( object -- vector )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    [ ] NSFastEnumeration-map ;
							 |