[prev in list] [next in list] [prev in thread] [next in thread] 

List:       appscript-changes
Subject:    [appscript-changes] [121] rb-appscript/trunk
From:       source_changes () macosforge ! org (source_changes () macosforge ! org)
Date:       2007-01-18 8:33:02
Message-ID: 20070118161529.649A34858A9 () cvs ! opensource ! apple ! com
[Download RAW message or body]

Revision: 121
          http://trac.macosforge.org/projects/appscript/changeset/121
Author:   hengist.podd@virgin.net
Date:     2007-01-18 08:15:29 -0800 (Thu, 18 Jan 2007)

Log Message:
-----------
[rb-appscript] added Terminology.dump; some tidying

Modified Paths:
--------------
    rb-appscript/trunk/CHANGES
    rb-appscript/trunk/TODO
    rb-appscript/trunk/sample/AB_list_people_with_emails.rb
    rb-appscript/trunk/sample/Select_all_HTML_files.rb
    rb-appscript/trunk/src/lib/_aem/connect.rb
    rb-appscript/trunk/src/lib/_appscript/terminology.rb

Modified: rb-appscript/trunk/CHANGES
===================================================================
--- rb-appscript/trunk/CHANGES	2007-01-18 16:13:27 UTC (rev 120)
+++ rb-appscript/trunk/CHANGES	2007-01-18 16:15:29 UTC (rev 121)
@@ -1,4 +1,4 @@
-2007-01-16 -- 0.3.0
+2007-01-18 -- 0.3.0
 
 - removed 'AS' alias; client scripts should refer to Appscript module, e.g.:
 
@@ -50,11 +50,13 @@
 
 - added default value ('StandardAdditions') for OSAX.osax's name argument
 
-- added Add_iCal_event.rb, Export_Address_Book_phone_numbers.rb examples; updated \
Hello_World.rb example to also demonstrate OSAX usage +- added Add_iCal_event.rb, \
Export_Address_Book_phone_numbers.rb examples; updated Hello_World.rb example to also \
demonstrate OSAX usage; made Select_all_HTML_files.rb example clearer  
 - improved handling of synonyms in Terminology, TerminologyParser modules \
(definitions with same codes but different names are now retained; previously only \
the last-found definition was retained). Still doesn't mimic AS's behaviour 100%, but \
it's difficult to get any closer without studying the original AS source code.  
+- added Terminology.dump method; removed misc/dump.rb file
 
+
 2006-11-29 -- 0.2.1
 
 - renamed AS module to Appscript. An 'AS' alias is temporarily provided for \
backwards compatibility but this will be removed in a future release. Users should \
update their scripts accordingly.

Modified: rb-appscript/trunk/TODO
===================================================================
--- rb-appscript/trunk/TODO	2007-01-18 16:13:27 UTC (rev 120)
+++ rb-appscript/trunk/TODO	2007-01-18 16:15:29 UTC (rev 121)
@@ -1,17 +1,27 @@
 TO DO
 
-- see if there's a way to provide a SafeObject base class for Appscript::Reference \
and Appscript::GenericReference that doesn't require adding traps to Module. (e.g. \
Could an alternative base class be implemented in C to act as a buffer between the \
two?) +- see if there's a way to provide a SafeObject base class for \
Appscript::Reference and Appscript::GenericReference that doesn't depend on inserting \
callbacks into Module (or are Rubyists fine with the current approach?)  
-- see if it's possible to work better with irb's autocomplete (autocomplete support \
is currently limited to start of a reference) +- see if it's possible to work better \
with irb's autocomplete (autocomplete support is currently limited to start of a \
reference; not sure why)  
 - ae/aem/appscript-defined exception classes aren't quite idiomatic Ruby
 
-- include an example project (or source for) that uses ruby2exe to build a \
standalone 'applet' +- any additional tests
 
-- finish writing tests
+- improve/polish documentation
 
-- improve and polish documentation
+- see also TO DO comments in rbae.c
 
-- see also TO DO items in source files
+-------
 
-- see also py-appscript's todo.txt file
+- _aem/connect.rb module refers directly to Send::Event instead of going via the \
AEM::Application::Event hook, which might cause problems when used in an OSA \
component or other situation where client needs to customise all event creation \
and/or dispatch. +
+- support sending and receiving events on non-main threads
+
+- provide an example project (or source for) that uses ruby2exe to build a \
standalone 'applet' +
+- any more built-in Ruby class<->AE type converters needed?
+
+- in AEM::CommandError, extract and report any kOSA... error parameters, if present
+
+- implement built-in help by bridging to osadict
\ No newline at end of file

Modified: rb-appscript/trunk/sample/AB_list_people_with_emails.rb
===================================================================
--- rb-appscript/trunk/sample/AB_list_people_with_emails.rb	2007-01-18 16:13:27 UTC \
                (rev 120)
+++ rb-appscript/trunk/sample/AB_list_people_with_emails.rb	2007-01-18 16:15:29 UTC \
(rev 121) @@ -1,6 +1,7 @@
 #!/usr/bin/env ruby
 
-# Lists the name and email(s) of every person in Address Book with one or more email \
addresses. +# Lists the name and email(s) of every person in Address Book with
+# one or more email addresses.
 
 require "appscript"
 include Appscript

Modified: rb-appscript/trunk/sample/Select_all_HTML_files.rb
===================================================================
--- rb-appscript/trunk/sample/Select_all_HTML_files.rb	2007-01-18 16:13:27 UTC (rev \
                120)
+++ rb-appscript/trunk/sample/Select_all_HTML_files.rb	2007-01-18 16:15:29 UTC (rev \
121) @@ -5,5 +5,7 @@
 require "appscript"
 include Appscript
 
-w = app('Finder').Finder_windows[1].target.get
-w.files[its.name_extension.is_in(['htm', 'html'])].select
\ No newline at end of file
+finder = app('Finder')
+finder.activate
+folder = finder.Finder_windows[1].target.get
+folder.files[its.name_extension.is_in(['htm', 'html'])].select
\ No newline at end of file

Modified: rb-appscript/trunk/src/lib/_aem/connect.rb
===================================================================
--- rb-appscript/trunk/src/lib/_aem/connect.rb	2007-01-18 16:13:27 UTC (rev 120)
+++ rb-appscript/trunk/src/lib/_aem/connect.rb	2007-01-18 16:15:29 UTC (rev 121)
@@ -2,8 +2,6 @@
 # Copyright (C) 2006 HAS. 
 # Released under MIT License.
 
-# TO DO: this module refers directly to Send::Event instead of going via the \
AEM::Application::Event hook, which might cause problems when used in an OSA \
component or other situation where client needs to customise all event creation \
                and/or dispatch.
-
 module Connect
 	# Creates Apple event descriptor records of typeProcessSerialNumber, \
typeKernelProcessID and typeApplicationURL, used to specify the target application in \
Send::Event constructor.  

Modified: rb-appscript/trunk/src/lib/_appscript/terminology.rb
===================================================================
--- rb-appscript/trunk/src/lib/_appscript/terminology.rb	2007-01-18 16:13:27 UTC (rev \
                120)
+++ rb-appscript/trunk/src/lib/_appscript/terminology.rb	2007-01-18 16:15:29 UTC (rev \
121) @@ -322,7 +322,7 @@
 	def Terminology.tables_for_aetes(aetes)
 		# Build terminology tables from a list of unpacked aete byte strings.
 		# Result : list of hash -- [typebycode, typebyname, referencebycode, \
                referencebyname]
-		classes, enums, properties, elements, commands = \
TerminologyParser.build_tables_for_aetes(aetes.delete_if { |aete| not \
(aete.is_a?(AE::AEDesc) and aete.type == 'aete') }) +		classes, enums, properties, \
elements, commands = TerminologyParser.build_tables_for_aetes(aetes.delete_if { \
|aete| not (aete.is_a?(AE::AEDesc) and aete.type == KAE::TypeAETE) })  return \
_make_type_table(classes, enums, properties) + _make_reference_table(properties, \
elements, commands)  end
 	
@@ -363,5 +363,57 @@
 		end
 		return @@_terminology_cache[aem_app.identity]
 	end
+	
+	#######
+	
+	def Terminology.dump(app_name, module_name, out_path)
+		# Export terminology tables as a Ruby module
+		# app_path : string -- name or path of application
+		# module_name : string -- name of generated module (must be a valid Ruby constant)
+		# out_path : string -- module file to write
+		app_path = FindApp.by_name(app_name)
+		if not /^[A-Z][A-Za-z0-9_]*$/ === module_name
+			raise RuntimeError, "Invalid module name."
+		end
+		# Write module
+		File.open(out_path, "w") do |f|
+			# Get aete(s)
+			begin
+				aetes = AEM::Codecs.new.unpack(AE.get_app_terminology(app_path).coerce(KAE::TypeAEList))
 +			rescue AE::MacOSError => e
+				if  e.to_i == -192 # aete resource not found
+					raise RuntimeError, "No terminology found."
+				else
+					raise
+				end
+			end
+			aetes.delete_if { |aete| not (aete.is_a?(AE::AEDesc) and aete.type == \
KAE::TypeAETE) } +			# Parse aete(s) into intermediate tables, suitable for use by \
Terminology#tables_for_module +			tables = \
TerminologyParser.build_tables_for_aetes(aetes) +			# Write module code
+			f.puts "module #{module_name}"
+			f.puts "\tVersion = 1.1"
+			f.puts "\tPath = #{app_path.inspect}"
+			f.puts
+			(["Classes", "Enumerators", "Properties", "Elements"].zip(tables[0,4])).each do \
|name, table| +				f.puts "\t#{name} = ["
+				table.sort.each do |item|
+					f.puts "\t\t#{item.inspect},"
+				end
+				f.puts "\t]"
+				f.puts
+			end
+			f.puts "\tCommands = ["
+			tables[4].sort.each do |name, code, params|
+				f.puts "\t\t[#{name.inspect}, #{code.inspect}, ["
+					params.each do |item|
+						f.puts "\t\t\t#{item.inspect},"
+					end
+				f.puts "\t\t]],"
+			end
+			f.puts "\t]"
+			f.puts "end"
+		end
+	end
 end
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/appscript-changes/attachments/20070118/0a4803d0/attachment.html



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic