File: os_custom.c

package info (click to toggle)
swt-gtk 3.4-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 11,896 kB
  • ctags: 21,996
  • sloc: java: 102,480; ansic: 28,645; cpp: 3,683; sh: 154; makefile: 43; xml: 42
file content (142 lines) | stat: -rw-r--r-- 5,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
* available at http://www.gnu.org/licenses/lgpl.html.  If the version
* of the LGPL at http://www.gnu.org is different to the version of
* the LGPL accompanying this distribution and there is any conflict
* between the two license versions, the terms of the LGPL accompanying
* this distribution shall govern.
* 
* Contributors:
*     IBM Corporation - initial API and implementation
*******************************************************************************/

#include "swt.h"
#include "os_structs.h"
#include "os_stats.h"

#define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_OS_##func

#ifndef NO_GDK_1WINDOWING_1X11
JNIEXPORT jboolean JNICALL OS_NATIVE(GDK_1WINDOWING_1X11)
	(JNIEnv *env, jclass that)
{
	jboolean rc;
	OS_NATIVE_ENTER(env, that, GDK_1WINDOWING_1X11_FUNC)
#ifdef GDK_WINDOWING_X11
	rc = (jboolean)1;
#else
	rc = (jboolean)0;
#endif	
	OS_NATIVE_EXIT(env, that, GDK_1WINDOWING_1X11_FUNC)
	return rc;
}
#endif

#ifndef NO__1gtk_1file_1chooser_1dialog_1new
JNIEXPORT SWT_PTR JNICALL OS_NATIVE(_1gtk_1file_1chooser_1dialog_1new)
	(JNIEnv *env, jclass that, jbyteArray arg0, SWT_PTR arg1, jint arg2, SWT_PTR arg3, jint arg4, SWT_PTR arg5, jint arg6, SWT_PTR arg7)
{
	jbyte *lparg0=NULL;
	SWT_PTR rc = 0;
	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);
	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
/*
	rc = (SWT_PTR)gtk_file_chooser_dialog_new(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
*/
	{
		static int initialized = 0;
		static void *handle = NULL;
		/*
		* On AMD64, it is critical that functions which have a variable number of
		* arguments, indicated by '...', include the '...' in their prototype.  This
		* changes the calling convention, and leaving it out will cause crashes.
		*
		* For some reason, we must also explicitly declare all of the arguments we
		* are passing in, otherwise it crashes.
		*/
/*		typedef SWT_PTR (*FPTR)(jbyte *, SWT_PTR, jint, SWT_PTR, ...); */
		typedef SWT_PTR (*FPTR)(jbyte *, SWT_PTR, jint, SWT_PTR, jint, SWT_PTR, jint, SWT_PTR, ...);
		static FPTR fptr;
		rc = 0;
		if (!initialized) {
			if (!handle) handle = dlopen(gtk_file_chooser_dialog_new_LIB, RTLD_LAZY);
			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_dialog_new");
			initialized = 1;
		}
		if (fptr) {
			rc = (SWT_PTR)(*fptr)(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
		}
	}
fail:
	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);
	return rc;
}
#endif

#ifndef NO__1gtk_1cell_1layout_1set_1attributes
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1set_1attributes)
	(JNIEnv *env, jclass that, SWT_PTR arg0, SWT_PTR arg1, jbyteArray arg2, jint arg3, SWT_PTR arg4)
{
	jbyte *lparg2=NULL;
	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1layout_1set_1attributes_FUNC);
	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
/*
	gtk_cell_layout_set_attributes(arg0, arg1, lparg2, arg3, arg4);
*/
	{
		static int initialized = 0;
		static void *handle = NULL;
		/*
		* On AMD64, it is critical that functions which have a variable number of
		* arguments, indicated by '...', include the '...' in their prototype.  This
		* changes the calling convention, and leaving it out will cause crashes.
		*
		* For some reason, we must also explicitly declare all of the arguments we
		* are passing in, otherwise it crashes.
		*/
/*		typedef void (*FPTR)(SWT_PTR, SWT_PTR, ...); */
		typedef void (*FPTR)(SWT_PTR, SWT_PTR, jbyte *, jint, SWT_PTR, ...);
		static FPTR fptr;
		if (!initialized) {
			if (!handle) handle = dlopen(gtk_cell_layout_set_attributes_LIB, RTLD_LAZY);
			if (handle) fptr = (FPTR)dlsym(handle, "gtk_cell_layout_set_attributes");
			initialized = 1;
		}
		if (fptr) {
			(*fptr)(arg0, arg1, lparg2, arg3, arg4);
		}
	}
fail:
	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1layout_1set_1attributes_FUNC);
}
#endif

struct _PangoLayoutLineSWT
{
  PangoLayout *layout;
  gint         start_index; 
  gint         length;      
  GSList      *runs;
  guint        is_paragraph_start : 1;
  guint        resolved_dir : 3;
};
typedef struct _PangoLayoutLineSWT  PangoLayoutLineSWT;

#ifndef NO__1pango_1layout_1line_1get_1resolved_1dir
JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1line_1get_1resolved_1dir)
	(JNIEnv *env, jclass that, SWT_PTR arg0)
{
	jint rc = 0;
	OS_NATIVE_ENTER(env, that, _1pango_1layout_1line_1get_1resolved_1dir_FUNC);
	if (gtk_check_version(2,4,0) == NULL) {
		rc = ((PangoLayoutLineSWT*)(arg0))->resolved_dir;
	}
	OS_NATIVE_EXIT(env, that, _1pango_1layout_1line_1get_1resolved_1dir_FUNC);
	return rc;
}
#endif