From 5e2a1bc9e56003349e533f7e5841041ba5c04e28 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 4 Oct 2005 02:02:15 +0000 Subject: starting to commit gridflow 0.8.0 ... if you know how to use "cvs import" please mail me and i'll use it for 0.8.1 svn path=/trunk/; revision=3646 --- externals/gridflow/base/main.rb | 369 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 369 insertions(+) create mode 100644 externals/gridflow/base/main.rb (limited to 'externals/gridflow/base/main.rb') diff --git a/externals/gridflow/base/main.rb b/externals/gridflow/base/main.rb new file mode 100644 index 00000000..82976fb6 --- /dev/null +++ b/externals/gridflow/base/main.rb @@ -0,0 +1,369 @@ +=begin + $Id: main.rb,v 1.1 2005-10-04 02:02:13 matju Exp $ + + GridFlow + Copyright (c) 2001,2002 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 +} + -- cgit v1.2.1