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-9874: BlackBerry: implement require() #96

Merged
merged 4 commits into from Jul 12, 2012

Conversation

dlifshitz-maca
Copy link

Reviewers: Alex, Harut

[Issues Fixed]
TIMOB-9874: BlackBerry: implement require()

[Changes]
NativeLoggerWorker.cpp
- add newline to message first so the stream doesn't split it up

TiRootObject.cpp
- function executeScript
  - use variables for the bootstrap and app filenames
  - pass the filenames to the calls to Compile()
  - add the javascript filename and line number to the log message
- implement function _require

TiTitaniumObject.cpp
- function _include
  - add the javascript filename and line number to the log message

[Tests]
Test 1: Build and run an app (using .js files from Jira)
1) Put the .js files in the Resources dir so they will get packaged
2) Build, package, and run the app
3) Verify the correct info is shown in the app
4) Close the app, get the log, and verify the "module being loaded!" message is only shown once

Test 2: Crash the app
1) Put an undeclared variable in app.js, a file being included, and a file being required
2) Run the app, verify it crashes, get the log, and verify the location of the problem is shown
3) Remove the offending variable
4) Repeat Steps 2-3 until all offending variables are gone and the app runs successfully

[Issues Fixed]
TIMOB-9874: BlackBerry: implement require()

[Changes]
NativeLoggerWorker.cpp
- add newline to message first so the stream doesn't split it up

TiRootObject.cpp
- function executeScript
  - use variables for the bootstrap and app filenames
  - pass the filenames to the calls to Compile()
  - add the javascript filename and line number to the log message
- implement function _require

TiTitaniumObject.cpp
- function _include
  - add the javascript filename and line number to the log message

[Tests]
Test 1: Build and run an app (using .js files from Jira)
1) Put the .js files in the Resources dir so they will get packaged
2) Build, package, and run the app
3) Verify the correct info is shown in the app
4) Close the app, get the log, and verify the "module being loaded!" message is only shown once

Test 2: Crash the app
1) Put an undeclared variable in app.js, a file being included, and a file being required
2) Run the app, verify it crashes, get the log, and verify the location of the problem is shown
3) Remove the offending variable
4) Repeat Steps 2-3 until all offending variables are gone and the app runs successfully
String::Utf8Value error(tryCatch.Exception());
TiLogger::getInstance().log(*error);
Local<Value> exception = tryCatch.Exception();
if (exception->IsString())

Choose a reason for hiding this comment

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

Is that something, that could happen? I don't think it could be string.

Copy link
Author

Choose a reason for hiding this comment

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

I put a FIXME to handle this better

@alexandergalstyan
Copy link

Are we able to load module with its ID? If not please add todo for that.

@alexandergalstyan
Copy link

Update apidoc, since it says NYI for BlackBerry

@alexandergalstyan
Copy link

Reviewed

@dlifshitz-maca
Copy link
Author

For the ID, isn't that just the filename without the ".js"? If not then that would be something we'd need to investigate more.

updated require() documentation
put module error string in central location
check if Message() is empty
replace exception->IsString() hack with FIXME
rename v8Id to be more representative
add space in include() error string
@dlifshitz-maca
Copy link
Author

Updated apidoc

@dlifshitz-maca
Copy link
Author

Updated patch

@alexandergalstyan
Copy link

For the ID I meant the native modules referenced with say com.macadamian.module1. Please add todo, so we can track it later.

@alexandergalstyan
Copy link

Approved with comment

@@ -180,7 +180,8 @@ methods:
require ('/myModule/module.js')

#### BlackBerry
NYI

Currently, only base paths are valid. Relative paths are NYI.
Copy link

Choose a reason for hiding this comment

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

Have you created a JIRA task to track that NYI stuff? I can't see it from the commit description.

@Harutyun
Copy link

Approved with comment

Conflicts:
	blackberry/tibb/TiMessageStrings.h
@dlifshitz-maca
Copy link
Author

@alexandergalstyan I've added a TODO
@Harutyun, @jpl-mac I'll be creating jiras

dlifshitz-maca added a commit that referenced this pull request Jul 12, 2012
TIMOB-9874: BlackBerry: implement require()

[Issues Fixed]
TIMOB-9874: BlackBerry: implement require()

[Changes]
NativeLoggerWorker.cpp
- add newline to message first so the stream doesn't split it up

TiRootObject.cpp
- function executeScript
  - use variables for the bootstrap and app filenames
  - pass the filenames to the calls to Compile()
  - add the javascript filename and line number to the log message
- implement function _require

TiTitaniumObject.cpp
- function _include
  - add the javascript filename and line number to the log message

[Tests]
Test 1: Build and run an app (using .js files from Jira)
1) Put the .js files in the Resources dir so they will get packaged
2) Build, package, and run the app
3) Verify the correct info is shown in the app
4) Close the app, get the log, and verify the "module being loaded!" message is only shown once

Test 2: Crash the app
1) Put an undeclared variable in app.js, a file being included, and a file being required
2) Run the app, verify it crashes, get the log, and verify the location of the problem is shown
3) Remove the offending variable
4) Repeat Steps 2-3 until all offending variables are gone and the app runs successfully
@dlifshitz-maca dlifshitz-maca merged commit c063ca4 into Macadamian:blackberry Jul 12, 2012
@dlifshitz-maca
Copy link
Author

Created Jiras:
https://jira.appcelerator.org/browse/TIMOB-9950 BlackBerry: Fix/implement relative include/require
https://jira.appcelerator.org/browse/TIMOB-9953 BlackBerry: Fix logging/exception tags and exception output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants