PageRenderTime 38ms CodeModel.GetById 35ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Unknown | 45 lines | 34 code | 11 blank | 0 comment | 0 complexity | 329e9b2f835212d6be43dff2c0d9c653 MD5 | raw file
 1/**
 2
 3	Set the namespace (context) of the current scope.
 4	<p/>
 5
 6The following example illustrates swapping the current namespace.
 7<p/>
 8
 9<pre>
10fooState = object(); 
11barState = object(); 
12
13print(this.namespace);
14setNameSpace(fooState.namespace);
15print(this.namespace);
16a=5;
17setNameSpace(barState.namespace);
18print(this.namespace);
19a=6;
20
21setNameSpace(fooState.namespace);
22print(this.namespace);
23print(a);  // 5
24
25setNameSpace(barState.namespace);
26print(this.namespace);
27print(a); // 6
28</pre>
29<p/>
30
31You could use this to creats the effect of a static namespace for a
32method by explicitly setting the namespace upon entry.
33<p/>
34
35*/
36
37bsh.help.setNameSpace =
38	"usage: setNameSpace( bsh.NameSpace )";
39
40setNameSpace( ns ) 
41{
42	// Set the namespace at depth one (our caller) to the specified namespace.
43	this.callstack.set( 1, ns );
44}
45