Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 389749 - make GDK_WIDGET_FLAGS dynamic
Summary: make GDK_WIDGET_FLAGS dynamic
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.3 M3   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2012-09-17 13:51 EDT by Anatoly Spektor CLA
Modified: 2012-10-24 14:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anatoly Spektor CLA 2012-09-17 13:51:55 EDT
This patch makes GDK_WIDGET_FLAGS dynamic:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=make_dynamic_flags
Comment 1 Silenio Quarti CLA 2012-09-17 14:02:33 EDT
#define macros cannot be made dynamic. GTK_WIDGET_FLAGS is only available at compile time (not runtime).
Comment 2 Anatoly Spektor CLA 2012-09-17 14:17:33 EDT
If you take a look at OS.java, you will find out method GTK_WIDGET_FLAGS;

public static final native int _GTK_WIDGET_FLAGS(int /*long*/ wid);
public static final int GTK_WIDGET_FLAGS(int /*long*/ wid) {
	lock.lock();
	try {
		return _GTK_WIDGET_FLAGS(wid);
	} finally {
		lock.unlock();
	}
}



It does not look like regular #define macros, if I try the approach I used with macros it gives me this:

os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS__1GTK_1WIDGET_1FLAGS’:
os.c:1554:13: error: ‘GTK_WIDGET_FLAGS’ undeclared (first use in this function)
os.c:1554:13: note: each undeclared identifier is reported only once for each function it appears in
Comment 3 Anatoly Spektor CLA 2012-09-17 14:24:26 EDT
(In reply to comment #2)
> If you take a look at OS.java, you will find out method GTK_WIDGET_FLAGS;
> 
> public static final native int _GTK_WIDGET_FLAGS(int /*long*/ wid);
> public static final int GTK_WIDGET_FLAGS(int /*long*/ wid) {
> 	lock.lock();
> 	try {
> 		return _GTK_WIDGET_FLAGS(wid);
> 	} finally {
> 		lock.unlock();
> 	}
> }
> 
> 
> 
> It does not look like regular #define macros, if I try the approach I used
> with macros it gives me this:
> 
> os.c: In function
> ‘Java_org_eclipse_swt_internal_gtk_OS__1GTK_1WIDGET_1FLAGS’:
> os.c:1554:13: error: ‘GTK_WIDGET_FLAGS’ undeclared (first use in this
> function)
> os.c:1554:13: note: each undeclared identifier is reported only once for
> each function it appears in

by  approach I used I meant:

#ifndef GTK_WIDGET_FLAGS
#define GTK_WIDGET_FLAGS(arg0) 0
#endif
Comment 4 Silenio Quarti CLA 2012-09-17 14:33:45 EDT
Which gtk version are you compiling against? GTK 3?

1) Would this work?

#if GTK_CHECK_VERSION(3,0,0)
#define GTK_WIDGET_FLAGS(arg0) 0
#else

2) Another option?

#if GTK_CHECK_VERSION(3,0,0)
#define NO__1GTK_1WIDGET_1FLAGS
#else

Option 2 is different from what we have been doing, but it might be a better option. The native would not be compiled (save some space) when the SWT libraries are compiled against GTK 3.   If the java code tries to call that native, we would get a java exception instead of silently fail and return 0.  It would be easier to track problems.
Comment 5 Anatoly Spektor CLA 2012-09-17 14:44:13 EDT
(In reply to comment #4)
> Which gtk version are you compiling against? GTK 3?
> 
> 1) Would this work?
> 
> #if GTK_CHECK_VERSION(3,0,0)
> #define GTK_WIDGET_FLAGS(arg0) 0
> #else
> 
> 2) Another option?
> 
> #if GTK_CHECK_VERSION(3,0,0)
> #define NO__1GTK_1WIDGET_1FLAGS
> #else
> 
> Option 2 is different from what we have been doing, but it might be a better
> option. The native would not be compiled (save some space) when the SWT
> libraries are compiled against GTK 3.   If the java code tries to call that
> native, we would get a java exception instead of silently fail and return 0.
> It would be easier to track problems.

What is supposed to go after #else ? 

When I try:

#if GTK_CHECK_VERSION(3,0,0)
#define GTK_WIDGET_FLAGS(arg0) 0
#endif

or

#if GTK_CHECK_VERSION(3,0,0)
#define NO__1GTK_1WIDGET_1FLAGS
#endif


It gives me in both cases:
os.c:1554:13: error: ‘GTK_WIDGET_FLAGS’ undeclared (first use in this function)
os.c:1554:13: note: each undeclared identifier is reported only once for each function it appears in
Comment 6 Silenio Quarti CLA 2012-09-17 15:11:15 EDT
(In reply to comment #5)

> What is supposed to go after #else ? 

#endif instead of #else is right.

What gtk version are you compiling against?
Comment 7 Anatoly Spektor CLA 2012-09-17 15:12:54 EDT
(In reply to comment #6)
> (In reply to comment #5)
> 
> > What is supposed to go after #else ? 
> 
> #endif instead of #else is right.
> 
> What gtk version are you compiling against?

against GTK 3
Comment 8 Anatoly Spektor CLA 2012-09-18 11:14:16 EDT
I think the problem with #define was due to some merging problems in my branch. After resetting the branch I tried  defining GTK_WIDGET_FLAGS and  version guarding it. It seems to work fine for me now. 

 Here is the patch:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=make_dynamic_flags


 I would appreciate if you could double check and let me know if it actually works for you.

 Regards,

Anatoly
Comment 9 Silenio Quarti CLA 2012-09-18 11:27:46 EDT
Patch works for me. I will push once 4.3 M2 is done.
Comment 10 Anatoly Spektor CLA 2012-09-18 11:28:39 EDT
(In reply to comment #9)
> Patch works for me. I will push once 4.3 M2 is done.

Ok, thanks!