Skip to content

Commit

Permalink
Remove deprecated version.h and version_range.h
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Jan 4, 2024
1 parent fc76439 commit 63fa8b1
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 878 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <stdlib.h>
#include <json_rpc.h>
#include <assert.h>
#include "version.h"
#include "celix_version.h"
#include "dyn_interface.h"
#include "import_registration.h"
#include "import_registration_dfi.h"
Expand All @@ -32,7 +32,7 @@ struct import_registration {
celix_bundle_context_t *context;
endpoint_description_t * endpoint; //TODO owner? -> free when destroyed
const char *classObject; //NOTE owned by endpoint
version_pt version;
celix_version_t* version;

send_func_type send;
void *sendHandle;
Expand Down Expand Up @@ -75,7 +75,6 @@ celix_status_t importRegistration_create(
void* sendFnHandle,
FILE *logFile,
import_registration_t **out) {
celix_status_t status = CELIX_SUCCESS;
import_registration_t *reg = calloc(1, sizeof(*reg));
reg->context = context;
reg->endpoint = endpoint;
Expand All @@ -87,7 +86,7 @@ celix_status_t importRegistration_create(
remoteInterceptorsHandler_create(context, &reg->interceptorsHandler);

celixThreadMutex_create(&reg->proxiesMutex, NULL);
status = version_createVersionFromString((char*)serviceVersion,&(reg->version));
reg->version = celix_version_createVersionFromString((char*)serviceVersion);

reg->factorySvcId = -1;
reg->factory.handle = reg;
Expand All @@ -96,14 +95,15 @@ celix_status_t importRegistration_create(
reg->logFile = logFile;


if (status == CELIX_SUCCESS) {
if (reg && reg->version && reg->proxies && reg->interceptorsHandler) {
//printf("IMPORT REGISTRATION IS %p\n", reg);
*out = reg;
return CELIX_ENOMEM;
} else {
importRegistration_destroy(reg);
}

return status;
return CELIX_SUCCESS;
}

static void importRegistration_clearProxies(import_registration_t *import) {
Expand Down Expand Up @@ -134,9 +134,7 @@ static void importRegistration_destroyCallback(void* data) {

pthread_mutex_destroy(&import->proxiesMutex);

if (import->version != NULL) {
version_destroy(import->version);
}
celix_version_destroy(import->version);
free(import);
}

Expand Down Expand Up @@ -230,16 +228,14 @@ static celix_status_t importRegistration_createProxy(import_registration_t *impo
}

/* Check if the imported service version is compatible with the one in the consumer descriptor */
version_pt consumerVersion = NULL;
celix_version_t* consumerVersion = NULL;
bool isCompatible = false;
dynInterface_getVersion(intf,&consumerVersion);
version_isCompatible(consumerVersion,import->version,&isCompatible);
isCompatible = celix_version_isCompatible(consumerVersion, import->version);

if(!isCompatible){
char* cVerString = NULL;
char* pVerString = NULL;
version_toString(consumerVersion,&cVerString);
version_toString(import->version,&pVerString);
char* cVerString = celix_version_toString(consumerVersion);
char* pVerString = celix_version_toString(import->version);
printf("Service version mismatch: consumer has %s, provider has %s. NOT creating proxy.\n",cVerString,pVerString);
dynInterface_destroy(intf);
free(cVerString);
Expand Down
11 changes: 5 additions & 6 deletions libs/dfi/gtest/src/dyn_interface_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {

#include "dyn_common.h"
#include "dyn_interface.h"
#include "version.h"
#include "celix_version.h"

#if NO_MEMSTREAM_AVAILABLE
#include "open_memstream.h"
Expand All @@ -57,14 +57,13 @@ extern "C" {
status = dynInterface_getVersionString(dynIntf, &version);
ASSERT_EQ(0, status);
ASSERT_STREQ(v, version);
version_pt msgVersion = NULL, localMsgVersion = NULL;
int cmpVersion = -1;
version_createVersionFromString(version, &localMsgVersion);
celix_version_t* msgVersion = nullptr;
celix_version_t* localMsgVersion = localMsgVersion = celix_version_createVersionFromString(version);
status = dynInterface_getVersion(dynIntf, &msgVersion);
ASSERT_EQ(0, status);
version_compareTo(msgVersion, localMsgVersion, &cmpVersion);
int cmpVersion = celix_version_compareTo(msgVersion, localMsgVersion);
ASSERT_EQ(cmpVersion, 0);
version_destroy(localMsgVersion);
celix_version_destroy(localMsgVersion);
}

static void test1(void) {
Expand Down
12 changes: 5 additions & 7 deletions libs/dfi/gtest/src/dyn_message_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "gtest/gtest.h"

#include <stdarg.h>
#include "version.h"
#include "celix_version.h"


extern "C" {
Expand Down Expand Up @@ -57,15 +57,13 @@ static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){
status = dynMessage_getVersionString(dynMsg, &version);
ASSERT_EQ(0, status);
ASSERT_STREQ(v, version);
version_pt msgVersion = NULL, localMsgVersion = NULL;
int cmpVersion = -1;
version_createVersionFromString(version,&localMsgVersion);
celix_version_t* msgVersion = nullptr;
celix_version_t* localMsgVersion = celix_version_createVersionFromString(version);
status = dynMessage_getVersion(dynMsg,&msgVersion);
ASSERT_EQ(0, status);
version_compareTo(msgVersion,localMsgVersion,&cmpVersion);
int cmpVersion = celix_version_compareTo(msgVersion, localMsgVersion);
ASSERT_EQ(cmpVersion,0);
version_destroy(localMsgVersion);

celix_version_destroy(localMsgVersion);
}


Expand Down
3 changes: 1 addition & 2 deletions libs/framework/include_deprecated/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ typedef struct module celix_module_t;

#include "linked_list.h"
#include "manifest.h"
#include "version.h"
#include "array_list.h"
#include "bundle.h"
#include "celix_framework_export.h"
Expand All @@ -53,7 +52,7 @@ CELIX_FRAMEWORK_DEPRECATED_EXPORT unsigned int module_hash(void *module);

CELIX_FRAMEWORK_DEPRECATED_EXPORT int module_equals(void *module, void *compare);

CELIX_FRAMEWORK_DEPRECATED_EXPORT version_pt module_getVersion(module_pt module);
CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_version_t* module_getVersion(module_pt module);

CELIX_FRAMEWORK_DEPRECATED_EXPORT celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName);

Expand Down
15 changes: 7 additions & 8 deletions libs/framework/src/manifest_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct manifestParser {
module_pt owner;
manifest_pt manifest;

version_pt bundleVersion;
celix_version_t* bundleVersion;
//TODO: Implement Requirement-Capability-Model using RCM library
};

Expand All @@ -54,11 +54,9 @@ celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, mani

bundleVersion = manifest_getValue(manifest, CELIX_FRAMEWORK_BUNDLE_VERSION);
if (bundleVersion != NULL) {
parser->bundleVersion = NULL;
version_createVersionFromString(bundleVersion, &parser->bundleVersion);
parser->bundleVersion = celix_version_createVersionFromString(bundleVersion);
} else {
parser->bundleVersion = NULL;
version_createEmptyVersion(&parser->bundleVersion);
parser->bundleVersion = celix_version_createEmptyVersion();
}

*manifest_parser = parser;
Expand All @@ -74,7 +72,7 @@ celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, mani
}

celix_status_t manifestParser_destroy(manifest_parser_pt mp) {
version_destroy(mp->bundleVersion);
celix_version_destroy(mp->bundleVersion);
mp->bundleVersion = NULL;
mp->manifest = NULL;
mp->owner = NULL;
Expand Down Expand Up @@ -110,6 +108,7 @@ celix_status_t manifestParser_getAndDuplicateDescription(manifest_parser_pt pars
return manifestParser_getDuplicateEntry(parser, CELIX_FRAMEWORK_BUNDLE_DESCRIPTION, description);
}

celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version) {
return version_clone(parser->bundleVersion, version);
celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, celix_version_t **version) {
*version = celix_version_copy(parser->bundleVersion);
return *version == NULL ? CELIX_ENOMEM : CELIX_SUCCESS;
}
4 changes: 2 additions & 2 deletions libs/framework/src/manifest_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define MANIFEST_PARSER_H_

#include "module.h"
#include "version.h"
#include "celix_version.h"
#include "manifest.h"
#include "linked_list.h"

Expand All @@ -40,7 +40,7 @@ celix_status_t manifestParser_destroy(manifest_parser_pt mp);
celix_status_t manifestParser_getAndDuplicateSymbolicName(manifest_parser_pt parser, char **symbolicName);
celix_status_t manifestParser_getAndDuplicateName(manifest_parser_pt parser, char **name);
celix_status_t manifestParser_getAndDuplicateDescription(manifest_parser_pt parser, char **description);
celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, version_pt *version);
celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, celix_version_t **version);
celix_status_t manifestParser_getAndDuplicateGroup(manifest_parser_pt parser, char **group);

#endif /* MANIFEST_PARSER_H_ */
48 changes: 22 additions & 26 deletions libs/framework/src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
struct module {
celix_framework_t* fw;

version_pt version;
char* symbolicName;
char* group;
celix_version_t* version;
char* symbolicName;
char* group;
char* name;
char* description;
bool resolved;
bool resolved;

char * id;
char* id;

celix_bundle_t *bundle;
celix_bundle_t* bundle;

celix_thread_mutex_t handlesLock; //protects libraryHandles and bundleActivatorHandle
celix_thread_mutex_t handlesLock; // protects libraryHandles and bundleActivatorHandle
celix_array_list_t* libraryHandles;
void* bundleActivatorHandle;
};
Expand Down Expand Up @@ -106,42 +106,38 @@ module_pt module_create(manifest_pt headerMap, const char * moduleId, bundle_pt
module_pt module_createFrameworkModule(celix_framework_t* fw, bundle_pt bundle) {
module_pt module;

module = (module_pt) calloc(1, sizeof(*module));
module = (module_pt)calloc(1, sizeof(*module));
char modId[2];
snprintf(modId, 2, "%li", CELIX_FRAMEWORK_BUNDLE_ID);
if (module) {
if (module) {
module->fw = fw;
module->id = celix_utils_strdup(modId);
module->symbolicName = celix_utils_strdup("celix_framework");
module->group = celix_utils_strdup("Celix/Framework");
module->name = celix_utils_strdup("Celix Framework");
module->description = celix_utils_strdup("The Celix Framework System Bundle");
module->version = NULL;
version_createVersion(1, 0, 0, "", &module->version);
module->version = celix_version_create(1, 0, 0, "");
module->resolved = false;
module->bundle = bundle;
celixThreadMutex_create(&module->handlesLock, NULL);
module->libraryHandles = celix_arrayList_create();
}
return module;
}
return module;
}

void module_destroy(module_pt module) {

version_destroy(module->version);
free(module->id);
free(module->symbolicName);
free(module->name);
free(module->group);
free(module->description);
celix_arrayList_destroy(module->libraryHandles);
celixThreadMutex_destroy(&module->handlesLock);
free(module);
celix_version_destroy(module->version);
free(module->id);
free(module->symbolicName);
free(module->name);
free(module->group);
free(module->description);
celix_arrayList_destroy(module->libraryHandles);
celixThreadMutex_destroy(&module->handlesLock);
free(module);
}

version_pt module_getVersion(module_pt module) {
return module->version;
}
celix_version_t* module_getVersion(module_pt module) { return module->version; }

celix_status_t module_getSymbolicName(module_pt module, const char **symbolicName) {
celix_status_t status = CELIX_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/src/service_registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ char* celix_serviceRegistry_createFilterFor(celix_service_registry_t* registry,
"Error incorrect version range.");
return NULL;
}
versionRange = versionRange_createLDAPFilter(range, CELIX_FRAMEWORK_SERVICE_VERSION);
versionRange = celix_versionRange_createLDAPFilter(range, CELIX_FRAMEWORK_SERVICE_VERSION);
if (versionRange == NULL) {
celix_framework_log(registry->framework->logger, CELIX_LOG_LEVEL_ERROR, __FUNCTION__, __BASE_FILE__, __LINE__,
"Error creating LDAP filter.");
Expand Down
Loading

0 comments on commit 63fa8b1

Please sign in to comment.