Skip to content

Commit

Permalink
Add C++ mangle wrappers for extras
Browse files Browse the repository at this point in the history
  • Loading branch information
svaarala committed Oct 22, 2017
1 parent dfc0b1c commit 6d2752c
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 1 deletion.
8 changes: 8 additions & 0 deletions extras/alloc-pool/duk_alloc_pool.h
Expand Up @@ -3,6 +3,10 @@

#include "duktape.h"

#if defined(__cplusplus)
extern "C" {
#endif

/* 32-bit (big endian) marker used at the end of pool entries so that wasted
* space can be detected. Waste tracking must be enabled explicitly.
*/
Expand Down Expand Up @@ -220,4 +224,8 @@ static DUK__ALLOC_POOL_ALWAYS_INLINE void *duk_alloc_pool_dec16(duk_uint16_t val
}
#endif

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_ALLOC_POOL_H_INCLUDED */
8 changes: 8 additions & 0 deletions extras/console/duk_console.h
Expand Up @@ -3,6 +3,10 @@

#include "duktape.h"

#if defined(__cplusplus)
extern "C" {
#endif

/* Use a proxy wrapper to make undefined methods (console.foo()) no-ops. */
#define DUK_CONSOLE_PROXY_WRAPPER (1 << 0)

Expand All @@ -11,4 +15,8 @@

extern void duk_console_init(duk_context *ctx, duk_uint_t flags);

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_CONSOLE_H_INCLUDED */
8 changes: 8 additions & 0 deletions extras/duk-v1-compat/duk_v1_compat.h
Expand Up @@ -3,6 +3,10 @@

#include "duktape.h"

#if defined(__cplusplus)
extern "C" {
#endif

/* Straight flag rename */
#if !defined(DUK_ENUM_INCLUDE_INTERNAL)
#define DUK_ENUM_INCLUDE_INTERNAL DUK_ENUM_INCLUDE_HIDDEN
Expand All @@ -25,4 +29,8 @@ extern void duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint)
#define duk_push_string_file(ctx,path) \
duk_push_string_file_raw((ctx), (path), 0)

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_V1_COMPAT_INCLUDED */
10 changes: 9 additions & 1 deletion extras/logging/duk_logging.h
Expand Up @@ -3,7 +3,11 @@

#include "duktape.h"

/* Log levels */
#if defined(__cplusplus)
extern "C" {
#endif

/* Log levels. */
#define DUK_LOG_TRACE 0
#define DUK_LOG_DEBUG 1
#define DUK_LOG_INFO 2
Expand All @@ -17,4 +21,8 @@ extern void duk_logging_init(duk_context *ctx, duk_uint_t flags);
extern void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap);
extern void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_LOGGING_H_INCLUDED */
8 changes: 8 additions & 0 deletions extras/minimal-printf/duk_minimal_printf.h
Expand Up @@ -4,9 +4,17 @@
#include <stdarg.h> /* va_list etc */
#include <stddef.h> /* size_t */

#if defined(__cplusplus)
extern "C" {
#endif

extern int duk_minimal_sprintf(char *str, const char *format, ...);
extern int duk_minimal_snprintf(char *str, size_t size, const char *format, ...);
extern int duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap);
extern int duk_minimal_sscanf(const char *str, const char *format, ...);

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_MINIMAL_PRINTF_H_INCLUDED */
8 changes: 8 additions & 0 deletions extras/module-duktape/duk_module_duktape.h
Expand Up @@ -3,6 +3,10 @@

#include "duktape.h"

#if defined(__cplusplus)
extern "C" {
#endif

/* Maximum length of CommonJS module identifier to resolve. Length includes
* both current module ID, requested (possibly relative) module ID, and a
* slash in between.
Expand All @@ -11,4 +15,8 @@

extern void duk_module_duktape_init(duk_context *ctx);

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_MODULE_DUKTAPE_H_INCLUDED */
8 changes: 8 additions & 0 deletions extras/print-alert/duk_print_alert.h
Expand Up @@ -3,8 +3,16 @@

#include "duktape.h"

#if defined(__cplusplus)
extern "C" {
#endif

/* No flags at the moment. */

extern void duk_print_alert_init(duk_context *ctx, duk_uint_t flags);

#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

#endif /* DUK_PRINT_ALERT_H_INCLUDED */

2 comments on commit 6d2752c

@remoe
Copy link
Contributor

@remoe remoe commented on 6d2752c May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
I don't find this changes in the 2.2.1 release. https://github.com/svaarala/duktape/releases/download/v2.2.1/duktape-2.2.1.tar.xz
Is this correct?

@svaarala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, it's only in master.

Please sign in to comment.