@@ -162,23 +162,17 @@ Napi::Value ActionCreateServer(const Napi::CallbackInfo& info) {
162162 }
163163}
164164
165- NAN_METHOD (ActionServerIsAvailable) {
166- RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
167- Nan::To<v8::Object>(info[0 ]).ToLocalChecked ());
168- rcl_node_t * node = reinterpret_cast <rcl_node_t *>(node_handle->ptr ());
169- RclHandle* action_client_handle = RclHandle::Unwrap<RclHandle>(
170- Nan::To<v8::Object>(info[1 ]).ToLocalChecked ());
171- rcl_action_client_t * action_client =
172- reinterpret_cast <rcl_action_client_t *>(action_client_handle->ptr ());
165+ Napi::Value ActionServerIsAvailable (const Napi::CallbackInfo& info) {
166+ Napi::Env env = info.Env ();
167+ RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(info[0 ].As <Napi::Object>());
168+ rcl_action_server_t * action_server =
169+ reinterpret_cast <rcl_action_server_t *>(action_server_handle->ptr ());
170+ rcl_action_goal_info_t * buffer = reinterpret_cast <rcl_action_goal_info_t *>(
171+ node::Buffer::Data (info[1 ].As <Napi::Object>()));
173172
174- bool is_available;
175- THROW_ERROR_IF_NOT_EQUAL (
176- RCL_RET_OK,
177- rcl_action_server_is_available (node, action_client, &is_available),
178- rcl_get_error_string ().str );
173+ bool exists = rcl_action_server_goal_exists (action_server, buffer);
179174
180- v8::Local<v8::Boolean> result = Nan::New<v8::Boolean>(is_available);
181- info.GetReturnValue ().Set (result);
175+ return Napi::Boolean::New (env, exists);
182176}
183177
184178NAN_METHOD (ActionSendGoalRequest) {
@@ -683,35 +677,31 @@ NAN_METHOD(ActionServerGoalExists) {
683677 info.GetReturnValue ().Set (result);
684678}
685679
686- NAN_METHOD (ActionExpireGoals) {
687- v8::Local<v8::Context> currentContent = Nan::GetCurrentContext ();
688- RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(
689- Nan::To<v8::Object>(info[0 ]).ToLocalChecked ());
680+ Napi::Value ActionExpireGoals (const Napi::CallbackInfo& info) {
681+ Napi::Env env = info.Env ();
682+ RclHandle* action_server_handle = RclHandle::Unwrap<RclHandle>(info[0 ].As <Napi::Object>());
690683 rcl_action_server_t * action_server =
691684 reinterpret_cast <rcl_action_server_t *>(action_server_handle->ptr ());
692- int64_t max_num_goals = info[1 ]-> IntegerValue (currentContent). FromJust ();
685+ int64_t max_num_goals = info[1 ]. As <Napi::Number>(). Int64Value ();
693686 rcl_action_goal_info_t * buffer = reinterpret_cast <rcl_action_goal_info_t *>(
694- node::Buffer::Data (Nan::To<v8::Object>( info[2 ]). ToLocalChecked ()));
687+ node::Buffer::Data (info[2 ]. As <Napi::Object> ()));
695688
696689 size_t num_expired;
697690 THROW_ERROR_IF_NOT_EQUAL (rcl_action_expire_goals (action_server, buffer,
698691 max_num_goals, &num_expired),
699692 RCL_RET_OK, rcl_get_error_string ().str );
700693
701- v8::Local<v8::Integer> result =
702- Nan::New<v8::Integer>(static_cast <int32_t >(num_expired));
703- info.GetReturnValue ().Set (result);
694+ return Napi::Number::New (env, static_cast <int32_t >(num_expired));
704695}
705696
706- NAN_METHOD (ActionGetClientNamesAndTypesByNode) {
707- v8::Local<v8::Context> currentContent = Nan::GetCurrentContext ();
708- RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(
709- Nan::To<v8::Object>(info[0 ]).ToLocalChecked ());
697+ Napi::Value ActionGetClientNamesAndTypesByNode (const Napi::CallbackInfo& info) {
698+ Napi::Env env = info.Env ();
699+ RclHandle* node_handle = RclHandle::Unwrap<RclHandle>(info[0 ].As <Napi::Object>());
710700 rcl_node_t * node = reinterpret_cast <rcl_node_t *>(node_handle->ptr ());
711701 std::string node_name =
712- * Nan::Utf8String ( info[1 ]-> ToString (currentContent). ToLocalChecked () );
702+ info[1 ]. As <Napi::String>(). Utf8Value ( );
713703 std::string node_namespace =
714- * Nan::Utf8String ( info[2 ]-> ToString (currentContent). ToLocalChecked () );
704+ info[2 ]. As <Napi::String>(). Utf8Value ( );
715705
716706 rcl_names_and_types_t names_and_types =
717707 rcl_get_zero_initialized_names_and_types ();
@@ -722,15 +712,14 @@ NAN_METHOD(ActionGetClientNamesAndTypesByNode) {
722712 node_namespace.c_str (), &names_and_types),
723713 " Failed to action client names and types." );
724714
725- v8::Local<v8::Array> result_list =
726- Nan::New<v8::Array>(names_and_types.names .size );
727- ExtractNamesAndTypes (names_and_types, &result_list);
715+ Napi::Array result_list = Napi::Array::New (env, names_and_types.names .size );
716+ ExtractNamesAndTypes (env, names_and_types, result_list);
728717
729718 THROW_ERROR_IF_NOT_EQUAL (RCL_RET_OK,
730719 rcl_names_and_types_fini (&names_and_types),
731720 " Failed to destroy names_and_types" );
732721
733- info. GetReturnValue (). Set ( result_list) ;
722+ return result_list;
734723}
735724
736725NAN_METHOD (ActionGetServerNamesAndTypesByNode) {
0 commit comments