Skip to content

Commit 95a2a51

Browse files
committed
Remove EXTERN_C macros and use block based solution
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent 684ed72 commit 95a2a51

File tree

15 files changed

+149
-198
lines changed

15 files changed

+149
-198
lines changed

jerry-core/jerry-api.h

Lines changed: 32 additions & 75 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,9 +23,7 @@
2223
#include <sys/types.h>
2324

2425
#ifdef __cplusplus
25-
# define EXTERN_C "C"
26-
#else /* !__cplusplus */
27-
# define EXTERN_C
26+
extern "C" {
2827
#endif /* !__cplusplus */
2928

3029
/** \addtogroup jerry Jerry engine interface
@@ -147,25 +146,25 @@ typedef bool (*jerry_object_field_foreach_t) (const jerry_api_string_t *field_na
147146
/**
148147
* Returns whether the given jerry_api_value_t is void.
149148
*/
150-
extern EXTERN_C bool
149+
bool
151150
jerry_api_value_is_void (const jerry_api_value_t *value_p);
152151

153152
/**
154153
* Returns whether the given jerry_api_value_t is null.
155154
*/
156-
extern EXTERN_C bool
155+
bool
157156
jerry_api_value_is_null (const jerry_api_value_t *value_p);
158157

159158
/**
160159
* Returns whether the given jerry_api_value_t is undefined.
161160
*/
162-
extern EXTERN_C bool
161+
bool
163162
jerry_api_value_is_undefined (const jerry_api_value_t *value_p);
164163

165164
/**
166165
* Returns whether the given jerry_api_value_t has boolean type.
167166
*/
168-
extern EXTERN_C bool
167+
bool
169168
jerry_api_value_is_boolean (const jerry_api_value_t *value_p);
170169

171170
/**
@@ -174,19 +173,19 @@ jerry_api_value_is_boolean (const jerry_api_value_t *value_p);
174173
* More specifically, returns true if the type is JERRY_API_DATA_TYPE_FLOAT32,
175174
* JERRY_API_DATA_TYPE_FLOAT64 or JERRY_API_DATA_TYPE_UINT32, false otherwise.
176175
*/
177-
extern EXTERN_C bool
176+
bool
178177
jerry_api_value_is_number (const jerry_api_value_t *value_p);
179178

180179
/**
181180
* Returns whether the given jerry_api_value_t is string.
182181
*/
183-
extern EXTERN_C bool
182+
bool
184183
jerry_api_value_is_string (const jerry_api_value_t *value_p);
185184

186185
/**
187186
* Returns whether the given jerry_api_value_t is object.
188187
*/
189-
extern EXTERN_C bool
188+
bool
190189
jerry_api_value_is_object (const jerry_api_value_t *value_p);
191190

192191
/**
@@ -197,15 +196,15 @@ jerry_api_value_is_object (const jerry_api_value_t *value_p);
197196
* jerry_api_is_function() functiron return true for its v_object member,
198197
* otherwise false.
199198
*/
200-
extern EXTERN_C bool
199+
bool
201200
jerry_api_value_is_function (const jerry_api_value_t *value_p);
202201

203202
/**
204203
* Returns the boolean v_bool member of the given jerry_api_value_t structure.
205204
* If the given jerry_api_value_t structure has type other than
206205
* JERRY_API_DATA_TYPE_BOOLEAN, JERRY_ASSERT fails.
207206
*/
208-
extern EXTERN_C bool
207+
bool
209208
jerry_api_get_boolean_value (const jerry_api_value_t *value_p);
210209

211210
/**
@@ -219,171 +218,129 @@ jerry_api_get_boolean_value (const jerry_api_value_t *value_p);
219218
* JERRY_API_DATA_TYPE_FLOAT64 the function returns the v_float64 member.
220219
* As long as the type is none of the above, JERRY_ASSERT falis.
221220
*/
222-
extern EXTERN_C double
221+
double
223222
jerry_api_get_number_value (const jerry_api_value_t *value_p);
224223

225224
/**
226225
* Returns the v_string member of the given jerry_api_value_t structure.
227226
* If the given jerry_api_value_t structure has type other than
228227
* JERRY_API_DATA_TYPE_STRING, JERRY_ASSERT fails.
229228
*/
230-
extern EXTERN_C jerry_api_string_t *
229+
jerry_api_string_t *
231230
jerry_api_get_string_value (const jerry_api_value_t *value_p);
232231

233232
/**
234233
* Returns the v_object member of the given jerry_api_value_t structure.
235234
* If the given jerry_api_value_t structure has type other than
236235
* JERRY_API_DATA_TYPE_OBJECT, JERRY_ASSERT fails.
237236
*/
238-
extern EXTERN_C jerry_api_object_t *
237+
jerry_api_object_t *
239238
jerry_api_get_object_value (const jerry_api_value_t *value_p);
240239

241240
/**
242241
* Creates and returns a jerry_api_value_t with type
243242
* JERRY_API_DATA_TYPE_VOID.
244243
*/
245-
extern EXTERN_C jerry_api_value_t
244+
jerry_api_value_t
246245
jerry_api_create_void_value (void);
247246

248247
/**
249248
* Creates and returns a jerry_api_value_t with type
250249
* JERRY_API_DATA_TYPE_NULL.
251250
*/
252-
extern EXTERN_C jerry_api_value_t
251+
jerry_api_value_t
253252
jerry_api_create_null_value (void);
254253

255254
/**
256255
* Creates and returns a jerry_api_value_t with type
257256
* JERRY_API_DATA_TYPE_UNDEFINED.
258257
*/
259-
extern EXTERN_C jerry_api_value_t
258+
jerry_api_value_t
260259
jerry_api_create_undefined_value (void);
261260

262261
/**
263262
* Creates a JERRY_API_DATA_TYPE_BOOLEAN jerry_api_value_t from the given
264263
* boolean parameter and returns with it.
265264
*/
266-
extern EXTERN_C jerry_api_value_t
265+
jerry_api_value_t
267266
jerry_api_create_boolean_value (bool value);
268267

269268
/**
270269
* Creates a jerry_api_value_t from the given double parameter and returns
271270
* with it.
272271
* The v_float64 member will be set and the will be JERRY_API_DATA_TYPE_FLOAT64.
273272
*/
274-
extern EXTERN_C jerry_api_value_t
273+
jerry_api_value_t
275274
jerry_api_create_number_value (double value);
276275

277276
/**
278277
* Creates a JERRY_API_DATA_TYPE_OBJECT type jerry_api_value_t from the
279278
* given jerry_api_object_t *parameter and returns with it.
280279
*/
281-
extern EXTERN_C jerry_api_value_t
280+
jerry_api_value_t
282281
jerry_api_create_object_value (jerry_api_object_t *value);
283282

284283
/**
285284
* Creates a JERRY_API_DATA_TYPE_STRING type jerry_api_value_t from the
286285
* given jerry_api_string_t *parameter and returns with it.
287286
*/
288-
extern EXTERN_C jerry_api_value_t
289-
jerry_api_create_string_value (jerry_api_string_t *value);
287+
jerry_api_value_t jerry_api_create_string_value (jerry_api_string_t *value);
290288

291-
extern EXTERN_C ssize_t
292-
jerry_api_string_to_char_buffer (const jerry_api_string_t *, jerry_api_char_t *, ssize_t);
293-
extern EXTERN_C
289+
ssize_t jerry_api_string_to_char_buffer (const jerry_api_string_t *, jerry_api_char_t *, ssize_t);
294290
jerry_api_string_t *jerry_api_acquire_string (jerry_api_string_t *);
295-
extern EXTERN_C
296-
void jerry_api_release_string (jerry_api_string_t *);
297-
298-
extern EXTERN_C
299291
jerry_api_object_t *jerry_api_acquire_object (jerry_api_object_t *);
300-
extern EXTERN_C
301-
void jerry_api_release_object (jerry_api_object_t *);
302292

303-
extern EXTERN_C
293+
void jerry_api_release_object (jerry_api_object_t *);
294+
void jerry_api_release_string (jerry_api_string_t *);
304295
void jerry_api_release_value (jerry_api_value_t *);
305296

306-
extern EXTERN_C
297+
jerry_api_object_t *jerry_api_create_array_object (jerry_api_size_t);
298+
jerry_api_object_t *jerry_api_create_object (void);
307299
jerry_api_string_t *jerry_api_create_string (const jerry_api_char_t *);
308-
extern EXTERN_C
309300
jerry_api_string_t *jerry_api_create_string_sz (const jerry_api_char_t *, jerry_api_size_t);
310-
extern EXTERN_C
311-
jerry_api_object_t *jerry_api_create_object (void);
312301

313-
extern EXTERN_C
314-
jerry_api_object_t *jerry_api_create_array_object (jerry_api_size_t);
315-
extern EXTERN_C
316302
bool jerry_api_set_array_index_value (jerry_api_object_t *, jerry_api_length_t, jerry_api_value_t *);
317-
extern EXTERN_C
318303
bool jerry_api_get_array_index_value (jerry_api_object_t *, jerry_api_length_t, jerry_api_value_t *);
319304

320-
extern EXTERN_C
321305
jerry_api_object_t *jerry_api_create_error (jerry_api_error_t, const jerry_api_char_t *);
322-
extern EXTERN_C
323306
jerry_api_object_t *jerry_api_create_error_sz (jerry_api_error_t, const jerry_api_char_t *, jerry_api_size_t);
324-
extern EXTERN_C
325307
jerry_api_object_t *jerry_api_create_external_function (jerry_external_handler_t);
326308

327-
extern EXTERN_C
328-
bool jerry_api_is_function (const jerry_api_object_t *);
329-
extern EXTERN_C
330309
bool jerry_api_is_constructor (const jerry_api_object_t *);
310+
bool jerry_api_is_function (const jerry_api_object_t *);
331311

332-
extern EXTERN_C
333312
bool jerry_api_add_object_field (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
334313
const jerry_api_value_t *, bool);
335-
extern EXTERN_C
336314
bool jerry_api_delete_object_field (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t);
337-
extern EXTERN_C
338-
bool jerry_api_get_object_field_value (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_value_t *);
339315

340-
extern EXTERN_C
316+
bool jerry_api_get_object_field_value (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_value_t *);
341317
bool jerry_api_get_object_field_value_sz (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
342318
jerry_api_value_t *);
343319

344-
extern EXTERN_C
345320
bool jerry_api_set_object_field_value (jerry_api_object_t *, const jerry_api_char_t *, const jerry_api_value_t *);
346-
347-
extern EXTERN_C
348321
bool jerry_api_set_object_field_value_sz (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
349322
const jerry_api_value_t *);
350323

351-
extern EXTERN_C
352324
bool jerry_api_foreach_object_field (jerry_api_object_t *, jerry_object_field_foreach_t, void *);
353-
354-
extern EXTERN_C
355325
bool jerry_api_get_object_native_handle (jerry_api_object_t *, uintptr_t *);
356-
357-
extern EXTERN_C
358326
void jerry_api_set_object_native_handle (jerry_api_object_t *, uintptr_t, jerry_object_free_callback_t);
359-
360-
extern EXTERN_C
361327
bool jerry_api_call_function (jerry_api_object_t *, jerry_api_object_t *, jerry_api_value_t *,
362328
const jerry_api_value_t[], uint16_t);
363-
364-
extern EXTERN_C
365329
bool jerry_api_construct_object (jerry_api_object_t *, jerry_api_value_t *, const jerry_api_value_t[], uint16_t);
366-
367-
extern EXTERN_C
368330
jerry_completion_code_t jerry_api_eval (const jerry_api_char_t *, size_t, bool, bool, jerry_api_value_t *);
369-
370-
extern EXTERN_C
371331
jerry_api_object_t *jerry_api_get_global (void);
372332

373-
extern EXTERN_C
374333
void jerry_api_gc (void);
375-
376-
extern EXTERN_C
377334
void jerry_register_external_magic_strings (const jerry_api_char_ptr_t *, uint32_t, const jerry_api_length_t *);
378335

379-
extern EXTERN_C
380336
size_t jerry_parse_and_save_snapshot (const jerry_api_char_t *, size_t, bool, uint8_t *, size_t);
381-
382-
extern EXTERN_C
383337
jerry_completion_code_t jerry_exec_snapshot (const void *, size_t, bool, jerry_api_value_t *);
384338

385339
/**
386340
* @}
387341
*/
388342

343+
#ifdef __cplusplus
344+
}
345+
#endif /* !__cplusplus */
389346
#endif /* !JERRY_API_H */

jerry-core/jerry-port.h

Lines changed: 6 additions & 9 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,9 +20,7 @@
1920
#include <stdio.h>
2021

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

2726
/** \addtogroup jerry_port Jerry engine port
@@ -31,17 +30,15 @@
3130
/**
3231
* Target port functions for console output
3332
*/
34-
extern EXTERN_C
3533
int jerry_port_logmsg (FILE *stream, const char *format, ...);
36-
37-
extern EXTERN_C
3834
int jerry_port_errormsg (const char *format, ...);
39-
40-
extern EXTERN_C
4135
int jerry_port_putchar (int c);
4236

4337
/**
4438
* @}
4539
*/
4640

4741
#endif /* !JERRY_API_H */
42+
#ifdef __cplusplus
43+
}
44+
#endif /* !__cplusplus */

0 commit comments

Comments
 (0)