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-9390: Blackberry: implement rest of String.formatXXX methods (other than format) #76
TIMOB-9390: Blackberry: implement rest of String.formatXXX methods (other than format) #76
Conversation
…88' into formatReview #Some more info....
…rry' into formatReview #Some more info....
Reviewers: DavidC, JP ChangeLog: - Implement decode/encode URIComponent Test Cases: - Using sample tibbtest project create var with the value of: 'http://www.example.com/List%20of%20holidays.xml' - Use decodeURIComponent to decode the uri. - Make sure it decodes successfully. - Using sample tibbtest project create var with the value of: 'http://www.example.com/List of holidays.xml' - Use encodeURIComponent to encode the uri. - Make sure it encodes successfully.
…ther than format) Reviewers: HarutM, JP ChangeLog: - Added new TiDateObject class. - Added new message constants. - Implemented formatDate, formatTime, formatCurrency, formatDecimal methods Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. NOTE: locale & pattern not yet implemented for formatDecimal
Can you be more explicit on the test cases? If i were to try and run these tests on my own, i wouldn't know what to do or look for. what's a "var with value of Date"? The value behind the Tests section in the patch description is so a QA or someone else with no knowledge of the patch can look at the tests and run them. |
DATE_FORMAT_LONG, | ||
DATE_FORMAT_MEDIUM, | ||
DATE_FORMAT_SHORT | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
apidoc needs to be updated |
|
||
Local<Object> obj = Object::Cast(*value); | ||
// Get year property | ||
Local<Value> getYear_prop = (Object::Cast(*value)->Get(String::New("getFullYear"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just use obj instead of casting *value everytime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Reviewed |
@@ -0,0 +1,9 @@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this cpp file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the constants need to be defined in a cpp.
it's macro dark magic :)
…ther than format) ver2 ChangeLog: - Address comments. - Update String.yml apidoc. - Change the QDateTime to QTime for formatTime method. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. NOTE: locale & pattern not yet implemented for formatDecimal NOTE: test snippet available at discussion page.
Updated. Added test cases snippets |
Reviewed |
Conflicts: blackberry/tibb/TiRootObject.cpp
…rry' into formatBranch #Some more info....
…ther than format) ver3 Reviewers: HarutM, JP Review the 99130f8 ChangeLog: - Remove TiDateObject class. - Address comments. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language.
Updated behalf on #82 |
Now that you also have the patch for built-in JS keywords, it would be good to validate the use of StringObjects and then remove the TODOs |
…rry' into formatBranch #Some more info....
…89' into formatBranch Conflicts: blackberry/tibb/TiRootObject.cpp blackberry/tibb/TiStringObject.cpp
// Try to parse optional format argument | ||
if (args.Length() > 1 && (args[1]->IsString() || args[1]->IsStringObject())) | ||
{ | ||
const String::Utf8Value utf8(args[1]->ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually some care is needed around using ToString().
So we want to convert non string litteral (IsString() == true) args using ToString() when a string is expected, but we don't want to call ToString on strings.
This is the behaviour that we see from the chrome js console. So far i've had ToString() return a null pointer on string literals so that stopped me from using ToString on all args. If it works for you though you could do that.
This comment also applies to the other use further down
if (args.Length() > 1) | ||
{ | ||
Local<Value> format = args[1]; | ||
if (!(format->IsString() || format->IsStringObject())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition only needs to check for IsString. The ToString() methods should be applied to StringObjects also. This is how JS behaves in Chrome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Rereviewed |
…rry' into formatBranch Conflicts: blackberry/tibbtest/app.js
…ther than format) ver3 Reviewers: HarutM, JP Review the 99130f8 ChangeLog: - Remove TiDateObject class. - Address comments. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language.
Updated. |
static QString formatString(QString s, Local<Value> arg); | ||
static QString formatPointer(QString s, Local<Value> arg); | ||
|
||
// Helper function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prototypes above is for helper functions, this one can be bunched with the others at merge time
Approved with trivial comment, can be done at merge time I don't think Harut has approved yet. Also this PR needs to wait for #84 to be merged first. |
Approved |
…rry' into formatBranch Conflicts: blackberry/tibb/NativeStringInterface.cpp blackberry/tibb/TiMessageStrings.h blackberry/tibb/TiRootObject.cpp
…ther than format) ver4 Reviewers: HarutM, JP ChangeLog: - Address comments. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. NOTE: locale & pattern not yet implemented for formatDecimal Test snippet from app.js: // // create root window // var win1 = Titanium.UI.createWindow({ backgroundColor:'#F00' }); var date = new Date(); var format = String.formatDate(date, 'short'); //var date = new Date(); //var format = String.formatDate(date, 'medium'); //var date = new Date(); //var format = String.formatDate(date, 'long'); //var date = new Date(); //var format = String.formatTime(date, 'short'); //var date = new Date(); //var format = String.formatTime(date, 'medium'); //var date = new Date(); //var format = String.formatTime(date, 'long'); var label1 = Ti.UI.createLabel({ textAlign : 'center', text:'Hello, world!', color:'green', top: 200 }); label1.text = format; win1.add(label1); // open window win1.open();
@@ -22,6 +22,7 @@ | |||
{ | |||
|
|||
N_MESSAGESTRINGS_CONST_DEF(char*, An_error_occurred_converting_to_int, "An error occurred converting to int"); | |||
N_MESSAGESTRINGS_CONST_DEF(char*, Expected_argument_of_type_date, "Expected argument of type date"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivial: Date type in js is with a capital D so the message should reflect that, can be done at merge time
…rry' into formatBranch #Some more info....
…ther than format) Reviewers: HarutM, JP ChangeLog: - Move the date conversion logics into the NativeControlObject. - Address comments. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. NOTE: locale & pattern not yet implemented for formatDecimal Test snippet from app.js: // // create root window // var win1 = Titanium.UI.createWindow({ backgroundColor:'#F00' }); var date = new Date(); var format = String.formatDate(date, 'short'); //var date = new Date(); //var format = String.formatDate(date, 'medium'); //var date = new Date(); //var format = String.formatDate(date, 'long'); //var date = new Date(); //var format = String.formatTime(date, 'short'); //var date = new Date(); //var format = String.formatTime(date, 'medium'); //var date = new Date(); //var format = String.formatTime(date, 'long'); var label1 = Ti.UI.createLabel({ textAlign : 'center', text:'Hello, world!', color:'green', top: 200 }); label1.text = format; win1.add(label1); // open window win1.open();
Updated. |
@@ -7,7 +7,7 @@ | |||
|
|||
#include "NativeDateTimePickerObject.h" | |||
|
|||
#include "ConversionHelper.h" | |||
#include "NativeControlObject.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be necessary as it's already a parent class of NDTP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
…rry' into formatBranch Conflicts: blackberry/tibb/NativeControlObject.cpp
…ther than format) ver6 Reviewers: HarutM, JP ChangeLog: - Address comments. - Remove ConversionHelper class. Test Cases: - Using sample tibbtest project create var with the value of Date - Use formatDate(date, [format]), formatTime(date, [format]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatCurrency(number) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. - Create var with number value. - Use formatDecimal(number, [locale], [pattern]) in app.js - Make sure string correctly formatted. - Try the same with previously changed language. NOTE: locale & pattern not yet implemented for formatDecimal Test snippet from app.js: // // create root window // var win1 = Titanium.UI.createWindow({ backgroundColor:'#F00' }); var date = new Date(); var format = String.formatDate(date, 'short'); //var date = new Date(); //var format = String.formatDate(date, 'medium'); //var date = new Date(); //var format = String.formatDate(date, 'long'); //var date = new Date(); //var format = String.formatTime(date, 'short'); //var date = new Date(); //var format = String.formatTime(date, 'medium'); //var date = new Date(); //var format = String.formatTime(date, 'long'); var label1 = Ti.UI.createLabel({ textAlign : 'center', text:'Hello, world!', color:'green', top: 200 }); label1.text = format; win1.add(label1); // open window win1.open();
Updated |
Approved with comment |
Approved |
TIMOB-9390: Blackberry: implement rest of String.formatXXX methods (other than format)
Reviewers: HarutM, JP
Review the 99130f8
ChangeLog:
Test Cases:
NOTE: locale & pattern not yet implemented for formatDecimal
Test snippet from app.js:
//
// create root window
//
var win1 = Titanium.UI.createWindow({
backgroundColor:'#F00'
});
var date = new Date();
var format = String.formatDate(date, 'short');
//var date = new Date();
//var format = String.formatDate(date, 'medium');
//var date = new Date();
//var format = String.formatDate(date, 'long');
//var date = new Date();
//var format = String.formatTime(date, 'short');
//var date = new Date();
//var format = String.formatTime(date, 'medium');
//var date = new Date();
//var format = String.formatTime(date, 'long');
var label1 = Ti.UI.createLabel({
textAlign : 'center',
text:'Hello, world!',
color:'green',
top: 200
});
label1.text = format;
win1.add(label1);
// open window
win1.open();