Closed Bug 1277624 Opened 8 years ago Closed 8 years ago

fix misplaced declarations of mozilla::jni::Context<>::name for clang's benefit

Categories

(Core Graveyard :: Widget: Android, defect)

All
Android
defect
Not set
normal

Tracking

(firefox49 affected, firefox50 fixed)

RESOLVED FIXED
mozilla50
Tracking Status
firefox49 --- affected
firefox50 --- fixed

People

(Reporter: froydnj, Assigned: jchen)

References

Details

Attachments

(3 files)

Generated Android bindings have code like:

namespace mozilla {
namespace widget {
namespace sdk {

template<> const char mozilla::jni::Context<Rect, jobject>::name[] =
        "android/graphics/Rect";

...

clang complains about this:

/opt/build/froydnj/build-android/widget/android/bindings/AndroidRect.cpp:14:61: error: cannot define or redeclare 'name' here because namespace 'sdk' does not enclose namespace 'Context<mozilla::widget::sdk::Rect, _jobject *>'
template<> const char mozilla::jni::Context<Rect, jobject>::name[] =
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
/opt/build/froydnj/build-android/widget/android/bindings/AndroidRect.cpp:556:62: error: cannot define or redeclare 'name' here because namespace 'sdk' does not enclose namespace 'Context<mozilla::widget::sdk::RectF, _jobject *>'
template<> const char mozilla::jni::Context<RectF, jobject>::name[] =
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

So I guess we need to move these out a couple of levels.
Assignee: nobody → nchen
Status: NEW → ASSIGNED
Move the class name strings into ObjectBase, so that the strings can be
overridden by derived classes in other namespaces.
Attachment #8759731 - Flags: review?(snorp)
Trivial patch to not use anonymous namespace in headers, which can
introduce multiple copies of the same code in different compilation
units.
Attachment #8759733 - Flags: review+
For the record, these patches do fix the compilation errors with clang.
Attachment #8759731 - Flags: review?(snorp) → review+
Jim, can you land these?
Flags: needinfo?(nchen)
Pushed by nchen@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/91ca677e4496
Move JNI class name out of Context; r=snorp
https://hg.mozilla.org/integration/mozilla-inbound/rev/6f2a56ca83e7
Update auto-generated bindings; r=me
https://hg.mozilla.org/integration/mozilla-inbound/rev/5c6ee7ceb0a9
Don't use anonymous namespace in headers; r=me
Flags: needinfo?(nchen)
https://hg.mozilla.org/mozilla-central/rev/91ca677e4496
https://hg.mozilla.org/mozilla-central/rev/6f2a56ca83e7
https://hg.mozilla.org/mozilla-central/rev/5c6ee7ceb0a9
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: