You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/05/29 17:33:08 UTC

[3/5] celix git commit: CELIX-446: Refactor bundle activator struct name to ensure it is unique

CELIX-446: Refactor bundle activator struct name to ensure it is unique


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/218d265c
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/218d265c
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/218d265c

Branch: refs/heads/feature/CELIX-426-cxx-api
Commit: 218d265c5082c1dafcdcb92863fed89da50f00ed
Parents: 3e5a6a7
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Mon May 28 16:08:29 2018 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Mon May 28 16:08:29 2018 +0200

----------------------------------------------------------------------
 .../foo1/private/src/foo1_activator.c                    |  4 ++--
 libs/framework/include/bundle.h                          |  7 +++++--
 libs/framework/include/framework.h                       |  3 ---
 libs/framework/private/mock/bundle_mock.c                |  4 ++--
 libs/framework/private/test/bundle_test.cpp              |  6 +++---
 libs/framework/src/bundle.c                              |  4 ++--
 libs/framework/src/bundle_private.h                      |  4 +++-
 libs/framework/src/framework.c                           | 11 +++++------
 8 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
----------------------------------------------------------------------
diff --git a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
index 6b2f578..61783ef 100644
--- a/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
+++ b/examples/celix-examples/best_practice_example_c/foo1/private/src/foo1_activator.c
@@ -22,9 +22,9 @@
 
 #include <stdlib.h>
 
-struct activator {
+typedef struct activator {
 	foo1_t *foo;
-};
+} activator_t;
 
 static celix_status_t activator_start(activator_t *act, celix_bundle_context_t *ctx) {
 	celix_status_t status = CELIX_SUCCESS;

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/include/bundle.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/bundle.h b/libs/framework/include/bundle.h
index b105615..1cd100a 100644
--- a/libs/framework/include/bundle.h
+++ b/libs/framework/include/bundle.h
@@ -44,6 +44,9 @@
 extern "C" {
 #endif
 
+struct celix_bundle_activator;
+typedef struct celix_bundle_activator celix_bundle_activator_t;
+
 FRAMEWORK_EXPORT celix_status_t bundle_create(bundle_pt *bundle);
 
 FRAMEWORK_EXPORT celix_status_t
@@ -63,9 +66,9 @@ FRAMEWORK_EXPORT void *bundle_getHandle(bundle_pt bundle);
 
 FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void *handle);
 
-FRAMEWORK_EXPORT activator_pt bundle_getActivator(bundle_pt bundle);
+FRAMEWORK_EXPORT celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle);
 
-FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator);
+FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator);
 
 FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/include/framework.h
----------------------------------------------------------------------
diff --git a/libs/framework/include/framework.h b/libs/framework/include/framework.h
index 5143f47..f02b784 100644
--- a/libs/framework/include/framework.h
+++ b/libs/framework/include/framework.h
@@ -27,9 +27,6 @@
 #ifndef FRAMEWORK_H_
 #define FRAMEWORK_H_
 
-typedef struct activator *activator_pt;
-typedef struct activator activator_t;
-
 typedef struct framework *framework_pt;
 typedef struct framework framework_t;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/private/mock/bundle_mock.c
----------------------------------------------------------------------
diff --git a/libs/framework/private/mock/bundle_mock.c b/libs/framework/private/mock/bundle_mock.c
index 8ab5068..c64a97b 100644
--- a/libs/framework/private/mock/bundle_mock.c
+++ b/libs/framework/private/mock/bundle_mock.c
@@ -81,12 +81,12 @@ void bundle_setHandle(bundle_pt bundle, void * handle) {
 	mock_c()->actualCall("bundle_setHandle");
 }
 
-activator_pt bundle_getActivator(bundle_pt bundle) {
+celix_bundle_activator_t *bundle_getActivator(bundle_pt bundle) {
 	mock_c()->actualCall("bundle_getActivator");
 	return mock_c()->returnValue().value.pointerValue;
 }
 
-celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
+celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator) {
 	mock_c()->actualCall("bundle_setActivator");
 	return mock_c()->returnValue().value.intValue;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/private/test/bundle_test.cpp
----------------------------------------------------------------------
diff --git a/libs/framework/private/test/bundle_test.cpp b/libs/framework/private/test/bundle_test.cpp
index 57ac1e2..f11b34d 100644
--- a/libs/framework/private/test/bundle_test.cpp
+++ b/libs/framework/private/test/bundle_test.cpp
@@ -258,10 +258,10 @@ TEST(bundle, setHandle) {
 
 TEST(bundle, getActivator) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
-	activator_pt expected = (activator_pt) 0x10;
+	celix_bundle_activator_t *expected = (celix_bundle_activator_t*) 0x10;
 	bundle->activator = expected;
 
-	activator_pt actual = bundle_getActivator(bundle);
+	celix_bundle_activator_t *actual = bundle_getActivator(bundle);
 	POINTERS_EQUAL(expected, actual);
 
 	free(bundle);
@@ -269,7 +269,7 @@ TEST(bundle, getActivator) {
 
 TEST(bundle, setActivator) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
-	activator_pt expected = (activator_pt) 0x10;
+	celix_bundle_activator_t *expected = (celix_bundle_activator_t*) 0x10;
 
 	celix_status_t status = bundle_setActivator(bundle, expected);
 	LONGS_EQUAL(CELIX_SUCCESS, status);

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/bundle.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c
index 6493c9f..bc6af4a 100644
--- a/libs/framework/src/bundle.c
+++ b/libs/framework/src/bundle.c
@@ -157,11 +157,11 @@ void bundle_setHandle(bundle_pt bundle, void * handle) {
 	bundle->handle = handle;
 }
 
-activator_pt bundle_getActivator(bundle_pt bundle) {
+celix_bundle_activator_t* bundle_getActivator(bundle_pt bundle) {
 	return bundle->activator;
 }
 
-celix_status_t bundle_setActivator(bundle_pt bundle, activator_pt activator) {
+celix_status_t bundle_setActivator(bundle_pt bundle, celix_bundle_activator_t *activator) {
 	bundle->activator = activator;
 	return CELIX_SUCCESS;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/bundle_private.h
----------------------------------------------------------------------
diff --git a/libs/framework/src/bundle_private.h b/libs/framework/src/bundle_private.h
index ea0a06e..1c295c3 100644
--- a/libs/framework/src/bundle_private.h
+++ b/libs/framework/src/bundle_private.h
@@ -24,9 +24,11 @@
 #include "bundle.h"
 #include "celix_bundle.h"
 
+
+
 struct bundle {
 	bundle_context_pt context;
-	activator_pt activator;
+	struct celix_bundle_activator *activator;
 	bundle_state_e state;
 	void * handle;
 	bundle_archive_pt archive;

http://git-wip-us.apache.org/repos/asf/celix/blob/218d265c/libs/framework/src/framework.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 8cbe183..c28153a 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -49,7 +49,7 @@ typedef celix_status_t (*start_function_fp)(void *userData, bundle_context_t *co
 typedef celix_status_t (*stop_function_fp)(void *userData, bundle_context_t *context);
 typedef celix_status_t (*destroy_function_fp)(void *userData, bundle_context_t *context);
 
-struct activator {
+struct celix_bundle_activator {
     void * userData;
 
     create_function_fp create;
@@ -454,8 +454,7 @@ celix_status_t fw_init(framework_pt framework) {
     status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
     status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
     if (status == CELIX_SUCCESS) {
-        activator_pt activator = NULL;
-        activator = (activator_pt) calloc(1,(sizeof(*activator)));
+        celix_bundle_activator_t *activator = calloc(1,(sizeof(*activator)));
         if (activator != NULL) {
             bundle_context_t *context = NULL;
             void * userData = NULL;
@@ -727,7 +726,7 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
 	bundle_context_t *context = NULL;
 	bundle_state_e state;
 	module_pt module = NULL;
-	activator_pt activator = NULL;
+    celix_bundle_activator_t *activator = NULL;
 	char *error = NULL;
 	const char *name = NULL;
 
@@ -776,7 +775,7 @@ celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int opti
                 status = CELIX_DO_IF(status, bundle_setContext(bundle, context));
 
                 if (status == CELIX_SUCCESS) {
-                    activator = (activator_pt) calloc(1,(sizeof(*activator)));
+                    activator = calloc(1,(sizeof(*activator)));
                     if (activator == NULL) {
                         status = CELIX_ENOMEM;
                     } else {
@@ -921,7 +920,7 @@ celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle,
 celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record) {
 	celix_status_t status = CELIX_SUCCESS;
 	bundle_state_e state;
-    activator_pt activator = NULL;
+    celix_bundle_activator_t *activator = NULL;
     bundle_context_t *context = NULL;
     bool wasActive = false;
     long id = 0;