Skip to content

Commit

Permalink
Merge pull request #137 from Oipo/const_pubsub_bundle
Browse files Browse the repository at this point in the history
Constify parameters to functions, assorted minor fixes
  • Loading branch information
pnoltes committed Dec 27, 2019
2 parents 0050527 + 902101b commit d3f2b3b
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 96 deletions.
Expand Up @@ -64,9 +64,9 @@ typedef struct pubsub_avrobin_msg_serializer_impl {
version_pt msgVersion;
} pubsub_avrobin_msg_serializer_impl_t;

static char *pubsubAvrobinSerializer_getMsgDescriptionDir(celix_bundle_t *bundle);
static void pubsubAvrobinSerializer_addMsgSerializerFromBundle(const char *root, celix_bundle_t *bundle, hash_map_pt msgTypesMap);
static void pubsubAvrobinSerializer_fillMsgSerializerMap(hash_map_pt msgTypesMap, celix_bundle_t *bundle);
static char *pubsubAvrobinSerializer_getMsgDescriptionDir(const celix_bundle_t *bundle);
static void pubsubAvrobinSerializer_addMsgSerializerFromBundle(const char *root, const celix_bundle_t *bundle, hash_map_pt msgTypesMap);
static void pubsubAvrobinSerializer_fillMsgSerializerMap(hash_map_pt msgTypesMap, const celix_bundle_t *bundle);

static int pubsubMsgAvrobinSerializer_convertDescriptor(FILE* file_ptr, pubsub_msg_serializer_t* serializer);
static int pubsubMsgAvrobinSerializer_convertAvpr(FILE* file_ptr, pubsub_msg_serializer_t* serializer, const char* fqn);
Expand Down Expand Up @@ -116,7 +116,7 @@ celix_status_t pubsubAvrobinSerializer_destroy(pubsub_avrobin_serializer_t *seri
return status;
}

