Skip to content

Commit 17766ef

Browse files
committed
Remove EXTERN_C macros and use block based solution
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
1 parent 415293f commit 17766ef

File tree

12 files changed

+510
-562
lines changed

12 files changed

+510
-562
lines changed

jerry-core/jerry-api.h

Lines changed: 311 additions & 353 deletions
Large diffs are not rendered by default.

jerry-core/jerry-port.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
2+
* Copyright 2016 University of Szeged.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
@@ -19,29 +20,26 @@
1920
#include <stdio.h>
2021

2122
#ifdef __cplusplus
22-
# define EXTERN_C "C"
23-
#else /* !__cplusplus */
24-
# define EXTERN_C
23+
extern "C"
24+
{
2525
#endif /* !__cplusplus */
2626

2727
/** \addtogroup jerry_port Jerry engine port
2828
* @{
2929
*/
3030

31-
/**
32-
* Target port functions for console output
33-
*/
34-
extern EXTERN_C
35-
int jerry_port_logmsg (FILE *stream, const char *format, ...);
36-
37-
extern EXTERN_C
38-
int jerry_port_errormsg (const char *format, ...);
39-
40-
extern EXTERN_C
41-
int jerry_port_putchar (int c);
31+
/**
32+
* Target port functions for console output
33+
*/
34+
int jerry_port_logmsg (FILE *stream, const char *format, ...);
35+
int jerry_port_errormsg (const char *format, ...);
36+
int jerry_port_putchar (int c);
4237

4338
/**
4439
* @}
4540
*/
4641

4742
#endif /* !JERRY_API_H */
43+
#ifdef __cplusplus
44+
} /* */
45+
#endif /* !__cplusplus */

jerry-core/jerry.h

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
2+
* Copyright 2016 University of Szeged.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
@@ -22,15 +23,15 @@
2223
#include "jerry-api.h"
2324
#include "jerry-port.h"
2425

26+
#ifdef __cplusplus
27+
extern "C"
28+
{
29+
#endif /* !__cplusplus */
30+
2531
/** \addtogroup jerry Jerry engine interface
2632
* @{
2733
*/
2834

29-
/**
30-
* Jerry flags
31-
*/
32-
typedef uint32_t jerry_flag_t;
33-
3435
#define JERRY_FLAG_EMPTY (0u) /**< empty flag set */
3536
#define JERRY_FLAG_SHOW_OPCODES (1u << 0) /**< dump byte-code to stdout after parse */
3637
#define JERRY_FLAG_MEM_STATS (1u << 1) /**< dump memory statistics */
@@ -43,70 +44,74 @@ typedef uint32_t jerry_flag_t;
4344
#define JERRY_FLAG_ENABLE_LOG (1u << 5) /**< enable logging */
4445
#define JERRY_FLAG_ABORT_ON_FAIL (1u << 6) /**< abort instead of exit in case of failure */
4546

46-
/**
47-
* Error codes
48-
*/
49-
typedef enum
50-
{
51-
ERR_OUT_OF_MEMORY = 10,
52-
ERR_SYSCALL = 11,
53-
ERR_REF_COUNT_LIMIT = 12,
54-
ERR_UNIMPLEMENTED_CASE = 118,
55-
ERR_FAILED_INTERNAL_ASSERTION = 120
56-
} jerry_fatal_code_t;
57-
58-
/**
59-
* Jerry engine build date
60-
*/
61-
extern const char *jerry_build_date;
62-
63-
/**
64-
* Jerry engine build commit hash
65-
*/
66-
extern const char *jerry_commit_hash;
67-
68-
/**
69-
* Jerry engine build branch name
70-
*/
71-
extern const char *jerry_branch_name;
47+
/**
48+
* Jerry flags
49+
*/
50+
typedef uint32_t jerry_flag_t;
51+
52+
/**
53+
* Error codes
54+
*/
55+
typedef enum
56+
{
57+
ERR_OUT_OF_MEMORY = 10,
58+
ERR_SYSCALL = 11,
59+
ERR_REF_COUNT_LIMIT = 12,
60+
ERR_UNIMPLEMENTED_CASE = 118,
61+
ERR_FAILED_INTERNAL_ASSERTION = 120
62+
} jerry_fatal_code_t;
63+
64+
/**
65+
* Jerry engine build date
66+
*/
67+
extern const char *jerry_build_date;
68+
69+
/**
70+
* Jerry engine build commit hash
71+
*/
72+
extern const char *jerry_commit_hash;
73+
74+
/**
75+
* Jerry engine build branch name
76+
*/
77+
extern const char *jerry_branch_name;
7278

7379
#ifdef JERRY_ENABLE_LOG
74-
extern int jerry_debug_level;
75-
extern FILE *jerry_log_file;
80+
extern int jerry_debug_level;
81+
extern FILE *jerry_log_file;
7682
#endif /* JERRY_ENABLE_LOG */
7783

78-
/**
79-
* Jerry error callback type
80-
*/
81-
typedef void (*jerry_error_callback_t) (jerry_fatal_code_t);
84+
/**
85+
* Jerry error callback type
86+
*/
87+
typedef void (*jerry_error_callback_t) (jerry_fatal_code_t);
8288

83-
extern EXTERN_C void jerry_init (jerry_flag_t);
84-
extern EXTERN_C void jerry_cleanup (void);
8589

86-
extern EXTERN_C void jerry_get_memory_limits (size_t *, size_t *);
87-
extern EXTERN_C void jerry_reg_err_callback (jerry_error_callback_t);
90+
void jerry_init (jerry_flag_t);
91+
void jerry_cleanup (void);
8892

89-
extern EXTERN_C bool jerry_parse (const jerry_api_char_t *, size_t);
90-
extern EXTERN_C jerry_completion_code_t jerry_run (void);
93+
void jerry_get_memory_limits (size_t *, size_t *);
94+
void jerry_reg_err_callback (jerry_error_callback_t);
9195

92-
extern EXTERN_C jerry_completion_code_t
93-
jerry_run_simple (const jerry_api_char_t *, size_t, jerry_flag_t);
96+
bool jerry_parse (const jerry_api_char_t *, size_t);
97+
jerry_completion_code_t jerry_run (void);
98+
jerry_completion_code_t jerry_run_simple (const jerry_api_char_t *, size_t, jerry_flag_t);
9499

95100
#ifdef CONFIG_JERRY_ENABLE_CONTEXTS
96101
/** \addtogroup jerry Jerry run contexts-related interface
97102
* @{
98103
*/
99104

100-
/**
101-
* Jerry run context descriptor
102-
*/
103-
typedef struct jerry_ctx_t jerry_ctx_t;
105+
/**
106+
* Jerry run context descriptor
107+
*/
108+
typedef struct jerry_ctx_t jerry_ctx_t;
104109

105-
extern EXTERN_C jerry_ctx_t *jerry_new_ctx (void);
106-
extern EXTERN_C void jerry_cleanup_ctx (jerry_ctx_t *);
110+
jerry_ctx_t *jerry_new_ctx (void);
111+
void jerry_cleanup_ctx (jerry_ctx_t *);
107112

108-
extern EXTERN_C void jerry_push_ctx (jerry_ctx_t *);
109-
extern EXTERN_C void jerry_pop_ctx (void);
113+
void jerry_push_ctx (jerry_ctx_t *);
114+
void jerry_pop_ctx (void);
110115

111116
/**
112117
* @}
@@ -117,4 +122,7 @@ extern EXTERN_C void jerry_pop_ctx (void);
117122
* @}
118123
*/
119124

125+
#ifdef __cplusplus
126+
} /* */
127+
#endif /* !__cplusplus */
120128
#endif /* !JERRY_H */

