[Poet-commit] SF.net SVN: poet:[39] trunk
Brought to you by:
mercurio
|
From: <mer...@us...> - 2008-10-01 17:46:16
|
Revision: 39
http://poet.svn.sourceforge.net/poet/?rev=39&view=rev
Author: mercurio
Date: 2008-10-01 17:45:58 +0000 (Wed, 01 Oct 2008)
Log Message:
-----------
Added Poet addLibrary and Poet preload methods, to make
it easier to preload individual application files when
using Poet's autoloading mechanism.
Modified Paths:
--------------
trunk/lib/Poet.tcl
trunk/lib/tier1/tier1-poet.tcl
trunk/lib/tier1/tier1-thingpool.tcl
trunk/testing/debug.poet/Thing_AnonCounter.thg
trunk/testing/debug.poet/tclIndex
Modified: trunk/lib/Poet.tcl
===================================================================
--- trunk/lib/Poet.tcl 2008-08-25 22:43:21 UTC (rev 38)
+++ trunk/lib/Poet.tcl 2008-10-01 17:45:58 UTC (rev 39)
@@ -809,6 +809,9 @@
# Load all of the objects in one of the preload_indexes.
#
+# This is the version used internally within Poet, applications
+# that need preloading should call ``Poet preload``.
+#
proc ::Poet::preloadSet {index} {
if {[info exists ::Poet::preload_index($index)]} {
foreach p [set ::Poet::preload_index($index)] {
Modified: trunk/lib/tier1/tier1-poet.tcl
===================================================================
--- trunk/lib/tier1/tier1-poet.tcl 2008-08-25 22:43:21 UTC (rev 38)
+++ trunk/lib/tier1/tier1-poet.tcl 2008-10-01 17:45:58 UTC (rev 39)
@@ -6,9 +6,41 @@
# PJM 20070529 Methods for manipulating the constraint network
# added, using poetGlobals
# PJM 20080103 Added style, wrapper for ttk::style
+# PJM 20080926 Added addLibrary and preload
Object construct Poet
+# Add the given path as a Poet library, set up for autoloading.
+# We add it to ::auto_path and source poetIndex, if present.
+# There should be a tclIndex file present too.
+#
+Poet method addLibrary {dir} {
+ lappend ::auto_path $dir
+ catch {source [file join $dir poetIndex]}
+}
+
+# Load all of the objects in one of the preload_indexes.
+#
+# When autoloading, you can mark a file for preloading
+# with (must start in column 1):
+#``
+# ::Poet::Preload <tag>
+#``
+# where <tag> is a unique string, most likely the name of
+# your application. Then, as part of your initialization,
+# invoke this method with that tag as the argument. All
+# the objects marked with ::Poet:Preload will be loaded.
+# If the tag is invalid or nothing has been marked, no
+# error is generated.
+#
+Poet method preload {tag} {
+ if {[info exists ::Poet::preload_index($tag)]} {
+ foreach p [set ::Poet::preload_index($tag)] {
+ $p noop
+ }
+ }
+}
+
# Return the version string, which is of the
# form ``major.minor.release``. Individual
# components can be returned by giving them
Modified: trunk/lib/tier1/tier1-thingpool.tcl
===================================================================
--- trunk/lib/tier1/tier1-thingpool.tcl 2008-08-25 22:43:21 UTC (rev 38)
+++ trunk/lib/tier1/tier1-thingpool.tcl 2008-10-01 17:45:58 UTC (rev 39)
@@ -326,7 +326,7 @@
}
while {[gets $f line] >= 0} {
- if {[regexp {auto_index\((.+)\).*;# parent: (.+)$} $line ign obj mom]} {
+ if {[regexp {auto_index\((.+)\).*;# parent: (.+)$} $line -> obj mom]} {
lappend res [list $obj $mom]
}
}
Modified: trunk/testing/debug.poet/Thing_AnonCounter.thg
===================================================================
--- trunk/testing/debug.poet/Thing_AnonCounter.thg 2008-08-25 22:43:21 UTC (rev 38)
+++ trunk/testing/debug.poet/Thing_AnonCounter.thg 2008-10-01 17:45:58 UTC (rev 39)
@@ -1,17 +1,17 @@
-## Persistent storage for Thing_AnonCounter.
-## Do not edit this file!
-##
-
-
-Thing construct Thing_AnonCounter
-
-
-
-
-
-Thing_AnonCounter slot loaded "0"
-Thing_AnonCounter slot n "@1"
-Thing_AnonCounter slot nDel "1"
-Thing_AnonCounter slot saved "0"
-
-Thing_AnonCounter Thing_postload
+## Persistent storage for Thing_AnonCounter.
+## Do not edit this file!
+##
+
+
+Thing construct Thing_AnonCounter
+
+
+
+
+
+Thing_AnonCounter slot loaded "0"
+Thing_AnonCounter slot n "@1"
+Thing_AnonCounter slot nDel "1"
+Thing_AnonCounter slot saved "0"
+
+Thing_AnonCounter Thing_postload
Modified: trunk/testing/debug.poet/tclIndex
===================================================================
--- trunk/testing/debug.poet/tclIndex 2008-08-25 22:43:21 UTC (rev 38)
+++ trunk/testing/debug.poet/tclIndex 2008-10-01 17:45:58 UTC (rev 39)
@@ -1,12 +1,12 @@
-# Tcl autoload index file, version 2.0
-# This file is generated by ThingPool (Poet Tier 1)
-# and sourced to set up indexing information for one or
-# more Poet objects. Typically each line is a command that
-# sets an element in the auto_index array, where the
-# element name is the name of a command and the value is
-# a script that loads the command.
-#
-# Note: the comment after some lines is used by ThingPool list
-
-
-set auto_index(Thing_AnonCounter) [list source [file join $dir Thing_AnonCounter.thg]] ;# parent: Thing
+# Tcl autoload index file, version 2.0
+# This file is generated by ThingPool (Poet Tier 1)
+# and sourced to set up indexing information for one or
+# more Poet objects. Typically each line is a command that
+# sets an element in the auto_index array, where the
+# element name is the name of a command and the value is
+# a script that loads the command.
+#
+# Note: the comment after some lines is used by ThingPool list
+
+
+set auto_index(Thing_AnonCounter) [list source [file join $dir Thing_AnonCounter.thg]] ;# parent: Thing
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|