Package list lwjgl / 09bd29f
import upstream 2.7.1+dfsg Michael Gilbert 10 years ago
527 changed file(s) with 31672 addition(s) and 7801 deletion(s). Raw diff Collapse all Expand all
55 <import file="platform_build/build-generator.xml"/>
66 <import file="platform_build/build-applet.xml"/>
77 <import file="platform_build/build-webstart.xml"/>
8 <import file="platform_build/build-maven.xml"/>
89
910 <!-- ================================================================== -->
1011 <!-- Everything below this line is targets. -->
1516 <!-- Initialize build -->
1617 <!-- ================================================================== -->
1718 <target name="-initialize">
18 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
19 <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing bin folder" />
20 <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" />
21 <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" />
22 <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" />
23 <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" />
24 <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" />
25 <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" />
26 <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" />
27 <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" />
28 <mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
29 <mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
30 <mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
31 <mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
32 <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
33 </target>
34
19 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
20 <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing native bin folder" />
21 <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" />
22 <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" />
23 <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" />
24 <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" />
25 <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" />
26 <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" />
27 <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" />
28 <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" />
29 <mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
30 <mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
31 <mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
32 <mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
33 <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
34 </target>
35
3536 <!-- Cleans up any files created during the execution of this script -->
36 <target name="clean" description="Cleans the diectories controlled by this ant script" depends="clean-generated">
37 <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" />
38 <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" />
39 <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" />
40 </target>
41
37 <target name="clean" description="Cleans all directories controlled by this ant script" depends="clean-java, clean-native"/>
38
39 <!-- Cleans up any non-native files created during the execution of this script -->
40 <target name="clean-java" description="Cleans non-native files generated by this ant script" depends="clean-generated">
41 <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" />
42 <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" />
43 <!-- Delete java classes only to avoid unnecessary native recompilation -->
44 <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" />
45 </target>
46
47 <!-- Useful when we need to force native recompilation -->
48 <target name="clean-native" description="Cleans native files generated by this ant script" depends="clean-generated-native">
49 <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" />
50 </target>
51
4252 <!-- Creates a distribution of LWJGL -->
4353 <target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
4454 <!-- Warn user -->
4555 <echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
46 <input
47 message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
48 validargs="yes,no"
49 addproperty="do.delete"
50 />
51 <condition property="do.abort">
52 <equals arg1="no" arg2="${do.delete}"/>
53 </condition>
54 <fail if="do.abort">Build aborted by user.</fail>
55
56 <!-- prepare -->
57 <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" />
58 <antcall target="clean" />
59 <antcall target="-initialize" />
60
61 <!-- compile and create jars -->
62 <antcall target="generate-debug"/>
63 <antcall target="compile" />
64 <antcall target="-createdebugjars" />
56 <input
57 message="All data in the ${lwjgl.dist} folder will be deleted. Continue? "
58 validargs="yes,no"
59 addproperty="do.delete"
60 />
61 <condition property="do.abort">
62 <equals arg1="no" arg2="${do.delete}"/>
63 </condition>
64 <fail if="do.abort">Build aborted by user.</fail>
65
66 <!-- prepare -->
67 <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" />
68 <antcall target="clean-java" />
69 <antcall target="-initialize" />
70
71 <!-- compile and create debug jars -->
72 <antcall target="generate-debug" />
73 <antcall target="compile" />
74 <antcall target="-createdebugjars" />
75
6576 <!-- Generator will skip all templates if we don't clean -->
66 <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" />
67 <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" />
68 <antcall target="generate-all"/>
69 <antcall target="compile" />
70 <antcall target="-createjars" />
71 <antcall target="-jars_NoDEP" />
72 <antcall target="javadoc" />
73 <antcall target="applet-release" />
74
75 <!-- copy resources to res folder -->
76 <copy todir="${lwjgl.temp}/res">
77 <fileset dir="res"/>
78 </copy>
79
80 <!-- copy docs -->
77 <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" />
78
79 <!-- compile and create jars -->
80 <antcall target="generate-all" />
81 <antcall target="compile" />
82 <antcall target="-createjars" />
83
84 <antcall target="-jars_NoDEP" />
85 <antcall target="javadoc" />
86 <antcall target="applet-release" />
87
88 <!-- copy resources to res folder -->
89 <copy todir="${lwjgl.temp}/res">
90 <fileset dir="res"/>
91 </copy>
92
93 <!-- copy docs -->
8194 <copy todir="${lwjgl.temp}/doc">
8295 <fileset dir="${lwjgl.docs}">
8396 <patternset refid="lwjgl-docs.fileset" />
8497 </fileset>
85 </copy>
86
98 </copy>
99
87100 <!-- create distribution from files in libs/ and temp/ -->
88101 <antcall target="-distribution_javadoc" />
89102 <antcall target="-distribution_source" />
104117 </fileset>
105118 </move>
106119 </target>
107
120
108121 <!-- Packages the java files -->
109122 <target name="-createdebugjars">
110123 <!-- Create lwjgl.jar -->
115128 </manifest>
116129 </jar>
117130 </target>
118
131
119132 <!-- Packages the java files -->
120133 <target name="-createjars">
121134 <!-- Create lwjgl.jar -->
125138 <attribute name="Sealed" value="true"/>
126139 </manifest>
127140 </jar>
128
141
129142 <!-- Create lwjgl_util_applet.jar -->
130143 <jar destfile="${lwjgl.temp}/jar/lwjgl_util_applet.jar" taskname="lwjgl_util_applet.jar">
144 <fileset dir="${lwjgl.res}" includes="applet*"/>
131145 <fileset refid="lwjgl_util_applet.fileset" />
132146 <manifest>
133147 <attribute name="Sealed" value="true"/>
150164 <target name="-distribute">
151165 <delete>
152166 <fileset dir="${lwjgl.temp}/native/" includes="**/*"/>
153 </delete>
167 </delete>
154168
155169 <copy todir="${lwjgl.temp}/jar">
156170 <fileset dir="${lwjgl.lib}/" includes="*.jar"/>
174188 <fileset dir="${lwjgl.lib}/solaris">
175189 <patternset refid="lwjgl-solaris.fileset" />
176190 </fileset>
177 </copy>
178
191 </copy>
192
179193 <!-- create base package -->
180194 <zip destfile="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip">
181195 <zipfileset dir="${lwjgl.temp}" prefix="lwjgl-${lwjgl.version}/">
182196 <patternset refid="lwjgl_base"/>
183 </zipfileset>
197 </zipfileset>
184198 </zip>
185
199
186200 <!-- create applet package -->
187201 <zip destfile="${lwjgl.dist}/lwjgl_applet-${lwjgl.version}.zip">
188202 <zipfileset dir="." prefix="lwjgl_applet-${lwjgl.version}/">
189203 <patternset refid="lwjgl_applet"/>
190 </zipfileset>
204 </zipfileset>
191205 </zip>
192206 </target>
193207
195209 <target name="-distribution_javadoc">
196210 <zip destfile="${lwjgl.dist}/lwjgl-docs-${lwjgl.version}.zip" basedir="${lwjgl.docs}" includes="javadoc/**" />
197211 </target>
198
212
199213 <!-- Creates a versioned distribution of the source code -->
200214 <target name="-distribution_source">
201215 <zip destfile="${lwjgl.dist}/lwjgl-source-${lwjgl.version}.zip">
202216 <fileset refid="lwjgl.source.fileset" />
203217 </zip>
204 </target>
205
218 </target>
219
206220 <!-- Generates the native headers from source files -->
207221 <target name="headers" description="invokes javah on java classes" depends="compile">
208222 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
218232 <class name="org.lwjgl.opengl.LinuxContextImplementation" />
219233 <class name="org.lwjgl.opengl.LinuxCanvasImplementation" />
220234 </javah>
221
235
222236 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
223237 <class name="org.lwjgl.opengl.WindowsKeyboard" />
224238 <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" />
230244 <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" />
231245 <class name="org.lwjgl.opengl.WindowsContextImplementation" />
232246 </javah>
233
247
234248 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
235249 <class name="org.lwjgl.MacOSXSysImplementation" />
236250 <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
240254 <class name="org.lwjgl.opengl.MacOSXDisplay" />
241255 <class name="org.lwjgl.opengl.MacOSXContextImplementation" />
242256 </javah>
243
257
244258 <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
245259 <class name="org.lwjgl.opengl.AWTSurfaceLock" />
246260 <class name="org.lwjgl.DefaultSysImplementation" />
250264 <class name="org.lwjgl.openal.AL" />
251265 <class name="org.lwjgl.opengl.GLContext" />
252266 <class name="org.lwjgl.opengl.Pbuffer" />
253 <class name="org.lwjgl.opengl.AMDDebugOutputCallback" />
267 <class name="org.lwjgl.opengl.CallbackUtil" />
268 <class name="org.lwjgl.opencl.CL" />
269 <class name="org.lwjgl.opencl.CallbackUtil" />
270 <class name="org.lwjgl.BufferUtils" />
254271 </javah>
255272 </target>
256
273
257274 <target name="touch-version">
258275 <touch file="${lwjgl.src.native}/windows/org_lwjgl_opengl_Display.c"/>
259276 <touch file="${lwjgl.src.native}/linux/org_lwjgl_opengl_Display.c"/>
260277 <touch file="${lwjgl.src.native}/macosx/org_lwjgl_opengl_Display.m"/>
261278 </target>
262
279
263280 <target name="version-mismatch">
264281 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version">
265282 <filterchain>
274291 <containsstring contains="JNI_VERSION ="/>
275292 </tokenfilter>
276293 </filterchain>
277 </loadfile>
294 </loadfile>
278295 <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version">
279296 <filterchain>
280297 <tokenfilter>
295312 <containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
296313 </tokenfilter>
297314 </filterchain>
298 </loadfile>
315 </loadfile>
299316 <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
300317 <filterchain>
301318 <tokenfilter>
305322 </loadfile>
306323 <echo>
307324 lwjgl.java.windows.version = ${lwjgl.java.windows.version}
308 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
325 lwjgl.native.windows.version = ${lwjgl.native.windows.version}
309326 lwjgl.java.linux.version = ${lwjgl.java.linux.version}
310 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
327 lwjgl.native.linux.version = ${lwjgl.native.linux.version}
311328 lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
312 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
329 lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
313330 </echo>
314331 </target>
315
332
316333 <macrodef name="version-check">
317334 <attribute name="platform"/>
318335 <sequential>
319336 <java classname="org.lwjgl.test.NativeTest" logError="false" resultproperty="nativetest.res" outputproperty="nativetest.out" errorproperty="nativetest.err" fork="true">
320337 <jvmarg value="-Djava.library.path=libs/@{platform}"/>
338 <jvmarg value="-Dorg.lwjgl.util.Debug=true"/>
321339 <classpath>
322340 <pathelement path="${lwjgl.bin}"/>
323341 <pathelement path="${java.class.path}"/>
324342 </classpath>
325343 </java>
326
344
327345 <fail message="Unable to load native library: ${nativetest.err}">
328346 <condition>
329347 <not>
331349 </not>
332350 </condition>
333351 </fail>
334
352
335353 <echo message="Successfully executed NativeTest"/>
336354 </sequential>
337355 </macrodef>
338
356
339357 <!-- Compiles the Java source code -->
340358 <target name="compile" description="Compiles the java source code" depends="-initialize">
341 <javac debug="yes" destdir="${lwjgl.bin}" source="1.4" target="1.4" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
359 <javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core">
360 <!--<compilerarg value="-Xlint:unchecked"/>-->
342361 <src path="${lwjgl.src}/java/"/>
343362 <src path="${lwjgl.src}/generated/"/>
344363 <include name="org/lwjgl/*.java"/>
345364 <include name="org/lwjgl/input/**"/>
346365 <include name="org/lwjgl/opengl/**"/>
347366 <include name="org/lwjgl/openal/**"/>
367 <include name="org/lwjgl/opencl/**"/>
348368 <include name="org/lwjgl/util/**"/>
349369 <exclude name="org/lwjgl/util/generator/**"/>
350370 </javac>
351 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.4" target="1.4" taskname="test" />
352 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.4" target="1.4" taskname="examples" />
353 </target>
354
355 <target name="compile_native" depends="headers, touch-version, version-mismatch" description="Compiles the native files">
371 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.5" target="1.5" taskname="test" />
372 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.5" target="1.5" taskname="examples" />
373 </target>
374
375 <target name="compile_native" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
356376 <condition property="lwjgl.platform.windows">
357377 <os family="windows" />
358378 </condition>
372392 <os name="Mac OS X" />
373393 </condition>
374394 <antcall target="-compile_native_macosx" />
375 </target>
395 </target>
376396
377397 <!-- Compiles LWJGL on Win32 platforms -->
378398 <target name="-compile_native_win32" if="lwjgl.platform.windows">
408428 <copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
409429 <version-check platform="macosx"/>
410430 </target>
411
431
412432 <target name="repack200" description="Pack200-repack a jar file">
413433 <pack200 src="${input}" destfile="${output}" repack="true"/>
414434 </target>
428448 <arg value="${output}"/>
429449 </java>
430450 </target>
431
451
432452 <target name="compress-sign-class">
433453 <antcall target="repack200">
434454 <param name="input" value="${dir}${jarfile}.jar"/>
441461 </antcall>
442462 <antcall target="lzma">
443463 <param name="input" value="${dir}${jarfile}.jar.pack"/>
444 <param name="output" value="${dir}${jarfile}.jar.pack.lzma"/>
464 <param name="output" value="${outputdir}${jarfile}.jar.pack.lzma"/>
445465 </antcall>
446 <delete file="${dir}${jarfile}-repack.jar"/>
466 <!--delete file="${dir}${jarfile}-repack.jar"/-->
447467 <delete file="${dir}${jarfile}.jar.pack"/>
448 <delete file="${dir}${jarfile}.jar"/>
449 </target>
450
468 <!--delete file="${dir}${jarfile}.jar"/-->
469 <rename src="${dir}${jarfile}-repack.jar" dest="${dir}${jarfile}.jar" replace="yes"/>
470 </target>
471
451472 <target name="compress-resource">
452473 <antcall target="lzma">
453474 <param name="input" value="${input}"/>
454475 <param name="output" value="${output}"/>
455476 </antcall>
456477 </target>
457
478
458479 <target name="applettest" depends="applet">
459480 <exec executable="appletviewer">
460481 <arg value="-J-Djava.security.policy=applet/appletviewer.policy"/>
484505 <sysproperty key="java.library.path" value="${native_path_expanded}"/>
485506 <arg line="${args}"/>
486507 </java>
487 </target>
488
508 </target>
509
489510 <!-- Creates the Javadoc -->
490511 <target name="javadoc" description="Creates javadoc from java source code">
491 <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.4" windowtitle="LWJGL API" useexternalfile="true">
512 <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL API" useexternalfile="true">
492513 <fileset refid="lwjgl.javadoc.fileset" />
493514 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
494515 <bottom><![CDATA[<i>Copyright &#169; 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
22 <!-- Create our packer task -->
33 <taskdef name="pack200" classname="com.sun.tools.apache.ant.pack200.Pack200Task" classpath="platform_build/Pack200Task.jar"/>
44
5 <target name="applet" depends="all">
5 <target name="applet">
66 <antcall target="-applet">
77 <param name="keystore" value="applet/lwjglkeystore"/>
88 <param name="alias" value="lwjgl"/>
3030 <target name="-applet">
3131
3232 <!-- Create lwjgl_applet.jar -->
33 <jar destfile="applet/lwjgl_applet.jar" taskname="lwjgl_applet.jar">
33 <jar destfile="applet/basic/lwjgl_applet.jar" taskname="lwjgl_applet.jar">
3434 <fileset refid="lwjgl_applet.fileset" />
3535 </jar>
3636
3737 <!-- create each of the native jars -->
38 <jar destfile="applet/windows_natives.jar" taskname="windows_natives.jar">
38 <jar destfile="applet/basic/windows_natives.jar" taskname="windows_natives.jar">
3939 <fileset dir="${lwjgl.lib}/windows">
4040 <patternset refid="lwjgl-windows.fileset"/>
4141 </fileset>
4242 </jar>
43 <signjar jar="applet/windows_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
43 <signjar jar="applet/basic/windows_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
4444
45 <jar destfile="applet/linux_natives.jar" taskname="linux_natives.jar">
45 <jar destfile="applet/basic/linux_natives.jar" taskname="linux_natives.jar">
4646 <fileset dir="${lwjgl.lib}/linux">
4747 <patternset refid="lwjgl-linux.fileset"/>
4848 </fileset>
4949 </jar>
50 <signjar jar="applet/linux_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
50 <signjar jar="applet/basic/linux_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
5151
52 <jar destfile="applet/macosx_natives.jar" taskname="macosx_natives.jar">
52 <jar destfile="applet/basic/macosx_natives.jar" taskname="macosx_natives.jar">
5353 <fileset dir="${lwjgl.lib}/macosx">
5454 <patternset refid="lwjgl-macosx.fileset"/>
5555 </fileset>
5656 </jar>
57 <signjar jar="applet/macosx_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
57 <signjar jar="applet/basic/macosx_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
5858
59 <jar destfile="applet/solaris_natives.jar" taskname="solaris_natives.jar">
59 <jar destfile="applet/basic/solaris_natives.jar" taskname="solaris_natives.jar">
6060 <fileset dir="${lwjgl.lib}/solaris">
6161 <patternset refid="lwjgl-solaris.fileset"/>
6262 </fileset>
6363 </jar>
64 <signjar jar="applet/solaris_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
65
66 <jar destfile="${lwjgl.lib}/lwjgl_util_applet.jar" update="true">
67 <fileset dir="${lwjgl.res}" includes="applet*"/>
68 </jar>
64 <signjar jar="applet/basic/solaris_natives.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
6965
70 <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet" overwrite="true"/>
71 <copy file="${lwjgl.lib}/lwjgl-debug.jar" todir="applet" overwrite="true"/>
72 <copy file="${lwjgl.lib}/lwjgl_util_applet.jar" todir="applet" overwrite="true"/>
73 <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet" overwrite="true"/>
74 <copy file="${lwjgl.lib}/jinput.jar" todir="applet" overwrite="true"/>
75 <copy file="${lwjgl.lib}/lzma.jar" todir="applet" overwrite="true"/>
76 <zip destfile="applet/res.jar">
77 <zipfileset dir="${lwjgl.res}" includes="Footsteps.wav, ILtest.tga, Missing_you.mod"/>
78 </zip>
79 <signjar jar="applet/lwjgl_util_applet.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
80 <signjar jar="applet/lzma.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
66 <copy file="${lwjgl.lib}/lwjgl.jar" todir="applet/basic" overwrite="true"/>
67 <copy file="${lwjgl.lib}/lwjgl-debug.jar" todir="applet/basic" overwrite="true"/>
68 <copy file="${lwjgl.lib}/lwjgl_util_applet.jar" todir="applet/basic" overwrite="true"/>
69 <copy file="${lwjgl.lib}/lwjgl_util.jar" todir="applet/basic" overwrite="true"/>
70 <copy file="${lwjgl.lib}/jinput.jar" todir="applet/basic" overwrite="true"/>
71 <copy file="${lwjgl.lib}/lzma.jar" todir="applet/advance" overwrite="true"/>
8172
73 <signjar jar="applet/basic/lwjgl_util_applet.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
74 <signjar jar="applet/advance/lzma.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
75 <copy file="applet/basic/lwjgl_util_applet.jar" todir="applet/advance" overwrite="true"/>
76
8277 <!-- LZMA only, for 1.4 only clients -->
83 <antcall target="compress-resource">
84 <param name="input" value="applet/lwjgl.jar"/>
85 <param name="output" value="applet/lwjgl.jar.lzma"/>
78 <!--antcall target="compress-resource">
79 <param name="input" value="applet/basic/lwjgl.jar"/>
80 <param name="output" value="applet/advance/lwjgl.jar.lzma"/>
8681 </antcall>
8782 <antcall target="compress-resource">
88 <param name="input" value="applet/lwjgl-debug.jar"/>
89 <param name="output" value="applet/lwjgl-debug.jar.lzma"/>
83 <param name="input" value="applet/basic/lwjgl-debug.jar"/>
84 <param name="output" value="applet/advance/lwjgl-debug.jar.lzma"/>
9085 </antcall>
9186
9287 <antcall target="compress-resource">
93 <param name="input" value="applet/lwjgl_util.jar"/>
94 <param name="output" value="applet/lwjgl_util.jar.lzma"/>
88 <param name="input" value="applet/basic/lwjgl_util.jar"/>
89 <param name="output" value="applet/advance/lwjgl_util.jar.lzma"/>
9590 </antcall>
9691 <antcall target="compress-resource">
97 <param name="input" value="applet/jinput.jar"/>
98 <param name="output" value="applet/jinput.jar.lzma"/>
92 <param name="input" value="applet/basic/jinput.jar"/>
93 <param name="output" value="applet/advance/jinput.jar.lzma"/>
9994 </antcall>
10095 <antcall target="compress-resource">
101 <param name="input" value="applet/lwjgl_applet.jar"/>
102 <param name="output" value="applet/lwjgl_applet.jar.lzma"/>
96 <param name="input" value="applet/basic/lwjgl_applet.jar"/>
97 <param name="output" value="applet/advance/lwjgl_applet.jar.lzma"/>
10398 </antcall>
10499 <antcall target="compress-resource">
105 <param name="input" value="applet/windows_natives.jar"/>
106 <param name="output" value="applet/windows_natives.jar.lzma"/>
107 </antcall>
100 <param name="input" value="applet/basic/windows_natives.jar"/>
101 <param name="output" value="applet/advance/windows_natives.jar.lzma"/>
102 </antcall -->
103
108104 <antcall target="compress-sign-class">
109 <param name="dir" value="applet/"/>
105 <param name="dir" value="applet/basic/"/>
106 <param name="outputdir" value="applet/advance/"/>
110107 <param name="jarfile" value="lwjgl"/>
111108 </antcall>
112109 <antcall target="compress-sign-class">
113 <param name="dir" value="applet/"/>
110 <param name="dir" value="applet/basic/"/>
111 <param name="outputdir" value="applet/advance/"/>
114112 <param name="jarfile" value="lwjgl-debug"/>
115113 </antcall>
116114 <antcall target="compress-sign-class">
117 <param name="dir" value="applet/"/>
115 <param name="dir" value="applet/basic/"/>
116 <param name="outputdir" value="applet/advance/"/>
118117 <param name="jarfile" value="lwjgl_util"/>
119118 </antcall>
120119 <antcall target="compress-sign-class">
121 <param name="dir" value="applet/"/>
120 <param name="dir" value="applet/basic/"/>
121 <param name="outputdir" value="applet/advance/"/>
122122 <param name="jarfile" value="jinput"/>
123123 </antcall>
124124 <antcall target="compress-sign-class">
125 <param name="dir" value="applet/"/>
125 <param name="dir" value="applet/basic/"/>
126 <param name="outputdir" value="applet/advance/"/>
126127 <param name="jarfile" value="lwjgl_applet"/>
127128 </antcall>
128129 <antcall target="compress-resource">
129 <param name="input" value="applet/windows_natives.jar"/>
130 <param name="output" value="applet/windows_natives.jar.lzma"/>
130 <param name="input" value="applet/basic/windows_natives.jar"/>
131 <param name="output" value="applet/advance/windows_natives.jar.lzma"/>
131132 </antcall>
132133 <antcall target="compress-resource">
133 <param name="input" value="applet/macosx_natives.jar"/>
134 <param name="output" value="applet/macosx_natives.jar.lzma"/>
134 <param name="input" value="applet/basic/macosx_natives.jar"/>
135 <param name="output" value="applet/advance/macosx_natives.jar.lzma"/>
135136 </antcall>
136137 <antcall target="compress-resource">
137 <param name="input" value="applet/linux_natives.jar"/>
138 <param name="output" value="applet/linux_natives.jar.lzma"/>
138 <param name="input" value="applet/basic/linux_natives.jar"/>
139 <param name="output" value="applet/advance/linux_natives.jar.lzma"/>
139140 </antcall>
140141 <antcall target="compress-resource">
141 <param name="input" value="applet/solaris_natives.jar"/>
142 <param name="output" value="applet/solaris_natives.jar.lzma"/>
143 </antcall>
144
145 <antcall target="compress-resource">
146 <param name="input" value="applet/res.jar"/>
147 <param name="output" value="applet/res.jar.lzma"/>
142 <param name="input" value="applet/basic/solaris_natives.jar"/>
143 <param name="output" value="applet/advance/solaris_natives.jar.lzma"/>
148144 </antcall>
149145 </target>
150146 </project>
11 <!-- ================================================================== -->
22 <!-- Global properties for build -->
33 <!-- ================================================================== -->
4 <property name="lwjgl.src" location="src" />
5 <property name="lwjgl.src.native" location="${lwjgl.src}/native" />
6 <property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
7 <property name="lwjgl.src.templates" location="${lwjgl.src}/templates" />
8 <property name="lwjgl.bin" location="bin" />
9 <property name="lwjgl.lib" location="libs" />
10 <property name="lwjgl.dist" location="dist" />
11 <property name="lwjgl.docs" location="doc" />
12 <property name="lwjgl.temp" location="temp" />
13 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.5" />
4 <property name="lwjgl.src" location="src" />
5 <property name="lwjgl.src.native" location="${lwjgl.src}/native" />
6 <property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
7 <property name="lwjgl.src.templates" location="${lwjgl.src}/templates" />
8 <property name="lwjgl.bin" location="bin" />
9 <property name="lwjgl.lib" location="libs" />
10 <property name="lwjgl.dist" location="dist" />
11 <property name="lwjgl.docs" location="doc" />
12 <property name="lwjgl.temp" location="temp" />
13 <property name="lwjgl.res" location="res" />
14 <property name="lwjgl.version" value="2.7.1" />
15 <property name="lwjgl.web" location="www" />
1516
1617 <property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/>
18 <property name="opencl-template-pattern-extensions" value="org/lwjgl/opencl/KHR*.java,org/lwjgl/opencl/EXT*.java,org/lwjgl/opencl/APPLE*.java,org/lwjgl/opencl/AMD*.java,org/lwjgl/opencl/NV*.java"/>
19 <property name="opencl-template-pattern" value="org/lwjgl/opencl/CL*.java,${opencl-template-pattern-extensions}"/>
20
1721 <!-- ================================================================== -->
1822 <!-- Filesets used for targets -->
1923 <!-- ================================================================== -->
2024
2125 <!-- Files to include in the lwjgl.jar file -->
2226 <fileset id="lwjgl.fileset" dir="${lwjgl.bin}">
23 <include name="org/**/*" />
24 <exclude name="org/lwjgl/d3d/**" />
25 <exclude name="org/lwjgl/test/**" />
26 <exclude name="org/lwjgl/util/**" />
27 <exclude name="org/lwjgl/examples/**" />
27 <patternset id="lwjgl.package.pattern">
28 <include name="org/**/*" />
29 <exclude name="org/lwjgl/d3d/**" />
30 <exclude name="org/lwjgl/test/**" />
31 <exclude name="org/lwjgl/util/**" />
32 <exclude name="org/lwjgl/examples/**" />
33 </patternset>
2834 </fileset>
29
35
36 <!-- Files to include in the lwjgl_util_applet.jar file -->
3037 <fileset id="lwjgl_util_applet.fileset" dir="${lwjgl.bin}">
31 <exclude name="**.*"/>
32 <include name="org/lwjgl/util/applet/**"/>
38 <patternset id="lwjgl_util_applet.package.pattern">
39 <exclude name="**.*"/>
40 <include name="org/lwjgl/util/applet/**"/>
41 </patternset>
3342 </fileset>
3443
3544 <!-- Files to include in the lwjgl_test.jar file -->
3847 <include name="org/lwjgl/test/**" />
3948 <include name="org/lwjgl/examples/**" />
4049 </fileset>
41
50
4251 <!-- More files to include in the lwjgl_test.jar file -->
4352 <fileset id="lwjgl_test_extra.fileset" dir="${lwjgl.src}/java">
4453 <exclude name="**.*" />
45 <include name="org/lwjgl/test/opengl/shaders/shaderFP.fp" />
46 <include name="org/lwjgl/test/opengl/shaders/shaderFP.vp" />
47 <include name="org/lwjgl/test/opengl/shaders/shaderFSH.fsh" />
48 <include name="org/lwjgl/test/opengl/shaders/shaderFSH.vsh" />
49 <include name="org/lwjgl/test/opengl/shaders/shaderVP.vp" />
50 <include name="org/lwjgl/test/opengl/shaders/shaderVSH.vsh" />
51 <include name="org/lwjgl/test/opengl/shaders/shaderUNI.vsh" />
52 </fileset>
54 <include name="org/lwjgl/test/opengl/shaders/*.fp" />
55 <include name="org/lwjgl/test/opengl/shaders/*.vp" />
56 <include name="org/lwjgl/test/opengl/shaders/*.vsh" />
57 <include name="org/lwjgl/test/opengl/shaders/*.fsh" />
58 <include name="org/lwjgl/test/opencl/gl/*.cl" />
59 </fileset>
5360
5461 <!-- Files to include in the lwjgl_util.jar file -->
5562 <fileset id="lwjgl_util.fileset" dir="${lwjgl.bin}">
56 <exclude name="**.*" />
57 <exclude name="org/lwjgl/util/generator/**" />
58 <exclude name="org/lwjgl/util/applet/**" />
59 <include name="org/lwjgl/util/**" />
63 <patternset id="lwjgl_util.package.pattern">
64 <exclude name="**.*" />
65 <exclude name="org/lwjgl/util/generator/**" />
66 <exclude name="org/lwjgl/util/applet/**" />
67 <include name="org/lwjgl/util/**" />
68 </patternset>
6069 </fileset>
70
6171
6272 <!-- Files to include in the lwjgl_applet.jar file -->
6373 <fileset id="lwjgl_applet.fileset" dir="${lwjgl.bin}">
6575 <include name="org/lwjgl/test/applet/**"/>
6676 <include name="org/lwjgl/test/opengl/awt/AWTGearsCanvas.class"/>
6777 </fileset>
68
78
6979 <!-- Files to make Javadoc from -->
7080 <fileset id="lwjgl.javadoc.fileset" dir="${lwjgl.src}">
7181 <include name="**/*.java" />
8797
8898 <!-- Files to include in windows package -->
8999 <patternset id="lwjgl-windows.fileset">
90 <include name="lwjgl.dll" />
91 <include name="lwjgl64.dll" />
92 <include name="OpenAL32.dll" />
93 <include name="OpenAL64.dll" />
94 <include name="jinput-dx8*.dll" />
95 <include name="jinput-raw*.dll" />
100 <patternset id="lwjgl-windows-lwjgl.fileset">
101 <include name="lwjgl.dll" />
102 <include name="lwjgl64.dll" />
103 <include name="OpenAL32.dll" />
104 <include name="OpenAL64.dll" />
105 </patternset>
106 <patternset id="lwjgl-windows-jinput.fileset">
107 <include name="jinput-dx8*.dll" />
108 <include name="jinput-raw*.dll" />
109 </patternset>
96110 </patternset>
97
111
98112 <!-- Files to include in linux, glibc2.3 package -->
99113 <patternset id="lwjgl-linux.fileset">
100 <include name="liblwjgl*.so" />
101 <include name="libopenal*.so" />
102 <include name="libjinput-linux.so" />
103 <include name="libjinput-linux64.so" />
114 <patternset id="lwjgl-linux-lwjgl.fileset">
115 <include name="liblwjgl*.so" />
116 <include name="libopenal*.so" />
117 </patternset>
118 <patternset id="lwjgl-linux-jinput.fileset">
119 <include name="libjinput-linux.so" />
120 <include name="libjinput-linux64.so" />
121 </patternset>
104122 </patternset>
105
123
106124 <!-- Files to include in mac os x package -->
107125 <patternset id="lwjgl-macosx.fileset">
108 <include name="liblwjgl.jnilib" />
109 <include name="openal.dylib" />
110 <include name="libjinput-osx.jnilib" />
111 <include name="libjinput-osx-legacy.jnilib" />
126 <patternset id="lwjgl-macosx-lwjgl.fileset">
127 <include name="liblwjgl.jnilib" />
128 <include name="openal.dylib" />
129 </patternset>
130 <patternset id="lwjgl-macosx-jinput.fileset">
131 <include name="libjinput-osx.jnilib" />
132 <include name="libjinput-osx-legacy.jnilib" />
133 </patternset>
112134 </patternset>
113
135
114136 <!-- Files to include in solaris package -->
115137 <patternset id="lwjgl-solaris.fileset">
116138 <include name="liblwjgl*.so" />
117 <include name="libopenal.so" />
139 <include name="libopenal*.so" />
118140 </patternset>
119
141
120142 <!-- Files to include in source distribution -->
121143 <fileset id="lwjgl.source.fileset" dir=".">
122144 <include name="build.xml" />
131153 <exclude name="res/Missing_you.mod" />
132154 <exclude name="res/phero*.*" />
133155 </patternset>
134
156
135157 <!-- files in the optional package -->
136158 <patternset id="lwjgl_optional">
137159 <include name="res/**" />
142164 <include name="doc/CREDITS" />
143165 <include name="doc/LICENSE" />
144166 <include name="doc/README" />
145 </patternset>
146
167 </patternset>
168
147169 <!-- files in the lwjgl_applet package -->
148170 <patternset id="lwjgl_applet">
149171 <include name="applet/**" />
150172 <exclude name="applet/appletviewer.policy" />
151173 <exclude name="applet/lwjglkeystore" />
152 </patternset>
153
174 </patternset>
175
154176 <uptodate property="lwjgl.main.built" targetfile="${lwjgl.lib}/windows/lwjgl.dll" >
155177 <srcfiles dir= "${lwjgl.src.native}/common" includes="*.c*"/>
156178 <srcfiles dir= "${lwjgl.src.native}/windows" includes="*.c"/>
157179 </uptodate>
158 </project>
180 </project>
00 <project name="generator">
11
22 <!-- clean the generated files -->
3 <target name="clean-generated" description="Deletes the generated java and native source">
3 <target name="clean-generated" description="Deletes the generated java source">
44 <delete quiet="true" failonerror="false">
55 <fileset dir="${lwjgl.src}/generated" includes="**"/>
6 <fileset dir="${lwjgl.src.native}/generated" includes="**"/>
76 </delete>
87 </target>
9
8
9 <target name="clean-generated-native" description="Deletes the generated native source" depends="clean-generated">
10 <delete quiet="false" failonerror="false">
11 <fileset dir="${lwjgl.src.native}/generated" includes="**"/>
12 </delete>
13 </target>
14
1015 <!-- Compiles the Java generator source code -->
1116 <target name="generators" description="Compiles the native method generators">
1217 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
18 <include name="org/lwjgl/util/generator/openal/**.java"/>
19 <include name="org/lwjgl/util/generator/opengl/**.java"/>
20 <include name="org/lwjgl/util/generator/opencl/**.java"/>
1321 <compilerarg value="-Xlint:all"/>
1422 </javac>
1523 <!-- Compile helper classes used by the templates -->
16 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.4" target="1.4" taskname="generator">
24 <javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
25 <include name="org/lwjgl/PointerWrapper.java"/>
26 <include name="org/lwjgl/PointerBuffer.java"/>
27 <!-- OpenGL -->
1728 <include name="org/lwjgl/opengl/GLSync.java"/>
1829 <include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
19 <include name="org/lwjgl/opengl/PointerWrapper.java"/>
30 <include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
31 <!-- OpenCL -->
32 <include name="org/lwjgl/opencl/CLPlatform.java"/>
33 <include name="org/lwjgl/opencl/CLDevice.java"/>
34 <include name="org/lwjgl/opencl/CLContext.java"/>
35 <include name="org/lwjgl/opencl/CLContextCallback.java"/>
36 <include name="org/lwjgl/opencl/CLCommandQueue.java"/>
37 <include name="org/lwjgl/opencl/CLMem.java"/>
38 <include name="org/lwjgl/opencl/CLMemObjectDestructorCallback.java"/>
39 <include name="org/lwjgl/opencl/CLBuildProgramCallback.java"/>
40 <include name="org/lwjgl/opencl/CLNativeKernel.java"/>
41 <include name="org/lwjgl/opencl/CLEventCallback.java"/>
42 <include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
2043 </javac>
2144 </target>
2245
2346 <!-- Proxy target to generate it all -->
24 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references" description="Generates java and native source"/>
25
26 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references" description="Generates java and native source"/>
47 <target name="generate-all" depends="generate-openal, generate-opengl, generate-opengl-capabilities, generate-opengl-references, generate-opencl, generate-opencl-capabilities" description="Generates java and native source"/>
48
49 <target name="generate-debug" depends="generate-openal-debug, generate-opengl-debug, generate-opengl-capabilities-debug, generate-opengl-references, generate-opencl-debug, generate-opencl-capabilities-debug" description="Generates java and native source with debug functionality"/>
2750
2851 <!-- Generate OpenAL -->
2952 <target name="generate-openal" depends="generators" description="Generates java and native source for AL">
3760 <arg path="${lwjgl.src}/generated"/>
3861 <arg value="-d"/>
3962 <arg path="${lwjgl.src.native}/generated"/>
40 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
63 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
4164 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
4265 </apply>
4366 </target>
44
67
4568 <!-- Generate OpenAL [DEBUG] -->
4669 <target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
4770 <apply executable="apt" parallel="true">
5477 <arg path="${lwjgl.src}/generated"/>
5578 <arg value="-d"/>
5679 <arg path="${lwjgl.src.native}/generated"/>
57 <arg value="-Atypemap=org.lwjgl.util.generator.ALTypeMap"/>
80 <arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
5881 <arg value="-Ageneratechecks"/>
5982 <fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
6083 </apply>
7396 <arg value="-d"/>
7497 <arg path="${lwjgl.src.native}/generated"/>
7598 <arg value="-Acontextspecific"/>
76 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
99 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
77100 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
78101 </apply>
79102 </target>
92115 <arg path="${lwjgl.src.native}/generated"/>
93116 <arg value="-Ageneratechecks"/>
94117 <arg value="-Acontextspecific"/>
95 <arg value="-Atypemap=org.lwjgl.util.generator.GLTypeMap"/>
96 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
97 </apply>
98 </target>
99
100 <!-- Generate references -->
118 <arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
119 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
120 </apply>
121 </target>
122
123 <!-- Generate OpenGL references -->
101124 <target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
102125 <apply executable="apt" parallel="true">
103126 <arg value="-nocompile"/>
104127 <arg value="-factory"/>
105 <arg value="org.lwjgl.util.generator.ReferencesGeneratorProcessorFactory"/>
106 <arg value="-cp"/>
107 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
108 <arg value="-s"/>
109 <arg path="${lwjgl.src}/generated"/>
110 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
111 </apply>
112 </target>
113
114 <!-- Generate context capabilities -->
128 <arg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessorFactory"/>
129 <arg value="-cp"/>
130 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
131 <arg value="-s"/>
132 <arg path="${lwjgl.src}/generated"/>
133 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
134 </apply>
135 </target>
136
137 <!-- Generate OpenGL context capabilities -->
115138 <target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
116139 <apply executable="apt" parallel="true">
117140 <arg value="-nocompile"/>
118141 <arg value="-factory"/>
119 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
120 <arg value="-cp"/>
121 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
122 <arg value="-s"/>
123 <arg path="${lwjgl.src}/generated"/>
124 <arg value="-Acontextspecific"/>
125 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
126 </apply>
127 </target>
128
129 <!-- Generate context capabilities [DEBUG] -->
142 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
143 <arg value="-cp"/>
144 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
145 <arg value="-s"/>
146 <arg path="${lwjgl.src}/generated"/>
147 <arg value="-Acontextspecific"/>
148 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
149 </apply>
150 </target>
151
152 <!-- Generate OpenGL context capabilities [DEBUG] -->
130153 <target name="generate-opengl-capabilities-debug" depends="generators" description="Generates java and native source for GL">
131154 <apply executable="apt" parallel="true">
132155 <arg value="-nocompile"/>
133156 <arg value="-factory"/>
134 <arg value="org.lwjgl.util.generator.ContextGeneratorProcessorFactory"/>
157 <arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
135158 <arg value="-cp"/>
136159 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
137160 <arg value="-s"/>
140163 <arg value="-Acontextspecific"/>
141164 <fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
142165 </apply>
143 </target>
166 </target>
167
168 <!-- Generate OpenCL -->
169 <target name="generate-opencl" depends="generators" description="Generates java and native source for CL">
170 <apply executable="apt" parallel="true">
171 <arg value="-nocompile"/>
172 <arg value="-factory"/>
173 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
174 <arg value="-cp"/>
175 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
176 <arg value="-s"/>
177 <arg path="${lwjgl.src}/generated"/>
178 <arg value="-d"/>
179 <arg path="${lwjgl.src.native}/generated"/>
180 <arg value="-Acontextspecific"/>
181 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
182 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
183 </apply>
184 </target>
185
186 <!-- Generate OpenCL [DEBUG] -->
187 <target name="generate-opencl-debug" depends="generators" description="Generates java and native source for CL">
188 <apply executable="apt" parallel="true">
189 <arg value="-nocompile"/>
190 <arg value="-factory"/>
191 <arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
192 <arg value="-cp"/>
193 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
194 <arg value="-s"/>
195 <arg path="${lwjgl.src}/generated"/>
196 <arg value="-d"/>
197 <arg path="${lwjgl.src.native}/generated"/>
198 <arg value="-Ageneratechecks"/>
199 <arg value="-Acontextspecific"/>
200 <arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
201 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
202 </apply>
203 </target>
204
205 <!-- Generate OpenCL capabilities -->
206 <target name="generate-opencl-capabilities" depends="generators" description="Generates capabilities for CL">
207 <apply executable="apt" parallel="true">
208 <arg value="-nocompile"/>
209 <arg value="-factory"/>
210 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
211 <arg value="-cp"/>
212 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
213 <arg value="-s"/>
214 <arg path="${lwjgl.src}/generated"/>
215 <arg value="-Acontextspecific"/>
216 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
217 </apply>
218 </target>
219
220 <!-- Generate OpenCL capabilities [DEBUG] -->
221 <target name="generate-opencl-capabilities-debug" depends="generators" description="Generates capabilities for CL">
222 <apply executable="apt" parallel="true">
223 <arg value="-nocompile"/>
224 <arg value="-factory"/>
225 <arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
226 <arg value="-cp"/>
227 <arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
228 <arg value="-s"/>
229 <arg path="${lwjgl.src}/generated"/>
230 <arg value="-Ageneratechecks"/>
231 <arg value="-Acontextspecific"/>
232 <fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
233 </apply>
234 </target>
144235 </project>
0 <project name="maven">
1 <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
2 <property name="lwjgl.src.generated" location="${lwjgl.src}/generated" />
3 <property name="lwjgl.maven" location="maven" />
4 <property name="lwjgl.dstMaven" location="${lwjgl.temp}/maven" />
5
6 <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
7
8 <property name="lwjgl-maven-version" value="2.7.0"/>
9
10 <fileset id="lwjgl-sources.manual.fileset" dir="${lwjgl.src.java}">
11 <patternset refid="lwjgl.package.pattern" />
12 </fileset>
13
14 <fileset id="lwjgl-sources.generated.fileset" dir="${lwjgl.src.generated}">
15 <include name="**/*" />
16 </fileset>
17 <fileset id="lwjgl_util_applet-sources.fileset" dir="${lwjgl.src.java}">
18 <patternset refid="lwjgl_util_applet.package.pattern" />
19 </fileset>
20
21 <fileset id="lwjgl_util-sources.fileset" dir="${lwjgl.src.java}">
22 <patternset refid="lwjgl_util.package.pattern" />
23 </fileset>
24
25
26 <target name="maven-full">
27 <antcall target="clean-java" />
28 <antcall target="-initialize" />
29
30 <antcall target="generate-all" />
31 <antcall target="compile" />
32 <antcall target="-createjars" />
33 <antcall target="maven"/>
34 </target>
35
36 <target name="maven">
37 <delete dir="${lwjgl.dstMaven}" quiet="true" failonerror="false" taskname="cleaning maven dist" />
38 <mkdir dir="${lwjgl.dstMaven}" taskname="initialiazing temp maven folder" />
39 <antcall target="-copylwjgljars" />
40 <antcall target="-createmavensourcejars" />
41 <antcall target="-createmavenjavadocs" />
42 <antcall target="-createmavennativejars" />
43 <antcall target="-copymavenpoms"/>
44 <antcall target="-copymavendeploybuild"/>
45 <antcall target="-copymaventdist"/>
46 </target>
47
48
49 <target name="-copylwjgljars">
50 <copy todir="${lwjgl.dstMaven}">
51 <fileset dir="${lwjgl.temp}/jar/">
52 <patternset>
53 <include name="lwjgl.jar" />
54 <include name="lwjgl_util.jar" />
55 <include name="lwjgl_util_applet.jar" />
56 </patternset>
57 </fileset>
58 </copy>
59 </target>
60
61 <!-- Packages the java files -->
62 <target name="-createmavensourcejars">
63
64 <jar destfile="${lwjgl.dstMaven}/lwjgl-sources.jar" taskname="lwjgl-sources.jar">
65 <fileset refid="lwjgl-sources.manual.fileset" />
66 <fileset refid="lwjgl-sources.generated.fileset" />
67 </jar>
68
69 <jar destfile="${lwjgl.dstMaven}/lwjgl_util_applet-sources.jar" taskname="lwjgl_util_applet-sources.jar">
70 <fileset refid="lwjgl_util_applet-sources.fileset" />
71 </jar>
72
73 <jar destfile="${lwjgl.dstMaven}/lwjgl_util-sources.jar" taskname="lwjgl_util-sources.jar">
74 <fileset refid="lwjgl_util-sources.fileset" />
75 </jar>
76 </target>
77
78 <target name="-createmavenjavadocs">
79 <!-- Creates the Javadoc -->
80
81 <javadoc destdir="${lwjgl.dstMaven}/lwjgl-javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL API" useexternalfile="true">
82 <fileset refid="lwjgl-sources.manual.fileset"/>
83 <fileset refid="lwjgl-sources.generated.fileset"/>
84 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
85 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
86 </javadoc>
87 <jar destfile="${lwjgl.dstMaven}/lwjgl-javadoc.jar" taskname="lwjgl-javadoc.jar">
88 <fileset dir="${lwjgl.dstMaven}/lwjgl-javadoc" />
89 </jar>
90
91 <javadoc destdir="${lwjgl.dstMaven}/lwjgl_util-javadoc" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/lwjgl.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL UTIL API" useexternalfile="true">
92 <fileset refid="lwjgl_util-sources.fileset"/>
93 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
94 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
95 </javadoc>
96 <jar destfile="${lwjgl.dstMaven}/lwjgl_util-javadoc.jar" taskname="lwjgl_util-javadoc.jar">
97 <fileset dir="${lwjgl.dstMaven}/lwjgl_util-javadoc" />
98 </jar>
99
100 <javadoc destdir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/lwjgl.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL UTIL API" useexternalfile="true">
101 <fileset refid="lwjgl_util_applet-sources.fileset"/>
102 <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle>
103 <bottom><![CDATA[<i>Copyright &#169; 2002-2010 lwjgl.org. All Rights Reserved.</i>]]></bottom>
104 </javadoc>
105 <jar destfile="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc.jar" taskname="lwjgl_util_applet-javadoc.jar">
106 <fileset dir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" />
107 </jar>
108
109 <delete dir="${lwjgl.dstMaven}/lwjgl-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl" />
110 <delete dir="${lwjgl.dstMaven}/lwjgl_util-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl_util" />
111 <delete dir="${lwjgl.dstMaven}/lwjgl_util_applet-javadoc" quiet="true" failonerror="false" taskname="cleaning maven javadoc temps lwjgl_util_applet" />
112 </target>
113
114 <target name="-createmavennativejars">
115 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-win.jar" taskname="lwjgl-platform-natives-win.jar">
116 <fileset dir="${lwjgl.lib}/windows">
117 <patternset refid="lwjgl-windows-lwjgl.fileset"/>
118 </fileset>
119 </jar>
120 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-linux.jar" taskname="lwjgl-platform-natives-linux.jar">
121 <fileset dir="${lwjgl.lib}/linux">
122 <patternset refid="lwjgl-linux-lwjgl.fileset"/>
123 </fileset>
124 </jar>
125 <jar destfile="${lwjgl.dstMaven}/lwjgl-platform-natives-mac.jar" taskname="lwjgl-platform-natives-mac.jar">
126 <fileset dir="${lwjgl.lib}/macosx">
127 <patternset refid="lwjgl-macosx-lwjgl.fileset"/>
128 </fileset>
129 </jar>
130 </target>
131
132 <target name="-copymavenpoms">
133 <copy todir="${lwjgl.dstMaven}">
134 <fileset dir="${lwjgl.maven}">
135 <include name="*.pom" />
136 </fileset>
137 <filterset>
138 <filter token="VERSION" value="${lwjgl-maven-version}"/>
139 </filterset>
140 </copy>
141 </target>
142
143 <target name="-copymavendeploybuild">
144 <copy todir="${lwjgl.dstMaven}">
145 <fileset dir="${lwjgl.maven}">
146 <include name="build.xml" />
147 </fileset>
148 </copy>
149 </target>
150
151 <target name="-copymaventdist">
152 <zip destfile="${lwjgl.dist}/lwjgl-maven-${lwjgl.version}.zip" basedir="${lwjgl.temp}" includes="maven/**" />
153 </target>
154 </project>
1010 <input message="Please type the password for the keystore" addproperty="sign.pwd"/>
1111
1212 <antcall target="-webstart_demo">
13 <param name="keystore" value="signing/matzon_java_code_signing.keystore"/>
14 <param name="alias" value="oddlabs_java_code_signing"/>
13 <param name="keystore" value="signing/lwjgl.jks"/>
14 <param name="alias" value="lwjgl"/>
1515 <param name="password" value="${sign.pwd}"/>
1616 </antcall>
1717 </target>
1818
19 <!-- -->
19 <!-- Create webstart demo and extension from release files -->
2020 <target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos">
2121
2222 <!-- delete existing temp -->
2323 <delete dir="${lwjgl.temp}"/>
2424
25 <!-- unzip common files -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/jnlp/temp" overwrite="true"/>
27 <copy file="${lwjgl.lib}/lwjgl_test.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_test.jar"/>
28 <copy file="${lwjgl.lib}/lwjgl_util.jar" tofile="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/lwjgl_util.jar"/>
25 <!-- unzip release to temp dir -->
26 <unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/webstart/temp" overwrite="true"/>
2927
30 <!-- move files to unified structure -->
31 <move todir="${lwjgl.temp}/jnlp/temp">
32 <fileset dir="${lwjgl.temp}/jnlp/temp/lwjgl-${lwjgl.version}/">
33 <include name="**"/>
28 <!-- DEMO SECTION -->
29 <move file="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/jar/lwjgl_test.jar" tofile="${lwjgl.temp}/webstart/lwjgl_test.jar"/>
30 <jar destfile="${lwjgl.temp}/webstart/lwjgl_test.jar" update="true">
31 <manifest>
32 <attribute name="Sealed" value="true"/>
33 </manifest>
34 </jar>
35 <jar destfile="${lwjgl.temp}/webstart/media.jar" basedir="${lwjgl.res}">
36 <manifest>
37 <attribute name="Sealed" value="true"/>
38 </manifest>
39 </jar>
40
41 <!-- EXTENSION SECTION -->
42 <move todir="${lwjgl.temp}/webstart/${lwjgl.version}/" flatten="true">
43 <fileset dir="${lwjgl.temp}/webstart/temp">
44 <include name="**/jinput.jar"/>
45 <include name="**/lwjgl*.jar"/>
46 <exclude name="**/lwjgl_util_applet.jar"/>
47 <exclude name="**/lwjgl-debug.jar"/>
3448 </fileset>
3549 </move>
3650
37 <!-- move relevant files to root -->
38 <move todir="${lwjgl.temp}/jnlp/" flatten="true">
39 <fileset dir="${lwjgl.temp}/jnlp/temp">
40 <include name="**/jinput.jar"/>
41 <include name="**/lwjgl*.jar"/>
42 </fileset>
43 </move>
44
45 <!-- update Trusted-Library -->
46 <jar destfile="${lwjgl.temp}/jnlp/lwjgl.jar" update="true">
51 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" update="true">
4752 <manifest>
53 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
54 <attribute name="Specification-Version" value="${lwjgl.version}"/>
55 <attribute name="Specification-Vendor" value="lwjgl.org"/>
56 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
57 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
58 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
59 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
60 <attribute name="Extension-Name" value="org.lwjgl"/>
4861 <attribute name="Sealed" value="true"/>
4962 <attribute name="Trusted-Library" value="true"/>
5063 </manifest>
5164 </jar>
5265
53 <jar destfile="${lwjgl.temp}/jnlp/jinput.jar" update="true">
66 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" update="true">
5467 <manifest>
68 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
69 <attribute name="Specification-Version" value="${lwjgl.version}"/>
70 <attribute name="Specification-Vendor" value="lwjgl.org"/>
71 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
72 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
73 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
74 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
75 <attribute name="Extension-Name" value="org.lwjgl"/>
5576 <attribute name="Sealed" value="true"/>
77 <attribute name="Trusted-Library" value="true"/>
5678 </manifest>
5779 </jar>
5880
59 <jar destfile="${lwjgl.temp}/jnlp/lwjgl_util.jar" update="true">
81 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" update="true">
6082 <manifest>
83 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
84 <attribute name="Specification-Version" value="${lwjgl.version}"/>
85 <attribute name="Specification-Vendor" value="lwjgl.org"/>
86 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
87 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
88 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
89 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
90 <attribute name="Extension-Name" value="org.lwjgl"/>
6191 <attribute name="Sealed" value="true"/>
92 <attribute name="Trusted-Library" value="true"/>
6293 </manifest>
63 </jar>
94 </jar>
6495
6596 <!-- create native jars -->
66 <jar destfile="${lwjgl.temp}/jnlp/native_windows.jar" basedir="${lwjgl.temp}/jnlp/temp/native/windows">
97 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/windows">
6798 <manifest>
99 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
100 <attribute name="Specification-Version" value="${lwjgl.version}"/>
101 <attribute name="Specification-Vendor" value="lwjgl.org"/>
102 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
103 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
104 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
105 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
106 <attribute name="Extension-Name" value="org.lwjgl"/>
68107 <attribute name="Sealed" value="true"/>
108 <attribute name="Trusted-Library" value="true"/>
69109 </manifest>
70110 </jar>
71111
72 <jar destfile="${lwjgl.temp}/jnlp/native_linux.jar" basedir="${lwjgl.temp}/jnlp/temp/native/linux">
112 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/linux">
73113 <manifest>
114 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
115 <attribute name="Specification-Version" value="${lwjgl.version}"/>
116 <attribute name="Specification-Vendor" value="lwjgl.org"/>
117 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
118 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
119 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
120 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
121 <attribute name="Extension-Name" value="org.lwjgl"/>
74122 <attribute name="Sealed" value="true"/>
123 <attribute name="Trusted-Library" value="true"/>
75124 </manifest>
76125 </jar>
77126
78 <jar destfile="${lwjgl.temp}/jnlp/native_macosx.jar" basedir="${lwjgl.temp}/jnlp/temp/native/macosx">
127 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/macosx">
79128 <manifest>
129 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
130 <attribute name="Specification-Version" value="${lwjgl.version}"/>
131 <attribute name="Specification-Vendor" value="lwjgl.org"/>
132 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
133 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
134 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
135 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
136 <attribute name="Extension-Name" value="org.lwjgl"/>
80137 <attribute name="Sealed" value="true"/>
138 <attribute name="Trusted-Library" value="true"/>
81139 </manifest>
82140 </jar>
83141
84 <jar destfile="${lwjgl.temp}/jnlp/native_solaris.jar" basedir="${lwjgl.temp}/jnlp/temp/native/solaris">
142 <jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/solaris">
85143 <manifest>
144 <attribute name="Specification-Title" value="LWJGL ${lwjgl.version}"/>
145 <attribute name="Specification-Version" value="${lwjgl.version}"/>
146 <attribute name="Specification-Vendor" value="lwjgl.org"/>
147 <attribute name="Implementation-Title" value="LWJGL ${lwjgl.version}"/>
148 <attribute name="Implementation-Version" value="${lwjgl.version}"/>
149 <attribute name="Implementation-Vendor" value="lwjgl.org"/>
150 <attribute name="Implementation-Vendor-Id" value="org.lwjgl"/>
151 <attribute name="Extension-Name" value="org.lwjgl"/>
86152 <attribute name="Sealed" value="true"/>
87 </manifest>
88 </jar>
89
90 <!-- create media jar -->
91 <jar destfile="${lwjgl.temp}/jnlp/media.jar" basedir="${lwjgl.res}">
92 <manifest>
93 <attribute name="Sealed" value="true"/>
153 <attribute name="Trusted-Library" value="true"/>
94154 </manifest>
95155 </jar>
96156
97157 <!-- sign 'em -->
98 <signjar jar="${lwjgl.temp}/jnlp/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
99 <signjar jar="${lwjgl.temp}/jnlp/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
100 <signjar jar="${lwjgl.temp}/jnlp/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
101 <signjar jar="${lwjgl.temp}/jnlp/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
102 <signjar jar="${lwjgl.temp}/jnlp/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
103 <signjar jar="${lwjgl.temp}/jnlp/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
104 <signjar jar="${lwjgl.temp}/jnlp/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
105 <signjar jar="${lwjgl.temp}/jnlp/media.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
158 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
159 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
160 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
161 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
162 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
163 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
164 <signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" alias="${alias}" keystore="${keystore}" storepass="${password}"/>
165
166 <!-- copy over extension jnlp file -->
167 <copy todir="${lwjgl.temp}/webstart/${lwjgl.version}">
168 <fileset dir="${lwjgl.web}/webstart">
169 <include name="extension.jnlp"/>
170 </fileset>
171 <filterset>
172 <filter token="LWJGL_VERSION" value="${lwjgl.version}"/>
173 </filterset>
174 </copy>
175
176 <!-- nuke extracted dir -->
177 <delete dir="${lwjgl.temp}/webstart/temp"/>
178
106179 </target>
107180 </project>
1515 <fileset dir="." includes="*.so"/>
1616 </delete>
1717 </target>
18
18
1919 <target name="compile">
2020 <exec executable="uname" outputproperty="hwplatform">
2121 <arg value="-m"/>
2626 <condition property="cflags_pthread" value="-pthreads" else="-pthread">
2727 <os name="SunOS" />
2828 </condition>
29 <condition property="version_script_flags32" value="" else="-Wl,--version-script=${native}/linux/lwjgl.map">
29 <condition property="version_script_flags32" value="" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
3030 <os name="SunOS" />
3131 </condition>
32 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script=${native}/linux/lwjgl.map">
32 <condition property="version_script_flags64" value="-m64" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
3333 <and>
3434 <os name="SunOS" />
3535 </and>
4949 </or>
5050 </not>
5151 </condition>
52
52
5353 <!-- On linux, the 64 bit jre doesn't have the 32 bit libs -->
5454 <condition property="build.64bit.only">
5555 <and>
5757 <equals arg1="${hwplatform}" arg2="x86_64"/>
5858 </and>
5959 </condition>
60
60
6161 <antcall target="compile32"/>
6262 <antcall target="compile64"/>
6363 </target>
64
64
6565 <target name="compile32" unless="build.64bit.only">
6666 <mkdir dir="x32"/>
6767 <apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
8888 </apply>
8989 </target>
9090
91 <target name="compile64" unless="build.32bit.only">
91 <target name="compile64" unless="build.32bit.only">
9292 <mkdir dir="x64"/>
9393 <apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
9494 <arg line="${cflags64} ${cflags_pthread}"/>
3030 */
3131 package org.lwjgl;
3232
33 import java.nio.Buffer;
34 import java.nio.ByteBuffer;
35 import java.nio.DoubleBuffer;
36 import java.nio.FloatBuffer;
37 import java.nio.IntBuffer;
38 import java.nio.ShortBuffer;
39 import java.nio.LongBuffer;
33 import java.nio.*;
4034
4135 /**
4236 * <p>A class to check buffer boundaries in general. If there is unsufficient space
4741 * </p>
4842 * @author cix_foo <cix_foo@users.sourceforge.net>
4943 * @author elias_naur <elias_naur@users.sourceforge.net>
50 * @version $Revision: 3334 $
51 * $Id: BufferChecks.java 3334 2010-04-22 23:21:48Z spasi $
44 * @version $Revision: 3419 $
45 * $Id: BufferChecks.java 3419 2010-09-30 17:21:50Z spasi $
5246 */
5347 public class BufferChecks {
5448 /** Static methods only! */
8680 }
8781 }
8882
89 /** Helper methods to ensure an IntBuffer is null-terminated */
83 /** Helper method to ensure an IntBuffer is null-terminated */
9084 public static void checkNullTerminated(IntBuffer buf) {
91 if ( buf.get(buf.limit() - 1) != 0 ) {
85 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
86 throw new IllegalArgumentException("Missing null termination");
87 }
88 }
89
90 /** Helper method to ensure a LongBuffer is null-terminated */
91 public static void checkNullTerminated(LongBuffer buf) {
92 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
93 throw new IllegalArgumentException("Missing null termination");
94 }
95 }
96
97 /** Helper method to ensure a PointerBuffer is null-terminated */
98 public static void checkNullTerminated(PointerBuffer buf) {
99 if ( LWJGLUtil.CHECKS && buf.get(buf.limit() - 1) != 0 ) {
92100 throw new IllegalArgumentException("Missing null termination");
93101 }
94102 }
137145 }
138146 }
139147
148 public static void checkDirect(PointerBuffer buf) {
149 // NO-OP, PointerBuffer is always direct.
150 }
151
152 public static void checkArray(Object[] array) {
153 if ( LWJGLUtil.CHECKS && (array == null || array.length == 0) )
154 throw new IllegalArgumentException("Invalid array");
155 }
156
140157 /**
141158 * This is a separate call to help inline checkBufferSize.
142159 */
143160 private static void throwBufferSizeException(Buffer buf, int size) {
144161 throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size);
162 }
163
164 private static void throwBufferSizeException(PointerBuffer buf, int size) {
165 throw new IllegalArgumentException("Number of remaining pointer buffer elements is " + buf.remaining() + ", must be at least " + size);
166 }
167
168 private static void throwArraySizeException(Object[] array, int size) {
169 throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
170 }
171
172 private static void throwArraySizeException(long[] array, int size) {
173 throw new IllegalArgumentException("Number of array elements is " + array.length + ", must be at least " + size);
145174 }
146175
147176 /**
160189 }
161190 }
162191
192 /**
193 * Detects the buffer type and performs the corresponding check
194 * and also returns the buffer position in bytes.
195 *
196 * @param buffer the buffer to check
197 * @param size the size to check
198 *
199 * @return the buffer position in bytes
200 */
201 public static int checkBuffer(final Buffer buffer, final int size) {
202 final int posShift;
203 if ( buffer instanceof ByteBuffer ) {
204 BufferChecks.checkBuffer((ByteBuffer)buffer, size);
205 posShift = 0;
206 } else if ( buffer instanceof ShortBuffer ) {
207 BufferChecks.checkBuffer((ShortBuffer)buffer, size);
208 posShift = 1;
209 } else if ( buffer instanceof IntBuffer ) {
210 BufferChecks.checkBuffer((IntBuffer)buffer, size);
211 posShift = 2;
212 } else if ( buffer instanceof LongBuffer ) {
213 BufferChecks.checkBuffer((LongBuffer)buffer, size);
214 posShift = 4;
215 } else if ( buffer instanceof FloatBuffer ) {
216 BufferChecks.checkBuffer((FloatBuffer)buffer, size);
217 posShift = 2;
218 } else if ( buffer instanceof DoubleBuffer ) {
219 BufferChecks.checkBuffer((DoubleBuffer)buffer, size);
220 posShift = 4;
221 } else
222 throw new IllegalArgumentException("Unsupported Buffer type specified: " + buffer.getClass());
223
224 return buffer.position() << posShift;
225 }
226
163227 public static void checkBuffer(ByteBuffer buf, int size) {
164228 if ( LWJGLUtil.CHECKS ) {
165229 checkBufferSize(buf, size);
201265 checkDirect(buf);
202266 }
203267 }
204 }
268
269 public static void checkBuffer(PointerBuffer buf, int size) {
270 if ( LWJGLUtil.CHECKS && buf.remaining() < size ) {
271 throwBufferSizeException(buf, size);
272 }
273 }
274
275 public static void checkArray(Object[] array, int size) {
276 if ( LWJGLUtil.CHECKS && array.length < size )
277 throwArraySizeException(array, size);
278 }
279
280 public static void checkArray(long[] array, int size) {
281 if ( LWJGLUtil.CHECKS && array.length < size )
282 throwArraySizeException(array, size);
283 }
284
285 }
4444 * Some often-used Buffer code for creating native buffers of the appropriate size.
4545 *
4646 * @author $Author: matzon $
47 * @version $Revision: 2983 $
48 * $Id: BufferUtils.java 2983 2008-04-07 18:36:09Z matzon $
47 * @version $Revision: 3456 $
48 * $Id: BufferUtils.java 3456 2010-11-24 21:48:23Z matzon $
4949 */
5050
5151 public final class BufferUtils {
120120 }
121121
122122 /**
123 * Construct a PointerBuffer with the specified number
124 * of elements.
125 * @param size The size, in memory addresses
126 * @return a PointerBuffer
127 */
128 public static PointerBuffer createPointerBuffer(int size) {
129 return PointerBuffer.allocateDirect(size);
130 }
131
132 /**
123133 * @return n, where buffer_element_size=2^n.
124134 */
125135 public static int getElementSizeExponent(Buffer buf) {
144154 return buffer.position() << getElementSizeExponent(buffer);
145155 }
146156
157 /** Fill buffer with zeros from position to remaining */
158 public static void zeroBuffer(ByteBuffer b) {
159 zeroBuffer0(b, b.position(), b.remaining());
160 }
161
162 /** Fill buffer with zeros from position to remaining */
163 public static void zeroBuffer(ShortBuffer b) {
164 zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
165 }
166
167 /** Fill buffer with zeros from position to remaining */
168 public static void zeroBuffer(CharBuffer b) {
169 zeroBuffer0(b, b.position()*2L, b.remaining()*2L);
170 }
171
172 /** Fill buffer with zeros from position to remaining */
173 public static void zeroBuffer(IntBuffer b) {
174 zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
175 }
176
177 /** Fill buffer with zeros from position to remaining */
178 public static void zeroBuffer(FloatBuffer b) {
179 zeroBuffer0(b, b.position()*4L, b.remaining()*4L);
180 }
181
182 /** Fill buffer with zeros from position to remaining */
183 public static void zeroBuffer(LongBuffer b) {
184 zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
185 }
186
187 /** Fill buffer with zeros from position to remaining */
188 public static void zeroBuffer(DoubleBuffer b) {
189 zeroBuffer0(b, b.position()*8L, b.remaining()*8L);
190 }
191
192 /** Fill buffer with zeros from position to remaining */
193 private static native void zeroBuffer0(Buffer b, long off, long size);
147194 }
3434 /**
3535 *
3636 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3055 $
38 * $Id: DefaultSysImplementation.java 3055 2008-04-30 14:58:47Z elias_naur $
37 * @version $Revision: 3426 $
38 * $Id: DefaultSysImplementation.java 3426 2010-10-01 22:20:14Z spasi $
3939 */
4040 abstract class DefaultSysImplementation implements SysImplementation {
4141 public native int getJNIVersion();
42 public native int getPointerSize();
4243 public native void setDebug(boolean debug);
4344
4445 public long getTimerResolution() {
3131 package org.lwjgl;
3232
3333 import java.io.File;
34 import java.lang.reflect.Field;
3435 import java.lang.reflect.Method;
36 import java.lang.reflect.Modifier;
3537 import java.nio.ByteBuffer;
3638 import java.security.AccessController;
3739 import java.security.PrivilegedAction;
3840 import java.security.PrivilegedActionException;
3941 import java.security.PrivilegedExceptionAction;
40 import java.util.ArrayList;
41 import java.util.List;
42 import java.util.StringTokenizer;
43
42 import java.util.*;
4443
4544 /**
4645 * <p>
4847 * </p>
4948 *
5049 * @author Brian Matzon <brian@matzon.dk>
51 * @version $Revision: 3334 $
52 * $Id: LWJGLUtil.java 3334 2010-04-22 23:21:48Z spasi $
50 * @version $Revision: 3475 $
51 * $Id: LWJGLUtil.java 3475 2011-01-23 07:48:50Z matzon $
5352 */
5453 public class LWJGLUtil {
5554 public static final int PLATFORM_LINUX = 1;
5857 public static final String PLATFORM_LINUX_NAME = "linux";
5958 public static final String PLATFORM_MACOSX_NAME = "macosx";
6059 public static final String PLATFORM_WINDOWS_NAME = "windows";
61
60
6261 /** LWJGL Logo - 16 by 16 pixels */
63 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
62 public static final ByteBuffer LWJGLIcon16x16 = BufferUtils.createByteBuffer(16 * 16 * 4).put(new byte[] {
6463 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
6564 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -62, -41, -24, -1, 116, -92, -53, -1, 80, -117,
6665 -67, -1, 84, -114, -65, -1, -122, -81, -46, -1, -25, -17, -10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
105104 });
106105
107106 /** LWJGL Logo - 32 by 32 pixels */
108 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
107 public static final ByteBuffer LWJGLIcon32x32 = BufferUtils.createByteBuffer(32 * 32 * 4).put(new byte[] {
109108 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
110109 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
111110 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -6, -4, -3, -1, -53, -35,
268267
269268 public static final boolean CHECKS = !getPrivilegedBoolean("org.lwjgl.util.NoChecks");
270269
270 private static final int PLATFORM;
271
271272 static {
272273 LWJGLIcon16x16.flip();
273274 LWJGLIcon32x32.flip();
274 }
275
275
276 final String osName = getPrivilegedProperty("os.name");
277 if ( osName.startsWith("Windows") )
278 PLATFORM = PLATFORM_WINDOWS;
279 else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") )
280 PLATFORM = PLATFORM_LINUX;
281 else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
282 PLATFORM = PLATFORM_MACOSX;
283 else
284 throw new LinkageError("Unknown platform: " + osName);
285 }
286
276287 /**
277288 * @see #PLATFORM_WINDOWS
278289 * @see #PLATFORM_LINUX
280291 * @return the current platform type
281292 */
282293 public static int getPlatform() {
283 String osName = getPrivilegedProperty("os.name");
284
285 if (osName.startsWith("Windows")) {
286 return PLATFORM_WINDOWS;
287 } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) {
288 return PLATFORM_LINUX;
289 } else if (osName.startsWith("Mac OS X")) {
290 return PLATFORM_MACOSX;
291 } else {
292 throw new LinkageError("Unknown platform: " + osName);
293 }
294 }
295
294 return PLATFORM;
295 }
296
296297
297298 /**
298299 * @see #PLATFORM_WINDOWS_NAME
311312 default:
312313 return "unknown";
313314 }
314 }
315 }
315316
316317 /**
317318 * Locates the paths required by a library.
335336 */
336337 public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) {
337338 // need to pass path of possible locations of library to native side
338 List possible_paths = new ArrayList();
339 List<String> possible_paths = new ArrayList<String>();
339340
340341 String classloader_path = getPathFromClassLoader(libname, classloader);
341342 if (classloader_path != null) {
343344 possible_paths.add(classloader_path);
344345 }
345346
346 for (int i = 0; i < platform_lib_names.length; i++) {
347 String platform_lib_name = platform_lib_names[i];
347 for ( String platform_lib_name : platform_lib_names ) {
348348 String lwjgl_classloader_path = getPathFromClassLoader("lwjgl", classloader);
349 if (lwjgl_classloader_path != null) {
349 if ( lwjgl_classloader_path != null ) {
350350 log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path);
351351 possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator))
352 + File.separator + platform_lib_name);
352 + File.separator + platform_lib_name);
353353 }
354354
355355 // add Installer path
356356 String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath");
357 if (alternative_path != null) {
357 if ( alternative_path != null ) {
358358 possible_paths.add(alternative_path + File.separator + platform_lib_name);
359 }
359 }
360360
361361 // Add all possible paths from java.library.path
362362 String java_library_path = getPrivilegedProperty("java.library.path");
363363
364364 StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator);
365 while (st.hasMoreTokens()) {
365 while ( st.hasMoreTokens() ) {
366366 String path = st.nextToken();
367367 possible_paths.add(path + File.separator + platform_lib_name);
368368 }
376376 }
377377
378378 //create needed string array
379 String[] paths = new String[possible_paths.size()];
380 possible_paths.toArray(paths);
381 return paths;
379 return possible_paths.toArray(new String[possible_paths.size()]);
382380 }
383381
384382 static void execPrivileged(final String[] cmd_array) throws Exception {
385383 try {
386 Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() {
387 public Object run() throws Exception {
384 Process process = AccessController.doPrivileged(new PrivilegedExceptionAction<Process>() {
385 public Process run() throws Exception {
388386 return Runtime.getRuntime().exec(cmd_array);
389387 }
390388 });
398396 }
399397
400398 private static String getPrivilegedProperty(final String property_name) {
401 return (String)AccessController.doPrivileged(new PrivilegedAction() {
402 public Object run() {
399 return AccessController.doPrivileged(new PrivilegedAction<String>() {
400 public String run() {
403401 return System.getProperty(property_name);
404402 }
405403 });
419417 private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
420418 try {
421419 log("getPathFromClassLoader: searching for: " + libname);
422 Class c = classloader.getClass();
420 Class<?> c = classloader.getClass();
423421 while (c != null) {
424 final Class clazz = c;
422 final Class<?> clazz = c;
425423 try {
426 return (String)AccessController.doPrivileged(new PrivilegedExceptionAction() {
427 public Object run() throws Exception {
428 Method findLibrary = clazz.getDeclaredMethod("findLibrary", new Class[]{String.class});
424 return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() {
425 public String run() throws Exception {
426 Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class);
429427 findLibrary.setAccessible(true);
430 Object[] arguments = new Object[] {libname};
431 String path = (String)findLibrary.invoke(classloader, arguments);
428 String path = (String)findLibrary.invoke(classloader, libname);
432429 return path;
433430 }
434431 });
447444 * Gets a boolean property as a privileged action.
448445 */
449446 private static boolean getPrivilegedBoolean(final String property_name) {
450 Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() {
451 public Object run() {
452 return new Boolean(Boolean.getBoolean(property_name));
447 Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
448 public Boolean run() {
449 return Boolean.getBoolean(property_name);
453450 }
454451 });
455 return value.booleanValue();
456 }
457
452 return value;
453 }
454
458455 /**
459456 * Prints the given message to System.err if DEBUG is true.
460 *
457 *
461458 * @param msg Message to print
462459 */
463460 public static void log(String msg) {
465462 System.err.println(msg);
466463 }
467464 }
468
465
469466 /**
470467 * Method to determine if the current system is running a version of
471468 * Mac OS X better than the given version. This is only useful for Mac OS X
488485 }
489486 return major > major_required || (major == major_required && minor >= minor_required);
490487 }
491
492 }
488
489 /**
490 * Returns a map of public static final integer fields in the specified classes, to their String representations.
491 * An optional filter can be specified to only include specific fields. The target map may be null, in which
492 * case a new map is allocated and returned.
493 * <p>
494 * This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
495 *
496 * @param filter the filter to use (optional)
497 * @param target the target map (optional)
498 * @param tokenClasses an array of classes to get tokens from
499 *
500 * @return the token map
501 */
502
503 public static Map<Integer, String> getClassTokens(final TokenFilter filter, final Map<Integer, String> target, final Class ... tokenClasses) {
504 return getClassTokens(filter, target, Arrays.asList(tokenClasses));
505 }
506
507 /**
508 * Returns a map of public static final integer fields in the specified classes, to their String representations.
509 * An optional filter can be specified to only include specific fields. The target map may be null, in which
510 * case a new map is allocated and returned.
511 * <p>
512 * This method is useful when debugging to quickly identify values returned from the AL/GL/CL APIs.
513 *
514 * @param filter the filter to use (optional)
515 * @param target the target map (optional)
516 * @param tokenClasses the classes to get tokens from
517 *
518 * @return the token map
519 */
520 public static Map<Integer, String> getClassTokens(final TokenFilter filter, Map<Integer, String> target, final Iterable<Class> tokenClasses) {
521 if ( target == null )
522 target = new HashMap<Integer, String>();
523
524 final int TOKEN_MODIFIERS = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
525
526 for ( final Class tokenClass : tokenClasses ) {
527 for ( final Field field : tokenClass.getDeclaredFields() ) {
528 // Get only <public static final int> fields.
529 if ( (field.getModifiers() & TOKEN_MODIFIERS) == TOKEN_MODIFIERS && field.getType() == int.class ) {
530 try {
531 final int value = field.getInt(null);
532 if ( filter != null && !filter.accept(field, value) )
533 continue;
534
535 if ( target.containsKey(value) ) // Print colliding tokens in their hex representation.
536 target.put(value, toHexString(value));
537 else
538 target.put(value, field.getName());
539 } catch (IllegalAccessException e) {
540 // Ignore
541 }
542 }
543 }
544 }
545
546 return target;
547 }
548
549 /**
550 * Returns a string representation of the integer argument as an
551 * unsigned integer in base&nbsp;16. The string will be uppercase
552 * and will have a leading '0x'.
553 *
554 * @param value the integer value
555 *
556 * @return the hex string representation
557 */
558 public static String toHexString(final int value) {
559 return "0x" + Integer.toHexString(value).toUpperCase();
560 }
561
562 /** Simple interface for Field filtering. */
563 public interface TokenFilter {
564
565 /**
566 * Should return true if the specified Field passes the filter.
567 *
568 * @param field the Field to test
569 * @param value the integer value of the field
570 *
571 * @result true if the Field is accepted
572 */
573 boolean accept(Field field, int value);
574
575 }
576
577 }
3434 /**
3535 *
3636 * @author elias_naur <elias_naur@users.sourceforge.net>
37 * @version $Revision: 3298 $
38 * $Id: LinuxSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
37 * @version $Revision: 3418 $
38 * $Id: LinuxSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
3939 */
4040 final class LinuxSysImplementation extends J2SESysImplementation {
41 private final static int JNI_VERSION = 18;
41 private static final int JNI_VERSION = 19;
4242
4343 static {
4444 java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
5454
5555 String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
5656
57 for (int i = 0; i < browsers.length; i ++) {
58 final String browser = browsers[i];
57 for ( final String browser : browsers ) {
5958 try {
6059 LWJGLUtil.execPrivileged(new String[] { browser, url });
6160 return true;
3737 /**
3838 *
3939 * @author elias_naur <elias_naur@users.sourceforge.net>
40 * @version $Revision: 3298 $
41 * $Id: MacOSXSysImplementation.java 3298 2010-03-28 23:11:17Z matzon $
40 * @version $Revision: 3418 $
41 * $Id: MacOSXSysImplementation.java 3418 2010-09-28 21:11:35Z spasi $
4242 */
4343 final class MacOSXSysImplementation extends J2SESysImplementation {
44 private final static int JNI_VERSION = 18;
44 private static final int JNI_VERSION = 19;
4545
4646 static {
4747 // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
4848 * $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $
4949 */
5050 public final class NondirectBufferWrapper {
51 private final static int INITIAL_BUFFER_SIZE = 1;
52
53 private final static ThreadLocal thread_buffer = new ThreadLocal() {
54 protected Object initialValue() {
51 private static final int INITIAL_BUFFER_SIZE = 1;
52
53 private static final ThreadLocal<CachedBuffers> thread_buffer = new ThreadLocal<CachedBuffers>() {
54 protected CachedBuffers initialValue() {
5555 return new CachedBuffers(INITIAL_BUFFER_SIZE);
5656 }
5757 };
5858
5959 private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
60 CachedBuffers buffers = (CachedBuffers)thread_buffer.get();
60 CachedBuffers buffers = thread_buffer.get();
6161 int current_byte_size = buffers.byte_buffer.capacity();
6262 if (minimum_byte_size > current_byte_size) {
6363 buffers = new CachedBuffers(minimum_byte_size);
377377 return direct_buffer;
378378 }
379379
380 private final static class CachedBuffers {
380 private static final class CachedBuffers {
381381 private final ByteBuffer byte_buffer;
382382 private final ShortBuffer short_buffer_big;
383383 private final IntBuffer int_buffer_big;
0 /*
1 * Copyright (c) 2002-2010 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl;
32
33 import java.lang.reflect.Method;
34 import java.nio.*;
35
36 /**
37 * This class is a container for architecture independent pointer data.
38 * The interface mirrors the NIO LongBuffer API for convenience.
39 *
40 * @author Spasi
41 */
42 public class PointerBuffer implements Comparable {
43
44 private static final boolean is64Bit;
45
46 static {
47 // Use reflection so that we can compile this class for the Generator.
48 boolean is64 = false;
49 try {
50 Method m = Class.forName("org.lwjgl.Sys").getDeclaredMethod("is64Bit", (Class[])null);
51 is64 = (Boolean)m.invoke(null, (Object[])null);
52 } catch (Throwable t) {
53 // ignore
54 } finally {
55 is64Bit = is64;
56 }
57 }
58
59 protected final ByteBuffer pointers;
60
61 protected final Buffer view;
62 protected final IntBuffer view32;
63 protected final LongBuffer view64;
64
65 /**
66 * Creates a new PointerBuffer with the specified capacity.
67 *
68 * @param capacity the PointerBuffer size, in number of pointers
69 */
70 public PointerBuffer(final int capacity) {
71 this(BufferUtils.createByteBuffer(capacity * getPointerSize()));
72 }
73
74 /**
75 * Creates a new PointerBuffer using the specified ByteBuffer as its pointer
76 * data source. This is useful for users that do their own memory management
77 * over a big ByteBuffer, instead of allocating many small ones.
78 *
79 * @param source the source buffer
80 */
81 public PointerBuffer(final ByteBuffer source) {
82 if ( !source.isDirect() )
83 throw new IllegalArgumentException("ByteBuffer is not direct");
84
85 pointers = source.slice().order(source.order());
86
87 if ( is64Bit ) {
88 view32 = null;
89 view = view64 = pointers.asLongBuffer();
90 } else {
91 view = view32 = pointers.asIntBuffer();
92 view64 = null;
93 }
94 }
95
96 /**
97 * Returns the ByteBuffer that backs this PointerBuffer.
98 *
99 * @return the pointer ByteBuffer
100 */
101 public ByteBuffer getBuffer() {
102 return pointers;
103 }
104
105 /** Returns true if the underlying architecture is 64bit. */
106 public static boolean is64Bit() {
107 return is64Bit;
108 }
109
110 /**
111 * Returns the pointer size in bytes, based on the underlying architecture.
112 *
113 * @return The pointer size in bytes
114 */
115 public static int getPointerSize() {
116 return is64Bit ? 8 : 4;
117 }
118
119 /**
120 * Returns this buffer's capacity. </p>
121 *
122 * @return The capacity of this buffer
123 */
124 public final int capacity() {
125 return view.capacity();
126 }
127
128 /**
129 * Returns this buffer's position. </p>
130 *
131 * @return The position of this buffer
132 */
133 public final int position() {
134 return view.position();
135 }
136
137 /**
138 * Returns this buffer's position, in bytes. </p>
139 *
140 * @return The position of this buffer in bytes.
141 */
142 public final int positionByte() {
143 return position() * getPointerSize();
144 }
145
146 /**
147 * Sets this buffer's position. If the mark is defined and larger than the
148 * new position then it is discarded. </p>
149 *
150 * @param newPosition The new position value; must be non-negative
151 * and no larger than the current limit
152 *
153 * @return This buffer
154 *
155 * @throws IllegalArgumentException If the preconditions on <tt>newPosition</tt> do not hold
156 */
157 public final PointerBuffer position(int newPosition) {
158 view.position(newPosition);
159 return this;
160 }
161
162 /**
163 * Returns this buffer's limit. </p>
164 *
165 * @return The limit of this buffer
166 */
167 public final int limit() {
168 return view.limit();
169 }
170
171 /**
172 * Sets this buffer's limit. If the position is larger than the new limit
173 * then it is set to the new limit. If the mark is defined and larger than
174 * the new limit then it is discarded. </p>
175 *
176 * @param newLimit The new limit value; must be non-negative
177 * and no larger than this buffer's capacity
178 *
179 * @return This buffer
180 *
181 * @throws IllegalArgumentException If the preconditions on <tt>newLimit</tt> do not hold
182 */
183 public final PointerBuffer limit(int newLimit) {
184 view.limit(newLimit);
185 return this;
186 }
187
188 /**
189 * Sets this buffer's mark at its position. </p>
190 *
191 * @return This buffer
192 */
193 public final PointerBuffer mark() {
194 view.mark();
195 return this;
196 }
197
198 /**
199 * Resets this buffer's position to the previously-marked position.
200 * <p/>
201 * <p> Invoking this method neither changes nor discards the mark's
202 * value. </p>
203 *
204 * @return This buffer
205 *
206 * @throws java.nio.InvalidMarkException If the mark has not been set
207 */
208 public final PointerBuffer reset() {
209 view.reset();
210 return this;
211 }
212
213 /**
214 * Clears this buffer. The position is set to zero, the limit is set to
215 * the capacity, and the mark is discarded.
216 * <p/>
217 * <p> Invoke this method before using a sequence of channel-read or
218 * <i>put</i> operations to fill this buffer. For example:
219 * <p/>
220 * <blockquote><pre>
221 * buf.clear(); // Prepare buffer for reading
222 * in.read(buf); // Read data</pre></blockquote>
223 * <p/>
224 * <p> This method does not actually erase the data in the buffer, but it
225 * is named as if it did because it will most often be used in situations
226 * in which that might as well be the case. </p>
227 *
228 * @return This buffer
229 */
230 public final PointerBuffer clear() {
231 view.clear();
232 return this;
233 }
234
235 /**
236 * Flips this buffer. The limit is set to the current position and then
237 * the position is set to zero. If the mark is defined then it is
238 * discarded.
239 * <p/>
240 * <p> After a sequence of channel-read or <i>put</i> operations, invoke
241 * this method to prepare for a sequence of channel-write or relative
242 * <i>get</i> operations. For example:
243 * <p/>
244 * <blockquote><pre>
245 * buf.put(magic); // Prepend header
246 * in.read(buf); // Read data into rest of buffer
247 * buf.flip(); // Flip buffer
248 * out.write(buf); // Write header + data to channel</pre></blockquote>
249 * <p/>
250 * <p> This method is often used in conjunction with the {@link
251 * java.nio.ByteBuffer#compact compact} method when transferring data from
252 * one place to another. </p>
253 *
254 * @return This buffer
255 */
256 public final PointerBuffer flip() {
257 view.flip();
258 return this;
259 }
260
261 /**
262 * Rewinds this buffer. The position is set to zero and the mark is
263 * discarded.
264 * <p/>
265 * <p> Invoke this method before a sequence of channel-write or <i>get</i>
266 * operations, assuming that the limit has already been set
267 * appropriately. For example:
268 * <p/>
269 * <blockquote><pre>
270 * out.write(buf); // Write remaining data
271 * buf.rewind(); // Rewind buffer
272 * buf.get(array); // Copy data into array</pre></blockquote>
273 *
274 * @return This buffer
275 */
276 public final PointerBuffer rewind() {
277 view.rewind();
278 return this;
279 }
280
281 /**
282 * Returns the number of elements between the current position and the
283 * limit. </p>
284 *
285 * @return The number of elements remaining in this buffer
286 */
287 public final int remaining() {
288 return view.remaining();
289 }
290
291 /**
292 * Returns the number of bytes between the current position and the
293 * limit. </p>
294 *
295 * @return The number of bytes remaining in this buffer
296 */
297 public final int remainingByte() {
298 return remaining() * getPointerSize();
299 }
300
301 /**
302 * Tells whether there are any elements between the current position and
303 * the limit. </p>
304 *
305 * @return <tt>true</tt> if, and only if, there is at least one element
306 * remaining in this buffer
307 */
308 public final boolean hasRemaining() {
309 return view.hasRemaining();
310 }
311
312 /**
313 * Allocates a new pointer buffer.
314 * <p/>
315 * <p> The new buffer's position will be zero, its limit will be its
316 * capacity, and its mark will be undefined. </p>
317 *
318 * @param capacity The new buffer's capacity, in pointers
319 *
320 * @return The new pointer buffer
321 *
322 * @throws IllegalArgumentException If the <tt>capacity</tt> is a negative integer
323 */
324 public static PointerBuffer allocateDirect(int capacity) {
325 return new PointerBuffer(capacity);
326 }
327
328 /**
329 * This method is used in slice and duplicate instead of normal object construction,
330 * so that subclasses can return themselves.
331 *
332 * @param source
333 *
334 * @return A new PointerBuffer instance
335 */
336 protected PointerBuffer newInstance(final ByteBuffer source) {
337 return new PointerBuffer(source);
338 }
339
340 /**
341 * Creates a new pointer buffer whose content is a shared subsequence of
342 * this buffer's content.
343 * <p/>
344 * <p> The content of the new buffer will start at this buffer's current
345 * position. Changes to this buffer's content will be visible in the new
346 * buffer, and vice versa; the two buffers' position, limit, and mark
347 * values will be independent.
348 * <p/>
349 * <p> The new buffer's position will be zero, its capacity and its limit
350 * will be the number of longs remaining in this buffer, and its mark
351 * will be undefined. The new buffer will be direct if, and only if, this
352 * buffer is direct, and it will be read-only if, and only if, this buffer
353 * is read-only. </p>
354 *
355 * @return The new pointer buffer
356 */
357 public PointerBuffer slice() {
358 final int pointerSize = getPointerSize();
359
360 pointers.position(view.position() * pointerSize);
361 pointers.limit(view.limit() * pointerSize);
362
363 try {
364 // We're slicing in the constructor.
365 return newInstance(pointers);
366 } finally {
367 pointers.clear();
368 }
369 }
370
371 /**
372 * Creates a new pointer buffer that shares this buffer's content.
373 * <p/>
374 * <p> The content of the new buffer will be that of this buffer. Changes
375 * to this buffer's content will be visible in the new buffer, and vice
376 * versa; the two buffers' position, limit, and mark values will be
377 * independent.
378 * <p/>
379 * <p> The new buffer's capacity, limit and position will be
380 * identical to those of this buffer. The new buffer will be direct if,
381 * and only if, this buffer is direct, and it will be read-only if, and
382 * only if, this buffer is read-only. </p>
383 *
384 * @return The new pointer buffer
385 */
386 public PointerBuffer duplicate() {
387 final PointerBuffer buffer = newInstance(pointers);
388
389 buffer.position(view.position());
390 buffer.limit(view.limit());
391
392 return buffer;
393 }
394
395 /**
396 * Creates a new, read-only pointer buffer that shares this buffer's
397 * content.
398 * <p/>
399 * <p> The content of the new buffer will be that of this buffer. Changes
400 * to this buffer's content will be visible in the new buffer; the new
401 * buffer itself, however, will be read-only and will not allow the shared
402 * content to be modified. The two buffers' position, limit, and mark
403 * values will be independent.
404 * <p/>
405 * <p> The new buffer's capacity, limit and position will be
406 * identical to those of this buffer.
407 * <p/>
408 * <p> If this buffer is itself read-only then this method behaves in
409 * exactly the same way as the {@link #duplicate duplicate} method. </p>
410 *
411 * @return The new, read-only pointer buffer
412 */
413 public PointerBuffer asReadOnlyBuffer() {
414 final PointerBuffer buffer = new PointerBufferR(pointers);
415
416 buffer.position(view.position());
417 buffer.limit(view.limit());
418
419 return buffer;
420 }
421
422 public boolean isReadOnly() {
423 return false;
424 }
425
426 /**
427 * Relative <i>get</i> method. Reads the long at this buffer's
428 * current position, and then increments the position. </p>
429 *
430 * @return The long at the buffer's current position
431 *
432 * @throws BufferUnderflowException If the buffer's current position is not smaller than its limit
433 */
434 public long get() {
435 if ( is64Bit )
436 return view64.get();
437 else
438 return view32.get() & 0x00000000FFFFFFFFL;
439 }
440
441 /**
442 * Relative <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
443 * <p/>
444 * <p> Writes the given long into this buffer at the current
445 * position, and then increments the position. </p>
446 *
447 * @param l The long to be written
448 *
449 * @return This buffer
450 *
451 * @throws BufferOverflowException If this buffer's current position is not smaller than its limit
452 * @throws ReadOnlyBufferException If this buffer is read-only
453 */
454 public PointerBuffer put(long l) {
455 if ( is64Bit )
456 view64.put(l);
457 else
458 view32.put((int)l);
459 return this;
460 }
461
462 /**
463 * Convenience put that accepts PointerWrapper objects.
464 *
465 * @see #put(long)
466 */
467 public PointerBuffer put(final PointerWrapper pointer) {
468 return put(pointer.getPointer());
469 }
470
471 /**
472 * Convenience put on a target ByteBuffer.
473 *
474 * @param target the target ByteBuffer
475 * @param l the long value to be written
476 */
477 public static void put(final ByteBuffer target, long l) {
478 if ( is64Bit )
479 target.putLong(l);
480 else
481 target.putInt((int)l);
482 }
483
484 /**
485 * Absolute <i>get</i> method. Reads the long at the given
486 * index. </p>
487 *
488 * @param index The index from which the long will be read
489 *
490 * @return The long at the given index
491 *
492 * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
493 * or not smaller than the buffer's limit
494 */
495 public long get(int index) {
496 if ( is64Bit )
497 return view64.get(index);
498 else
499 return view32.get(index) & 0x00000000FFFFFFFFL;
500 }
501
502 /**
503 * Absolute <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
504 * <p/>
505 * <p> Writes the given long into this buffer at the given
506 * index. </p>
507 *
508 * @param index The index at which the long will be written
509 * @param l The long value to be written
510 *
511 * @return This buffer
512 *
513 * @throws IndexOutOfBoundsException If <tt>index</tt> is negative
514 * or not smaller than the buffer's limit
515 * @throws ReadOnlyBufferException If this buffer is read-only
516 */
517 public PointerBuffer put(int index, long l) {
518 if ( is64Bit )
519 view64.put(index, l);
520 else
521 view32.put(index, (int)l);
522 return this;
523 }
524
525 /**
526 * Convenience put that accepts PointerWrapper objects.
527 *
528 * @see #put(int, long)
529 */
530 public PointerBuffer put(int index, PointerWrapper pointer) {
531 return put(index, pointer.getPointer());
532 }
533
534 /**
535 * Convenience put on a target ByteBuffer.
536 *
537 * @param target the target ByteBuffer
538 * @param index the index at which the long will be written
539 * @param l the long value to be written
540 */
541 public static void put(final ByteBuffer target, int index, long l) {
542 if ( is64Bit )
543 target.putLong(index * 8, l);
544 else
545 target.putInt(index * 4, (int)l);
546 }
547
548 // -- Bulk get operations --
549
550 /**
551 * Relative bulk <i>get</i> method.
552 * <p/>
553 * <p> This method transfers longs from this buffer into the given
554 * destination array. If there are fewer longs remaining in the
555 * buffer than are required to satisfy the request, that is, if
556 * <tt>length</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>, then no
557 * longs are transferred and a {@link BufferUnderflowException} is
558 * thrown.
559 * <p/>
560 * <p> Otherwise, this method copies <tt>length</tt> longs from this
561 * buffer into the given array, starting at the current position of this
562 * buffer and at the given offset in the array. The position of this
563 * buffer is then incremented by <tt>length</tt>.
564 * <p/>
565 * <p> In other words, an invocation of this method of the form
566 * <tt>src.get(dst,&nbsp;off,&nbsp;len)</tt> has exactly the same effect as
567 * the loop
568 * <p/>
569 * <pre>
570 * for (int i = off; i < off + len; i++)
571 * dst[i] = src.get(); </pre>
572 * <p/>
573 * except that it first checks that there are sufficient longs in
574 * this buffer and it is potentially much more efficient. </p>
575 *
576 * @param dst The array into which longs are to be written
577 * @param offset The offset within the array of the first long to be
578 * written; must be non-negative and no larger than
579 * <tt>dst.length</tt>
580 * @param length The maximum number of longs to be written to the given
581 * array; must be non-negative and no larger than
582 * <tt>dst.length - offset</tt>
583 *
584 * @return This buffer
585 *
586 * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
587 * remaining in this buffer
588 * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and <tt>length</tt>
589 * parameters do not hold
590 */
591 public PointerBuffer get(long[] dst, int offset, int length) {
592 if ( is64Bit )
593 view64.get(dst, offset, length);
594 else {
595 checkBounds(offset, length, dst.length);
596 if ( length > view32.remaining() )
597 throw new BufferUnderflowException();
598 int end = offset + length;
599 for ( int i = offset; i < end; i++ )
600 dst[i] = view32.get() & 0x00000000FFFFFFFFL;
601 }
602
603 return this;
604 }
605
606 /**
607 * Relative bulk <i>get</i> method.
608 * <p/>
609 * <p> This method transfers longs from this buffer into the given
610 * destination array. An invocation of this method of the form
611 * <tt>src.get(a)</tt> behaves in exactly the same way as the invocation
612 * <p/>
613 * <pre>
614 * src.get(a, 0, a.length) </pre>
615 *
616 * @return This buffer
617 *
618 * @throws BufferUnderflowException If there are fewer than <tt>length</tt> longs
619 * remaining in this buffer
620 */
621 public PointerBuffer get(long[] dst) {
622 return get(dst, 0, dst.length);
623 }
624
625 /**
626 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
627 * <p/>
628 * <p> This method transfers the longs remaining in the given source
629 * buffer into this buffer. If there are more longs remaining in the
630 * source buffer than in this buffer, that is, if
631 * <tt>src.remaining()</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>,
632 * then no longs are transferred and a {@link
633 * BufferOverflowException} is thrown.
634 * <p/>
635 * <p> Otherwise, this method copies
636 * <i>n</i>&nbsp;=&nbsp;<tt>src.remaining()</tt> longs from the given
637 * buffer into this buffer, starting at each buffer's current position.
638 * The positions of both buffers are then incremented by <i>n</i>.
639 * <p/>
640 * <p> In other words, an invocation of this method of the form
641 * <tt>dst.put(src)</tt> has exactly the same effect as the loop
642 * <p/>
643 * <pre>
644 * while (src.hasRemaining())
645 * dst.put(src.get()); </pre>
646 * <p/>
647 * except that it first checks that there is sufficient space in this
648 * buffer and it is potentially much more efficient. </p>
649 *
650 * @param src The source buffer from which longs are to be read;
651 * must not be this buffer
652 *
653 * @return This buffer
654 *
655 * @throws BufferOverflowException If there is insufficient space in this buffer
656 * for the remaining longs in the source buffer
657 * @throws IllegalArgumentException If the source buffer is this buffer
658 * @throws ReadOnlyBufferException If this buffer is read-only
659 */
660 public PointerBuffer put(PointerBuffer src) {
661 if ( is64Bit )
662 view64.put(src.view64);
663 else
664 view32.put(src.view32);
665 return this;
666 }
667
668 /**
669 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
670 * <p/>
671 * <p> This method transfers longs into this buffer from the given
672 * source array. If there are more longs to be copied from the array
673 * than remain in this buffer, that is, if
674 * <tt>length</tt>&nbsp;<tt>&gt;</tt>&nbsp;<tt>remaining()</tt>, then no
675 * longs are transferred and a {@link BufferOverflowException} is
676 * thrown.
677 * <p/>
678 * <p> Otherwise, this method copies <tt>length</tt> longs from the
679 * given array into this buffer, starting at the given offset in the array
680 * and at the current position of this buffer. The position of this buffer
681 * is then incremented by <tt>length</tt>.
682 * <p/>
683 * <p> In other words, an invocation of this method of the form
684 * <tt>dst.put(src,&nbsp;off,&nbsp;len)</tt> has exactly the same effect as
685 * the loop
686 * <p/>
687 * <pre>
688 * for (int i = off; i < off + len; i++)
689 * dst.put(a[i]); </pre>
690 * <p/>
691 * except that it first checks that there is sufficient space in this
692 * buffer and it is potentially much more efficient. </p>
693 *
694 * @param src The array from which longs are to be read
695 * @param offset The offset within the array of the first long to be read;
696 * must be non-negative and no larger than <tt>array.length</tt>
697 * @param length The number of longs to be read from the given array;
698 * must be non-negative and no larger than
699 * <tt>array.length - offset</tt>
700 *
701 * @return This buffer
702 *
703 * @throws BufferOverflowException If there is insufficient space in this buffer
704 * @throws IndexOutOfBoundsException If the preconditions on the <tt>offset</tt> and <tt>length</tt>
705 * parameters do not hold
706 * @throws ReadOnlyBufferException If this buffer is read-only
707 */
708 public PointerBuffer put(long[] src, int offset, int length) {
709 if ( is64Bit )
710 view64.put(src, offset, length);
711 else {
712 checkBounds(offset, length, src.length);
713 if ( length > view32.remaining() )
714 throw new BufferOverflowException();
715 int end = offset + length;
716 for ( int i = offset; i < end; i++ )
717 view32.put((int)src[i]);
718 }
719
720 return this;
721 }
722
723 /**
724 * Relative bulk <i>put</i> method&nbsp;&nbsp;<i>(optional operation)</i>.
725 * <p/>
726 * <p> This method transfers the entire content of the given source
727 * long array into this buffer. An invocation of this method of the
728 * form <tt>dst.put(a)</tt> behaves in exactly the same way as the
729 * invocation
730 * <p/>
731 * <pre>
732 * dst.put(a, 0, a.length) </pre>
733 *
734 * @return This buffer
735 *
736 * @throws BufferOverflowException If there is insufficient space in this buffer
737 * @throws ReadOnlyBufferException If this buffer is read-only
738 */
739 public final PointerBuffer put(long[] src) {
740 return put(src, 0, src.length);
741 }
742
743 /**
744 * Compacts this buffer&nbsp;&nbsp;<i>(optional operation)</i>.
745 * <p/>
746 * <p> The longs between the buffer's current position and its limit,
747 * if any, are copied to the beginning of the buffer. That is, the
748 * long at index <i>p</i>&nbsp;=&nbsp;<tt>position()</tt> is copied
749 * to index zero, the long at index <i>p</i>&nbsp;+&nbsp;1 is copied
750 * to index one, and so forth until the long at index
751 * <tt>limit()</tt>&nbsp;-&nbsp;1 is copied to index
752 * <i>n</i>&nbsp;=&nbsp;<tt>limit()</tt>&nbsp;-&nbsp;<tt>1</tt>&nbsp;-&nbsp;<i>p</i>.
753 * The buffer's position is then set to <i>n+1</i> and its limit is set to
754 * its capacity. The mark, if defined, is discarded.
755 * <p/>
756 * <p> The buffer's position is set to the number of longs copied,
757 * rather than to zero, so that an invocation of this method can be
758 * followed immediately by an invocation of another relative <i>put</i>
759 * method. </p>
760 *
761 * @return This buffer
762 *
763 * @throws ReadOnlyBufferException If this buffer is read-only
764 */
765 public PointerBuffer compact() {
766 if ( is64Bit )
767 view64.compact();
768 else
769 view32.compact();
770 return this;
771 }
772
773 /**
774 * Retrieves this buffer's byte order.
775 * <p/>
776 * <p> The byte order of a pointer buffer created by allocation or by
777 * wrapping an existing <tt>long</tt> array is the {@link
778 * ByteOrder#nativeOrder </code>native order<code>} of the underlying
779 * hardware. The byte order of a pointer buffer created as a <a
780 * href="ByteBuffer.html#views">view</a> of a byte buffer is that of the
781 * byte buffer at the moment that the view is created. </p>
782 *
783 * @return This buffer's byte order
784 */
785 public ByteOrder order() {
786 if ( is64Bit )
787 return view64.order();
788 else
789 return view32.order();
790 }
791
792 /**
793 * Returns a string summarizing the state of this buffer. </p>
794 *
795 * @return A summary string
796 */
797 public String toString() {
798 StringBuilder sb = new StringBuilder(48);
799 sb.append(getClass().getName());
800 sb.append("[pos=");
801 sb.append(position());
802 sb.append(" lim=");
803 sb.append(limit());
804 sb.append(" cap=");
805 sb.append(capacity());
806 sb.append("]");
807 return sb.toString();
808 }
809
810 /**
811 * Returns the current hash code of this buffer.
812 * <p/>
813 * <p> The hash code of a pointer buffer depends only upon its remaining
814 * elements; that is, upon the elements from <tt>position()</tt> up to, and
815 * including, the element at <tt>limit()</tt>&nbsp;-&nbsp;<tt>1</tt>.
816 * <p/>
817 * <p> Because buffer hash codes are content-dependent, it is inadvisable
818 * to use buffers as keys in hash maps or similar data structures unless it
819 * is known that their contents will not change. </p>
820 *
821 * @return The current hash code of this buffer
822 */
823 public int hashCode() {
824 int h = 1;
825 int p = position();
826 for ( int i = limit() - 1; i >= p; i-- )
827 h = 31 * h + (int)get(i);
828 return h;
829 }
830
831 /**
832 * Tells whether or not this buffer is equal to another object.
833 * <p/>
834 * <p> Two pointer buffers are equal if, and only if,
835 * <p/>
836 * <p><ol>
837 * <p/>
838 * <li><p> They have the same element type, </p></li>
839 * <p/>
840 * <li><p> They have the same number of remaining elements, and
841 * </p></li>
842 * <p/>
843 * <li><p> The two sequences of remaining elements, considered
844 * independently of their starting positions, are pointwise equal.
845 * </p></li>
846 * <p/>
847 * </ol>
848 * <p/>
849 * <p> A pointer buffer is not equal to any other type of object. </p>
850 *
851 * @param ob The object to which this buffer is to be compared
852 *
853 * @return <tt>true</tt> if, and only if, this buffer is equal to the
854 * given object
855 */
856 public boolean equals(Object ob) {
857 if ( !(ob instanceof PointerBuffer) )
858 return false;
859 PointerBuffer that = (PointerBuffer)ob;
860 if ( this.remaining() != that.remaining() )
861 return false;
862 int p = this.position();
863 for ( int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j-- ) {
864 long v1 = this.get(i);
865 long v2 = that.get(j);
866 if ( v1 != v2 ) {
867 return false;
868 }
869 }
870 return true;
871 }
872
873 /**
874 * Compares this buffer to another.
875 * <p/>
876 * <p> Two pointer buffers are compared by comparing their sequences of
877 * remaining elements lexicographically, without regard to the starting
878 * position of each sequence within its corresponding buffer.
879 * <p/>
880 * <p> A pointer buffer is not comparable to any other type of object.
881 *
882 * @return A negative integer, zero, or a positive integer as this buffer
883 * is less than, equal to, or greater than the given buffer
884 */
885 public int compareTo(Object o) {
886 final PointerBuffer that = (PointerBuffer)o;
887 int n = this.position() + Math.min(this.remaining(), that.remaining());
888 for ( int i = this.position(), j = that.position(); i < n; i++, j++ ) {
889 long v1 = this.get(i);
890 long v2 = that.get(j);
891 if ( v1 == v2 )
892 continue;
893 if ( v1 < v2 )
894 return -1;
895 return +1;
896 }
897 return this.remaining() - that.remaining();
898 }
899
900 private static void checkBounds(int off, int len, int size) {
901 if ( (off | len | (off + len) | (size - (off + len))) < 0 )
902 throw new IndexOutOfBoundsException();
903 }
904
905 /**
906 * Read-only version of PointerBuffer.
907 *
908 * @author Spasi
909 */
910 private static final class PointerBufferR extends PointerBuffer {
911
912 PointerBufferR(final ByteBuffer source) {
913 super(source);
914 }
915
916 public boolean isReadOnly() {
917 return true;
918 }
919
920 protected PointerBuffer newInstance(final ByteBuffer source) {
921 return new PointerBufferR(source);
922 }
923
924 public PointerBuffer asReadOnlyBuffer() {
925 return duplicate();
926 }
927
928 public PointerBuffer put(final long l) {
929 throw new ReadOnlyBufferException();
930 }
931
932 public PointerBuffer put(final int index, final long l) {
933 throw new ReadOnlyBufferException();
934 }
935
936 public PointerBuffer put(final PointerBuffer src) {
937 throw new ReadOnlyBufferException();
938 }
939
940 public PointerBuffer put(final long[] src, final int offset, final int length) {
941 throw new ReadOnlyBufferException();
942 }
943
944 public PointerBuffer compact() {
945 throw new ReadOnlyBufferException();
946 }
947
948 }
949
950 }
0 /*
1 * Copyright (c) 2002-2008 LWJGL Project
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of 'LWJGL' nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package org.lwjgl;
32
33 /**
34 * A common interface for classes that wrap pointer addresses.
35 *
36 * @author Spasi
37 */
38 public interface PointerWrapper {
39
40 long getPointer();