Skip to content

Convert all locals and parameter names to snake_case #193

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Mar 23, 2017

Conversation

boingoing
Copy link

Standardize some parameter names across the N-API surface such as napi_env env and size_t length. Make all the parameter names in the header match the cc file and expand some parameter names from single characters into meaningful words.

Also addresses a couple of minor PR feedback items:

  • Rename napi_reference_addref and napi_reference_release to napi_reference_ref and napi_reference_unref (respectively)
  • Rename Reference::AddRef and Reference::Release to Reference::Ref and Reference::Unref (respectively)
  • Remove napi_create_boolean, napi_get_true, and napi_get_false and replace them with napi_get_boolean
  • Rename napi_get_type_of_value to napi_typeof
  • Add a result_data out parameter to napi_create_buffer_copy which returns the data pointer of the new buffer
  • Change napi_get_value_string_utf8 and napi_get_value_string_utf16 to accept a null output buffer and return the length of the source string in that case via the result parameter
  • Remove napi_get_value_string_utf8_length and napi_get_value_string_utf16_length due to the above
  • Change Reference ctor and dtor to be protected and added public static Reference* Reference::New and static void Reference::Delete methods to make it more clear how the Reference objects are allocated and cleaned-up
  • Add a type check to napi_get_array_length which returns an error if the argument is not an array object
  • Change napi_create_symbol to take a napi_value instead of a const char* for the symbol description string. The API now throws if description is not a string but NULL is allowed.

Addresses #189 and #188 and some feedback in nodejs/node#11975.

Standardize some parameter names across the N-API surface such as ```napi_env env``` and ```size_t length```. Make all the parameter names in the header match the cc file and expand some parameter names from single characters into meaningful words.

Also addresses a couple of minor PR feedback items:
 - Rename ```napi_reference_addref``` and ```napi_reference_release``` to ```napi_reference_ref``` and ```napi_reference_unref``` (respectively)
 - Rename ```Reference::AddRef``` and ```Reference::Release``` to ```Reference::Ref``` and ```Reference::Unref``` (respectively)
 - Remove ```napi_create_boolean```, ```napi_get_true```, and ```napi_get_false``` and replace them with ```napi_get_boolean```
 - Rename ```napi_get_type_of_value``` to ```napi_typeof```
 - Add a ```result_data``` out parameter to ```napi_create_buffer_copy``` which returns the data pointer of the new buffer
 - Change ```napi_get_value_string_utf8``` and ```napi_get_value_string_utf16``` to accept a null output buffer and return the length of the source string in that case via the ```result``` parameter
 - Remove ```napi_get_value_string_utf8_length``` and ```napi_get_value_string_utf16_length``` due to the above
 - Change ```Reference``` ctor and dtor to be protected and added public ```static Reference* Reference::New``` and ```static void Reference::Delete``` methods to make it more clear how the ```Reference``` objects are allocated and cleaned-up
 - Add a type check to ``napi_get_array_length``` which returns an error if the argument is not an array object
 - Change ```napi_create_symbol``` to take a ```napi_value``` instead of a ```const char*``` for the symbol description string. The API now throws if description is not a string but NULL is allowed.
@jasongin
Copy link
Member

Change napi_get_value_string_utf8 and napi_get_value_string_utf16 to accept a null output buffer and return the length of the source string in that case via the result parameter
Remove napi_get_value_string_utf8_length and napi_get_value_string_utf16_length due to the above

The latin1 string API PR will need these changes (whichever PR goes second).

jasongin

This comment was marked as off-topic.

jasongin

This comment was marked as off-topic.

jasongin

This comment was marked as off-topic.

jasongin

This comment was marked as off-topic.

@boingoing
Copy link
Author

mhdawson

This comment was marked as off-topic.

jasongin

This comment was marked as off-topic.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants