Skip to content

Commit

Permalink
Merge branch 'master' into feature/674-add-element-type-to-array-list
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGES.md
  • Loading branch information
pnoltes committed Feb 17, 2024
2 parents 05047d5 + 6a550a4 commit 2bd5e42
Show file tree
Hide file tree
Showing 18 changed files with 312 additions and 882 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ limitations under the License.
- ip_utils.h is removed and no longer supported.
- array_list.h is removed and no longer supported. Use celix_array_list.h instead.
- the celix_arrayList_add function no longer accepts a NULL value.
- version.h and version_range.h are removed and no longer supported. Use celix_version.h and celix_version_range.h
instead.

## New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <libxml/xmlreader.h>

#include "celix_log_helper.h"
Expand Down
24 changes: 10 additions & 14 deletions libs/dfi/gtest/src/dyn_message_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#include "gtest/gtest.h"

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


extern "C" {
Expand All @@ -37,24 +36,21 @@ extern "C" {
#include "celix_err.h"
#include "celix_version.h"

static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){
int status = 0;
static void checkMessageVersion(dyn_message_type* dynMsg, const char* v) {
int status = 0;

const char* version = dynMessage_getVersionString(dynMsg);
ASSERT_STREQ(v, version);
const char* version = dynMessage_getVersionString(dynMsg);
ASSERT_STREQ(v, version);
const celix_version_t* msgVersion = nullptr;
celix_version_t* localMsgVersion = nullptr;
int cmpVersion = -1;
version_createVersionFromString(version,&localMsgVersion);
celix_version_t* localMsgVersion = celix_version_createVersionFromString(version);
int cmpVersion = -1;
msgVersion = dynMessage_getVersion(dynMsg);
ASSERT_EQ(0, status);
ASSERT_EQ(0, status);
cmpVersion = celix_version_compareTo(msgVersion, localMsgVersion);
ASSERT_EQ(cmpVersion,0);
version_destroy(localMsgVersion);

ASSERT_EQ(cmpVersion, 0);
celix_version_destroy(localMsgVersion);
}


static void msg_test1(void) {
int status = 0;
dyn_message_type *dynMsg = NULL;
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 @@ -33,7 +33,6 @@ typedef struct module celix_module_t;
#include <stdbool.h>

#include "manifest.h"
#include "version.h"
#include "bundle.h"
#include "celix_framework_export.h"

Expand All @@ -51,7 +50,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
22 changes: 10 additions & 12 deletions libs/framework/src/manifest_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
#include "celix_log.h"

struct manifestParser {
module_pt owner;
manifest_pt manifest;

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

celix_status_t manifestParser_create(module_pt owner, manifest_pt manifest, manifest_parser_pt *manifest_parser) {
Expand All @@ -54,11 +53,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 +71,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 +107,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"

typedef struct manifestParser * manifest_parser_pt;
Expand All @@ -39,7 +39,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 @@ -47,18 +47,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 @@ -105,42 +105,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
Loading

0 comments on commit 2bd5e42

Please sign in to comment.