Browse Source

Merge pull request #1486 from ombre5733/MF-REMOVE-DUKTAPE-V1-COMPAT

Remove Duktape V1 compatibility module
JoshEngebretson 8 years ago
parent
commit
d6aab469c1

+ 1 - 1
Source/AtomicJS/Javascript/JSPlugin.cpp

@@ -194,7 +194,7 @@ namespace Atomic
         gJSVMExports.duk_push_pointer = duk_push_pointer;
         gJSVMExports.duk_push_pointer = duk_push_pointer;
         gJSVMExports.duk_push_sprintf = duk_push_sprintf;
         gJSVMExports.duk_push_sprintf = duk_push_sprintf;
         gJSVMExports.duk_push_vsprintf = duk_push_vsprintf;
         gJSVMExports.duk_push_vsprintf = duk_push_vsprintf;
-        gJSVMExports.duk_push_string_file_raw = duk_push_string_file_raw;
+        //gJSVMExports.duk_push_string_file_raw = duk_push_string_file_raw;
 
 
         gJSVMExports.duk_push_this = duk_push_this;
         gJSVMExports.duk_push_this = duk_push_this;
         gJSVMExports.duk_push_current_function = duk_push_current_function;
         gJSVMExports.duk_push_current_function = duk_push_current_function;

+ 0 - 1
Source/AtomicJS/Javascript/JSPluginExports.h

@@ -24,7 +24,6 @@
 
 
 #include <Duktape/duktape.h>
 #include <Duktape/duktape.h>
 #include <Duktape/duk_logging.h>
 #include <Duktape/duk_logging.h>
