jni.hpp icon indicating copy to clipboard operation
jni.hpp copied to clipboard

Deduplicate tags to unique jni::Tag<...> types

Open kkaefer opened this issue 8 years ago • 1 comments

Convert Tag types to jni::Tag<char...> types before instantiating the Object/Class/Method/Constructor/StaticMethod/Field/StaticField types. This removes a source of error where two Tag types returning the same string yielded incompatible Object/... types. Instead of templating these by Tag, we generate a jni::Tag<char...> type like jni::Type<'j', 'a', 'v', 'a', '/', 'l', 'a', 'n', 'g', '/', 'O', 'b', 'j', 'e', 'c', 't'>, which means that two distinct Tags produce the identical type if the returned string is identical.

The primary change is the rename from Object to TypedObject, with a type alias from Object => TypedObject. Then, I changed TypeObject to only have a specialization when the TagType is a jni::Tag, and the type alias automatically converts the tag to a Type type. Same applies to the other entities.

This means that it should be largely backwards-compatible.

kkaefer avatar Apr 27 '17 14:04 kkaefer

Trying to gauge the benefits of this versus the added complexity. What are the consequence of mistakenly having two types returning the same string? Just that code you expected to work doesn't compile? Did this come up in mapbox-gl-native somewhere?

jfirebaugh avatar Apr 27 '17 22:04 jfirebaugh