Skip to content

Commit a0d4218

Browse files
committed
Minor refactor of R error handling code
1 parent 995b443 commit a0d4218

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

Lib/r/rrun.swg

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1-
#include <stdarg.h> // va_list, va_start, va_end
2-
#include <stdio.h> // vsnprintf
1+
/* Remove global namespace pollution */
2+
#if !defined(SWIG_NO_R_NO_REMAP)
3+
# define R_NO_REMAP
4+
#endif
5+
#if !defined(SWIG_NO_STRICT_R_HEADERS)
6+
# define STRICT_R_HEADERS
7+
#endif
8+
9+
#include <Rdefines.h>
10+
#include <Rversion.h>
11+
12+
#ifdef __cplusplus
13+
#include <exception>
14+
extern "C" {
15+
#endif
16+
17+
/* for raw pointer */
18+
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
19+
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
20+
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
21+
22+
#include <stdio.h>
23+
#include <stdlib.h>
24+
#include <assert.h>
25+
#include <stdarg.h>
26+
27+
#if R_VERSION >= R_Version(2,6,0)
28+
#define VMAXTYPE void *
29+
#else
30+
#define VMAXTYPE char *
31+
#endif
332

433
/* Last error */
534
static int SWIG_lasterror_code = 0;
@@ -12,7 +41,7 @@ SWIGRUNTIME void SWIG_Error(int code, const char *format, ...) {
1241
va_end(arg);
1342
}
1443

15-
SWIGRUNTIME const char* SWIG_ErrorType(int code) {
44+
SWIGRUNTIME const char *SWIG_ErrorType(int code) {
1645
switch (code) {
1746
case SWIG_MemoryError:
1847
return "SWIG:MemoryError";
@@ -42,37 +71,6 @@ SWIGRUNTIME const char* SWIG_ErrorType(int code) {
4271

4372
#define SWIG_fail goto fail
4473

45-
/* Remove global namespace pollution */
46-
#if !defined(SWIG_NO_R_NO_REMAP)
47-
# define R_NO_REMAP
48-
#endif
49-
#if !defined(SWIG_NO_STRICT_R_HEADERS)
50-
# define STRICT_R_HEADERS
51-
#endif
52-
53-
#include <Rdefines.h>
54-
#include <Rversion.h>
55-
56-
#ifdef __cplusplus
57-
#include <exception>
58-
extern "C" {
59-
#endif
60-
61-
/* for raw pointer */
62-
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
63-
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
64-
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
65-
66-
#include <stdio.h>
67-
#include <stdlib.h>
68-
#include <assert.h>
69-
70-
#if R_VERSION >= R_Version(2,6,0)
71-
#define VMAXTYPE void *
72-
#else
73-
#define VMAXTYPE char *
74-
#endif
75-
7674
/*
7775
This is mainly a way to avoid having lots of local variables that may
7876
conflict with those in the routine.

0 commit comments

Comments
 (0)