Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
ofbiz-rhino
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d2ec9a6d
authored
2014-04-16 10:44:27 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Move load/print into a separate, static Interface class.
1 parent
3f9fa324
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
src/com/brainfood/rhino/Require.java
src/com/brainfood/rhino/Require.java
View file @
d2ec9a6
...
...
@@ -89,7 +89,7 @@ public class Require {
public
Function
run
(
Context
cx
,
RhinoContainer
<?>
container
)
throws
FileNotFoundException
,
IOException
{
container
.
configureTopScriptable
(
cx
,
this
);
defineFunctionProperties
(
new
String
[]
{
"load"
,
"print"
},
Loader
.
class
,
ScriptableObject
.
DONTENUM
);
defineFunctionProperties
(
new
String
[]
{
"load"
,
"print"
},
Interface
.
class
,
ScriptableObject
.
DONTENUM
);
Scriptable
argsObj
=
cx
.
newArray
(
this
,
new
Object
[]
{});
defineProperty
(
"arguments"
,
argsObj
,
ScriptableObject
.
DONTENUM
);
...
...
@@ -101,21 +101,29 @@ public class Require {
return
(
Function
)
cx
.
evaluateString
(
this
,
"require"
,
null
,
-
1
,
null
);
}
public
static
void
print
(
Context
cx
,
Scriptable
thisObj
,
Object
[]
args
,
Function
funObj
)
{
Loader
loader
=
(
Loader
)
getTopLevelScope
(
thisObj
);
loader
.
container
.
print
(
cx
,
thisObj
,
args
,
funObj
);
public
void
print
(
Context
cx
,
Object
[]
args
,
Function
funObj
)
{
container
.
print
(
cx
,
this
,
args
,
funObj
);
}
public
static
void
load
(
Context
cx
,
Scriptable
thisObj
,
Object
[]
args
,
Function
funObj
)
throws
FileNotFoundException
,
IOException
{
Loader
loader
=
(
Loader
)
getTopLevelScope
(
thisObj
);
public
void
load
(
Context
cx
,
Object
[]
args
,
Function
funObj
)
throws
FileNotFoundException
,
IOException
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
String
path
=
Context
.
toString
(
args
[
i
]);
if
(
path
.
endsWith
(
"/jquery.js"
))
{
loader
.
container
.
print
(
cx
,
thisObj
,
new
Object
[]
{
"Skipping file "
+
path
},
funObj
);
container
.
print
(
cx
,
this
,
new
Object
[]
{
"Skipping file "
+
path
},
funObj
);
continue
;
}
loader
.
container
.
print
(
cx
,
thisObj
,
new
Object
[]
{
"Loading file "
+
path
},
funObj
);
loader
.
container
.
processSource
(
cx
,
thisObj
,
path
);
container
.
print
(
cx
,
this
,
new
Object
[]
{
"Loading file "
+
path
},
funObj
);
container
.
processSource
(
cx
,
this
,
path
);
}
}
public
static
final
class
Interface
{
public
static
void
load
(
Context
cx
,
Scriptable
thisObj
,
Object
[]
args
,
Function
funObj
)
throws
FileNotFoundException
,
IOException
{
((
Loader
)
getTopLevelScope
(
thisObj
)).
load
(
cx
,
args
,
funObj
);
}
public
static
void
print
(
Context
cx
,
Scriptable
thisObj
,
Object
[]
args
,
Function
funObj
)
{
((
Loader
)
getTopLevelScope
(
thisObj
)).
print
(
cx
,
args
,
funObj
);
}
}
}
...
...
Please
register
or
sign in
to post a comment