From: <jfa...@us...> - 2012-04-15 14:42:15
|
Revision: 7761 http://oorexx.svn.sourceforge.net/oorexx/?rev=7761&view=rev Author: jfaucher Date: 2012-04-15 14:42:05 +0000 (Sun, 15 Apr 2012) Log Message: ----------- Commit pending changes Modified Paths: -------------- sandbox/jlf/_diary.txt sandbox/jlf/delivery/platform/unix/create_packages sandbox/jlf/delivery/readme.txt sandbox/jlf/internals/notes/pipes.txt sandbox/jlf/samples/benchmark/call-benchmark.rex sandbox/jlf/samples/concurrency/coactivity.cls sandbox/jlf/samples/concurrency/generator.cls sandbox/jlf/samples/pipeline/pipe_extension.cls sandbox/jlf/samples/pipeline/pipe_readme.txt sandbox/jlf/trunk/extensions/platform/windows/oodialog/ControlDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/EventNotification.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/Menu.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/PlainBaseDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/oodMenu.cpp sandbox/jlf/trunk/extensions/platform/windows/oodialog/oodMenu.hpp sandbox/jlf/trunk/extensions/platform/windows/oodialog/oodMessaging.cpp sandbox/jlf/trunk/extensions/platform/windows/oodialog/oodPackageEntry.cpp sandbox/jlf/trunk/interpreter/RexxClasses/Parser.orx sandbox/jlf/trunk/platform/windows/install/oorexx.nsi sandbox/jlf/trunk/samples/windows/oodialog/TabDemo.rex sandbox/jlf/trunk/samples/windows/oodialog/menus/BinaryMenuBar.rex sandbox/jlf/trunk/samples/windows/oodialog/menus/UserMenuBar.rex sandbox/jlf/trunk/samples/windows/oodialog/res/res.mak sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise03/WowView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise04/CustomerView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise05/ProductView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Customer/CustomerListView.rc sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Customer/CustomerListView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Customer/CustomerView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Order/OrderFormView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Order/OrderListView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Order/OrderView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/OrderMgr/OrderMgrBaseView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/OrderMgr/OrderMgrView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Product/ProductListView.rex sandbox/jlf/trunk/samples/windows/oodialog/userGuide/exercises/Exercise06/Product/ProductView.rex sandbox/jlf/trunk/utilities/platform/windows/rexxpaws/rexxpaws.cpp sandbox/jlf/trunk/utilities/rexx/platform/unix/rexx.cpp sandbox/jlf/trunk/utilities/rexx/platform/windows/rexx.cpp Added Paths: ----------- sandbox/jlf/samples/ooRexxTry/ sandbox/jlf/samples/ooRexxTry/ooRexxTry.rxj sandbox/jlf/samples/ooRexxTry/readme.txt Removed Paths: ------------- sandbox/jlf/trunk/samples/windows/oodialog/oopet.rex sandbox/jlf/trunk/samples/windows/oodialog/oopet1.rex sandbox/jlf/trunk/samples/windows/oodialog/rc/oopet.rc Property Changed: ---------------- sandbox/jlf/trunk/ sandbox/jlf/trunk/Makefile.am sandbox/jlf/trunk/api/ sandbox/jlf/trunk/configure.ac sandbox/jlf/trunk/extensions/hostemu/ sandbox/jlf/trunk/extensions/platform/unix/ sandbox/jlf/trunk/extensions/platform/windows/oodialog/AnimatedButton.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/BaseDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/CategoryDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/DeprecatedClasses.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/DialogControls.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/DialogExtensions.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/DynamicDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/PlainBaseDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/PropertySheet.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/ResDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/UserDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/UtilityClasses.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog/oodViewControls.cpp sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/AnimatedButton.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/BaseDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/CategoryDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/DeprecatedClasses.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/DialogControls.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/DialogExtensions.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/DynamicDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/PlainBaseDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/PropertySheet.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/ResDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/UserDialog.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/UtilityClasses.cls sandbox/jlf/trunk/extensions/platform/windows/oodialog.wchar/oodViewControls.cpp sandbox/jlf/trunk/extensions/rexxutil/ sandbox/jlf/trunk/extensions/rxsock/ sandbox/jlf/trunk/extensions/rxsock/mime.cls sandbox/jlf/trunk/extensions/rxsock/smtp.cls sandbox/jlf/trunk/extensions/rxsock/streamsocket.cls sandbox/jlf/trunk/interpreter/ sandbox/jlf/trunk/makeorx.bat sandbox/jlf/trunk/platform/ sandbox/jlf/trunk/platform/unix/ sandbox/jlf/trunk/platform/windows/ sandbox/jlf/trunk/rexxapi/ sandbox/jlf/trunk/samples/ sandbox/jlf/trunk/samples/windows/oodialog/userGuide/ sandbox/jlf/trunk/samples/windows/oodialog/wav/ sandbox/jlf/trunk/samples/windows/oodialog/winsystem/ sandbox/jlf/trunk/samples/windows/rexutils/ sandbox/jlf/trunk/samples/windows/wsh/ sandbox/jlf/trunk/utilities/ Modified: sandbox/jlf/_diary.txt =================================================================== --- sandbox/jlf/_diary.txt 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/_diary.txt 2012-04-15 14:42:05 UTC (rev 7761) @@ -128,10 +128,59 @@ Profiler todo : Error "does not understand message XXX_UNPROTECTED" when the method XXX is private. +Clauser todo : +Keep the multi-line source literals as-is (multi-line), for better error report. +That makes the transformation of clauses more difficult, since a clause can be +multi-line. +Remember : a multi-line source literal is flattened only if a transformation is +made on the clause which contains it. + =============================================================================== 2012 mar 23 +merge 7691-7736 from main/trunk + + +Adaptation of ooRexxTry.rxj : +Preloads all the main components (math, ftp, socket, bsf, hostemu, ...). +The '=' shortcut is managed at the end of each clause. +Now, it's possible to write that : + dir;rc=;unknown;rc= +The transformed command is : + dir; + options "NOCOMMANDS"; + rc ; + if var("result") then call dumpResult(result); + options "COMMANDS"; + unknown; + options "NOCOMMANDS"; + rc ; + if var("result") then call dumpResult(result); + options "COMMANDS" + + +[pipes] +Fixed a deadlock. +The methods ~pipe, ~pipe.generate, pipeProfile and pipeProfile.generate must be unguarded. + + +[coactivity] +Added support for onStart and onTerminate at the class level. +Needed to attach/detach properly to/from the Java thread in ooRexxTry.rxj. + + +[parser] +Fixed a bug in .Clauser. +When parsing a multi-line source literal, a single line is created by concatenating each line. +A ';' was missing to delimitate the clauses. +Probably to rework : should keep the source literal as-is (multi-line) to have good line numbers +in case of error. + + +=============================================================================== +2012 mar 23 + merge 7390-7647 from main/trunk merge 7647-7688 from main/trunk merge 7688-7691 from main/trunk @@ -361,8 +410,8 @@ RexxActivation::evaluateLocalCompoundVariable : done --> cancelled <to continue...> --> not needed, the objects should be protected by the stack decodeExternalMethod - RexxSource::methodDirective - RexxSource::attributeDirective + RexxSource::methodDirective : done + RexxSource::attributeDirective : done =============================================================================== @@ -3615,3 +3664,5 @@ merge 7647-7688 from main/trunk merge 7688-7691 from main/trunk + +merge 7691-7736 from main/trunk Modified: sandbox/jlf/delivery/platform/unix/create_packages =================================================================== --- sandbox/jlf/delivery/platform/unix/create_packages 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/delivery/platform/unix/create_packages 2012-04-15 14:42:05 UTC (rev 7761) @@ -4,7 +4,7 @@ # It gathers various files from samples and incubator, to create a "packages" directory in delivery. # Can be run as many times as needed, but you have to remove the existing "packages" directory, if any (otherwise the script stops). # -# Usage : ./platform/unix/create_packages.sh +# Usage : ./platform/unix/create_packages # # Note : this script can be used under Windows, from the Cygwin shell. @@ -73,6 +73,7 @@ copy_file ../../../incubator/ooRexxShell/oorexxshell copy_file ../../../incubator/ooRexxShell/oorexxshell.bat copy_file ../../../incubator/ooRexxShell/oorexxshell.rex + copy_file ../samples/ooRexxTry/ooRexxTry.rxj create_Makefile_am "_samples concurrency extension pipeline profiling regex rgf_util2 trace" DEST=regex Modified: sandbox/jlf/delivery/readme.txt =================================================================== --- sandbox/jlf/delivery/readme.txt 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/delivery/readme.txt 2012-04-15 14:42:05 UTC (rev 7761) @@ -55,9 +55,8 @@ Good point : the history of commands is kept. -If an ooRexx command line ends with "=" then the command line is transformed -to display the result : -'1+2=' becomes 'options "NOCOMMANDS";1+2;call dumpResult' +If an ooRexx clause ends with "=" then the command line is transformed to display the result : +'1+2=' becomes 'command= options "NOCOMMANDS"; 1+2 ;if var("result") then call dumpResult(result); options "COMMANDS"' '=' alone displays the current value of the variable RESULT. @@ -66,6 +65,31 @@ ===================================================================================== +ooRexxTry.rxj +===================================================================================== + +Adaptation of ooRexxTry.rxj (http://sourceforge.net/projects/bsf4oorexx) : +Load all the packages/libraries delivered in the snapshot. +If an ooRexx clause ends with "=" then the command line is transformed to display the result. + +Unlike ooRexxShell, ooRexxTry lets enter multiline code. +Example taken from GetJavaSystemProperties.rxj : +Get the Java System Properties from java.lang.System using the services set up by BSF.CLS. + c= {::coactivity + properties=.bsf4rexx ~System.class ~getProperties -- get the System properties + enum=properties~propertyNames -- get an enumeration of the property names + + do while enum~hasMoreElements -- loop over enumeration + key=enum~nextElement -- get next element + value = properties~getProperty(key) + .yield[.array~of(key, value)] + end + } + c~do= -- ['java.runtime.name','Java(TM) SE Runtime Environment'] + c~do= -- ['sun.boot.library.path','C:\Program Files\Java\jre6\bin'] + + +===================================================================================== Extension of predefined classes. ===================================================================================== @@ -296,16 +320,18 @@ This is an abstraction of routine, method, message, coactivity, closure. When used as a doer, a string is a message. -This abstraction is useful with the ~reduce method. +This abstraction is useful with the higher-order methods. Ex : say "length"~("John") -- 4 ("John"~"length") +say "length of each word"~mapW("length") -- A string "6 2 4 4" +say "length of each word"~eachW("length") -- An array [6,2,4,4] Each doer has its own "do" method, and knows what to do with the arguments. routine : forward message "call" method : use strict arg object, ... ; forward to (object) message "run" array (self, "a", arg(2,"a")) message : use strict arg object, ... ; forward to (object) message ("sendWith") array (self, arg(2,"a")) coactivity : forward message ("resume") -closure : user-defined source literal +closure : user-defined method block : forward to (self~doer) A DoerFactory is an object who knows how to create a doer. @@ -604,7 +630,7 @@ -- If you need a result object which is of the same type as the iterated object then use ~map. .set~of(1,2,3)~supplier~each{2*item} "abcdef"~eachC{item} -{::coactivity do i=1 to 3; .yield[i]; end}~doer~each{2*item} +{::coactivity do i=1 to 3; .yield[i]; end}~doer~iterator~each{2*item} -- Filter on any sequence @@ -643,8 +669,8 @@ ===================================================================================== When applied to a coactivity, the higher-order methods return a new coactivity instead -of an array or results. The results are returned one by one. -Sometimes, you want to iterate over all the values produced by a coactivity. In this case, +of an array or items. The items are returned one by one. +Sometimes, you want to iterate over all the items produced by a coactivity. In this case, use the method ~iterator which returns a supplier specialized for iteration, where all items are consumed in one loop. Example : @@ -653,7 +679,12 @@ The .Generator class is a Coactivity which applies an action to a source (any object) -and yields the results one by one. The following options can be specified : +and yields the results one by one. + generator = .Generator~new(source)~option1~option2... + r1 = generator~do + r2 = generator~do + ... +The following options can be specified : ~action(action) : The action to execute on each item. The default action is {use arg item ; return item}. An action of type message (string) is supported. For convenience, the message is sent only @@ -735,9 +766,9 @@ -- Illustration of depthFirst (default) vs breadthFirst "one two three"~generateW{if depth == 0 then item; else if item <> "" then item~substr(2)}~recursive~makeArray= - ['one','ne','e','','two','wo','o','','three','hree','ree','ee','e',''] + -- ['one','ne','e','','two','wo','o','','three','hree','ree','ee','e',''] "one two three"~generateW{if depth == 0 then item; else if item <> "" then item~substr(2)}~recursive("breadthFirst")~makeArray= - ['one','two','three','ne','wo','hree','e','o','ree','','','ee','e',''] + -- ['one','two','three','ne','wo','hree','e','o','ree','','','ee','e',''] -- Generation of all natural numbers : 1 2 3 ... g=0~generate{item+1}~recursive @@ -825,9 +856,7 @@ -- A coactivty can be a source of pipe : each yielded value is injected in the pipe. -- Example : --- This coactivity yields two results. --- The hello outputs are not in the pipeline flow (not displayed by the .console). -{::coactivity echo hello ; .yield["a"] ; say hello ; .yield["b"] }~doer~pipe(.console) +{::coactivity .yield["a"] ; .yield["b"] }~doer~pipe(.console) -- A collection can be sorted by item (default) @@ -860,7 +889,7 @@ -- Do something for each item (the returned result replaces the item's value). -- Here, only one result is calculated for an item, so resultIndex is always 1. -.array~of(1, , 2, , 3)~pipe(.do {return 2*item} mem | .console) +.array~of(1, , 2, , 3)~pipe(.do {return 2*item} | .console) -- Each injected value can be used as input to inject a new value, recursively. @@ -873,16 +902,6 @@ .array~of(1, , 2, , 3)~pipe(.inject {item*30} recursive.2 | .console) --- Methods (not inherited) of all the classes whose id starts with "R". -.environment~pipe(, - .select {item~isA(.class)} |, - .select {item~id~caselessAbbrev('R') <> 0} |, - .inject {item~methods(item)} after memorize |, - .sort byIndex |, - .console, - ) - - -- Display the 4 first sorted items .array~of(5, 8, 1, 3, 6, 2)~pipe(.sort | .take 4 | .console) @@ -918,8 +937,23 @@ "/tmp"~pipe(.fileTree recursive.memorize | .take 50 | .console dataflow) +-- Methods (not inherited) of all the classes whose id starts with "R". +.environment~pipe(, + .select {item~isA(.class)} memorize.class |, + .select {item~id~caselessAbbrev('R') <> 0} |, + .inject {item~methods(item)} iterateAfter |, + .sort {index} {dataflow["class"]~item~id} |, + .console {dataflow["class"]~item~id} {index}, + ) + + -- Public classes by package -.context~package~pipe(.importedPackages recursive once after memorize.package | .inject {item~publicClasses} iterateAfter | .sort {item~id} {dataflow["package"]~item~name} | .console {.file~new(dataflow["package"]~item~name)~name} ":" item) +.context~package~pipe(, + .importedPackages recursive once after memorize.package |, + .inject {item~publicClasses} iterateAfter |, + .sort {item~id} {dataflow["package"]~item~name} |, + .console {.file~new(dataflow["package"]~item~name)~name} ":" item, + ) ===================================================================================== @@ -935,6 +969,11 @@ | each | eachC eachW | | | | | eachI | eachCI eachWI | | | | -|--------|-----------|-----------|------------|--------|-------|-------|--------------|----------- + | reject | rejectC rejectW | | | | + | rejectI | rejectCI rejectWI | | | | + | select | selectC selectW | | | | + | selectI | selectCI selectWI | | | | + -|--------|-----------|-----------|------------|--------|-------|-------|--------------|----------- | | drop dropC dropW | | | | | | dropI dropCI dropWI | | | | | | dropLast dropLastC dropLastW | | | | @@ -943,10 +982,6 @@ | | dropUntilI dropUntilCI dropUntilWI | | | | | | dropWhile dropWhileC dropWhileW | | | | | | dropWhileI dropWhileCI dropWhileWI | | | | - | reject | rejectC rejectW | | | | - | rejectI | rejectCI rejectWI | | | | - | select | selectC selectW | | | | - | selectI | selectCI selectWI | | | | | | take takeC takeW | | | | | | takeI takeCI takeWI | | | | | | takeLast takeLastC takeLastW | | | | Modified: sandbox/jlf/internals/notes/pipes.txt =================================================================== --- sandbox/jlf/internals/notes/pipes.txt 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/internals/notes/pipes.txt 2012-04-15 14:42:05 UTC (rev 7761) @@ -107,4 +107,29 @@ Open Object Rexx Version 4.1.0 Build date: Dec 3 2010 Addressing Mode: 64 + + ============================================================================ +Notes about pipe.rex + +fanout : forward eof to self~next and self~secondary, but not to super + +merge : send a 'done' message + +console : process does forward class (super) --> why needed here, and not in other classes ? +answer : because .console does not transform the items, it just displays them. So it can +forward to class (super) which will take care of sending the item & index to next pipestage. +The other classes transform the items, and write themselves the new item. If they forwarded +to class (super) then the unchanged item would be also sent to the next pipeStage. + + +http://freshmeat.net/projects/pv +pv (Pipe Viewer) is a terminal-based tool for monitoring the progress of data through a pipeline. +It can be inserted into any normal pipeline between two processes to give a visual indication of +how quickly data is passing through, how long it has taken, how near to completion it is, and an +estimate of how long it will be until completion. + + +http://www.softpanorama.org/Scripting/Shellorama/Control_structures/pipes_in_loops.shtml + + Modified: sandbox/jlf/samples/benchmark/call-benchmark.rex =================================================================== --- sandbox/jlf/samples/benchmark/call-benchmark.rex 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/samples/benchmark/call-benchmark.rex 2012-04-15 14:42:05 UTC (rev 7761) @@ -1,5 +1,5 @@ /* -Repeat 10 times a piece of code which calls 10000 times a procedure / routine by name / .routine / class method / instance method +Repeat 10 times a piece of code which calls 1000000 times a procedure / routine by name / .routine / class method / instance method Why is a .routine call slower than a method call (undex WinXP - almost no difference under MacOsX)? Problem identified and fixed : it's because the environment variable RXTRACE is read at each call. @@ -55,7 +55,7 @@ use strict arg count do count call time('r') - do value=1 to 10000 + do value=1 to 1000000 call myProcedure value end call charout ,time('e')~format(2,4)" " @@ -64,13 +64,13 @@ myProcedure: procedure use strict arg value - return + return value ::routine runRoutineByNameN use strict arg count do count call time('r') - do value=1 to 10000 + do value=1 to 1000000 call myRoutine value end call charout ,time('e')~format(2,4)" " @@ -81,7 +81,7 @@ use strict arg count, routine do count call time('r') - do value=1 to 10000 + do value=1 to 1000000 routine~call(value) end call charout ,time('e')~format(2,4)" " @@ -92,7 +92,7 @@ use strict arg count, object do count call time('r') - do value=1 to 10000 + do value=1 to 1000000 object~myMethod(value) end call charout ,time('e')~format(2,4)" " @@ -101,13 +101,13 @@ ::routine myRoutine use strict arg value - return + return value ::class myClass ::method myMethod class use strict arg value - return + return value ::method myMethod use strict arg value - return + return value Modified: sandbox/jlf/samples/concurrency/coactivity.cls =================================================================== --- sandbox/jlf/samples/concurrency/coactivity.cls 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/samples/concurrency/coactivity.cls 2012-04-15 14:42:05 UTC (rev 7761) @@ -106,9 +106,22 @@ expose coactivityObj proxy = .WeakProxy~new(self) use strict arg action="main", start=.false, object=(proxy) -- object must reference the proxy, not directly the coactivity, otherwise the coactivity will never be GC'ed - coactivityObj = .CoactivityObj~new(action, start, object, proxy) -- pass itself as proxy, to be stored on the wrapped coactivityObj (needed for supplier) + + -- The following methods, if defined, will be attached to the instance of CoactivityObj + -- Must do that, because when calling "onTerminate", the instance of Coactivity may be already garbage collected. + -- In this case, proxy~value is .nil, and you can't run a method on it. + -- This problem don't occur for "onStart" but I prefer to use a consistent way for handling these events. + -- Probably to rework : must search from .coactivity explicitely, not from self~class because method not found when subclassing. + instanceOnStart = .nil ; if self~hasMethod("onStart") then instanceOnStart = self~instanceMethod("onStart") + classOnStart = .nil ; if /*self~class*/ .Coactivity~hasMethod("onStart") then classOnStart = /*self~class*/ .Coactivity~instanceMethod("onStart") + instanceOnTerminate = .nil ; if self~hasMethod("onTerminate") then instanceOnTerminate = self~instanceMethod("onTerminate") + classOnTerminate = .nil ; if /*self~class*/ .Coactivity~hasMethod("onTerminate") then classOnTerminate = /*self~class*/ .Coactivity~instanceMethod("onTerminate") + -- pass itself as proxy, to be stored on the wrapped coactivityObj (needed for supplier) + coactivityObj = .CoactivityObj~new(action, start, object, proxy,, + instanceOnStart, classOnStart, instanceOnTerminate, classOnTerminate) + ::method uninit expose coactivityObj coactivityObj~end @@ -230,6 +243,10 @@ forward to (coactivityObj) +::method setMethod class public unguarded -- override the private setMethod inherited from Object to make it public + forward class (super) + + -------------------------------------------------------------------------------- ::class "CoactivityObj" @@ -259,10 +276,14 @@ ::method init unguarded expose doer object proxy status yieldIndex - use strict arg action, start, object, proxy + use strict arg action, start, object, proxy, instanceOnStart, classOnStart, instanceOnTerminate, classOnTerminate doer = action~doer status = .CoactivityObj~notStarted yieldIndex = 0 + if instanceOnStart <> .nil then self~setMethod("onStart", instanceOnStart) + if classOnStart <> .nil then self~class~setMethod("onStart", classOnStart) + if instanceOnTerminate <> .nil then self~setMethod("onTerminate", instanceOnTerminate) + if classOnTerminate <> .nil then self~class~setMethod("onTerminate", classOnTerminate) if start then self~start @@ -287,6 +308,8 @@ .Coactivity~register(self) signal on any name trapCondition -- catch all signal on syntax name trapCondition -- gives better messages + if self~class~hasMethod("onStart") then self~class~onStart(self) + if self~hasMethod("onStart") then self~onStart guard off guard on when status <> .CoactivityObj~suspended if status == .CoactivityObj~running then do @@ -302,6 +325,7 @@ trapCondition: self~kill -- maybe already killed or ended if self~hasMethod("onTerminate") then self~onTerminate + if self~class~hasMethod("onTerminate") then self~class~onTerminate(self) .Coactivity~unregister(self) if self~isKilled & condition("o") <> .nil then raise propagate Modified: sandbox/jlf/samples/concurrency/generator.cls =================================================================== --- sandbox/jlf/samples/concurrency/generator.cls 2012-04-14 23:56:26 UTC (rev 7760) +++ sandbox/jlf/samples/concurrency/generator.cls 2012-04-15 14:42:05 UTC (rev 7761) @@ -519,22 +519,22 @@ -------------------------------------------------- -- Yield each character one by one -::method generateC +::method generateC unguarded use strict arg action={item} return .Generator~new(self~makeArray(""))~iterateBefore~action(action) -- Yield each character one by one, as a pair (char, char_pos) -::method generateCI +::method generateCI unguarded use strict arg action={item} return .Generator~new(self~makeArray(""))~iterateBefore~action(action)~returnIndex -- Yield each word one by one -::method generateW +::method generateW unguarded use strict arg action={item} return .Generator~new(self~subwords)~iterateBefore~action(action) -- Yield each word one by one, as a pair (word, word_index) -::method generateWI +::method generateWI unguarded use strict arg action={item} return .Generator~new(self~subwords)~iterateBefore~action(action)~returnIndex @@ -544,22 +544,22 @@ --------------------------------------------------------- -- Yield each character one by one -::method generateC +::method generateC unguarded use strict arg action={item} return .Generator~new(self~makeArray(""))~iterateBefore~action(action) -- Yield each character one by one, as a pair (char, char_pos) -::method generateCI +::method generateCI unguarded use strict arg action={item} return .Generator~new(self~makeArray(""))~iterateBefore~action(action)~returnIndex -- Yield each word one by one -::method generateW +::method generateW unguarded use strict arg action={item} return .Generator~new(self~subwords)~iterateBefore~action(action) -- Yield each word one by one, as a pair (word, word_index) -::method generateWI +::method generateWI unguarded use strict arg action={item} return .Generator~new(self~subwords)~iterateBefore~action(action)~returnIndex @@ -569,11 +569,11 @@ ------------------------------------------------------ -- Yield each item one by one -::method generate +::method generate unguarded forward to (self~supplier) -- Yield each item one by one, as a pair (item, index) -::method generateI +::method generateI unguarded forward to (self~supplier) @@ -582,12 +582,12 @@ ---------------------------------------------------- -- Yield each item one by one -::method generate +::method generate unguarded use strict arg action={item} return .Generator~new(self)~iterateBefore~action(action) -- Yield each item one by one, as a pair (item, index) -::method generateI +::method generateI unguarded use strict arg action={item} return .Generator~new(self)~iterateBefore~action(action)~returnIndex @@ -596,10 +596,10 @@ ::class "CoactivityGenerator" mixinclass Object public ------------------------------------------------------ -::method generate +::method generate unguarded forward to (self~supplier) -::method generateI +::method generateI unguarded forward to (self~supplier) Added: sandbox/jlf/samples/ooRexxTry/ooRexxTry.rxj =================================================================== --- sandbox/jlf/samples/ooRexxTry/ooRexxTry.rxj (rev 0) +++ sandbox/jlf/samples/ooRexxTry/ooRexxTry.rxj 2012-04-15 14:42:05 UTC (rev 7761) @@ -0,0 +1,3103 @@ +#!/usr/bin/rexx +/* Name: ooRexxTry.rxj + Purpose: GUI supported testing of ooRexx and Bsf4ooRexx enhanced Java support + Author: Markus Moldaschl + + Version: 1.1 + Changes: 2011-02-20, Rony G. Flatscher: + - removed MacOSX-related change to name of menu "Exit" + to "Quit" as MacOSX has its own application + "Quit" menu at all times + - using "VK_E" instead of "VK_X" for "Exit" button + 2011-02-21 Rony G. Flatscher + - make sure to act upon the Apple application quit event + - adding icon image to JFrame + - make sure that a bsf.exit() is not carried out, if the RexxAndJava + version is capable of doing that + 2011-02-23 Rony G. Flatscher + - renamed class "CreateSocket" to "CreateServerSocket" + - added logic to allow new ooRexxTry.rxj instances to be + created, even if the port is already taken (ask user + for another new portnumber) + - use new BSF-subfunction "carryOutSystemExit" + - use SysTempFileName() to create unique temporary filenames + 2011-02-28 Rony G. Flatscher + - usability improvement: add Rexx and BSF version to title bar + 2011-03-19 Rony G. Flatscher + - display help-PDF, take different operating systems into account + - edit font-picker code (added "Courier 10 Pitch", "FreeMno", + special handling of font "Monospace" which Java guarantees to + be mappable + - make sure that it can be run on older versions that do not + have "carryOutSystemExit" implemented + 2012-02-23 Rony G. Fltascher + - fix for bug 3434228 not working on some Linux distributions + due to not having write permissions to its directory: now + using "user.home" as working and temporary directory, returned + by new routine getHomeDir() + - fixed a bug referring to .preferred_path instead of .mm.dir~preferredPath + - accustomed for Java 1.4 swing forcing to use "getContentPane" before + adding a component to a JFrame or JDialog + + 2012-03-27 Jean-Louis Faucher + - Fix bug 3512053 + + 2012-03-29 Rony G. Flatscher + - make sure that .input, .output and .error GUI interface can be used, + even if Rexx code is run on a separate thread; quick fix, experimental + + 2012-04-03 Rony G. Flatscher + - fix bug ID: 3514658 + - Java classes are now stored in .local by there fully qualified name; + this way there should be no interference with any other class (JLF + reported a name clash with .file, which is defined as an ooRexx class + and which was offset by java.io.File that was saved in .local as .file) + + 2012-04-05 JLF + - Convert the result to a string before displaying in returnsArea + - Support empty arguments : arg(N, "e") returns 1 if line N is empty in argsArea. + - The temporary file ooRexxTry_test was created with a path in home directory, + but then only the filename part was kept. Now keeps the whole path. + - The path to ooRexxTry_test is surrounded by quotes to support whitespaces. + - The file ooRexxTry.rc is saved in the home directory. + - No longer accumulate text in say_stg and error_stg, better to use the method + append of JTextArea. + + 2012-04-12 JLF (functionalities available only in JLF sandbox) + - Preloads all the main components (math, ftp, socket, bsf, hostemu, ...). + - Display the elapsed duration and number of coactivities after each run. + - Manage the '=' shortcut at the end of each clause. + Ex : dir;rc=;unknown;rc= +*/ + +/*----------------------------------------------------------------------------*/ +/* Copyright 2011 Markus Moldaschl, 2011-2012 Rony G. Flatscher */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/*----------------------------------------------------------------------------*/ + + + +/*Based on ooRexxTry.rex and code samples from Lee Peedin and Dr. Rony G. Flatscher*/ +/*----------------------------------------------------------------------------*/ +/* */ +/* Copyright (c) 2007-2009 Rexx Language Association. All rights reserved. */ +/* */ +/* This program and the accompanying materials are made available under */ +/* the terms of the Common Public License v1.0 which accompanies this */ +/* distribution. A copy is also available at the following address: */ +/* http://www.oorexx.org/license.html */ +/* */ +/* Redistribution and use in source and binary forms, with or */ +/* without modification, are permitted provided that the following */ +/* conditions are met: */ +/* */ +/* Redistributions of source code must retain the above copyright */ +/* notice, this list of conditions and the following disclaimer. */ +/* Redistributions in binary form must reproduce the above copyright */ +/* notice, this list of conditions and the following disclaimer in */ +/* the documentation and/or other materials provided with the distribution. */ +/* */ +/* Neither the name of Rexx Language Association nor the names */ +/* of its contributors may be used to endorse or promote products */ +/* derived from this software without specific prior written permission. */ +/* */ +/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ +/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ +/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */ +/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ +/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */ +/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ +/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */ +/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ +/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ +/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* */ +/*----------------------------------------------------------------------------*/ + + +userData = .directory~new -- Directory to certain objects +.local~mm.dir = .directory~new -- locally accessable directory + -- holds frequently used key variables +.mm.dir~start.tid=BSFGetTID() -- get this instance's thread id +parse arg isDefault + +.mm.dir~useDefault = .false -- use default settings +if isDefault~translate = 'DEFAULT' then + .mm.dir~useDefault = .true + +parse source . . s +pngFn=filespec("Location",s) || .bsf4rexx~file.separator || 'ooRexxTry.png' +.mm.dir~ooRexxTry.png=pngFn -- save path to image +.mm.dir~ooRexxTry.pdf=filespec("Location",s) || .bsf4rexx~file.separator || 'ooRexxTry.pdf' + +if .bsf4rexx~opsys="MACOSX" then -- on MacOSX display the standard ooRexx4OOo logo +do +-- frame~setIconImage(.bsf~new("javax.swing.ImageIcon", pngFn)~getImage) + .bsf4rexx~apple_application~setDockIconImage(.bsf~new("javax.swing.ImageIcon",pngFn)~getImage) + +end + + +say +say "*-----------------------------------------------------------------------------*" +say "| This console is only used for input regarding the Rexx Utility SysGetKey(). |" +say '| Please use the area named "Input" on the GUI as your primary input device. |' +say "*-----------------------------------------------------------------------------*" +say +call dontBSFExit -- do not carry out a bsf.exit as this would abort this program as well +call importClasses -- Import all utilized java classes +.mm.dir~mainPackage = .context~package -- Will be used when creating a method to run code +call LoadEnvironment -- Set up the environment to work with +.platform~initialize +call LoadOptionalComponents +.traceOutput~destination(.stdout) +.mm.dir~storage = .Store~new -- Instance, later on used to store code executions +.mm.dir~storage~makeQueue(5) +gui = .GUI~new(userData) -- Create the basic GUI elements and draw the GUI + + +/*Change the destination of the .input, .output and .error monitor + from the standard stream to a custom GUI stream or file stream. + No need for command prompt!*/ +if .mm.dir~inputMonitorDestination~equals('GUIInputStream') then + do + .local~mm.dir~guiInputStream = .GUIInputStream~new('STDIN') + .input~destination(.mm.dir~guiInputStream) + end +else + do + .mm.dir~infilestream = .stream~new(.mm.dir~inputMonitorDestination) + .input~destination(.mm.dir~infilestream) + end + +if .mm.dir~outputMonitorDestination~equals('GUIOutputStream') then + do + .local~mm.dir~guiOutputStream = .GUIOutputStream~new('STDOUT') + .output~destination(.mm.dir~guiOutputStream) + end +else + do + .mm.dir~outfilestream = .stream~new(.mm.dir~outputMonitorDestination) + .output~destination(.mm.dir~outfilestream) + end + +if .mm.dir~errorMonitorDestination~equals('GUIErrorStream') then + do + .local~mm.dir~guiErrorStream = .GUIErrorStream~new('STDERR') + .error~destination(.mm.dir~guiErrorStream) + end +else + do + if \.mm.dir~errorMonitorDestination~equals(.mm.dir~outputMonitorDestination) + then .mm.dir~errfilestream = .stream~new(.mm.dir~errorMonitorDestination) + else .mm.dir~errfilestream = .mm.dir~outfilestream + .error~destination(.mm.dir~errfilestream) + end + +.CreateServerSocket~new~~run -- setup up a server socket + +userData~rexxCloseEH~waitforExit -- wait until we are allowed to end the program + +call SysSleep .3 -- let Java's RexxProxy finalizations find a running Rexx instance +return + +------------------------------------------------------------------------------- +-- Load optional packages/libraries +-- Remember : don't implement that as a procedure or routine or method ! +loadOptionalComponents: + if .platform~is("windows") then do + call loadPackage("oodialog.cls") + call loadPackage("winsystm.cls") + end + if \.platform~is("windows") then do + call loadLibrary("rxunixsys") + end + call loadLibrary("hostemu") + call loadPackage("mime.cls") + call loadPackage("rxftp.cls") + call loadLibrary("rxmath") + call loadPackage("rxregexp.cls") + call loadPackage("regex/regex.cls") + call loadPackage("smtp.cls") + call loadPackage("socket.cls") + call loadPackage("streamsocket.cls") + call loadPackage("pipeline/pipe.rex") + call loadPackage("rgf_util2/rgf_util2.rex") -- http://wi.wu.ac.at/rgf/rexx/orx20/rgf_util2.rex + call loadPackage("BSF.CLS") + call loadPackage("UNO.CLS") + .local~mm.dir~ooRexx.isExtended = .true + if \loadPackage("extension/extensions.cls") then do -- requires jlf sandbox ooRexx + .local~mm.dir~ooRexx.isExtended = .false + call loadPackage("extension/std/extensions-std.cls") -- works with standard ooRexx, but integration is weak + end + if .local~mm.dir~ooRexx.isExtended then do + call loadPackage("concurrency/coactivity.cls") + call loadPackage("pipeline/pipe_extension.cls") + call loadPackage("rgf_util2/rgf_util2_wrappers.rex") + .Coactivity~setMethod('onStart', .array~of(, + 'use strict arg coactivity;', + 'signal on syntax;', + 'call BsfAttachToTid .mm.dir~start.tid;', + 'coactivity~setMethod("onTerminate", "call BsfDetach");', + 'syntax:')) + end + + return + + +------------------------------------------------------------------------------- +-- Remember : don't implement that as a procedure or routine or method ! +loadPackage: + use strict arg filename + signal on syntax name loadPackageError + .context~package~loadPackage(filename) + say "loadPackage OK for" filename + return .true + loadPackageError: + say "loadPackage KO for" filename + return .false + + +------------------------------------------------------------------------------- +-- Remember : don't implement that as a procedure or routine or method ! +loadLibrary: + use strict arg filename + signal on syntax name loadLibraryError + if .context~package~loadLibrary(filename) then do + say "loadLibrary OK for" filename + return .true + end + loadLibraryError: + say "loadLibrary KO for" filename + return .false + + +------------------------------------------------------------------------------- + +--::options trace i + +/*Creates a dialog, providing some meta data and a link to the documentation .pdf.*/ +::class AboutDialog +::method actionPerformed + use arg , slotDir + + mainframe = .mm.dir~frame + adialog = .javax.swing.JDialog~new(mainframe, 'About') + adialog~setResizable(.false) + contentpane = adialog~getContentPane + gridbag = .java.awt.GridBagLayout~new + c = .java.awt.GridBagConstraints~new + contentpane~setLayout(gridbag) + verpanel = .javax.swing.JPanel~new + verpanel~~setBackground(.java.awt.Color~magenta)~~add(.javax.swing.JLabel~new("Version")) + version = .javax.swing.JPanel~new + version~add(.javax.swing.JLabel~new(.mm.dir~version)) + atpanel = .javax.swing.JPanel~new + atpanel~~setBackground(.java.awt.Color~magenta)~~add(.javax.swing.JLabel~new("Author")) + author = .javax.swing.JPanel~new + author~add(.javax.swing.JLabel~new("Markus Moldaschl")) + docpanel = .javax.swing.JPanel~new + docpanel~~setBackground(.java.awt.Color~magenta)~~add(.javax.swing.JLabel~new("Documentation")) + doc = .javax.swing.JPanel~new + docbutton = .javax.swing.JButton~new("PDF") + rexxDocEH = .Doc~new + rpDocEH = BsfCreateRexxProxy(rexxDocEH, slotDir~userData, .java.awt.event.ActionListener) + docbutton~addActionListener(rpDocEH) + doc~add(docbutton) + c~fill = .java.awt.GridBagConstraints~horizontal + c~weightx = 1.0 + c~gridwidth = .java.awt.GridBagConstraints~remainder + c~insets = .java.awt.Insets~new(2,3,0,3) + gridbag~setConstraints(verpanel, c) + gridbag~setConstraints(version, c) + gridbag~setConstraints(atpanel, c) + gridbag~setConstraints(author, c) + gridbag~setConstraints(docpanel, c) + gridbag~setConstraints(doc, c) + contentpane~~add(verpanel)~~add(version)~~add(atpanel)~~add(author)~~add(docpanel)~~add(doc) + adialog~pack + adialog~setBounds((mainframe~getX+mainframe~getWidth/3)~format(,0), (mainframe~getY+mainframe~getHeight/3)~format(,0), 200, 210) + adialog~~show~~tofront + + +/*Custom list cell renderer; renders the elements from the listmodel with seperate JTextAreas in a JList on the screen.*/ +::class CellRenderer +::method getListCellRendererComponent + use arg list, value, index, isSelected, cellHasFocus, slotDir + + listarea = .javax.swing.JTextArea~new + listarea~setFont(.java.awt.Font~new(.mm.dir~fontname, .java.awt.Font~plain, "12")) + listarea~setText(value~makeString) + listarea~setLineWrap(.true) + + if isSelected then + do + listarea~setBackground(listarea~getSelectionColor) + listarea~setForeground(.java.awt.Color~white) + slotDir~userData~restorebutton~setEnabled(.true) + end + laScrollPane = .javax.swing.JScrollPane~new(listarea, .javax.swing.JScrollPane~vertical_scrollbar_as_needed, .javax.swing.JScrollPane~horizontal_scrollbar_never) + return laScrollPane + + +/*Clear all text from appropriate input and output areas according to the menu item clicked on.*/ +::class ClearData +::method actionPerformed + use arg eventObject, slotDir + + argsCl = slotDir~userData~clearSubMenu~getItem(0) + codeCl = slotDir~userData~clearSubMenu~getItem(1) + saysCl = slotDir~userData~clearSubMenu~getItem(2) + returnsCl = slotDir~userData~clearSubMenu~getItem(3) + errorsCl = slotDir~userData~clearSubMenu~getItem(4) + historyCl = slotDir~userData~clearSubMenu~getItem(5) + allCl = slotDir~userData~clearSubMenu~getItem(6) + source = eventObject~getSource + + select + when source~equals(argsCl) then + .mm.dir~argsArea~setText('') + + when source~equals(codeCl) then + .mm.dir~codeArea~setText('') + + when source~equals(saysCl) then + .mm.dir~saysArea~setText('') + + when source~equals(returnsCl) then + .mm.dir~returnsArea~setText('') + + when source~equals(errorsCl) then + .mm.dir~errorsArea~setText('') + + when source~equals(historyCl) then + do + .mm.dir~storage~circq = .circularQueue~new(.mm.dir~historySize) + .mm.dir~listmodel~clear + end + + when source~equals(allCl) | source~equals(slotDir~userData~fileMenu~getItem(0)) then + do + .mm.dir~argsArea~setText('') + .mm.dir~codeArea~setText('') + .mm.dir~saysArea~setText('') + .mm.dir~returnsArea~setText('') + .mm.dir~errorsArea~setText('') + .mm.dir~storage~circq = .circularQueue~new(.mm.dir~historySize) + .mm.dir~listmodel~clear + end + otherwise + nop + end + + .mm.dir~codeArea~requestFocus + + +/*Copies certain data from the input and output areas to the system clipboard.*/ +::class CopyToClipboard +::method actionPerformed + use arg eventObject, slotDir + + argsCo = slotDir~userData~copySubMenu~getItem(0) + codeCo = slotDir~userData~copySubMenu~getItem(1) + saysCo = slotDir~userData~copySubMenu~getItem(2) + returnsCo = slotDir~userData~copySubMenu~getItem(3) + errorsCo = slotDir~userData~copySubMenu~getItem(4) + allCo = slotDir~userData~copySubMenu~getItem(5) + source = eventObject~getSource + codeArea = .mm.dir~codeArea + cursorpos = codeArea~getCaretPosition + + select + when source~equals(argsCo) then + do + cp_content = .mm.dir~argsArea~getText + cp_string = .java.awt.datatransfer.StringSelection~new(cp_content) + self~toClipboard(cp_string) + .local~mm.dir~imsg = 'Arguments Are On ClipBoard' + end + when source~equals(codeCo) then + do + cp_content = codeArea~getText + cp_string = .java.awt.datatransfer.StringSelection~new(cp_content) + self~toClipboard(cp_string) + .local~mm.dir~imsg = 'Code Is On ClipBoard' + end + when source~equals(saysCo) then + do + cp_content = .mm.dir~saysArea~getText + cp_string = .java.awt.datatransfer.StringSelection~new(cp_content) + self~toClipboard(cp_string) + .local~mm.dir~imsg = 'Says Are On ClipBoard' + end + when source~equals(returnsCo) then + do + cp_content = .mm.dir~returnsArea~getText + cp_string = .java.awt.datatransfer.StringSelection~new(cp_content) + self~toClipboard(cp_string) + .local~mm.dir~imsg = 'Returns Are On ClipBoard' + end + when source~equals(errorsCo) then + do + cp_content = .mm.dir~errorsArea~getText + cp_string = .java.awt.datatransfer.StringSelection~new(cp_content) + self~toClipboard(cp_string) + .local~mm.dir~imsg = 'Errors Are On ClipBoard' + end + when source~equals(allCo) then + do + allData = 'The Following Output Was Generated With ooRexxTry'.endOfLine||.endOfLine + cp_content = .mm.dir~argsArea~getText + allData = alldata||'Arguments'||.endOfLine||cp_content||.endOfLine||'-'~copies(20)||.endOfLine + + cp_content = codeArea~getText + allData = allData||'Code'||.endOfLine||cp_content||.endOfLine||'-'~copies(20)||.endOfLine + + cp_content = .mm.dir~saysArea~getText + allData = allData||'Says'||.endOfLine||cp_content||.endOfLine||'-'~copies(20)||.endOfLine + + cp_content = .mm.dir~returnsArea~getText + allData = allData||'Results'||.endOfLine||cp_content||.endOfLine||'-'~copies(20)||.endOfLine + + cp_content = .mm.dir~errorsArea~getText + allData = allData||'Errors/Information'||.endOfLine||cp_content||.endOfLine||'-'~copies(20)||.endOfLine + allData = .java.awt.datatransfer.StringSelection~new(allData) + self~toClipboard(allData) + .local~mm.dir~imsg = 'All Data Is On ClipBoard' + end + otherwise + nop + end + .mm.dir~errorsArea~setText(.mm.dir~imsg) + codeArea~requestFocus + +::method toClipboard + use arg data + + systemClip = .java.awt.Toolkit~getDefaultToolkit~getSystemClipboard + systemClip~setContents(data, .nil) + + +/*Create a server socket. While flagged for listening, start accepting client + connections and manage them in a separate thread.*/ +::class CreateServerSocket +::method run + newSocket=create_socket(.mm.dir~port) -- try to create a server socket + if newSocket=.nil then -- force abort + do + RAISE SYNTAX 40.900 array ("CreateServerSocket::run - cannot create the server socket") + end + + -- .mm.dir~srvSock = .bsf~new("java.net.ServerSocket", .mm.dir~port) + .mm.dir~srvSock = newSocket + .mm.dir~listening = .true + do while .mm.dir~listening = .true + runnableSocket = BsfCreateRexxProxy(.SocketConnection~new, ,.java.lang.Runnable) + .java.lang.Thread~new(runnableSocket)~~bsf.dispatch("start") + end + .mm.dir~srvSock~close + + + -- if the server port is not available, ask user for a different one, once! +::routine create_socket -- rgf, 2011-02-23 + parse arg port + + signal on syntax name syntax1 + return .bsf~new("java.net.ServerSocket", port) + +syntax1: -- port probably taken! + co1=condition('o') -- fetch condition object + signal on syntax name syntax2 + newPort=.bsf.dialog~inputBox( makeErrorText(co1) - + "Please enter a free port number to which the server socket should listen to (1024-65535)", - + "Problem: cannot create server socket on port" pp(port)"!", - + "error") + if newPort=.nil then return .nil + + if newPort<1024 | newPort>65535 then + do + res=.bsf.dialog~messageBox(pp(newPort)": is not in the range of '1024' to '65535', aborting!", - + "Invalid port number!", - + "error") + return .nil + end + .mm.dir~port=newPort + return .bsf~new("java.net.ServerSocket", newPort) + + +syntax2: + co2=condition('o') -- fetch condition object + res=.bsf.dialog~messageBox( makeErrorText(co2) , - -- show (Java-originated) error message + "Could not create server socket!", - + "error") + return .nil + +::routine makeErrorText + use arg co + lf="0a"x + tmp="" + do i over co~traceback + if tmp="" then tmp=i + else tmp=tmp lf || i + end + if tmp<>"" then tmp=tmp lf + tmp=tmp || "Error" co~rc co~errortext lf + tmp=tmp || "Error" co~code":" co~message lf + return tmp lf + + +::class DestinationSwitch + +/*Whenever settings in the the monitor option dialog gets approved the method configures the monitors according + to the choosen configuration.*/ +::method actionPerformed + expose source + use arg eventObject, slotDir + + mdialog = slotDir~userData~mdialog + + if eventObject~getSource~equals(slotDir~userData~monitorOkButton) then + do + incmd = slotDir~userData~ingroup~getSelection~getActionCommand + if incmd~equals("indefault") then + do + .input~destination(.mm.dir~guiInputStream) + .mm.dir~inputMonitorDestination = 'GUIInputStream' + end + else + do + -- Create a new stream to use a file as the primary source for input arguments + filename = slotDir~userData~infiletf~getText + .mm.dir~infilestream = .stream~new(filename) + .input~destination(.mm.dir~infilestream) + .mm.dir~inputMonitorDestination = filename + end + outcmd = slotDir~userData~outgroup~getSelection~getActionCommand + if outcmd~equals("outdefault") then + do + .output~destination(.mm.dir~guiOutputStream) + .mm.dir~outputMonitorDestination = 'GUIOutputStream' + end + else + do + -- Create a new stream to write output arguments to a file + filename = slotDir~userData~outfiletf~getText + if \filename~equals(slotDir~userData~errfiletf~getText) then .mm.dir~outfilestream = .stream~new(filename) + else + do + if .mm.dir~errfilestream = .nil then .mm.dir~outfilestream = .stream~new(filename) + else .mm.dir~outfilestream = .mm.dir~errfilestream + end + .output~destination(.mm.dir~outfilestream) + .mm.dir~outputMonitorDestination = filename + end + errcmd = slotDir~userData~errgroup~getSelection~getActionCommand + if errcmd~equals("errdefault") then + do + .error~destination(.mm.dir~guiErrorStream) + .mm.dir~errorMonitorDestination = 'GUIErrorStream' + end + else + do + -- Write error data to a file + filename = slotDir~userData~errfiletf~getText + if \filename~equals(slotDir~userData~errfiletf~getText) then .mm.dir~errfilestream = .stream~new(filename) + else + do + if .mm.dir~outfilestream = .nil then .mm.dir~errfilestream = .stream~new(filename) + else .mm.dir~errfilestream = .mm.dir~outfilestream + end + .error~destination(.m... [truncated message content] |