=begin $Id: main.rb,v 1.2 2006-03-15 04:37:28 matju Exp $ GridFlow Copyright (c) 2001,2002,2003,2004,2005 by Mathieu Bouchard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See file ../COPYING for further informations on licensing terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =end # ENV["RUBY_VERBOSE_GC"]="yes" # this file gets loaded by main.c upon startup # module GridFlow is supposed to be created by main.c # this includes GridFlow.post_string(s) # because Ruby1.6 has no #object_id and Ruby1.8 warns on #id unless Object.instance_methods(true).include? "object_id" class Object; alias object_id id end end # in case of bug in Ruby ("Error: Success") module Errno; class E000 < StandardError; end; end #$post_log = File.open "/tmp/gridflow.log", "w" $post_log = nil class Array def split(elem) r=[] j=0 for i in 0...length (r<" else super end end def initialize(*argv) s = GridFlow.stringify_list argv @argv = argv @args = "[" @args << (self.class.foreign_name || self.to_s) @args << " " if s.length>0 @args << s << "]" @parent_patcher = nil @properties = {} @init_messages = [] end end class FPatcher < FObject class << self attr_reader :fobjects attr_reader :wires end def initialize(*) super fobjects = self.class.fobjects wires = self.class.wires @fobjects = fobjects.map {|x| if String===x then FObject[x] else x.call end } @inlets = [] @ninlets = self.class.ninlets or raise "oops" i=0 @fobjects << self while i e STDERR.puts "#{e.class}: #{e}" STDERR.puts e.backtrace end def GridFlow.load_user_config require "gridflow/bridge/puredata.rb" if GridFlow.bridge_name == "puredata" user_config_file = ENV["HOME"] + "/.gridflow_startup" begin load user_config_file if File.exist? user_config_file rescue Exception => e GridFlow.post "#{e.class}: #{e}:\n" + e.backtrace.join("\n") GridFlow.post "while loading ~/.gridflow_startup" end end require "gridflow/base/flow_objects.rb" require "gridflow/format/main.rb" %w( # #for #finished #type #dim #transpose #perspective #store #outer #grade #redim #import #export #export_list #cast #scale_by #downscale_by #draw_polygon #draw_image #layer #print #pack #export_symbol #rotate #in #out ).each {|k| GridFlow::FObject.name_lookup(k).add_creator k.gsub(/#/,"@") } END { GridFlow.fobjects.each {|k,v| k.delete if k.respond_to? :delete } GridFlow.fobjects.clear GC.start }