[Gridflow-cvs] [svn] commit: r3298 - /trunk/base/flow_objects.rb

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Wed Mar 26 15:16:43 EDT 2008


Author: matju
Date: Wed Mar 26 15:16:42 2008
New Revision: 3298

Log:
[args]: better reporting, don't abort when any args are missing (should it?), and added support for wildcard * (does not work in parenthese 
form) which outputs the rest of the args as a list.

Modified:
    trunk/base/flow_objects.rb

Modified: trunk/base/flow_objects.rb
==============================================================================
--- trunk/base/flow_objects.rb (original)
+++ trunk/base/flow_objects.rb Wed Mar 26 15:16:42 2008
@@ -23,8 +23,6 @@
 
 module GridFlow
 GridFlow = ::GridFlow # ruby is nuts... sometimes
-
-#-------- fClasses for: control + misc
 
 # a dummy class that gives access to any stuff global to GridFlow.
 FObject.subclass("gridflow",1,1) {
@@ -131,8 +129,6 @@
         def _0_glob  (s) send_out 0, :list, *Dir[    s.to_s].map {|x| x.intern } end
 }
 
-#-------- fClasses for: video
-
 #<vektor> told me to:
 # RGBtoYUV : @fobjects = ["#inner (3 3 # 66 -38 112 128 -74 -94 25 112 -18)",
 #	"@ >> 8","@ + {16 128 128}"]
@@ -143,15 +139,11 @@
 	def initialize(*argspecs) @argspecs = argspecs end
 	#def initialize2; add_outlets @argspecs.length end
 	def initialize2; self.noutlets = @argspecs.length+1 end
-
-	# apparently, i can't define a Array#split,
-	# possibly because it's a reserved keyword, in a "duck taping" kind of way
-	# (#respond_to? and stuff)
-	def split(ary,sep)
-		i=0; r=[[]]
-		ary.each {|x| if sep===x then r.last << x else r << [] end }
-		r
-	end
+#	def split(ary,sep)
+#		i=0; r=[[]]
+#		ary.each {|x| if sep===x then r.last << x else r << [] end }
+#		r
+#	end
 	def _0_bang
 		pa,*loadbang=patcherargs.split(:",")
 		GridFlow.handle_braces! pa
@@ -165,10 +157,16 @@
 			if not v then
 				if Array===@argspecs[i] and @argspecs[i][2] then
 					v = @argspecs[i][2]
-				else
+				elsif @argspecs[i].to_s!="*"
 					#raise "missing argument!"
-					GridFlow.post "missing argument!"; return
+					GridFlow.post "missing %d argument", i+1
+					next
 				end
+			end
+			if @argspecs[i].to_s=="*" then
+				rest = pa[i..-1]||[]
+				send_out i,:list,*rest
+				break
 			end
 			case pa[i]
 			when Symbol; send_out i,:symbol,v
@@ -317,8 +315,6 @@
 	end
 	install "pd_netsocket", 2, 2
 end
-
-#-------- fClasses for: jMax compatibility
 
 # make this with variable number of outlets?
 # what about moving this to desiredata?
@@ -354,9 +350,7 @@
 	class Demux < self; install "demux", 2, 0; end
 }
 
-#-------- fClasses for: list manipulation (jMax-compatible)
 # maybe that some of them could be replaced by 0.39 abstractions
-
 	FObject.subclass("listmake",2,1) {
 		def initialize(*a) @a=a end
 		def _0_list(*a) @a=a; _0_bang end
@@ -463,8 +457,6 @@
   doc_out:_0_float,"position of the incoming float in the stored list"
 }
 
-#-------- fClasses for: GUI
-
 module Gooey # to be included in any FObject class
 	def initialize(*)
 		super
@@ -623,8 +615,6 @@
   end
 }
 
-#-------- fClasses for: Hardware
-
 FObject.subclass("joystick_port",0,1) {
   def initialize(port)
     @f = File.open(port.to_s,"r+")
@@ -734,7 +724,6 @@
 		ioctl(arg1,s="blah")
 		return s.unpack("l")[0]
 	end
-
 end
 
 # Linux::ParallelPort



More information about the Gridflow-cvs mailing list