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-10161: BlackBerry: Implement Ti.Buffer for Anvil [Partial implementation] #125

Merged

Conversation

alexandergalstyan
Copy link

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();

…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];

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.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@dlifshitz-maca
Copy link

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();
@alexandergalstyan
Copy link
Author

Updated.

const static TiProperty g_tiProperties[] =
{
{
"byteOrder", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE, N_BUFFER_PROP_BYTEORDER

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)

Copy link
Author

Choose a reason for hiding this comment

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

Updated.

@dlifshitz-maca
Copy link

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.
@alexandergalstyan
Copy link
Author

Updated.

// Fills the entire byte array
internalData_.fill(fillByte);
}
else

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

Copy link
Author

Choose a reason for hiding this comment

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

Done

@dlifshitz-maca
Copy link

Reviewed.
The app.js you added to the jira has some wrong expected output but the actual output seems correct. I didn't do more testing on the functions that are out of scope.

…mentation part4]

Reviewers: DavidL

Changelog:
- Address comments.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
@alexandergalstyan
Copy link
Author

Updated


int NativeBufferObject::copy(NativeBufferObject* sourceBuffer, int offset, int sourceOffset, int sourceLength)
{
if (offset >= internalData_.size() - 1)

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 >.

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

Copy link
Author

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.
@alexandergalstyan
Copy link
Author

Updated

@dlifshitz-maca
Copy link

Approved

alexandergalstyan added a commit that referenced this pull request Aug 9, 2012
TIMOB-10161: BlackBerry: Implement Ti.Buffer for Anvil [Partial implementation]
@alexandergalstyan alexandergalstyan merged commit c67eaf7 into Macadamian:blackberry Aug 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants