J
John Eskie
I'm trying to do something which I'm not sure is even possible.
I made a code generator which has a C/C++ output writer module and will in
future also have a java output writer module.
These modules will write out source code.
The generated code will need a runtime engine which is small and must be
written in the native language. I wrote one for C and now I'd like to reuse
the same source for java.
I'm unsure if there are any C compilers that can generate java bytecode but
a preprocessor would probably do in my case.
What I have in mind is something like:
typedef struct _foo
{
unsigned char H1[24];
unsigned char H2[24];
} foo;
becomming something like:
#ifdef JAVA
#define U1 byte
#else
#define U1 unsigned char
#endif
#ifdef JAVA
class foo
#else
typedef struct _foo
#endif
{
U1 H1[24];
U2 H2[24];
}
#ifndef JAVA
foo;
}
Atleast something along those lines.
The idea is to twist out those minor differences between the languages.
Before someone says this is impossible I'd like to say that my runtime will
be very small and won't have every possible language feature included so
there should be a chance to develop it.
The alternative is to have 2 codebases but thats bad if you want to have
them in sync.
Thanks in advance.
-- John
I made a code generator which has a C/C++ output writer module and will in
future also have a java output writer module.
These modules will write out source code.
The generated code will need a runtime engine which is small and must be
written in the native language. I wrote one for C and now I'd like to reuse
the same source for java.
I'm unsure if there are any C compilers that can generate java bytecode but
a preprocessor would probably do in my case.
What I have in mind is something like:
typedef struct _foo
{
unsigned char H1[24];
unsigned char H2[24];
} foo;
becomming something like:
#ifdef JAVA
#define U1 byte
#else
#define U1 unsigned char
#endif
#ifdef JAVA
class foo
#else
typedef struct _foo
#endif
{
U1 H1[24];
U2 H2[24];
}
#ifndef JAVA
foo;
}
Atleast something along those lines.
The idea is to twist out those minor differences between the languages.
Before someone says this is impossible I'd like to say that my runtime will
be very small and won't have every possible language feature included so
there should be a chance to develop it.
The alternative is to have 2 codebases but thats bad if you want to have
them in sync.
Thanks in advance.
-- John