Skip to content

Commit

Permalink
Update for modula3
Browse files Browse the repository at this point in the history
  • Loading branch information
demoitem committed Jan 6, 2023
1 parent b18b753 commit ee7e848
Show file tree
Hide file tree
Showing 6 changed files with 5,864 additions and 1 deletion.
789 changes: 789 additions & 0 deletions Lib/modula3/modula3.swg

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions Lib/modula3/modula3head.swg
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* -----------------------------------------------------------------------------
* modula3head.swg
*
* Modula3 support code
* ----------------------------------------------------------------------------- */

%insert(runtime) %{

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
%}

#if 0
%insert(runtime) %{
/* Support for throwing Modula3 exceptions */
typedef enum {
SWIG_JavaOutOfMemoryError = 1,
SWIG_JavaIOException,
SWIG_JavaRuntimeException,
SWIG_JavaIndexOutOfBoundsException,
SWIG_JavaArithmeticException,
SWIG_JavaIllegalArgumentException,
SWIG_JavaNullPointerException,
SWIG_JavaUnknownError
} SWIG_JavaExceptionCodes;

typedef struct {
SWIG_JavaExceptionCodes code;
const char *java_exception;
} SWIG_JavaExceptions_t;

#if defined(SWIG_NOINCLUDE)
void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg);
#else
%}
%insert(runtime) {
void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
jclass excep;
static const SWIG_JavaExceptions_t java_exceptions[] = {
{ SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
{ SWIG_JavaIOException, "java/io/IOException" },
{ SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
{ SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
{ SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
{ SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
{ SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
{ SWIG_JavaUnknownError, "java/lang/UnknownError" },
{ (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } };
const SWIG_JavaExceptions_t *except_ptr = java_exceptions;

while (except_ptr->code != code && except_ptr->code)
except_ptr++;

JCALL0(ExceptionClear, jenv);
excep = JCALL1(FindClass, jenv, except_ptr->java_exception);
if (excep)
JCALL2(ThrowNew, jenv, excep, msg);
}
}
%insert(runtime) %{
#endif
%}
#endif
74 changes: 74 additions & 0 deletions Lib/modula3/typemaps.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/* -----------------------------------------------------------------------------
* typemaps.i
*
* Pointer and reference handling typemap library
*
* These mappings provide support for input/output arguments and common
* uses for C/C++ pointers and C++ references.
* ----------------------------------------------------------------------------- */

/* These typemaps will eventually probably maybe make their way into named typemaps
* OUTPUT * and OUTPUT & as they currently break functions that return a pointer or
* reference. */

%typemap(ctype) bool *, bool & "bool *"
%typemap(ctype) char & "char *"
%typemap(ctype) signed char *, signed char & "signed char *"
%typemap(ctype) unsigned char *, unsigned char & "unsigned short *"
%typemap(ctype) short *, short & "short *"
%typemap(ctype) unsigned short *, unsigned short & "unsigned short *"
%typemap(ctype) int *, int & "int *"
%typemap(ctype) unsigned int *, unsigned int & "unsigned int *"
%typemap(ctype) long *, long & "long *"
%typemap(ctype) unsigned long *, unsigned long & "unsigned long *"
%typemap(ctype) long long *, long long & "long long *"
%typemap(ctype) unsigned long long *, unsigned long long & "unsigned long long *"
%typemap(ctype) float *, float & "float *"
%typemap(ctype) double *, double & "double *"

%typemap(imtype) bool *, bool & "ref bool"
%typemap(imtype) char & "ref char"
%typemap(imtype) signed char *, signed char & "ref sbyte"
%typemap(imtype) unsigned char *, unsigned char & "ref byte"
%typemap(imtype) short *, short & "ref short"
%typemap(imtype) unsigned short *, unsigned short & "ref ushort"
%typemap(imtype) int *, int & "ref int"
%typemap(imtype) unsigned int *, unsigned int & "ref uint"
%typemap(imtype) long *, long & "ref int"
%typemap(imtype) unsigned long *, unsigned long & "ref uint"
%typemap(imtype) long long *, long long & "ref long"
%typemap(imtype) unsigned long long *, unsigned long long & "ref ulong"
%typemap(imtype) float *, float & "ref float"
%typemap(imtype) double *, double & "ref double"

%typemap(cstype) bool *, bool & "ref bool"
%typemap(cstype) char & "ref char"
%typemap(cstype) signed char *, signed char & "ref sbyte"
%typemap(cstype) unsigned char *, unsigned char & "ref byte"
%typemap(cstype) short *, short & "ref short"
%typemap(cstype) unsigned short *, unsigned short & "ref ushort"
%typemap(cstype) int *, int & "ref int"
%typemap(cstype) unsigned int *, unsigned int & "ref uint"
%typemap(cstype) long *, long & "ref int"
%typemap(cstype) unsigned long *, unsigned long & "ref uint"
%typemap(cstype) long long *, long long & "ref long"
%typemap(cstype) unsigned long long *, unsigned long long & "ref ulong"
%typemap(cstype) float *, float & "ref float"
%typemap(cstype) double *, double & "ref double"

%typemap(csin) bool *, bool &,
char &,
signed char *, signed char &,
unsigned char *, unsigned char &,
short *, short &,
unsigned short *, unsigned short &,
int *, int &,
unsigned int *, unsigned int &,
long *, long &,
unsigned long *, unsigned long &,
long long *, long long &,
unsigned long long *, unsigned long long &,
float *, float &,
double *, double &
"ref $csinput"

11 changes: 11 additions & 0 deletions Source/Include/swigwarn.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@
/* please leave 830-849 free for C# */

/* 850-860 were used by Modula 3 (removed in SWIG 4.1.0) - avoid reusing for now */
#define WARN_MODULA3_TYPEMAP_TYPE_UNDEF 850
#define WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF 851
#define WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF 852
#define WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF 853
#define WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN 854
#define WARN_MODULA3_MULTIPLE_INHERITANCE 855
#define WARN_MODULA3_TYPECONSTRUCTOR_UNKNOWN 856
#define WARN_MODULA3_UNKNOWN_PRAGMA 857
#define WARN_MODULA3_BAD_ENUMERATION 858
#define WARN_MODULA3_DOUBLE_ID 859
#define WARN_MODULA3_BAD_IMPORT 860

#define WARN_PHP_MULTIPLE_INHERITANCE 870
#define WARN_PHP_UNKNOWN_PRAGMA 871
Expand Down
Loading

0 comments on commit ee7e848

Please sign in to comment.