celix_status_t pubsubAvrobinSerializer_createSerializerMap(void *handle, celix_bundle_t *bundle, hash_map_pt *serializerMap) {
celix_status_t pubsubAvrobinSerializer_createSerializerMap(void *handle, const celix_bundle_t *bundle, hash_map_pt *serializerMap) {
celix_status_t status = CELIX_SUCCESS;
pubsub_avrobin_serializer_t *serializer = handle;

Expand Down Expand Up @@ -214,7 +214,7 @@ static void pubsubMsgAvrobinSerializer_freeMsg(void *handle, void *msg) {
}
}

static char *pubsubAvrobinSerializer_getMsgDescriptionDir(celix_bundle_t *bundle) {
static char *pubsubAvrobinSerializer_getMsgDescriptionDir(const celix_bundle_t *bundle) {
char *root = NULL;

bool isSystemBundle = false;
Expand All @@ -240,7 +240,7 @@ static char *pubsubAvrobinSerializer_getMsgDescriptionDir(celix_bundle_t *bundle
return root;
}

static void pubsubAvrobinSerializer_addMsgSerializerFromBundle(const char *root, celix_bundle_t *bundle, hash_map_pt msgTypesMap) {
static void pubsubAvrobinSerializer_addMsgSerializerFromBundle(const char *root, const celix_bundle_t *bundle, hash_map_pt msgTypesMap) {
char fqn[MAX_PATH_LEN];
char path[MAX_PATH_LEN];
const char* entry_name = NULL;
Expand Down Expand Up @@ -305,7 +305,7 @@ static void pubsubAvrobinSerializer_addMsgSerializerFromBundle(const char *root,
}
}

static void pubsubAvrobinSerializer_fillMsgSerializerMap(hash_map_pt msgTypesMap, celix_bundle_t *bundle) {
static void pubsubAvrobinSerializer_fillMsgSerializerMap(hash_map_pt msgTypesMap, const celix_bundle_t *bundle) {
char *root = NULL;
char *metaInfPath = NULL;

Expand Down
Expand Up @@ -34,7 +34,7 @@ typedef struct pubsub_avrobin_serializer pubsub_avrobin_serializer_t;
celix_status_t pubsubAvrobinSerializer_create(celix_bundle_context_t *context, pubsub_avrobin_serializer_t **serializer);
celix_status_t pubsubAvrobinSerializer_destroy(pubsub_avrobin_serializer_t *serializer);

celix_status_t pubsubAvrobinSerializer_createSerializerMap(void *handle, celix_bundle_t *bundle, hash_map_pt *serializerMap);
celix_status_t pubsubAvrobinSerializer_createSerializerMap(void *handle, const celix_bundle_t *bundle, hash_map_pt *serializerMap);
celix_status_t pubsubAvrobinSerializer_destroySerializerMap(void *handle, hash_map_pt serializerMap);

#endif /* PUBSUB_SERIALIZER_AVROBIN_H_ */
Expand Up @@ -77,9 +77,9 @@ typedef struct pubsub_json_msg_serializer_impl {
version_pt msgVersion;
} pubsub_json_msg_serializer_impl_t;

static char* pubsubSerializer_getMsgDescriptionDir(celix_bundle_t *bundle);
static void pubsubSerializer_addMsgSerializerFromBundle(pubsub_json_serializer_t* serializer, const char *root, celix_bundle_t *bundle, hash_map_pt msgSerializers);
static void pubsubSerializer_fillMsgSerializerMap(pubsub_json_serializer_t* serializer, hash_map_pt msgSerializers,celix_bundle_t *bundle);
static char* pubsubSerializer_getMsgDescriptionDir(const celix_bundle_t *bundle);
static void pubsubSerializer_addMsgSerializerFromBundle(pubsub_json_serializer_t* serializer, const char *root, const celix_bundle_t *bundle, hash_map_pt msgSerializers);
static void pubsubSerializer_fillMsgSerializerMap(pubsub_json_serializer_t* serializer, hash_map_pt msgSerializers, const celix_bundle_t *bundle);

static int pubsubMsgSerializer_convertDescriptor(pubsub_json_serializer_t* serializer, FILE* file_ptr, pubsub_msg_serializer_t* msgSerializer);
static int pubsubMsgSerializer_convertAvpr(pubsub_json_serializer_t *serializer, FILE* file_ptr, pubsub_msg_serializer_t* msgSerializer, const char* fqn);
Expand Down Expand Up @@ -131,7 +131,7 @@ celix_status_t pubsubSerializer_destroy(pubsub_json_serializer_t* serializer) {
return status;
}

celix_status_t pubsubSerializer_createSerializerMap(void *handle, celix_bundle_t *bundle, hash_map_pt* serializerMap) {
celix_status_t pubsubSerializer_createSerializerMap(void *handle, const celix_bundle_t *bundle, hash_map_pt* serializerMap) {
pubsub_json_serializer_t *serializer = handle;

hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
Expand Down Expand Up @@ -210,7 +210,7 @@ void pubsubMsgSerializer_freeMsg(void* handle, void *msg) {
}


static void pubsubSerializer_fillMsgSerializerMap(pubsub_json_serializer_t* serializer, hash_map_pt msgSerializers, celix_bundle_t *bundle) {
static void pubsubSerializer_fillMsgSerializerMap(pubsub_json_serializer_t* serializer, hash_map_pt msgSerializers, const celix_bundle_t *bundle) {
char* root = NULL;
char* metaInfPath = NULL;

Expand All @@ -227,7 +227,7 @@ static void pubsubSerializer_fillMsgSerializerMap(pubsub_json_serializer_t* seri
}
}

static char* pubsubSerializer_getMsgDescriptionDir(celix_bundle_t *bundle) {
static char* pubsubSerializer_getMsgDescriptionDir(const celix_bundle_t *bundle) {
char *root = NULL;

bool isSystemBundle = false;
Expand All @@ -253,7 +253,7 @@ static char* pubsubSerializer_getMsgDescriptionDir(celix_bundle_t *bundle) {
return root;
}

static void pubsubSerializer_addMsgSerializerFromBundle(pubsub_json_serializer_t* serializer, const char *root, celix_bundle_t *bundle, hash_map_pt msgSerializers) {
static void pubsubSerializer_addMsgSerializerFromBundle(pubsub_json_serializer_t* serializer, const char *root, const celix_bundle_t *bundle, hash_map_pt msgSerializers) {
char fqn[MAX_PATH_LEN];
char pathOrError[MAX_PATH_LEN];
const char* entry_name = NULL;
Expand Down
Expand Up @@ -34,7 +34,7 @@ typedef struct pubsub_json_serializer pubsub_json_serializer_t;
celix_status_t pubsubSerializer_create(celix_bundle_context_t *context, pubsub_json_serializer_t **serializer);
celix_status_t pubsubSerializer_destroy(pubsub_json_serializer_t* serializer);

celix_status_t pubsubSerializer_createSerializerMap(void *handle, celix_bundle_t *bundle, hash_map_pt* serializerMap);
celix_status_t pubsubSerializer_createSerializerMap(void *handle, const celix_bundle_t *bundle, hash_map_pt* serializerMap);
celix_status_t pubsubSerializer_destroySerializerMap(void *handle, hash_map_pt serializerMap);

#endif /* PUBSUB_SERIALIZER_JSON_H_ */
2 changes: 1 addition & 1 deletion bundles/pubsub/pubsub_spi/include/pubsub_serializer.h
Expand Up @@ -53,7 +53,7 @@ typedef struct pubsub_msg_serializer {
typedef struct pubsub_serializer_service {
void* handle;

celix_status_t (*createSerializerMap)(void* handle, celix_bundle_t *bundle, hash_map_pt* serializerMap);
celix_status_t (*createSerializerMap)(void* handle, const celix_bundle_t *bundle, hash_map_pt* serializerMap);
celix_status_t (*destroySerializerMap)(void* handle, hash_map_pt serializerMap);

} pubsub_serializer_service_t;
Expand Down
28 changes: 14 additions & 14 deletions libs/framework/include/bundle.h
Expand Up @@ -47,27 +47,27 @@ bundle_createFromArchive(celix_bundle_t **bundle, celix_framework_t *framework,

FRAMEWORK_EXPORT celix_status_t bundle_destroy(celix_bundle_t *bundle);

FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(celix_bundle_t *bundle, bool *systemBundle);
FRAMEWORK_EXPORT celix_status_t bundle_isSystemBundle(const celix_bundle_t *bundle, bool *systemBundle);

FRAMEWORK_EXPORT celix_status_t bundle_getArchive(celix_bundle_t *bundle, bundle_archive_pt *archive);
FRAMEWORK_EXPORT celix_status_t bundle_getArchive(const celix_bundle_t *bundle, bundle_archive_pt *archive);

FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(celix_bundle_t *bundle, module_pt *module);
FRAMEWORK_EXPORT celix_status_t bundle_getCurrentModule(const celix_bundle_t *bundle, module_pt *module);

FRAMEWORK_EXPORT celix_array_list_t *bundle_getModules(celix_bundle_t *bundle);
FRAMEWORK_EXPORT celix_array_list_t *bundle_getModules(const celix_bundle_t *bundle);

FRAMEWORK_EXPORT void *bundle_getHandle(celix_bundle_t *bundle);

FRAMEWORK_EXPORT void bundle_setHandle(celix_bundle_t *bundle, void *handle);

FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(celix_bundle_t *bundle);
FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(const celix_bundle_t *bundle);

FRAMEWORK_EXPORT celix_status_t bundle_setActivator(celix_bundle_t *bundle, celix_bundle_activator_t *activator);

FRAMEWORK_EXPORT celix_status_t bundle_getContext(celix_bundle_t *bundle, celix_bundle_context_t **context);
FRAMEWORK_EXPORT celix_status_t bundle_getContext(const celix_bundle_t *bundle, celix_bundle_context_t **context);

FRAMEWORK_EXPORT celix_status_t bundle_setContext(celix_bundle_t *bundle, celix_bundle_context_t *context);

FRAMEWORK_EXPORT celix_status_t bundle_getEntry(celix_bundle_t *bundle, const char *name, char **entry);
FRAMEWORK_EXPORT celix_status_t bundle_getEntry(const celix_bundle_t *bundle, const char *name, char **entry);

FRAMEWORK_EXPORT celix_status_t bundle_start(celix_bundle_t *bundle);

Expand All @@ -93,32 +93,32 @@ FRAMEWORK_EXPORT celix_status_t bundle_revise(celix_bundle_t *bundle, const char

FRAMEWORK_EXPORT celix_status_t bundle_addModule(celix_bundle_t *bundle, module_pt module);

FRAMEWORK_EXPORT celix_status_t bundle_closeModules(celix_bundle_t *bundle);
FRAMEWORK_EXPORT celix_status_t bundle_closeModules(const celix_bundle_t *bundle);

// Service Reference Functions
FRAMEWORK_EXPORT celix_array_list_t *getUsingBundles(service_reference_pt reference);

FRAMEWORK_EXPORT int compareTo(service_reference_pt a, service_reference_pt b);

FRAMEWORK_EXPORT celix_status_t bundle_getState(celix_bundle_t *bundle, bundle_state_e *state);
FRAMEWORK_EXPORT celix_status_t bundle_getState(const celix_bundle_t *bundle, bundle_state_e *state);

FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(celix_bundle_t *bundle);
FRAMEWORK_EXPORT celix_status_t bundle_closeAndDelete(const celix_bundle_t *bundle);

FRAMEWORK_EXPORT celix_status_t bundle_close(celix_bundle_t *bundle);
FRAMEWORK_EXPORT celix_status_t bundle_close(const celix_bundle_t *bundle);

FRAMEWORK_EXPORT celix_status_t bundle_refresh(celix_bundle_t *bundle);

FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(celix_bundle_t *bundle, long *id);
FRAMEWORK_EXPORT celix_status_t bundle_getBundleId(const celix_bundle_t *bundle, long *id);

FRAMEWORK_EXPORT celix_status_t bundle_getRegisteredServices(celix_bundle_t *bundle, celix_array_list_t **list);

FRAMEWORK_EXPORT celix_status_t bundle_getServicesInUse(celix_bundle_t *bundle, celix_array_list_t **list);

FRAMEWORK_EXPORT celix_status_t bundle_setFramework(celix_bundle_t *bundle, celix_framework_t *framework);

FRAMEWORK_EXPORT celix_status_t bundle_getFramework(celix_bundle_t *bundle, celix_framework_t **framework);
FRAMEWORK_EXPORT celix_status_t bundle_getFramework(const celix_bundle_t *bundle, celix_framework_t **framework);

FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(celix_bundle_t *bundle, const char **location);
FRAMEWORK_EXPORT celix_status_t bundle_getBundleLocation(const celix_bundle_t *bundle, const char **location);


#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions libs/framework/include/celix_types.h
Expand Up @@ -53,8 +53,10 @@ typedef struct celix_dm_service_dependency dm_service_dependency_t CELIX_DEPRECA
typedef struct celix_bundle_context *bundle_context_pt CELIX_DEPRECATED_ATTR;
typedef struct celix_bundle_context bundle_context_t CELIX_DEPRECATED_ATTR;
typedef struct celix_framework *framework_pt CELIX_DEPRECATED_ATTR;
typedef const struct celix_framework *const_framework_pt CELIX_DEPRECATED_ATTR;
typedef struct celix_framework framework_t CELIX_DEPRECATED_ATTR;
typedef struct celix_bundle * bundle_pt CELIX_DEPRECATED_ATTR;
typedef const struct celix_bundle * const_bundle_pt CELIX_DEPRECATED_ATTR;
typedef struct celix_bundle bundle_t CELIX_DEPRECATED_ATTR;

// will be deprecated in the future
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/include/framework.h
Expand Up @@ -48,9 +48,9 @@ FRAMEWORK_EXPORT celix_status_t framework_destroy(celix_framework_t *framework);

FRAMEWORK_EXPORT celix_status_t framework_waitForStop(celix_framework_t *framework);

FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(celix_framework_t *framework, celix_bundle_t **bundle);
FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(const celix_framework_t *framework, celix_bundle_t **bundle);

celix_bundle_context_t* framework_getContext(celix_framework_t *framework);
celix_bundle_context_t* framework_getContext(const celix_framework_t *framework);

#ifdef __cplusplus
}
Expand Down
44 changes: 22 additions & 22 deletions libs/framework/private/mock/bundle_mock.c
Expand Up @@ -49,26 +49,26 @@ celix_status_t bundle_destroy(bundle_pt bundle) {
}


celix_status_t bundle_isSystemBundle(bundle_pt bundle, bool *systemBundle) {
celix_status_t bundle_isSystemBundle(const_bundle_pt bundle, bool *systemBundle) {
mock_c()->actualCall("bundle_isSystembundle")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("systemBundle", systemBundle);
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getArchive(bundle_pt bundle, bundle_archive_pt *archive) {
celix_status_t bundle_getArchive(const_bundle_pt bundle, bundle_archive_pt *archive) {
mock_c()->actualCall("bundle_getArchive");
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getCurrentModule(bundle_pt bundle, module_pt *module) {
celix_status_t bundle_getCurrentModule(const_bundle_pt bundle, module_pt *module) {
mock_c()->actualCall("bundle_getCurrentModule")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("module", (void **) module);
return mock_c()->returnValue().value.intValue;
}

array_list_pt bundle_getModules(bundle_pt bundle) {
array_list_pt bundle_getModules(const_bundle_pt bundle) {
mock_c()->actualCall("bundle_getModules");
return mock_c()->returnValue().value.pointerValue;
}
Expand All @@ -82,7 +82,7 @@ void bundle_setHandle(bundle_pt bundle, void * handle) {
mock_c()->actualCall("bundle_setHandle");
}

celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle) {
celix_bundle_activator_t *bundle_getActivator(const_bundle_pt bundle) {
mock_c()->actualCall("bundle_getActivator");
return mock_c()->returnValue().value.pointerValue;
}
Expand All @@ -92,9 +92,9 @@ celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *a
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) {
celix_status_t bundle_getContext(const_bundle_pt bundle, bundle_context_pt *context) {
mock_c()->actualCall("bundle_getContext")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("context", context);
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -104,9 +104,9 @@ celix_status_t bundle_setContext(bundle_pt bundle, bundle_context_pt context) {
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getEntry(bundle_pt bundle, const char * name, char **entry) {
celix_status_t bundle_getEntry(const_bundle_pt bundle, const char * name, char **entry) {
mock_c()->actualCall("bundle_getEntry")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withStringParameters("name", name)
->withOutputParameter("entry", entry);
return mock_c()->returnValue().value.intValue;
Expand Down Expand Up @@ -158,9 +158,9 @@ celix_status_t bundle_setPersistentStateUninstalled(bundle_pt bundle) {
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location) {
celix_status_t bundle_getBundleLocation(const_bundle_pt bundle, const char **location) {
mock_c()->actualCall("bundle_getBundleLocation")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("location", location);
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -180,7 +180,7 @@ celix_status_t bundle_addModule(bundle_pt bundle, module_pt module) {
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_closeModules(bundle_pt bundle) {
celix_status_t bundle_closeModules(const_bundle_pt bundle) {
mock_c()->actualCall("bundle_closeModules");
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -199,9 +199,9 @@ int compareTo(service_reference_pt a, service_reference_pt b) {
}


celix_status_t bundle_getState(bundle_pt bundle, bundle_state_e *state) {
celix_status_t bundle_getState(const_bundle_pt bundle, bundle_state_e *state) {
mock_c()->actualCall("bundle_getState")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("state", state);
return mock_c()->returnValue().value.intValue;
}
Expand Down Expand Up @@ -235,12 +235,12 @@ celix_status_t bundle_unlock(bundle_pt bundle, bool *unlocked) {
}


celix_status_t bundle_closeAndDelete(bundle_pt bundle) {
celix_status_t bundle_closeAndDelete(const_bundle_pt bundle) {
mock_c()->actualCall("bundle_closeAndDelete");
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_close(bundle_pt bundle) {
celix_status_t bundle_close(const_bundle_pt bundle) {
mock_c()->actualCall("bundle_close");
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -251,9 +251,9 @@ celix_status_t bundle_refresh(bundle_pt bundle) {
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getBundleId(bundle_pt bundle, long *id) {
celix_status_t bundle_getBundleId(const_bundle_pt bundle, long *id) {
mock_c()->actualCall("bundle_getBundleId")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("id", id);
return mock_c()->returnValue().value.intValue;
}
Expand All @@ -278,9 +278,9 @@ celix_status_t bundle_setFramework(bundle_pt bundle, framework_pt framework) {
return mock_c()->returnValue().value.intValue;
}

celix_status_t bundle_getFramework(bundle_pt bundle, framework_pt *framework) {
celix_status_t bundle_getFramework(const_bundle_pt bundle, framework_pt *framework) {
mock_c()->actualCall("bundle_getFramework")
->withPointerParameters("bundle", bundle)
->withPointerParameters("bundle", (bundle_pt)bundle)
->withOutputParameter("framework", framework);
return mock_c()->returnValue().value.intValue;
}
Expand Down

0 comments on commit d3f2b3b

Please sign in to comment.