-#include <Duktape/duk_v1_compat.h>
 
 
 namespace Atomic
 namespace Atomic
 {
 {

+ 4 - 3
Source/ThirdParty/Duktape/README.TXT

@@ -8,6 +8,7 @@ python2 configure.py \
     --option-file ../config/examples/performance_sensitive.yaml \
     --option-file ../config/examples/performance_sensitive.yaml \
     --option-file ../config/examples/timing_sensitive.yaml
     --option-file ../config/examples/timing_sensitive.yaml
 
 
-An 'extern "C"' block has to be added to the headers duk_logging.h, duk_module_duktape.h and
-duk_v1_compat.h (from the directory ${DUKTAPE}/extras) to avoid C++ decoration of the function
-names.
+An 'extern "C"' block has to be added to the headers duk_logging.h and duk_module_duktape.h
+(from the directory ${DUKTAPE}/extras) to avoid C++ decoration of the function names.
+This is tracked in https://github.com/svaarala/duktape/issues/1405.
+

+ 0 - 131
Source/ThirdParty/Duktape/duk_v1_compat.c

@@ -1,131 +0,0 @@
-#include <stdio.h>
-#include "duktape.h"
-#include "duk_v1_compat.h"
-
-/*
- *  duk_dump_context_{stdout,stderr}()
- */
-
-void duk_dump_context_stdout(duk_context *ctx) {
-	duk_push_context_dump(ctx);
-	fprintf(stdout, "%s\n", duk_safe_to_string(ctx, -1));
-	duk_pop(ctx);
-}
-
-void duk_dump_context_stderr(duk_context *ctx) {
-	duk_push_context_dump(ctx);
-	fprintf(stderr, "%s\n", duk_safe_to_string(ctx, -1));
-	duk_pop(ctx);
-}
-
-/*
- *  duk_push_string_file() and duk_push_string_file_raw()
- */
-
-const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags) {
-	FILE *f = NULL;
-	char *buf;
-	long sz;  /* ANSI C typing */
-
-	if (!path) {
-		goto fail;
-	}
-	f = fopen(path, "rb");
-	if (!f) {
-		goto fail;
-	}
-	if (fseek(f, 0, SEEK_END) < 0) {
-		goto fail;
-	}
-	sz = ftell(f);
-	if (sz < 0) {
-		goto fail;
-	}
-	if (fseek(f, 0, SEEK_SET) < 0) {
-		goto fail;
-	}
-	buf = (char *) duk_push_fixed_buffer(ctx, (duk_size_t) sz);
-	if ((size_t) fread(buf, 1, (size_t) sz, f) != (size_t) sz) {
-		duk_pop(ctx);
-		goto fail;
-	}
-	(void) fclose(f);  /* ignore fclose() error */
-	return duk_buffer_to_string(ctx, -1);
-
- fail:
-	if (f) {
-		(void) fclose(f);  /* ignore fclose() error */
-	}
-
-	if (flags & DUK_STRING_PUSH_SAFE) {
-		duk_push_undefined(ctx);
-	} else {
-		duk_error(ctx, DUK_ERR_TYPE_ERROR, "read file error");
-	}
-	return NULL;
-}
-
-/*
- *  duk_eval_file(), duk_compile_file(), and their variants
- */
-
-void duk_eval_file(duk_context *ctx, const char *path) {
-	duk_push_string_file_raw(ctx, path, 0);
-	duk_push_string(ctx, path);
-	duk_compile(ctx, DUK_COMPILE_EVAL);
-	duk_push_global_object(ctx);  /* 'this' binding */
-	duk_call_method(ctx, 0);
-}
-
-void duk_eval_file_noresult(duk_context *ctx, const char *path) {
-	duk_eval_file(ctx, path);
-	duk_pop(ctx);
-}
-
-duk_int_t duk_peval_file(duk_context *ctx, const char *path) {
-	duk_int_t rc;
-
-	duk_push_string_file_raw(ctx, path, DUK_STRING_PUSH_SAFE);
-	duk_push_string(ctx, path);
-	rc = duk_pcompile(ctx, DUK_COMPILE_EVAL);
-	if (rc != 0) {
-		return rc;
-	}
-	duk_push_global_object(ctx);  /* 'this' binding */
-	rc = duk_pcall_method(ctx, 0);
-	return rc;
-}
-
-duk_int_t duk_peval_file_noresult(duk_context *ctx, const char *path) {
-	duk_int_t rc;
-
-	rc = duk_peval_file(ctx, path);
-	duk_pop(ctx);
-	return rc;
-}
-
-void duk_compile_file(duk_context *ctx, duk_uint_t flags, const char *path) {
-	duk_push_string_file_raw(ctx, path, 0);
-	duk_push_string(ctx, path);
-	duk_compile(ctx, flags);
-}
-
-duk_int_t duk_pcompile_file(duk_context *ctx, duk_uint_t flags, const char *path) {
-	duk_int_t rc;
-
-	duk_push_string_file_raw(ctx, path, DUK_STRING_PUSH_SAFE);
-	duk_push_string(ctx, path);
-	rc = duk_pcompile(ctx, flags);
-	return rc;
-}
-
-/*
- *  duk_to_defaultvalue()
- */
-
-void duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint) {
-	duk_require_type_mask(ctx, idx, DUK_TYPE_MASK_OBJECT |
-	                                DUK_TYPE_MASK_BUFFER |
-	                                DUK_TYPE_MASK_LIGHTFUNC);
-	duk_to_primitive(ctx, idx, hint);
-}

+ 0 - 36
Source/ThirdParty/Duktape/duk_v1_compat.h

@@ -1,36 +0,0 @@
-#if !defined(DUK_V1_COMPAT_INCLUDED)
-#define DUK_V1_COMPAT_INCLUDED
-
-#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
-#endif
-
-/* Flags for duk_push_string_file_raw() */
-#define DUK_STRING_PUSH_SAFE              (1 << 0)    /* no error if file does not exist */
-
-extern void duk_dump_context_stdout(duk_context *ctx);
-extern void duk_dump_context_stderr(duk_context *ctx);
-extern const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags);
-extern void duk_eval_file(duk_context *ctx, const char *path);
-extern void duk_eval_file_noresult(duk_context *ctx, const char *path);
-extern duk_int_t duk_peval_file(duk_context *ctx, const char *path);
-extern duk_int_t duk_peval_file_noresult(duk_context *ctx, const char *path);
-extern void duk_compile_file(duk_context *ctx, duk_uint_t flags, const char *path);
-extern duk_int_t duk_pcompile_file(duk_context *ctx, duk_uint_t flags, const char *path);
-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)
-} // extern "C"
-#endif
-
-#endif  /* DUK_V1_COMPAT_INCLUDED */