Commit 2081207c authored by Chun-wei Fan's avatar Chun-wei Fan Committed by Philip Chimento

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
parent 5ef8799a
......@@ -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)
......
......@@ -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
......
......@@ -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);
......
......@@ -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>
......
/* -*- 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 */
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment