Package ptolemy.moml.filter
Class JavaScriptThisUpdate
- java.lang.Object
-
- ptolemy.moml.filter.MoMLFilterSimple
-
- ptolemy.moml.filter.JavaScriptThisUpdate
-
- All Implemented Interfaces:
MoMLFilter
public class JavaScriptThisUpdate extends MoMLFilterSimple
Add "this." to certain places in the script parameter of a JavaScript actor.This class will eventually be removed after we have updated the files.
To update a model, try:
$PTII/bin/ptinvoke ptolemy.vergil.basic.imprt.accessor.ReloadAccessors model.xml
To update all the models that contain JavaScript actors:# Generate a list of all the text files in the ptII tree, excluding certain directories like vendors. $PTII/adm/bin/ptIItxtfiles <& /tmp/f # Generate a list of all of the .xml files. cat /tmp/f | egrep '.xml$' < /tmp/x # Generate a list of all the .xml files that contain the JavaScript actor. cat /tmp/x | xargs egrep 'ptolemy.actor.lib.jjs.JavaScript' | awk -F ':' '{print $1}' | sort | uniq < /tmp/javascriptx # Reload the accessors on all the .xml files that contain the JavaScript actor, # which as a side effect runs the Backward Compatibility script cat /tmp/jsaccessorx | xargs $PTII/bin/ptinvoke ptolemy.vergil.basic.imprt.accessor.ReloadAccessors
We use
ptinvoke
to set the classpath.ReloadAccessors, opens a model, reloads all the accessors (if any) and saves the model. While opening the model, the BackwardCompatibility MoML filters are run. This class can be one of those filters.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.reflect.Method
_diff
The ptolemy.util.test.Diff.diff(String, String) method.
-
Constructor Summary
Constructors Constructor Description JavaScriptThisUpdate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
Handle parameter name changes.void
filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile)
If the container is a property named "script" contained by the JavaScript actor, then add "this." to certain function calls.java.lang.String
toString()
Return a string that describes what the filter does.-
Methods inherited from class ptolemy.moml.filter.MoMLFilterSimple
filterAttributeValue, filterEndElement
-
-
-
-
Method Detail
-
filterAttributeValue
public java.lang.String filterAttributeValue(NamedObj container, java.lang.String element, java.lang.String attributeName, java.lang.String attributeValue, java.lang.String xmlFile)
Handle parameter name changes.- Parameters:
container
- The container for XML element.element
- The XML element name.attributeName
- The name of the attribute.attributeValue
- The value of the attribute.xmlFile
- The file currently being parsed.- Returns:
- A new value for the attribute, or the same value to leave it unchanged, or null to cause the current element to be ignored (unless the attributeValue argument is null).
-
filterEndElement
public void filterEndElement(NamedObj container, java.lang.String elementName, java.lang.StringBuffer currentCharData, java.lang.String xmlFile) throws java.lang.Exception
If the container is a property named "script" contained by the JavaScript actor, then add "this." to certain function calls.- Parameters:
container
- The object defined by the element that this is the end of.elementName
- The element name.currentCharData
- The character data, which appears only in the doc and configure elementsxmlFile
- The file currently being parsed.- Throws:
java.lang.Exception
- if there is a problem substituting in the new value.
-
toString
public java.lang.String toString()
Return a string that describes what the filter does.- Specified by:
toString
in interfaceMoMLFilter
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A description of the filter (ending with a newline).
-
-