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

Clang-tidy for Simple class. #43

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions interop.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

/*********************************************************************/

bool Interop_CreateInstance(const char *type_name, char *instance_id, int32_t instance_id_length,
void *execute_user_ptr, Interop_ExecuteCallback execute,
Interop_InvokeInstanceCallback *invoke_instance,
bool Interop_CreateInstance(const char *type_name, char *instance_id, int32_t max_instance_id, void *execute_user_ptr,
Interop_ExecuteCallback execute, Interop_InvokeInstanceCallback *invoke_instance,
Interop_ReleaseInstanceCallback *release_instance,
Interop_ProcessInstanceCallback *process_instance, void **user_ptr) {
if (strcmp(type_name, "SSN.Simple") == 0) {
void *context = Simple_Create();
Simple_GetInstanceId(context, instance_id, instance_id_length);
Simple_GetInstanceId(context, instance_id, max_instance_id);

*invoke_instance = Simple_Invoke;
*release_instance = Simple_Release;
Expand Down
48 changes: 25 additions & 23 deletions simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,58 +170,60 @@ bool Simple_Invoke(void *handle, echandle method_dictionary_handle, echandle ret
// it should marshal ok.

SimpleStruct *simple = (SimpleStruct *)handle;
echandle item_handle = NULL;
int32_t ret_val = true;
int32_t return_value = false;
bool ret = true;
const char *method = NULL;

if (!IDictionary_GetStringPtrByKey(method_dictionary_handle, "method", &method))
return false;

if (strcmp(method, "setIntProperty") == 0) {
bool return_value = false;
int64_t value = 0;
ret_val = IDictionary_GetInt64ByKey(method_dictionary_handle, "value", &value);
if (ret_val)
ret = IDictionary_GetInt64ByKey(method_dictionary_handle, "value", &value);
if (ret)
return_value = Simple_SetIntProperty(handle, value);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, &item_handle);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, NULL);
} else if (strcmp(method, "getIntProperty") == 0) {
const int64_t value = Simple_GetIntProperty(simple);
IDictionary_AddInt(return_dictionary_handle, "returnValue", value, &item_handle);
IDictionary_AddInt(return_dictionary_handle, "returnValue", value, NULL);
} else if (strcmp(method, "setFloatProperty") == 0) {
bool return_value = false;
float64_t value_float = 0;
ret_val = IDictionary_GetFloatByKey(method_dictionary_handle, "value", &value_float);
if (ret_val)
ret = IDictionary_GetFloatByKey(method_dictionary_handle, "value", &value_float);
if (ret)
return_value = Simple_SetFloatProperty(handle, value_float);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, &item_handle);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, NULL);
} else if (strcmp(method, "getFloatProperty") == 0) {
const float64_t value_float = Simple_GetFloatProperty(simple);
IDictionary_AddFloat(return_dictionary_handle, "returnValue", value_float, &item_handle);
IDictionary_AddFloat(return_dictionary_handle, "returnValue", value_float, NULL);
} else if (strcmp(method, "setBooleanProperty") == 0) {
bool return_value = false;
bool value = 0;
ret_val = IDictionary_GetBooleanByKey(method_dictionary_handle, "value", &value);
if (ret_val)
ret = IDictionary_GetBooleanByKey(method_dictionary_handle, "value", &value);
if (ret)
return_value = Simple_SetBooleanProperty(handle, value);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, &item_handle);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, NULL);
} else if (strcmp(method, "getBooleanProperty") == 0) {
const bool value = Simple_GetBooleanProperty(simple);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", value, &item_handle);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", value, NULL);
} else if (strcmp(method, "setStringProperty") == 0) {
bool return_value = false;
const char *value_string = NULL;
ret_val = IDictionary_GetStringPtrByKey(method_dictionary_handle, "value", &value_string);
if (ret_val)
ret = IDictionary_GetStringPtrByKey(method_dictionary_handle, "value", &value_string);
if (ret)
return_value = Simple_SetStringProperty(handle, value_string);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, &item_handle);
IDictionary_AddBoolean(return_dictionary_handle, "returnValue", return_value, NULL);
} else if (strcmp(method, "getStringProperty") == 0) {
const char *value_string = Simple_GetStringProperty(simple);
IDictionary_AddString(return_dictionary_handle, "returnValue", value_string, &item_handle);
IDictionary_AddString(return_dictionary_handle, "returnValue", value_string, NULL);
} else if (strcmp(method, "startValueRequest") == 0) {
ret_val = Simple_StartValueRequest(simple);
IDictionary_AddInt(return_dictionary_handle, "returnValue", ret_val, &item_handle);
ret = Simple_StartValueRequest(simple);
IDictionary_AddInt(return_dictionary_handle, "returnValue", ret, NULL);
} else {
ret_val = false;
ret = false;
}

return ret_val;
return ret;
}

/*********************************************************************/
Expand Down