a destination directory. Default is `.'.
## Process this file with automake to produce Makefile.in
-# $Id: Makefile.am 1486 2004-11-12 10:02:54Z twisti $
+# $Id: Makefile.am 1529 2004-11-17 17:19:14Z twisti $
@SET_MAKE@
@THREAD_LIB@
natheaders: cacaoh
- CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip ./cacaoh $(CLASSES)
+ CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip \
+ ./cacaoh -d nat/ \
+ $(CLASSES)
nativetable.inc: gennativetable nat/implementednatives.data
- CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip $(top_srcdir)/gennativetable $(CLASSES) > nativetable.inc
+ CLASSPATH=$(top_srcdir)/classpath/lib/bootstrap.zip \
+ $(top_srcdir)/gennativetable \
+ $(CLASSES) \
+ > nativetable.inc
native.c: nativetable.inc
Philipp Tomsich
Christian Thalinger
- $Id: cacaoh.c 1406 2004-08-17 10:03:55Z twisti $
+ $Id: cacaoh.c 1529 2004-11-17 17:19:14Z twisti $
*/
#include "global.h"
#include "headers.h"
#include "loader.h"
+#include "options.h"
#include "tables.h"
#include "mm/boehm.h"
#include "threads/thread.h"
#include "toolbox/memory.h"
-/************************** Function: main *******************************
+/* define cacaoh options ******************************************************/
+
+#define OPT_V 2
+#define OPT_DIRECTORY 3
+
+opt_struct opts[] = {
+ { "v", true, OPT_V },
+ { "d", true, OPT_DIRECTORY },
+ { NULL, false, 0 }
+};
+
+
+/* usage ***********************************************************************
+
+ Obviously prints usage information of cacaoh.
+
+*******************************************************************************/
+
+static void usage()
+{
+ printf("Usage: cacaoh [options] <classes>\n");
+ printf("\n");
+ printf(" -v verbose\n");
+ printf(" -d <dir> output directory\n");
+
+ /* exit with error code */
+
+ exit(1);
+}
+
+
+/* main ************************************************************************
Main program.
-**************************************************************************/
+*******************************************************************************/
int main(int argc, char **argv)
{
- s4 i,a;
+ s4 i, a;
char *cp;
classinfo *c;
-
+ bool opt_v;
+ char *opt_directory;
/********** internal (only used by main) *****************************/
/************ Collect some info from the environment *****************/
- if (argc < 2) {
- printf("Usage: cacaoh class [class..]\n");
- exit(1);
- }
+ if (argc < 2)
+ usage();
cp = getenv("CLASSPATH");
if (cp) {
strcpy(classpath + strlen(classpath), cp);
}
+ /* initialize options with default values */
+
+ opt_v = false;
+ opt_directory = NULL;
+
+ while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
+ switch (i) {
+ case OPT_IGNORE:
+ break;
+
+ case OPT_V:
+ opt_v = true;
+ break;
+ case OPT_DIRECTORY:
+ opt_directory = MNEW(char, strlen(opt_arg));
+ strcpy(opt_directory, opt_arg);
+ break;
+
+ default:
+ usage();
+ }
+ }
+
/**************************** Program start **************************/
- log_init(NULL);
- log_text("Java - header-generator started");
+ if (opt_v) {
+ log_init(NULL);
+ log_text("Java - header-generator started");
+ }
/* initialize the garbage collector */
gc_init(heapmaxsize, heapstartsize);
nativemethod_chain = chain_new();
nativeclass_chain = chain_new();
- for (a = 1; a < argc; a++) {
+ for (a = opt_ind; a < argc; a++) {
cp = argv[a];
/* convert classname */
class_load(c);
class_link(c);
- headerfile_generate(c);
+ headerfile_generate(c, opt_directory);
}
/************************ Release all resources **********************/
/* Print "finished" message */
- log_text("Java - header-generator stopped");
- log_cputime();
- mem_usagelog(1);
+ if (opt_v) {
+ log_text("Java - header-generator stopped");
+ log_cputime();
+ mem_usagelog(1);
+ }
return 0;
}
Philipp Tomsich
Christian Thalinger
- $Id: headers.c 1492 2004-11-12 13:26:03Z twisti $
+ $Id: headers.c 1529 2004-11-17 17:19:14Z twisti $
*/
/* create headerfile for classes and store native methods in chain ************/
-void headerfile_generate(classinfo *c)
+void headerfile_generate(classinfo *c, char *opt_directory)
{
char header_filename[1024] = "";
char classname[1024];
/* create chain for renaming fields */
ident_chain = chain_new();
- sprintf(header_filename, "nat/%s.h", classname);
+ if (opt_directory) {
+ sprintf(header_filename, "%s/%s.h", opt_directory, classname);
+
+ } else {
+ sprintf(header_filename, "%s.h", classname);
+ }
+
file = fopen(header_filename, "w");
- if (!file) panic("Can not open file to store header information");
+ if (!file)
+ panic("Can not open file to store header information");
fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
Authors: Christian Thalinger
- $Id: headers.h 1243 2004-06-30 20:12:42Z twisti $
+ $Id: headers.h 1529 2004-11-17 17:19:14Z twisti $
*/
void printmethod(methodinfo *m);
void gen_header_filename(char *buffer, utf *u);
void printnativetableentry(methodinfo *m);
-void headerfile_generate(classinfo *c);
+void headerfile_generate(classinfo *c, char *opt_directory);
#endif /* _HEADERS_H */
- Calling the class loader
- Running the main method
- $Id: main.c 1505 2004-11-14 14:15:58Z jowenn $
+ $Id: main.c 1529 2004-11-17 17:19:14Z twisti $
*/
#endif
-/* internal function: get_opt *************************************************
-
- decodes the next command line option
-
-******************************************************************************/
-
-#define OPT_DONE -1
-#define OPT_ERROR 0
-#define OPT_IGNORE 1
+/* define command line options ************************************************/
#define OPT_CLASSPATH 2
#define OPT_D 3
#define OPT_EAGER 33
-struct {char *name; bool arg; int value;} opts[] = {
+opt_struct opts[] = {
{"classpath", true, OPT_CLASSPATH},
{"cp", true, OPT_CLASSPATH},
{"D", true, OPT_D},
{NULL, false, 0}
};
-static int opt_ind = 1;
-static char *opt_arg;
-
-
-static int get_opt(int argc, char **argv)
-{
- char *a;
- int i;
-
- if (opt_ind >= argc) return OPT_DONE;
-
- a = argv[opt_ind];
- if (a[0] != '-') return OPT_DONE;
-
- for (i = 0; opts[i].name; i++) {
- if (!opts[i].arg) {
- if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
- opt_ind++;
- return opts[i].value;
- }
-
- } else {
- if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
- opt_ind++;
- if (opt_ind < argc) {
- opt_arg = argv[opt_ind];
- opt_ind++;
- return opts[i].value;
- }
- return OPT_ERROR;
-
- } else {
- size_t l = strlen(opts[i].name);
- if (strlen(a + 1) > l) {
- if (memcmp(a + 1, opts[i].name, l) == 0) {
- opt_ind++;
- opt_arg = a + 1 + l;
- return opts[i].value;
- }
- }
- }
- }
- } /* end for */
-
- return OPT_ERROR;
-}
-
/******************** interne Function: print_usage ************************
***************************************************************************/
-static void print_usage()
+static void usage()
{
printf("USAGE: cacao [options] classname [program arguments]\n");
printf("Options:\n");
printf(" -rt .................. use rapid type analysis\n");
printf(" -xta ................. use x type analysis\n");
printf(" -vta ................. use variable type analysis\n");
+
+ /* exit with error code */
+
+ exit(1);
}
checknull = false;
opt_noieee = false;
- while ((i = get_opt(argc, argv)) != OPT_DONE) {
+ while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
switch (i) {
- case OPT_IGNORE: break;
+ case OPT_IGNORE:
+ break;
case OPT_CLASSPATH:
/* forget old classpath and set the argument as new classpath */
goto didit;
}
}
- print_usage();
- exit(10);
+ usage();
didit: ;
}
checksync = false;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
showutf = true;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
inlineoutsiders = true;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
- if (opt_ind >= argc) {
- print_usage();
- exit(10);
- }
+ if (opt_ind >= argc)
+ usage();
mainstring = argv[opt_ind++];
for (i = strlen(mainstring) - 1; i >= 0; i--) { /* Transform dots into slashes */
Authors: Christian Thalinger
- $Id: options.c 1474 2004-11-11 10:09:10Z carolyn $
+ $Id: options.c 1529 2004-11-17 17:19:14Z twisti $
*/
-#include "global.h"
+#include <string.h>
+#include "options.h"
+#include "types.h"
/* command line option */
bool opt_eager = false;
+int opt_ind = 1; /* index of processed arguments */
+char *opt_arg; /* this one exports the option argument */
+
+
+/* get_opt *********************************************************************
+
+ DOCUMENT ME!!!
+
+*******************************************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts)
+{
+ char *a;
+ int i;
+
+ if (opt_ind >= argc)
+ return OPT_DONE;
+
+ a = argv[opt_ind];
+ if (a[0] != '-')
+ return OPT_DONE;
+
+ for (i = 0; opts[i].name; i++) {
+ if (!opts[i].arg) {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
+ opt_ind++;
+ return opts[i].value;
+ }
+
+ } else {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
+ opt_ind++;
+ if (opt_ind < argc) {
+ opt_arg = argv[opt_ind];
+ opt_ind++;
+ return opts[i].value;
+ }
+ return OPT_ERROR;
+
+ } else {
+ size_t l = strlen(opts[i].name);
+ if (strlen(a + 1) > l) {
+ if (memcmp(a + 1, opts[i].name, l) == 0) {
+ opt_ind++;
+ opt_arg = a + 1 + l;
+ return opts[i].value;
+ }
+ }
+ }
+ }
+ } /* end for */
+
+ return OPT_ERROR;
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Authors: Christian Thalinger
- $Id: options.h 1474 2004-11-11 10:09:10Z carolyn $
+ $Id: options.h 1529 2004-11-17 17:19:14Z twisti $
*/
#include "global.h"
-/* global variables */
+/* reserved option numbers ****************************************************/
+
+#define OPT_DONE -1
+#define OPT_ERROR 0
+#define OPT_IGNORE 1
+
+
+typedef struct opt_struct opt_struct;
+
+struct opt_struct {
+ char *name;
+ bool arg;
+ int value;
+};
+
+
+/* global variables ***********************************************************/
extern bool compileall;
extern bool verbose;
extern bool opt_verify;
extern bool opt_eager;
+extern int opt_ind;
+extern char *opt_arg;
+
+
+/* function prototypes ********************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts);
+
#endif /* _OPTIONS_H */
- Calling the class loader
- Running the main method
- $Id: cacao.c 1505 2004-11-14 14:15:58Z jowenn $
+ $Id: cacao.c 1529 2004-11-17 17:19:14Z twisti $
*/
#endif
-/* internal function: get_opt *************************************************
-
- decodes the next command line option
-
-******************************************************************************/
-
-#define OPT_DONE -1
-#define OPT_ERROR 0
-#define OPT_IGNORE 1
+/* define command line options ************************************************/
#define OPT_CLASSPATH 2
#define OPT_D 3
#define OPT_EAGER 33
-struct {char *name; bool arg; int value;} opts[] = {
+opt_struct opts[] = {
{"classpath", true, OPT_CLASSPATH},
{"cp", true, OPT_CLASSPATH},
{"D", true, OPT_D},
{NULL, false, 0}
};
-static int opt_ind = 1;
-static char *opt_arg;
-
-
-static int get_opt(int argc, char **argv)
-{
- char *a;
- int i;
-
- if (opt_ind >= argc) return OPT_DONE;
-
- a = argv[opt_ind];
- if (a[0] != '-') return OPT_DONE;
-
- for (i = 0; opts[i].name; i++) {
- if (!opts[i].arg) {
- if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
- opt_ind++;
- return opts[i].value;
- }
-
- } else {
- if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
- opt_ind++;
- if (opt_ind < argc) {
- opt_arg = argv[opt_ind];
- opt_ind++;
- return opts[i].value;
- }
- return OPT_ERROR;
-
- } else {
- size_t l = strlen(opts[i].name);
- if (strlen(a + 1) > l) {
- if (memcmp(a + 1, opts[i].name, l) == 0) {
- opt_ind++;
- opt_arg = a + 1 + l;
- return opts[i].value;
- }
- }
- }
- }
- } /* end for */
-
- return OPT_ERROR;
-}
-
/******************** interne Function: print_usage ************************
***************************************************************************/
-static void print_usage()
+static void usage()
{
printf("USAGE: cacao [options] classname [program arguments]\n");
printf("Options:\n");
printf(" -rt .................. use rapid type analysis\n");
printf(" -xta ................. use x type analysis\n");
printf(" -vta ................. use variable type analysis\n");
+
+ /* exit with error code */
+
+ exit(1);
}
checknull = false;
opt_noieee = false;
- while ((i = get_opt(argc, argv)) != OPT_DONE) {
+ while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
switch (i) {
- case OPT_IGNORE: break;
+ case OPT_IGNORE:
+ break;
case OPT_CLASSPATH:
/* forget old classpath and set the argument as new classpath */
goto didit;
}
}
- print_usage();
- exit(10);
+ usage();
didit: ;
}
checksync = false;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
showutf = true;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
inlineoutsiders = true;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
break;
break;
default:
- print_usage();
- exit(10);
+ usage();
}
}
- if (opt_ind >= argc) {
- print_usage();
- exit(10);
- }
+ if (opt_ind >= argc)
+ usage();
mainstring = argv[opt_ind++];
for (i = strlen(mainstring) - 1; i >= 0; i--) { /* Transform dots into slashes */
Philipp Tomsich
Christian Thalinger
- $Id: cacaoh.c 1406 2004-08-17 10:03:55Z twisti $
+ $Id: cacaoh.c 1529 2004-11-17 17:19:14Z twisti $
*/
#include "global.h"
#include "headers.h"
#include "loader.h"
+#include "options.h"
#include "tables.h"
#include "mm/boehm.h"
#include "threads/thread.h"
#include "toolbox/memory.h"
-/************************** Function: main *******************************
+/* define cacaoh options ******************************************************/
+
+#define OPT_V 2
+#define OPT_DIRECTORY 3
+
+opt_struct opts[] = {
+ { "v", true, OPT_V },
+ { "d", true, OPT_DIRECTORY },
+ { NULL, false, 0 }
+};
+
+
+/* usage ***********************************************************************
+
+ Obviously prints usage information of cacaoh.
+
+*******************************************************************************/
+
+static void usage()
+{
+ printf("Usage: cacaoh [options] <classes>\n");
+ printf("\n");
+ printf(" -v verbose\n");
+ printf(" -d <dir> output directory\n");
+
+ /* exit with error code */
+
+ exit(1);
+}
+
+
+/* main ************************************************************************
Main program.
-**************************************************************************/
+*******************************************************************************/
int main(int argc, char **argv)
{
- s4 i,a;
+ s4 i, a;
char *cp;
classinfo *c;
-
+ bool opt_v;
+ char *opt_directory;
/********** internal (only used by main) *****************************/
/************ Collect some info from the environment *****************/
- if (argc < 2) {
- printf("Usage: cacaoh class [class..]\n");
- exit(1);
- }
+ if (argc < 2)
+ usage();
cp = getenv("CLASSPATH");
if (cp) {
strcpy(classpath + strlen(classpath), cp);
}
+ /* initialize options with default values */
+
+ opt_v = false;
+ opt_directory = NULL;
+
+ while ((i = get_opt(argc, argv, opts)) != OPT_DONE) {
+ switch (i) {
+ case OPT_IGNORE:
+ break;
+
+ case OPT_V:
+ opt_v = true;
+ break;
+ case OPT_DIRECTORY:
+ opt_directory = MNEW(char, strlen(opt_arg));
+ strcpy(opt_directory, opt_arg);
+ break;
+
+ default:
+ usage();
+ }
+ }
+
/**************************** Program start **************************/
- log_init(NULL);
- log_text("Java - header-generator started");
+ if (opt_v) {
+ log_init(NULL);
+ log_text("Java - header-generator started");
+ }
/* initialize the garbage collector */
gc_init(heapmaxsize, heapstartsize);
nativemethod_chain = chain_new();
nativeclass_chain = chain_new();
- for (a = 1; a < argc; a++) {
+ for (a = opt_ind; a < argc; a++) {
cp = argv[a];
/* convert classname */
class_load(c);
class_link(c);
- headerfile_generate(c);
+ headerfile_generate(c, opt_directory);
}
/************************ Release all resources **********************/
/* Print "finished" message */
- log_text("Java - header-generator stopped");
- log_cputime();
- mem_usagelog(1);
+ if (opt_v) {
+ log_text("Java - header-generator stopped");
+ log_cputime();
+ mem_usagelog(1);
+ }
return 0;
}
Philipp Tomsich
Christian Thalinger
- $Id: headers.c 1492 2004-11-12 13:26:03Z twisti $
+ $Id: headers.c 1529 2004-11-17 17:19:14Z twisti $
*/
/* create headerfile for classes and store native methods in chain ************/
-void headerfile_generate(classinfo *c)
+void headerfile_generate(classinfo *c, char *opt_directory)
{
char header_filename[1024] = "";
char classname[1024];
/* create chain for renaming fields */
ident_chain = chain_new();
- sprintf(header_filename, "nat/%s.h", classname);
+ if (opt_directory) {
+ sprintf(header_filename, "%s/%s.h", opt_directory, classname);
+
+ } else {
+ sprintf(header_filename, "%s.h", classname);
+ }
+
file = fopen(header_filename, "w");
- if (!file) panic("Can not open file to store header information");
+ if (!file)
+ panic("Can not open file to store header information");
fprintf(file, "/* This file is machine generated, don't edit it !*/\n\n");
Authors: Christian Thalinger
- $Id: headers.h 1243 2004-06-30 20:12:42Z twisti $
+ $Id: headers.h 1529 2004-11-17 17:19:14Z twisti $
*/
void printmethod(methodinfo *m);
void gen_header_filename(char *buffer, utf *u);
void printnativetableentry(methodinfo *m);
-void headerfile_generate(classinfo *c);
+void headerfile_generate(classinfo *c, char *opt_directory);
#endif /* _HEADERS_H */
Authors: Christian Thalinger
- $Id: options.c 1474 2004-11-11 10:09:10Z carolyn $
+ $Id: options.c 1529 2004-11-17 17:19:14Z twisti $
*/
-#include "global.h"
+#include <string.h>
+#include "options.h"
+#include "types.h"
/* command line option */
bool opt_eager = false;
+int opt_ind = 1; /* index of processed arguments */
+char *opt_arg; /* this one exports the option argument */
+
+
+/* get_opt *********************************************************************
+
+ DOCUMENT ME!!!
+
+*******************************************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts)
+{
+ char *a;
+ int i;
+
+ if (opt_ind >= argc)
+ return OPT_DONE;
+
+ a = argv[opt_ind];
+ if (a[0] != '-')
+ return OPT_DONE;
+
+ for (i = 0; opts[i].name; i++) {
+ if (!opts[i].arg) {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
+ opt_ind++;
+ return opts[i].value;
+ }
+
+ } else {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
+ opt_ind++;
+ if (opt_ind < argc) {
+ opt_arg = argv[opt_ind];
+ opt_ind++;
+ return opts[i].value;
+ }
+ return OPT_ERROR;
+
+ } else {
+ size_t l = strlen(opts[i].name);
+ if (strlen(a + 1) > l) {
+ if (memcmp(a + 1, opts[i].name, l) == 0) {
+ opt_ind++;
+ opt_arg = a + 1 + l;
+ return opts[i].value;
+ }
+ }
+ }
+ }
+ } /* end for */
+
+ return OPT_ERROR;
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Authors: Christian Thalinger
- $Id: options.h 1474 2004-11-11 10:09:10Z carolyn $
+ $Id: options.h 1529 2004-11-17 17:19:14Z twisti $
*/
#include "global.h"
-/* global variables */
+/* reserved option numbers ****************************************************/
+
+#define OPT_DONE -1
+#define OPT_ERROR 0
+#define OPT_IGNORE 1
+
+
+typedef struct opt_struct opt_struct;
+
+struct opt_struct {
+ char *name;
+ bool arg;
+ int value;
+};
+
+
+/* global variables ***********************************************************/
extern bool compileall;
extern bool verbose;
extern bool opt_verify;
extern bool opt_eager;
+extern int opt_ind;
+extern char *opt_arg;
+
+
+/* function prototypes ********************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts);
+
#endif /* _OPTIONS_H */