This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: CNI header generator fixes
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 17 Apr 2005 14:45:57 -0600
- Subject: [gcjx] Patch: FYI: CNI header generator fixes
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
This fixes a few CNI header generator bugs;
* Now emits values for constant fields.
* Prints constructor names of member classes correctly.
* Correctly handles case where first member is package-private.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* header/cni.cc (write_field): Emit field value.
(generate): Change initialization of current_flags.
(write_method): Correctly handle constructors of
member classes.
(write_namespaces): Correctly handle member class names.
Index: header/cni.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/header/Attic/cni.cc,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 cni.cc
--- header/cni.cc 17 Apr 2005 18:41:49 -0000 1.1.2.5
+++ header/cni.cc 17 Apr 2005 20:44:51 -0000
@@ -369,7 +369,9 @@
}
indent (out, indentation);
- out << "class " << klass->get_name () << ";" << std::endl;
+ out << "class "
+ << get_simple_name (split (klass->get_fully_qualified_name (), '.'))
+ << ";" << std::endl;
}
move_to_package (out, current_package, base, indentation);
@@ -462,7 +464,11 @@
#endif
if (meth->constructor_p ())
- out << meth->get_declaring_class ()->get_name ();
+ {
+ std::string s
+ = meth->get_declaring_class ()->get_fully_qualified_name ();
+ out << get_simple_name (split (s, '.'));
+ }
else
{
if (meth->static_p ())
@@ -512,12 +518,17 @@
update_modifiers (out, new_flags, current_flags);
out << " ";
+ model_type *ftype = field->type ();
if (field->static_p ())
- out << "static ";
- out << cxxname (field->type ());
- if (! field->type ()->reference_p ())
- out << " ";
+ {
+ out << "static ";
+ if (field->constant_p () && ftype->integral_p ())
+ out << "const ";
+ }
+ out << cxxname (ftype);
+ if (! ftype->reference_p ())
+ out << " ";
if (is_first && ! field->static_p ())
{
is_first = false;
@@ -532,6 +543,22 @@
else if (keyword_p (field->get_name ()))
out << "$";
+ if (field->static_p () && field->constant_p () && ftype->integral_p ())
+ {
+ if (ftype == primitive_long_type)
+ {
+ jlong val = jlong (field->get_initializer ()->value ());
+ out << " = " << val << "LL";
+ }
+ else
+ {
+ model_primitive_base *bt
+ = assert_cast<model_primitive_base *> (primitive_int_type);
+ jint val = bt->convert (ftype, field->get_initializer ()->value ());
+ out << " = " << val << "L";
+ }
+ }
+
out << ";" << std::endl;
}
@@ -599,7 +626,8 @@
out << std::endl;
out << "{" << std::endl;
- modifier_t current_flags = 0;
+ // This ensures that we change the access for the very first member.
+ modifier_t current_flags = ACC_ACCESS;
std::set<std::string> method_names;
AllMethodsIterator end = klass->end_all_methods ();