From: <ha...@us...> - 2014-02-08 20:21:18
|
Revision: 19295 http://sourceforge.net/p/jmol/code/19295 Author: hansonr Date: 2014-02-08 20:21:15 +0000 (Sat, 08 Feb 2014) Log Message: ----------- Modified Paths: -------------- trunk/Jmol/src/org/jmol/script/SV.java Modified: trunk/Jmol/src/org/jmol/script/SV.java =================================================================== --- trunk/Jmol/src/org/jmol/script/SV.java 2014-02-08 20:18:49 UTC (rev 19294) +++ trunk/Jmol/src/org/jmol/script/SV.java 2014-02-08 20:21:15 UTC (rev 19295) @@ -102,6 +102,40 @@ return sv; } + /** + * + * Creates a NEW version of the variable. + * Object values are not copied. (Just found no + * use for that.) + * + * + * @param v + * @return new ScriptVariable + */ + SV setv(SV v) { + index = v.index; + intValue = v.intValue; + tok = v.tok; + value = v.value; +// never necessary: +// if (asCopy) { +// switch (tok) { +// case hash: +// value = new Hashtable<String, SV>( +// (Map<String, SV>) v.value); +// break; +// case varray: +// List<SV> o2 = new List<SV>(); +// List<SV> o1 = v.getList(); +// for (int i = 0; i < o1.size(); i++) +// o2.addLast(o1.get(i)); +// value = o2; +// break; +// } +// } + return this; + } + @SuppressWarnings("unchecked") static int sizeOf(T x) { switch (x == null ? nada : x.tok) { @@ -358,44 +392,6 @@ return newV(varray, objects); } - @SuppressWarnings("unchecked") - /** - * - * @j2sOverride - * - * creates a NEW version of the variable - * - * - * @param v - * @param asCopy create a new set of object pointers - * for an array; copies an associative array - * @return new ScriptVariable - */ - SV setv(SV v, boolean asCopy) { - // note: bitset, point3f ,point4f will not be copied - // because they are essentially immutable here - index = v.index; - intValue = v.intValue; - tok = v.tok; - value = v.value; - if (asCopy) { - switch (tok) { - case hash: - value = new Hashtable<String, SV>( - (Map<String, SV>) v.value); - break; - case varray: - List<SV> o2 = new List<SV>(); - List<SV> o1 = v.getList(); - for (int i = 0; i < o1.size(); i++) - o2.addLast(o1.get(i)); - value = o2; - break; - } - } - return this; - } - public SV setName(String name) { this.myName = name; flags |= FLAG_CANINCREMENT; @@ -1260,7 +1256,8 @@ /** * - * Script variables are pushed without any copying, as + * Script variables are pushed after cloning, because + * the name comes with them when we do otherwise * they are not mutable anyway. We do want to have actual * references to points, lists, and associative arrays * @@ -1272,7 +1269,7 @@ List<SV> x = getList(); if (o == null || x == null) return (x == null || x.size() == 0 ? newS("") : x.remove(x.size() - 1)); - x.addLast(o); + x.addLast(newI(0).setv(o)); return this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |