mozilla/webvtt — pull request #158 by RickEyre (2013-02-22 19:09:05+00:00)
Title: Rewrite node bindings.

Fixes issues #72, #80.

I've rewritten the node bindings as we've discussed. I've added in a
static const node that defines a safe empty node that we can use when
constructing default nodes. There is also a public webvtt_init_node
function that allows the Node bindings to access this functionality.
Finally, I've changed the webvtt_release_node function to set node to
0 once it has been deleted.

Fix node rewrite as per pull request discussion.

- Fixed webvtt_init_node to use a **node in order to have modifications be passed
back to the calling function.
- Changed the node bindings to throw std::out_of_range exception when trying to
retrieve from an index that is out of range.
- Changed webvtt_release_node to not check whether or not str->d exists becaused
webvtt_release_string will do this for us.
- Changed webvtt_ref_node to ensure that *node exists before attempting to
increase the ref count.

Update code based on discussion in pull request.

- Changed empty_node to have default ref count of 1
- Added in chceks for the getters in Node bindings in order to ensure that
it returns a safe and empty object if one does not exist in the c node.
- Wrapped some code in cue.c
- Changed the create node function to ensure that the node var passed in
is valid.

Rewrite plboldtag_unittest to use new bindings.

I've rewritten the plboldtag_unittest to use the new bindings in order to
see if this is the way we want to do this before we go through all of them
and rewrite. I've added some functions in the c library and on the String
binding class in order to help figure out whether or not a string is in an
empty state.

Rewrote payload unit tests to use new bindings.

I've changed all the syntax over of the payload unit tests to use
the new Node bindings. I've also added const qualifiers on the node
getters such as timeStamp(), text(), etc. I also added const qualifiers
on the String binding function isEmpty() and to the string.c function
webvtt_string_is_empty.

Convert ASSERT_TRUEs to ASSERT_EQs when checking lengths.

I've converted the ASSERT_TRUE( xLength == n ) to ASSERT_EQ( xLength, n )
in the payload unit tests as per Caitlin's request.

Reverse order of expected and actual in payload unit test asserts.