PageRenderTime 45ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/bsh/commands/setNameSpace.bsh

#
Unknown | 43 lines | 34 code | 9 blank | 0 comment | 0 complexity | fd12178b1694a135d3b55525d9d6738a MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /**
  2. Set the namespace (context) of the current scope.
  3. <p/>
  4. The following example illustrates swapping the current namespace.
  5. <p/>
  6. <pre>
  7. fooState = object();
  8. barState = object();
  9. print(this.namespace);
  10. setNameSpace(fooState.namespace);
  11. print(this.namespace);
  12. a=5;
  13. setNameSpace(barState.namespace);
  14. print(this.namespace);
  15. a=6;
  16. setNameSpace(fooState.namespace);
  17. print(this.namespace);
  18. print(a); // 5
  19. setNameSpace(barState.namespace);
  20. print(this.namespace);
  21. print(a); // 6
  22. </pre>
  23. <p/>
  24. You could use this to creates the effect of a static namespace for a
  25. method by explicitly setting the namespace upon entry.
  26. <p/>
  27. */
  28. bsh.help.setNameSpace =
  29. "usage: setNameSpace( bsh.NameSpace )";
  30. setNameSpace( ns )
  31. {
  32. // Set the namespace at depth one (our caller) to the specified namespace.
  33. this.callstack.set( 1, ns );
  34. }