PageRenderTime 78ms CodeModel.GetById 75ms app.highlight 1ms RepoModel.GetById 1ms 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
 1/**
 2	Set the namespace (context) of the current scope.
 3	<p/>
 4
 5	The following example illustrates swapping the current namespace.
 6	<p/>
 7
 8	<pre>
 9    fooState = object(); 
10    barState = object(); 
11    
12    print(this.namespace);
13    setNameSpace(fooState.namespace);
14    print(this.namespace);
15    a=5;
16    setNameSpace(barState.namespace);
17    print(this.namespace);
18    a=6;
19    
20    setNameSpace(fooState.namespace);
21    print(this.namespace);
22    print(a);  // 5
23    
24    setNameSpace(barState.namespace);
25    print(this.namespace);
26    print(a); // 6
27    </pre>
28	<p/>
29
30	You could use this to creates the effect of a static namespace for a
31	method by explicitly setting the namespace upon entry.
32	<p/>
33*/
34
35bsh.help.setNameSpace =
36	"usage: setNameSpace( bsh.NameSpace )";
37
38setNameSpace( ns ) 
39{
40	// Set the namespace at depth one (our caller) to the specified namespace.
41	this.callstack.set( 1, ns );
42}
43