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-10161: BlackBerry: Implement Ti.Buffer for Anvil [Partial implementation] #125
TIMOB-10161: BlackBerry: Implement Ti.Buffer for Anvil [Partial implementation] #125
Conversation
…mentation] Reviewers: DavidL Changelog: - Added NativeBufferObject class to represent Buffer natively. - Added TiBufferObject class to represent the v8 object. - Added properties byteOrder, length, type, value. - Added Ti.Buffer methods. - Implemented clear() method, length, value (partially) properties for Ti.Buffer. Test cases: - Use the following snippet to test current functionality. - Make the buffer length changed after the clear() method called. var win1 = Titanium.UI.createWindow({ backgroundColor:'#F00' }); var buffer = Ti.createBuffer({ value: "hello world" }); Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++'); buffer.clear(); Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++'); win1.open();
public: | ||
SetGetProperties(const NATIVE_PROPSETGET_SETTING* map, int mapEntries) | ||
{ | ||
setters_ = new NATIVE_PROPSETGET_CALLBACK[N_PROP_LAST]; |
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.
Why N_PROP_LAST
? Seems like it should be N_BUFFER_PROP_LAST
. Same with the rest of them.
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.
Fixed
Reviewed. |
…mentation part2] Reviewers: DavidL Changelog: - Added TiCodecObject class. - Updated apidoc. - Address comments. - Fix unused variables warnings. - Implement fill(), toString() methods, byteOrder property. - Added prototypes for TiCodeObject methods. Test cases: - Use the following snippets to test current functionality. - Make the buffer length changed after the clear() method called. var win1 = Titanium.UI.createWindow({ backgroundColor:'#F00' }); var buffer = Ti.createBuffer({length:9, value:110000011}); Ti.API.info('Before: ' + buffer.toString()); buffer.fill(6, 2, 5); Ti.API.info('After: ' + buffer.toString()); //var buffer = Ti.createBuffer({ value: "hello world" }); //Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++'); //buffer.clear(); //Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++'); win1.open();
Updated. |
const static TiProperty g_tiProperties[] = | ||
{ | ||
{ | ||
"byteOrder", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE, N_BUFFER_PROP_BYTEORDER |
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 set this value (creation only)
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 |
…mentation part3] Reviewers: DavidL Changelog: - Updated apidoc. - Address comments. - Implement copy(), append(), insert(), clone() methods. Test cases: - Use the snippets attached to JIRA to test current functionality.
Updated. |
// Fills the entire byte array | ||
internalData_.fill(fillByte); | ||
} | ||
else |
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.
need to check if length is >= 0 (maybe even do nothing if length == 0, depends what Qt supports) and offset needs to be >= 0 and < size, unless it's supposed to grow if offset >= size
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.
Done
Reviewed. |
…mentation part4] Reviewers: DavidL Changelog: - Address comments. Test cases: - Use the snippets attached to JIRA to test current functionality.
Updated |
|
||
int NativeBufferObject::copy(NativeBufferObject* sourceBuffer, int offset, int sourceOffset, int sourceLength) | ||
{ | ||
if (offset >= internalData_.size() - 1) |
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.
internalData_.size() - 1
is a valid offset (ie the last character). Either take out the -1
or change the >=
to >
.
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.
Also need to throw an exception if offset < 0
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.
Done
…mentation part5] Reviewers: DavidL Changelog: - Address comments. Test cases: - Use the snippets attached to JIRA to test current functionality.
Updated |
Approved |
TIMOB-10161: BlackBerry: Implement Ti.Buffer for Anvil [Partial implementation]
Reviewers: DavidL
Changelog:
Test cases:
var win1 = Titanium.UI.createWindow({
backgroundColor:'#F00'
});
var buffer = Ti.createBuffer({ value: "hello world" });
Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++');
buffer.clear();
Ti.API.info('+++++++++++++++++++++++++' + buffer.length + '+++++++++++++++++++++++++');
win1.open();