jerry-libc/include/ctype.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

jerry-libc/include/setjmp.h

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
2+
* Copyright 2016 University of Szeged.
23
*
34
* Licensed under the Apache License, Version 2.0 (the "License");
45
* you may not use this file except in compliance with the License.
@@ -19,44 +20,46 @@
1920
#include <stdint.h>
2021

2122
#ifdef __cplusplus
22-
# define EXTERN_C "C"
23-
#else /* !__cplusplus */
24-
# define EXTERN_C
23+
extern "C"
24+
{
2525
#endif /* !__cplusplus */
2626

27-
/**
28-
* Storage for context, used for nonlocal goto
29-
*
30-
* x86_64 (8 * 8 + 2 bytes):
31-
* 0x00 - %rsp
32-
* 0x08 - return address
33-
* 0x10 - %rbp
34-
* 0x18 - %rbx
35-
* 0x20 - %r12
36-
* 0x28 - %r13
37-
* 0x30 - %r14
38-
* 0x38 - %r15
39-
* 0x40 - x87 control word
40-
*
41-
* x86_32 (6 * 4 + 2 bytes):
42-
* - %ebx
43-
* - %esp
44-
* - %ebp
45-
* - %esi
46-
* - %edi
47-
* - return address (to jump to upon longjmp)
48-
* - x87 control word
49-
*
50-
* ARMv7 (10 * 4 + 16 * 4 bytes):
51-
* - r4 - r11, sp, lr
52-
* - s16 - s31 (if hardfp enabled)
53-
*
54-
* See also:
55-
* setjmp, longjmp
56-
*/
57-
typedef uint64_t jmp_buf[14];
27+
/**
28+
* Storage for context, used for nonlocal goto
29+
*
30+
* x86_64 (8 * 8 + 2 bytes):
31+
* 0x00 - %rsp
32+
* 0x08 - return address
33+
* 0x10 - %rbp
34+
* 0x18 - %rbx
35+
* 0x20 - %r12
36+
* 0x28 - %r13
37+
* 0x30 - %r14
38+
* 0x38 - %r15
39+
* 0x40 - x87 control word
40+
*
41+
* x86_32 (6 * 4 + 2 bytes):
42+
* - %ebx
43+
* - %esp
44+
* - %ebp
45+
* - %esi
46+
* - %edi
47+
* - return address (to jump to upon longjmp)
48+
* - x87 control word
49+
*
50+
* ARMv7 (10 * 4 + 16 * 4 bytes):
51+
* - r4 - r11, sp, lr
52+
* - s16 - s31 (if hardfp enabled)
53+
*
54+
* See also:
55+
* setjmp, longjmp
56+
*/
57+
typedef uint64_t jmp_buf[14];
5858

59-
extern EXTERN_C int setjmp (jmp_buf env);
60-
extern EXTERN_C void longjmp (jmp_buf env, int val);
59+
int setjmp (jmp_buf env);
60+
void longjmp (jmp_buf env, int val);
6161

62+
#ifdef __cplusplus
63+
} /* */
64+
#endif /* !__cplusplus */
6265
#endif /* !JERRY_LIBC_SETJMP_H */

0 commit comments

Comments
 (0)