This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
new option -fconstant-string-class added to the Objective-C frontend
- To: gcc-patches at gcc dot gnu dot org
- Subject: new option -fconstant-string-class added to the Objective-C frontend
- From: Ovidiu Predescu <ovidiu at cup dot hp dot com>
- Date: Sun, 06 Aug 2000 10:49:14 -0700
Hi,
The following patch adds a new option, -fconstant-string-class=<class name> to
the GNU Objective-C front-end. This option allows specifying a different class
name to be generated for Objective-C constant strings instead of the default
NXConstantString. This allows user level libraries, like GNUstep, to control
what constant string class is generated.
I've checked-in the changes.
Regards,
Ovidiu
Sun Aug 6 00:54:42 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
* objc/objc-act.c: New command line option -fconstant-string-class
to allow specifying a user defined constant string class,
different from NXConstantString.
* toplev.c: Moved the Objective-C specific options to
objc/lang-options.h.
* objc/lang-options.h: Moved the Objective-C specific options from
toplev.c. Added -fconstant-string-class.
* java/lang-options.h: Added a comma after the last element to avoid
syntax errors when other languages define additional options.
Index: gcc/java/lang-options.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang-options.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lang-options.h 2000/05/02 20:32:30 1.14
+++ lang-options.h 2000/08/06 07:47:20 1.15
@@ -50,4 +50,4 @@
{ "-fno-use-divide-subroutine", "Use built-in instructions for division" },
{ "-Wredundant-modifiers",
"Warn if modifiers are specified when not necessary"},
- { "-Wunsupported-jdk11", "Warn if `final' local variables are specified"}
+ { "-Wunsupported-jdk11", "Warn if `final' local variables are specified"},
Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/objc/objc-act.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- objc-act.c 2000/08/04 01:30:06 1.48
+++ objc-act.c 2000/08/06 07:54:40 1.49
@@ -374,6 +374,8 @@
#define STRING_OBJECT_CLASS_NAME "NXConstantString"
#define PROTOCOL_OBJECT_CLASS_NAME "Protocol"
+static const char *constant_string_class_name = NULL;
+
static const char *TAG_GETCLASS;
static const char *TAG_GETMETACLASS;
static const char *TAG_MSGSEND;
@@ -797,6 +799,7 @@
char **argv;
{
const char *p = argv[0];
+
if (!strcmp (p, "-lang-objc"))
c_language = clk_objective_c;
else if (!strcmp (p, "-gen-decls"))
@@ -819,6 +822,13 @@
flag_next_runtime = 1;
else if (!strcmp (p, "-print-objc-runtime-info"))
print_struct_values = 1;
+#define CSTSTRCLASS "-fconstant-string-class="
+ else if (!strncmp (p, CSTSTRCLASS, sizeof(CSTSTRCLASS) - 2)) {
+ if (strlen (argv[0]) <= strlen (CSTSTRCLASS))
+ error ("no class name specified as argument to -fconstant-string-class");
+ constant_string_class_name = xstrdup(argv[0] + sizeof(CSTSTRCLASS) - 1);
+ }
+#undef CSTSTRCLASS
else
return c_decode_option (argc, argv);
@@ -1382,7 +1392,10 @@
generate_forward_declaration_to_string_table ();
/* Forward declare constant_string_id and constant_string_type. */
- constant_string_id = get_identifier (STRING_OBJECT_CLASS_NAME);
+ if (!constant_string_class_name)
+ constant_string_class_name = STRING_OBJECT_CLASS_NAME;
+
+ constant_string_id = get_identifier (constant_string_class_name);
constant_string_type = xref_tag (RECORD_TYPE, constant_string_id);
}
Index: gcc/toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -r1.359 -r1.360
--- toplev.c 2000/08/03 07:29:11 1.359
+++ toplev.c 2000/08/06 07:52:35 1.360
@@ -1247,22 +1247,6 @@
#define DEFINE_LANG_NAME(NAME) { NULL, NAME },
- /* These are for Objective C. */
- DEFINE_LANG_NAME ("Objective C")
-
- { "-lang-objc", "" },
- { "-gen-decls", "Dump decls to a .decl file" },
- { "-fgnu-runtime", "Generate code for GNU runtime environment" },
- { "-fno-gnu-runtime", "" },
- { "-fnext-runtime", "Generate code for NeXT runtime environment" },
- { "-fno-next-runtime", "" },
- { "-Wselector", "Warn if a selector has multiple methods" },
- { "-Wno-selector", "" },
- { "-Wprotocol", "" },
- { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
- { "-print-objc-runtime-info",
- "Generate C header of platform specific features" },
-
#include "options.h"
};
Index: gcc/objc/lang-options.h
===================================================================
diff -u lang-options.h /dev/null
--- /dev/null Tue May 5 13:32:27 1998
+++ lang-options.h Sun Jul 30 23:04:30 2000
@@ -0,0 +1,43 @@
+/* Switch definitions for the GNU compiler for the Objective-C language.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+
+Java and all Java-based marks are trademarks or registered trademarks
+of Sun Microsystems, Inc. in the United States and other countries.
+The Free Software Foundation is independent of Sun Microsystems, Inc. */
+
+/* This is the contribution to the `lang_options' array in gcc.c for
+ Objective-C. */
+
+DEFINE_LANG_NAME ("Objective C")
+
+ { "-lang-objc", "" },
+ { "-gen-decls", "Dump decls to a .decl file" },
+ { "-fgnu-runtime", "Generate code for GNU runtime environment" },
+ { "-fno-gnu-runtime", "" },
+ { "-fnext-runtime", "Generate code for NeXT runtime environment" },
+ { "-fno-next-runtime", "" },
+ { "-Wselector", "Warn if a selector has multiple methods" },
+ { "-Wno-selector", "" },
+ { "-Wprotocol", "" },
+ { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"},
+ { "-print-objc-runtime-info",
+ "Generate C header of platform specific features" },
+ { "-fconstant-string-class",
+ "Specify the name of the class for constant strings" },
PGP signature