Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-5123 Use Rhino native require() CommonJS implementation #493

Merged
merged 12 commits into from Sep 28, 2011
Merged

TIMOB-5123 Use Rhino native require() CommonJS implementation #493

merged 12 commits into from Sep 28, 2011

Conversation

billdawson
Copy link
Contributor

http://jira.appcelerator.org/browse/TIMOB-5123

Please process also this rhino_titanium pull request:

https://github.com/appcelerator/rhino_titanium/pull/4

To test, simply try the app Kevin mentions in the JIRA item. You should test it both in non-production mode (i.e., just launching to emulator from inside Titanium Studio), to make sure I didn't break anything. Then test in production mode (Distribute - Android in Titanium Studio), which is the mode that wasn't working, to make sure i fixed it.

tiScript.scope = scope;
if (scriptClass != null) {
@SuppressWarnings("unchecked")
Class<NativeFunction> scriptClaxx = (Class<NativeFunction>) scriptClass;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the NativeFunction specialization (and @SuppressWarnings) necessary here? you're casting directly to Script on the line below

@ayeung
Copy link
Contributor

ayeung commented Sep 27, 2011

Code review and functional test Accepted

… TiScriptRunner, make KrollContext implement ModuleScriptProvider rather than making an anonymous instance of it, to save from putting one more class into the dex.
@billdawson
Copy link
Contributor Author

updated based on feedback. Allen will need to re-func test.

@billdawson
Copy link
Contributor Author

Sorry, wait to re-review, I haven't addressed the return value issue yet. Will tomorrow.

…f the call to Rhino require indeed returns an object. Else just return what it gives back.
@billdawson
Copy link
Contributor Author

Ready for re-review. Sorry, Allen, but my changes were significant so you'll need to re-test. :)


Scriptable exports = (Scriptable) result;
// CommonJS modules export all functions/properties as
// CommonJS modules export all functions/properties as
// properties of the special exports object provided
for (Object key : exports.getIds()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is overkill -- is there anything wrong with just returning the exports object as is? It's already an object that was created just for the module

@billdawson
Copy link
Contributor Author

Ready for re-review.

@marshall
Copy link
Contributor

Code review accepted

try {
br = new BufferedReader(new InputStreamReader(file.getInputStream()), 4000);
script = context.compileReader(br, uri, 1, null);
br.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could close br in a finally statement to ensure it gets closed if an exception occurs.

@ayeung
Copy link
Contributor

ayeung commented Sep 27, 2011

Code review and functional test Accepted (see minor comment above)

marshall added a commit that referenced this pull request Sep 28, 2011
TIMOB-5123 Use Rhino native require() CommonJS implementation
@marshall marshall merged commit 19190ee into tidev:master Sep 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants