Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #51 from nyx-project/cleanup_core_implementation

Cleanup of core implementation and headers
  • Loading branch information...
commit 60c8a43a60864e1a58ac87709046fda35e3015b4 2 parents 4de4dc9 + 432ba31
Keith Derrick authored
View
20 include/nyx/common/nyx_core.h
@@ -24,14 +24,18 @@
/**
* @brief Nyx's public core API.
*
+ * The core API provides methods for initializing and deinitializing
+ * the library. It also provides methods for querying, at run-time,
+ * the version of the loaded library instance.
+ *
*/
#ifndef _NYX_CORE_H_
#define _NYX_CORE_H_
-#include <stdbool.h>
#include <stdint.h>
+#include <nyx/common/nyx_macros.h>
#include <nyx/common/nyx_error.h>
#ifdef __cplusplus
@@ -50,7 +54,7 @@ extern "C" {
* @return error code (NYX_ERROR_NONE if operation is successful)
*
*/
-nyx_error_t nyx_init(void);
+NYX_API_EXPORT nyx_error_t nyx_init(void);
/**
* Deinitializes Nyx library.
@@ -58,14 +62,14 @@ nyx_error_t nyx_init(void);
* @return error code (NYX_ERROR_NONE if operation is successful)
*
*/
-nyx_error_t nyx_deinit(void);
+NYX_API_EXPORT nyx_error_t nyx_deinit(void);
/**
* Returns Nyx's library version.
*
- * @return pointer to string containing Nyx version
+ * @return pointer to string containing Nyx version
*/
-const char* nyx_get_library_version(void);
+NYX_API_EXPORT const char* nyx_get_library_version(void);
/**
* @brief Returns Nyx's major API version.
@@ -74,16 +78,16 @@ const char* nyx_get_library_version(void);
*
* @return integer specifying API major version
*/
-int32_t nyx_get_api_versioni_major(void);
+NYX_API_EXPORT int32_t nyx_get_api_version_major(void);
/**
* @brief Returns Nyx's minor API version.
*
* The minor version is incremented whenever the Nyx ABI changes in a binary-compatible way.
*
- * @return integer specifying API minorversion
+ * @return integer specifying the API minor version
*/
-int32_t nyx_get_api_version_minor(void);
+NYX_API_EXPORT int32_t nyx_get_api_version_minor(void);
/** @} */
#ifdef __cplusplus
View
10 include/nyx/common/nyx_error.h
@@ -20,7 +20,7 @@
* @file nyx_error.h
*
*/
-
+
/**
* @brief Nyx's public error interface.
*
@@ -41,18 +41,18 @@ extern "C" {
/**
- * Nyx error codes
+ * Error codes returned from Nyx API functions.
*/
typedef enum {
NYX_ERROR_NONE, /**< Operation successful */
- NYX_ERROR_INVALID_HANDLE, /**< Incorrect handle passes to API function */
- NYX_ERROR_WRONG_DEVICE_TYPE, /**< Device used for this operation has the wrong type */
+ NYX_ERROR_INVALID_HANDLE, /**< Invalid handle passed to an API function */
+ NYX_ERROR_WRONG_DEVICE_TYPE, /**< Operation not defined for the supplied device */
NYX_ERROR_DEVICE_NOT_EXIST, /**< Device does not exist */
NYX_ERROR_TOO_MANY_OPENS, /**< Reached maximum opens allowed on device */
NYX_ERROR_OUT_OF_MEMORY, /**< Out of memory */
NYX_ERROR_DEVICE_UNAVAILABLE, /**< Device not present OR Connection to device not available */
NYX_ERROR_UNSUPPORTED_DEVICE_TYPE, /**< No support for this device type currently */
- NYX_ERROR_INVALID_VALUE, /**< Value passed in is not valid */
+ NYX_ERROR_INVALID_VALUE, /**< Value passed to an API function is not valid */
NYX_ERROR_NOT_IMPLEMENTED, /**< The method/function has not been implemented by module */
NYX_ERROR_INVALID_EVENT_TYPE, /**< Event is of a wrong type for this operation */
NYX_ERROR_INVALID_OPERATION, /**< This operation cannot be performed at this time */
View
2  include/nyx/common/nyx_macros.h
@@ -19,7 +19,7 @@
/**
* @file nyx_macros.h
*
- * @brief definition of NYX's macros.
+ * @brief Definition of NYX's macros.
*
*/
View
53 src/core/nyx_core_impl.c
@@ -20,7 +20,7 @@
* @file nyx_core_impl.c
*
* @brief This is a part of the nyx core implementation
- ********************************************************************************/
+ ********************************************************************************/
#include <stdlib.h>
#include <pthread.h>
@@ -29,21 +29,6 @@
#include "nyx_core_impl.h"
-struct nyx_core {
- GMainContext* main_context;
- GMainLoop* main_loop;
- pthread_t worker;
-};
-
-static struct nyx_core nyx_core;
-
-static void *nyx_worker_thread(void *arg)
-{
- g_main_loop_run(nyx_core.main_loop);
-
- return NULL;
-}
-
typedef struct typeStringPair
{
nyx_device_type_t type;
@@ -96,51 +81,15 @@ const char* nyx_core_device_type_to_string(nyx_device_type_t type)
return name;
}
-GMainLoop* nyx_core_get_mainloop()
-{
- return nyx_core.main_loop;
-}
-
-GMainContext* nyx_core_get_maincontext()
-{
- return nyx_core.main_context;
-}
-
nyx_error_t nyx_core_init()
{
nyx_log_init();
- nyx_core.main_context = g_main_context_new();
- if (NULL == nyx_core.main_context) {
- nyx_error( "Unable to create GmainContext\n");
- return NYX_ERROR_GENERIC;
- }
-
- nyx_core.main_loop = g_main_loop_new(nyx_core.main_context, FALSE);
- if (NULL == nyx_core.main_loop) {
- nyx_error("Unable to create GmainLoop\n");
- return NYX_ERROR_GENERIC;
- }
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
-
- if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0) {
- nyx_error("Unable to create pthread attribute\n");
- return NYX_ERROR_GENERIC;
- }
-
- if (pthread_create(&nyx_core.worker, &attr, nyx_worker_thread, 0)
- != 0) {
- nyx_error("Unable to create worker thread\n");
- return NYX_ERROR_GENERIC;
- }
return NYX_ERROR_NONE;
}
nyx_error_t nyx_core_deinit(void)
{
- g_main_loop_quit(nyx_core.main_loop);
return NYX_ERROR_NONE;
}
View
5 src/core/nyx_core_impl.h
@@ -20,7 +20,7 @@
* @file nyx_core_impl.h
*
* @brief This is a header file of the nyx core implementation
- ********************************************************************************/
+ ********************************************************************************/
#ifndef _NYX_CORE_IMPL_H_
#define _NYX_CORE_IMPL_H_
@@ -28,9 +28,6 @@
#include <glib.h>
#include <nyx/nyx_client.h>
-GMainLoop* nyx_core_get_mainloop (void);
-GMainContext* nyx_core_get_maincontext (void);
-
nyx_error_t nyx_core_init(void);
nyx_error_t nyx_core_deinit(void);
const char* nyx_core_device_type_to_string(nyx_device_type_t type);
View
18 src/core/nyx_impl.c
@@ -20,9 +20,9 @@
* @file nyx_impl.c
*
* @brief This is part of the nyx core implementation
- ********************************************************************************/
+ ********************************************************************************/
-#include "nyx_impl.h"
+//#include "nyx_impl.h"
#include "nyx_core_impl.h"
#include "nyx_config.h"
#include <nyx/common/nyx_version.h>
@@ -32,17 +32,7 @@ nyx_error_t nyx_init(void)
nyx_error_t error = NYX_ERROR_NONE;
error = nyx_core_init();
- if (NYX_ERROR_NONE != error) {
- goto end;
- }
- GMainLoop* main_loop = nyx_core_get_mainloop();
- if (NULL == main_loop) {
- error = NYX_ERROR_GENERIC;
- goto end;
- }
-
-end:
return error;
}
@@ -51,11 +41,7 @@ nyx_error_t nyx_deinit(void)
nyx_error_t error = NYX_ERROR_NONE;
error = nyx_core_deinit ();
- if (NYX_ERROR_NONE != error) {
- goto end;
- }
-end:
return error;
}
Please sign in to comment.
Something went wrong with that request. Please try again.