On 3/24/14 3:11 PM, Anthony Petrov wrote:
How does IS_JNI_TRUE sound?
It looks good. If nobody objects, the final version will be:

#define IS_NULL(obj) ((obj) == NULL)
#define JNU_IsNull(env,obj) ((obj) == NULL)
+#define IS_JNI_TRUE(obj) ((obj) ? JNI_TRUE : JNI_FALSE)

without additional cast.

--
best regards,
Anthony

On 3/23/2014 10:10 PM, Alan Bateman wrote:
On 21/03/2014 15:22, Sergey Bylokhov wrote:
On 3/21/14 7:10 PM, roger riggs wrote:
The macro would just as useful (if I understand the cases) without
the cast.

How useful is a simple definition as:

#define IS_TRUE(obj) ((obj) ? JNI_TRUE : JNI_FALSE)

then it would look ok to see these in sources:

      return IS_TRUE(obj);

      if (IS_TRUE(obj)) {....}

      jboolean ret = IS_TRUE(obj);

The general purpose usage matches the general C conventions for
true and false and match the JNI semantics.
Actually that was my initial suggestion(name and usage).
I think the concern with IS_TRUE is that it's not obvious that it's a
jboolean. Also just the potential for it to easily collide with a macro
that casts to bool or (or Windows's BOOL). I can't tell from the JNI
spec if JNI_FALSE/JNI_TRUE are guaranteed to be defined as 0/1 but even
if they are then I guess there is still a concern that a jboolean is
defined as an unsigned 8 bits whereas a bool might not (and a Windows's
BOOL is an int I think). So if a macro is really needed then I think it
will need another name. I thought MIke's original proposal for
JNU_TO_JBOOLEAN wasn't too bad. I see Mike's mail about adding the cases
to the definitions but that isn't going to help with the cases that I
think you are running into where you need to go from Window's BOOL to
jboolean.

-Alan.


--
Best regards, Sergey.

Reply via email to