[gjs] Headers: Annotate public APIs with export macros



commit 2081207c552106afd9521a61a0fe01384b578bd2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jan 16 15:54:34 2017 +0800

    Headers: Annotate public APIs with export macros
    
    Visual Studio builds use either .def files or __declspec(dllexport) to
    export public symbols, so this uses the latter approach by using a macro
    do decorate the symbols in the public headers appropriately during the
    build, and for importing when one is using the gjs library.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775868

 Makefile.am    |    1 +
 gjs/context.h  |   16 ++++++++++++++++
 gjs/coverage.h |    2 ++
 gjs/gjs.h      |    1 +
 gjs/macros.h   |   39 +++++++++++++++++++++++++++++++++++++++
 util/error.h   |    3 +++
 6 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index cfe2089..f9c8ceb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,6 +38,7 @@ nobase_gjs_public_include_HEADERS =   \
        gjs/context.h           \
        gjs/coverage.h                  \
        gjs/gjs.h                       \
+       gjs/macros.h                    \
        util/error.h                    \
        $(NULL)
 
diff --git a/gjs/context.h b/gjs/context.h
index a459e5b..f066a33 100644
--- a/gjs/context.h
+++ b/gjs/context.h
@@ -31,6 +31,8 @@
 #include <stdbool.h>
 #include <glib-object.h>
 
+#include <gjs/macros.h>
+
 G_BEGIN_DECLS
 
 typedef struct _GjsContext      GjsContext;
@@ -43,39 +45,53 @@ typedef struct _GjsContextClass GjsContextClass;
 #define GJS_IS_CONTEXT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GJS_TYPE_CONTEXT))
 #define GJS_CONTEXT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GJS_TYPE_CONTEXT, GjsContextClass))
 
+GJS_EXPORT
 GType           gjs_context_get_type             (void) G_GNUC_CONST;
 
+GJS_EXPORT
 GjsContext*     gjs_context_new                  (void);
+GJS_EXPORT
 GjsContext*     gjs_context_new_with_search_path (char         **search_path);
+GJS_EXPORT
 bool            gjs_context_eval_file            (GjsContext  *js_context,
                                                   const char    *filename,
                                                   int           *exit_status_p,
                                                   GError       **error);
+GJS_EXPORT
 bool            gjs_context_eval                 (GjsContext  *js_context,
                                                   const char    *script,
                                                   gssize         script_len,
                                                   const char    *filename,
                                                   int           *exit_status_p,
                                                   GError       **error);
+GJS_EXPORT
 bool            gjs_context_define_string_array  (GjsContext  *js_context,
                                                   const char    *array_name,
                                                   gssize         array_length,
                                                   const char   **array_values,
                                                   GError       **error);
 
+GJS_EXPORT
 GList*          gjs_context_get_all              (void);
 
+GJS_EXPORT
 GjsContext     *gjs_context_get_current          (void);
+GJS_EXPORT
 void            gjs_context_make_current         (GjsContext *js_context);
 
+GJS_EXPORT
 void*           gjs_context_get_native_context   (GjsContext *js_context);
 
+GJS_EXPORT
 void            gjs_context_print_stack_stderr    (GjsContext *js_context);
 
+GJS_EXPORT
 void            gjs_context_maybe_gc              (GjsContext  *context);
 
+GJS_EXPORT
 void            gjs_context_gc                    (GjsContext  *context);
 
+GJS_EXPORT
 void            gjs_dumpstack                     (void);
 
 G_END_DECLS
diff --git a/gjs/coverage.h b/gjs/coverage.h
index f460b1d..f0a4838 100644
--- a/gjs/coverage.h
+++ b/gjs/coverage.h
@@ -31,8 +31,10 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE(GjsCoverage, gjs_coverage, GJS, COVERAGE, GObject);
 
+GJS_EXPORT
 void gjs_coverage_write_statistics(GjsCoverage *self);
 
+GJS_EXPORT
 GjsCoverage * gjs_coverage_new(const char * const *coverage_prefixes,
                                GjsContext         *coverage_context,
                                GFile              *output_dir);
diff --git a/gjs/gjs.h b/gjs/gjs.h
index 97f9906..dbee71c 100644
--- a/gjs/gjs.h
+++ b/gjs/gjs.h
@@ -24,6 +24,7 @@
 #ifndef __GJS_GJS_H__
 #define __GJS_GJS_H__
 
+#include <gjs/macros.h>
 #include <gjs/context.h>
 #include <gjs/coverage.h>
 #include <util/error.h>
diff --git a/gjs/macros.h b/gjs/macros.h
new file mode 100644
index 0000000..05457da
--- /dev/null
+++ b/gjs/macros.h
@@ -0,0 +1,39 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (c) 2017 Chun-wei Fan
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef GJS_MACROS_H
+#define GJS_MACROS_H
+
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+# ifdef GJS_COMPILATION
+#  define GJS_EXPORT __declspec(dllexport)
+# else
+#  define GJS_EXPORT __declspec(dllimport)
+# endif
+#else
+# define GJS_EXPORT
+#endif
+
+#endif /* GJS_MACROS_H */
diff --git a/util/error.h b/util/error.h
index 01fa96b..e4ab7f1 100644
--- a/util/error.h
+++ b/util/error.h
@@ -26,8 +26,11 @@
 
 #include <glib.h>
 
+#include <gjs/macros.h>
+
 G_BEGIN_DECLS
 
+GJS_EXPORT
 GQuark gjs_error_quark(void);
 #define GJS_ERROR gjs_error_quark()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]