--- old/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser 2014-07-01 15:13:02.187350281 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,207 +0,0 @@ -// !$*UTF8*$! -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -{ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - activeBuildConfigurationName = Release; - activeExecutable = 6A9FA6570246BA6C0CC91562 /* JObjC */; - activeTarget = EB9FD8610AEECCF5008E157E /* JObjC */; - addToTargets = ( - 4CEBA78E08679EF10015D03E /* JNILib */, - ); - breakpointsGroup = 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */; - codeSenseManager = 0AB364DB0B2F66FD00788B6C /* Code sense */; - executables = ( - 6A9FA6570246BA6C0CC91562 /* JObjC */, - ); - perUserDictionary = { - PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; - PBXFileTableDataSourceColumnWidthsKey = ( - 22, - 300, - 131, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXExecutablesDataSource_ActiveFlagID, - PBXExecutablesDataSource_NameID, - PBXExecutablesDataSource_CommentsID, - ); - }; - PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 245, - 20, - 48, - 43, - 43, - 20, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - PBXFileDataSource_Target_ColumnID, - ); - }; - PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 200, - 65, - 20, - 48, - 43, - 43, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXTargetDataSource_PrimaryAttribute, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - ); - }; - }; - sourceControlManager = 0AB364DA0B2F66FD00788B6C /* Source Control */; - userBuildSettings = { - }; - }; - 0AB364DA0B2F66FD00788B6C /* Source Control */ = { - isa = PBXSourceControlManager; - fallbackIsa = XCSourceControlManager; - isSCMEnabled = 0; - scmConfiguration = { - }; - scmType = ""; - }; - 0AB364DB0B2F66FD00788B6C /* Code sense */ = { - isa = PBXCodeSenseManager; - indexTemplatePath = ""; - }; - 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */ = { - isa = XCBreakpointsBucket; - name = "Project Breakpoints"; - objects = ( - ); - }; - 0AB365570B2F6ABB00788B6C /* JObjCdylib.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{84, 198}, {886, 912}}"; - }; - }; - 0A3CC35E0B94BB8800F6BA26 /* java */ = { - isa = PBXFileReference; - explicitFileType = "compiled.mach-o.executable"; - name = java; - path = /usr/bin/java; - sourceTree = ""; - }; - 363028F90383184400C91562 /* Manifest */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{38, 240}, {886, 912}}"; - }; - }; - 4CEBA78E08679EF10015D03E /* Dylib */ = { - activeExec = 0; - }; - 6A9FA6570246BA6C0CC91562 /* JObjC */ = { - isa = PBXExecutable; - activeArgIndex = 0; - activeArgIndices = ( - YES, - ); - argumentStrings = ( - "-cp JObjC.jar JObjC", - ); - autoAttachOnCrash = 1; - configStateDict = { - "PBXLSLaunchAction-0" = { - PBXLSLaunchAction = 0; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXLSRunLaunchConfig; - displayName = "Executable Runner"; - identifier = com.apple.Xcode.launch.runConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - "PBXLSLaunchAction-1" = { - PBXLSLaunchAction = 1; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXJavaDebuggingNativeLaunchConfig; - displayName = "Java Debugger"; - identifier = com.apple.Xcode.launch.JavaDebugNativeConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - }; - customDataFormattersEnabled = 1; - debuggerPlugin = GDBDebugging; - disassemblyDisplayState = 0; - dylibVariantSuffix = ""; - enableDebugStr = 1; - environmentEntries = ( - ); - executableSystemSymbolLevel = 0; - executableUserSymbolLevel = 0; - launchableReference = 0A3CC35E0B94BB8800F6BA26 /* java */; - libgmallocEnabled = 0; - name = JObjC; - sourceDirectories = ( - ); - startupPath = "dist"; - }; - EB9FD8610AEECCF5008E157E /* JObjC */ = { - activeExec = 0; - }; - EB9FD8720AEECD83008E157E /* build.xml */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 1260}}"; - sepNavSelRange = "{1260, 0}"; - sepNavVisRect = "{{0, 8}, {847, 783}}"; - sepNavWindowFrame = "{{752, 266}, {886, 912}}"; - }; - }; -} --- old/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj 2014-07-01 15:13:02.487350280 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,1397 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXAggregateTarget section */ - 89EBD58C0C95F43D000F04A0 /* B&I */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */; - buildPhases = ( - ); - dependencies = ( - C592D6590E12F27400D076FF /* PBXTargetDependency */, - C592D65B0E12F27600D076FF /* PBXTargetDependency */, - C592D65D0E12F27E00D076FF /* PBXTargetDependency */, - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */, - C592D65F0E12F28500D076FF /* PBXTargetDependency */, - C592D6610E12F28E00D076FF /* PBXTargetDependency */, - C592D6630E12F29200D076FF /* PBXTargetDependency */, - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */, - ); - name = "B&I"; - productName = "B&I"; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */; }; - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */; }; - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */; }; - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5742F700E316F8600093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */ = {isa = PBXBuildFile; fileRef = C5F3B1370E398F8E00B771AE /* FunCallBench.m */; }; - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2610E3AB0F300B771AE /* AppKit.framework */; }; - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2630E3AB0F300B771AE /* Cocoa.framework */; }; - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = C5F3B1530E39927900B771AE; - remoteInfo = "build-test-java"; - }; - 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC720CDE767500472EA2; - remoteInfo = "assemble-product-java"; - }; - C592D6580E12F27400D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - C592D65A0E12F27600D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - C592D65E0E12F28500D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC4C0CDE4C0400472EA2; - remoteInfo = "build-generated-java"; - }; - C592D6600E12F28E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - C592D6620E12F29200D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CCA20CDF9A2600472EA2; - remoteInfo = "build-additions-native"; - }; - C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 0AB364E40B2F671600788B6C /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; path = src; sourceTree = ""; }; - 890FBACA0C6F781000902C32 /* JavaVM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaVM.framework; path = /System/Library/Frameworks/JavaVM.framework; sourceTree = ""; }; - 890FBACC0C6F782C00902C32 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaNativeFoundation.framework; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework; sourceTree = ""; }; - 896D91230CC2ED34005625F5 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = ""; }; - 89736E5F0CE819E5008C4205 /* JObjC.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; path = JObjC.jar; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7C9EC0CDB900E00472EA2 /* CIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CIF.m; sourceTree = ""; }; - 89D7C9ED0CDB900E00472EA2 /* Coder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Coder.m; sourceTree = ""; }; - 89D7C9EE0CDB900E00472EA2 /* Function.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Function.m; sourceTree = ""; }; - 89D7C9EF0CDB900E00472EA2 /* ID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ID.m; sourceTree = ""; }; - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JObjCRuntime.m; sourceTree = ""; }; - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacOSXFramework.m; sourceTree = ""; }; - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeBuffer.h; sourceTree = ""; }; - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeBuffer.m; sourceTree = ""; }; - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeObjectLifecycleManager.m; sourceTree = ""; }; - 89D7C9F50CDB900E00472EA2 /* NSClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSClass.m; sourceTree = ""; }; - 89D7C9F60CDB900E00472EA2 /* SEL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SEL.m; sourceTree = ""; }; - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libJObjC.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeString.m; sourceTree = ""; }; - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeNumber.m; sourceTree = ""; }; - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeThread.m; sourceTree = ""; }; - 89E437680C97A7F200C756EE /* libffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libffi.dylib; path = /usr/lib/libffi.dylib; sourceTree = ""; }; - C5742F6B0E316EFA00093838 /* Subclassing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Subclassing.m; sourceTree = ""; }; - C5D196C80DF9E43C006F9FB9 /* FFIType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFIType.m; sourceTree = ""; }; - C5E454790E36729F0046D3E8 /* Invoke.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invoke.m; sourceTree = ""; }; - C5F3B1370E398F8E00B771AE /* FunCallBench.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunCallBench.m; sourceTree = ""; }; - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "libJObjC-tests.dylib"; sourceTree = BUILT_PRODUCTS_DIR; }; - C5F3B2610E3AB0F300B771AE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - EB9FD8720AEECD83008E157E /* build.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = build.xml; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4CEBA78D08679EF10015D03E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */, - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */, - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCB00CDF9A2600472EA2 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */, - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */, - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1430E39910500B771AE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */, - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */, - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00E6828FFEC88D1A11DB9C8B = { - isa = PBXGroup; - children = ( - 896D91230CC2ED34005625F5 /* README.txt */, - EB9FD8720AEECD83008E157E /* build.xml */, - 0AB364E40B2F671600788B6C /* src */, - 89D7C9EB0CDB900E00472EA2 /* native-core */, - 89D7CA020CDB902200472EA2 /* native-additions */, - C5A9597F0E398F050057C96D /* native-tests */, - 89D7CA030CDB903000472EA2 /* products */, - 890FBAC90C6F77B700902C32 /* frameworks */, - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */, - C5F3B2610E3AB0F300B771AE /* AppKit.framework */, - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */, - ); - sourceTree = ""; - }; - 890FBAC90C6F77B700902C32 /* frameworks */ = { - isa = PBXGroup; - children = ( - 890FBACC0C6F782C00902C32 /* Foundation.framework */, - 890FBACA0C6F781000902C32 /* JavaVM.framework */, - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */, - 89E437680C97A7F200C756EE /* libffi.dylib */, - ); - name = frameworks; - sourceTree = ""; - }; - 89D7C9EB0CDB900E00472EA2 /* native-core */ = { - isa = PBXGroup; - children = ( - 89D7C9EC0CDB900E00472EA2 /* CIF.m */, - 89D7C9ED0CDB900E00472EA2 /* Coder.m */, - C5D196C80DF9E43C006F9FB9 /* FFIType.m */, - 89D7C9EE0CDB900E00472EA2 /* Function.m */, - 89D7C9EF0CDB900E00472EA2 /* ID.m */, - C5E454790E36729F0046D3E8 /* Invoke.m */, - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */, - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */, - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */, - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */, - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */, - 89D7C9F50CDB900E00472EA2 /* NSClass.m */, - 89D7C9F60CDB900E00472EA2 /* SEL.m */, - C5742F6B0E316EFA00093838 /* Subclassing.m */, - ); - name = "native-core"; - path = src/core/native; - sourceTree = ""; - }; - 89D7CA020CDB902200472EA2 /* native-additions */ = { - isa = PBXGroup; - children = ( - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */, - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */, - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */, - ); - name = "native-additions"; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - 89D7CA030CDB903000472EA2 /* products */ = { - isa = PBXGroup; - children = ( - 89736E5F0CE819E5008C4205 /* JObjC.jar */, - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */, - ); - name = products; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - C5A9597F0E398F050057C96D /* native-tests */ = { - isa = PBXGroup; - children = ( - C5F3B1370E398F8E00B771AE /* FunCallBench.m */, - ); - name = "native-tests"; - path = src/tests/native; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 4CEBA78B08679EF10015D03E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA30CDF9A2600472EA2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1410E39910500B771AE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXLegacyTarget section */ - 89D7CA160CDBA94D00472EA2 /* build-generator-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */, - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */, - ); - name = "build-generator-java"; - passBuildSettingsInEnvironment = 1; - productName = "generator-build-java"; - }; - 89D7CB870CDC4ED000472EA2 /* run-generator */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556513A1323700B09D1B /* PBXTargetDependency */, - ); - name = "run-generator"; - passBuildSettingsInEnvironment = 1; - productName = "run-generator"; - }; - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556913A1325700B09D1B /* PBXTargetDependency */, - ); - name = "build-generated-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-generated-java"; - }; - 89D7CC600CDE75EC00472EA2 /* build-additions-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-additions-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-additions-java"; - }; - 89D7CC720CDE767500472EA2 /* assemble-product-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "assemble-product-java"; - passBuildSettingsInEnvironment = 1; - productName = "package-product"; - }; - C5F3B1530E39927900B771AE /* build-test-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-test-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-test"; - }; - EB9FD8610AEECCF5008E157E /* build-core-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - buildWorkingDirectory = ""; - dependencies = ( - ); - name = "build-core-java"; - passBuildSettingsInEnvironment = 1; - productName = AntJNIWrapper; - }; -/* End PBXLegacyTarget section */ - -/* Begin PBXNativeTarget section */ - 4CEBA78E08679EF10015D03E /* build-core-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */; - buildPhases = ( - 4CEBA78B08679EF10015D03E /* Headers */, - 4CEBA78C08679EF10015D03E /* Sources */, - 4CEBA78D08679EF10015D03E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556113A1322100B09D1B /* PBXTargetDependency */, - ); - name = "build-core-native"; - productName = DylibN; - productType = "com.apple.product-type.library.dynamic"; - }; - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */; - buildPhases = ( - 89D7CCA30CDF9A2600472EA2 /* Headers */, - 89D7CCA50CDF9A2600472EA2 /* Sources */, - 89D7CCB00CDF9A2600472EA2 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556713A1324300B09D1B /* PBXTargetDependency */, - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */, - ); - name = "build-additions-native"; - productName = DylibN; - productReference = 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; - C5F3B1440E39910500B771AE /* build-test-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */; - buildPhases = ( - C5F3B1410E39910500B771AE /* Headers */, - C5F3B1420E39910500B771AE /* Sources */, - C5F3B1430E39910500B771AE /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556313A1322800B09D1B /* PBXTargetDependency */, - ); - name = "build-test-native"; - productName = "build-tests-native"; - productReference = C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0410; - }; - buildConfigurationList = 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */; - compatibilityVersion = "Xcode 3.0"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 00E6828FFEC88D1A11DB9C8B; - productRefGroup = 00E6828FFEC88D1A11DB9C8B; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 89EBD58C0C95F43D000F04A0 /* B&I */, - EB9FD8610AEECCF5008E157E /* build-core-java */, - 4CEBA78E08679EF10015D03E /* build-core-native */, - 89D7CA160CDBA94D00472EA2 /* build-generator-java */, - 89D7CB870CDC4ED000472EA2 /* run-generator */, - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */, - 89D7CC600CDE75EC00472EA2 /* build-additions-java */, - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */, - 89D7CC720CDE767500472EA2 /* assemble-product-java */, - C5F3B1530E39927900B771AE /* build-test-java */, - C5F3B1440E39910500B771AE /* build-test-native */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 4CEBA78C08679EF10015D03E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */, - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */, - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */, - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */, - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */, - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */, - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */, - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */, - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */, - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */, - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */, - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA50CDF9A2600472EA2 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */, - C5742F700E316F8600093838 /* Subclassing.m in Sources */, - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */, - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */, - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */, - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */, - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */, - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */, - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */, - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */, - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */, - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */, - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */, - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */, - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1420E39910500B771AE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 2CC7556113A1322100B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556313A1322800B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = C5F3B1530E39927900B771AE /* build-test-java */; - targetProxy = 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556513A1323700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556713A1324300B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556913A1325700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */; - }; - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */; - }; - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC720CDE767500472EA2 /* assemble-product-java */; - targetProxy = 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */; - }; - C592D6590E12F27400D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = C592D6580E12F27400D076FF /* PBXContainerItemProxy */; - }; - C592D65B0E12F27600D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C592D65A0E12F27600D076FF /* PBXContainerItemProxy */; - }; - C592D65D0E12F27E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */; - }; - C592D65F0E12F28500D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */; - targetProxy = C592D65E0E12F28500D076FF /* PBXContainerItemProxy */; - }; - C592D6610E12F28E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = C592D6600E12F28E00D076FF /* PBXContainerItemProxy */; - }; - C592D6630E12F29200D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CCA20CDF9A2600472EA2 /* build-additions-native */; - targetProxy = C592D6620E12F29200D076FF /* PBXContainerItemProxy */; - }; - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 4CEBA75D08679E4D0015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - GCC_ENABLE_OBJC_GC = supported; - SYMROOT = build; - }; - name = Debug; - }; - 4CEBA75E08679E4D0015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_ENABLE_OBJC_GC = supported; - INSTALL_PATH = /System/Library/Java/Extensions; - }; - name = Release; - }; - 4CEBA79208679F100015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 4CEBA79308679F100015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CA170CDBA94D00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generator"; - }; - name = Debug; - }; - 89D7CA180CDBA94D00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CB880CDC4ED000472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = "\U00010"; - PRODUCT_NAME = "run-generator"; - }; - name = Debug; - }; - 89D7CB890CDC4ED000472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "run-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC4D0CDE4C0400472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generated"; - }; - name = Debug; - }; - 89D7CC4E0CDE4C0400472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generated"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC610CDE75EC00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-additions"; - }; - name = Debug; - }; - 89D7CC620CDE75EC00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-additions"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC730CDE767500472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "assemble-product"; - }; - name = Debug; - }; - 89D7CC740CDE767500472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "assemble-product"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CCB60CDF9A2600472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - INSTALL_PATH = /usr/local/lib; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 89D7CCB70CDF9A2600472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - x86_64, - ppc, - i386, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89EBD58D0C95F43D000F04A0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "B&I"; - }; - name = Debug; - }; - 89EBD58E0C95F43D000F04A0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "B&I"; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1460E39910500B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - C5F3B1470E39910500B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_MODEL_TUNING = G5; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1540E39927A00B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-test"; - }; - name = Debug; - }; - C5F3B1550E39927A00B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-test"; - ZERO_LINK = NO; - }; - name = Release; - }; - EB9FD86A0AEECD13008E157E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-core"; - }; - name = Debug; - }; - EB9FD86B0AEECD13008E157E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - PRODUCT_NAME = "build-core"; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA75D08679E4D0015D03E /* Debug */, - 4CEBA75E08679E4D0015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA79208679F100015D03E /* Debug */, - 4CEBA79308679F100015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CA170CDBA94D00472EA2 /* Debug */, - 89D7CA180CDBA94D00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CB880CDC4ED000472EA2 /* Debug */, - 89D7CB890CDC4ED000472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC4D0CDE4C0400472EA2 /* Debug */, - 89D7CC4E0CDE4C0400472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC610CDE75EC00472EA2 /* Debug */, - 89D7CC620CDE75EC00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC730CDE767500472EA2 /* Debug */, - 89D7CC740CDE767500472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CCB60CDF9A2600472EA2 /* Debug */, - 89D7CCB70CDF9A2600472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89EBD58D0C95F43D000F04A0 /* Debug */, - 89EBD58E0C95F43D000F04A0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1460E39910500B771AE /* Debug */, - C5F3B1470E39910500B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1540E39927A00B771AE /* Debug */, - C5F3B1550E39927A00B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - EB9FD86A0AEECD13008E157E /* Debug */, - EB9FD86B0AEECD13008E157E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 00E6828EFEC88D1A11DB9C8B /* Project object */; -} --- old/src/macosx/native/jobjc/README.txt 2014-07-01 15:13:02.807350279 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,132 +0,0 @@ -#title JObjC -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -JObjC core provides a pure Java interface for calling C functions and -sending ObjC messages. Given some information, it can marshal types -automatically. - -It also parses BridgeSupport to generate Java wrappers around -Framework bundles. These wrappers rely on the core to provide access -to the C constants, enums, structs, functions, ObjC classes, etc of a -framework. - -* How to build it - -Your best option is `ant all`. There's an Xcode "B&I" target that -works for buildit. - -You'll need a recent JavaNativeFoundation, and perhaps some other -things. Everything is usually there on SnowLeopard (or Leopard after -the common ~javabuild/bin/update runs). - -The build process is quite involved. Xcode takes care of the native -parts, ant takes care of the Java parts, and there's an unholy mix of -external targets and hidden dependencies that keep Xcode and ant (and -buildit on top of that) from stepping on each other. So a warning: the -ant and Xcode targets don't have proper dependencies set up because of -this. They have some dependencies configured, but not the entire -chain. This is because of the jumping back and forth between -externals. If you run the aggregate targets (Xcode B&I, ant all, ant -test, ant bench), everything's is good. But if you manually invoke -individual targets, chances are you'll miss something. Let's go over -it all step by step: - -** ant gen-pcoder - -The PrimitiveCoder subclasses have a lot of boiler plate which -simplifies the generated MixedPrimitiveCoder classes. So instead of -maintaining it, I maintain a tiny Haskell script that spits out the -Java code. This ant target runs that script if Haskell is available on -the system. If it isn't available, this will silently fail. That's -okay, because chances are the PrimitiveCoder.java that you got from -svn is current and does not need to be updated. - -** ant build-core / Xcode build-core-java - -Build core simply builds the JObjC core java classes, and also -generates headers for the JNI for Xcode. - -** ant build-core-native / Xcode build-core-native - -Xcode builds the native core, using the headers from the Java core. It -generates libJObjC.dylib. - -** ant build-generator / Xcode build-generator-java - -ant builds the generator. - -** ant run-generator / Xcode run-generator - -ant runs the generator, using the core Java and native classes. - -What is rungen? And what's run-generator-old? run-generator-old is the -preferred way to run the generator from ant, but there's a strange bug -when running from buildit that causes run-generator-old to -freeze. Pratik was helping me debug it, inspecting the stack and -snooping dtrace probes, but we never found the reason for the -block. So I figured that maybe if I just add a layer of indirection -maybe it'll work around that. And it did. Sad but true. - -** ant build-generated / Xcode build-generated-java - -Build the generator output. - -** ant build-additions / Xcode build-additions-java - -Builds java additions. - -** ant build-additions-native / Xcode build-additions-native - -This builds a new version of libJObjC.dylib. It will rebuild -everything from the core, and include everything from additions. - -** ant assemble-product / Xcode assemble-product-java - -Create a jar, copy products to destination, etc. - -* How to test it - -The test cases also contain a Java component and a native component, -and are built similarly to the above. The benchmarks are built -together with the tests. So "ant build-test" and "ant -build-test-native" will build both the benchmarks and the test. "ant -test" will run the test. "ant bench" will run benchmarks. If you only -want to run a specific benchmark, you can pass a regexp in the -environment variable BENCH_MATCH. - - -ant test -ant bench -BENCH_MATCH=Foo ant bench - - -Test and bench reports will end up in -build/JObjC.build/Debug/test-reports/ - -* How to use it - -Include the jar in your classpath and set your java.library.path to -the directory that contains the dylib. Same thing for app bundles. --- old/src/macosx/native/jobjc/TODOS 2014-07-01 15:13:03.119350278 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -egrep "(TODO|FIXME|XXX|HACK)" -r src --- old/src/macosx/native/jobjc/bridgesupport.gmk 2014-07-01 15:13:03.431350278 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,54 +0,0 @@ -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# makefile for generating a stable set of bridgesupport files that change timestamp -# only when the bridgesupport data actually changes - -FRAMEWORKS_DIR = /System/Library/Frameworks -GBM = /usr/bin/gen_bridge_metadata -GEN_HEADERS = $(addsuffix .headers,$(FRAMEWORKS)) -GEN_BRIDGESUPPORT = $(addsuffix .bridgesupport,$(FRAMEWORKS)) - -%.bridgesupport : %.headers $(FRAMEWORKS_DIR)/%.framework/Headers/*.h - @echo "generating bridge support for" $< - if [ -f $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) ] ; \ - then cp $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) $@ ; \ - else $(GBM) -F complete --framework $(<:.headers=.framework) -o $@ ; \ - fi - if cmp -s $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - then : ; \ - else cp $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - fi - -%.headers : $(FRAMEWORKS_DIR)/%.framework/Headers - @echo linking $< - ln -s $< $@ - -$(STABLE_GEN_DIR): - mkdir -p $(STABLE_GEN_DIR) - -$(GEN_BRIDGESUPPORT): $(GEN_HEADERS) $(STABLE_GEN_DIR) - -all: $(GEN_BRIDGESUPPORT) --- old/src/macosx/native/jobjc/build.xml 2014-07-01 15:13:03.743350277 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,520 +0,0 @@ - - - - - - - - Nothing to do for install-headers build phase - - - - Nothing to do for install-source build phase - - - - - - - This Ant build file depends on the native Xcode project to invoke - targets by defining $PRODUCT_NAME to specify the target. - - - --- Redirecting to target "${env.PRODUCT_NAME}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- old/src/macosx/native/jobjc/extract_classes.pl 2014-07-01 15:13:04.055350276 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -## - -$file_dir = $ARGV[0]; -@file_list = qx("/usr/bin/find" "$file_dir"); - -foreach $file (@file_list) { - if ($file =~ s/\.class//) { - if ($file !~ s/\$[0-9]//) { - $file =~ s/$file_dir\///g; - $file =~ s/\//\./g; - chomp($file); - print "$file,"; - } - } -} --- old/src/macosx/native/jobjc/run-and-write-if-okay 2014-07-01 15:13:04.359350275 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -if ARGV.length < 2 - puts <&1`. If it returns successfully, it writes the output to OUTPATH. -This script will return successfully unless writing the output fails. -EOF - exit -end - -EXECPATH = ARGV[0] -OUTPATH = ARGV[1] - -output = `#{EXECPATH}` -puts output - -if $?.to_i == 0 - puts "Writing output of #{EXECPATH} to #{OUTPATH}" - File.open(OUTPATH, 'w') {|f| f.write(output) } -else - puts "#{EXECPATH} failed to run trial. Ignoring." -end --- old/src/macosx/native/jobjc/rungen 2014-07-01 15:13:04.667350275 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -xcodeAction = ARGV[0] - -exit unless xcodeAction == "install" - -JOBJC_JAR = ARGV[1] -LIBPATH = ARGV[2] -OBJROOT = ARGV[3] -ARCHS = ARGV[4] -STABLE_GEN_DIR = ARGV[5] - -ourJavaHome = ENV['JAVA_HOME'] -ourJavaVersion = `java -fullversion 2>&1` -$stderr.puts "ENV['JAVA_HOME'] = #{ourJavaHome}" -$stderr.puts "java -fullversion = #{ourJavaVersion}" - -$stderr.puts "jobjc_jar = #{JOBJC_JAR}" -$stderr.puts "libpath = #{LIBPATH}" -$stderr.puts "objroot = #{OBJROOT}" -$stderr.puts "ARCHS = #{ARCHS}" -$stderr.puts "STABLE_GEN_DIR = #{STABLE_GEN_DIR}" - -jarch = if ARCHS =~ /x86_64/ then "-d64" else "-d32" end - -# compute the boot class path, but remove the JObjC jar file that may have been installed in the boot jdk - -bootclasspathcmd = "java -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator com.apple.internal.jobjc.generator.BootClassPathMinus #{JOBJC_JAR}" -$stderr.puts bootclasspathcmd -bootclasspath = `#{bootclasspathcmd}` - -$stderr.puts "bootclasspath is: " -$stderr.puts bootclasspath - -# we run the generator with our newly created JObjC. The installed version (if available) has been removed from -# the boot class path, so we are building with everything newly created. -cmd = "java #{jarch} -Xms128m -Xmx512m -Djava.library.path=#{LIBPATH} -Xbootclasspath:#{bootclasspath.chomp} -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator -ea com.apple.internal.jobjc.generator.Generator dst=#{OBJROOT}/src/jobjc frameworks=#{STABLE_GEN_DIR}" - -$stderr.puts cmd -puts `#{cmd} 2>&1` - -raise $?.to_i if $?.to_i != 0 --- old/src/macosx/native/jobjc/runjava 2014-07-01 15:13:04.971350274 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -java -ea -classpath "lib/junit-4.4.jar:build/JObjC.build/Debug/bin/core:build/JObjC.build/Debug/bin/generator:build/JObjC.build/Debug/bin/additions:build/JObjC.build/Debug/bin/test:build/JObjC.build/Debug/bin/generated" -Djava.library.path=build/Debug $@ --- old/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs 2014-07-01 15:13:05.263350273 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,275 +0,0 @@ -#!/usr/bin/env runhaskell - -{- -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ --} -{- -The simplest way to get Haskell is through MacPorts: sudo port install ghc - -Otherwise, see http://www.haskell.org/ghc/ --} - -import Data.List -import Data.Maybe -import Data.Char - -data Width = W32 | W64 - deriving (Show, Eq, Bounded, Enum) - -data NType = NBOOL | Nschar | Nuchar | Nsshort | Nushort | Nsint | Nuint - | Nslong | Nulong | Nslonglong | Nulonglong | Nfloat | Ndouble - deriving (Show, Eq, Bounded, Enum) - -data JPrim = Jboolean | Jbyte | Jchar | Jshort | Jint | Jlong | Jfloat | Jdouble - deriving (Show, Eq, Bounded, Enum) - -data JClass = JBoolean | JByte | JCharacter | JShort | JInteger | JLong - | JFloat | JDouble - deriving (Show, Eq, Bounded, Enum) - -data FFIType = SINT8 | UINT8 | SINT16 | UINT16 | SINT32 | UINT32 - | SINT64 | UINT64 | FLOAT | DOUBLE - deriving (Show, Eq, Bounded, Enum) - -widths = [minBound..maxBound] :: [Width] -ntypes = [minBound..maxBound] :: [NType] -jprims = [minBound..maxBound] :: [JPrim] -jclasses = [minBound..maxBound] :: [JClass] -ffitypes = [minBound..maxBound] :: [FFIType] - --- What's the FFIType for a given Width and NType? For example: W32 NBOOL -> SINT8 -ffitype :: Width -> NType -> FFIType -ffitype _ NBOOL = SINT8 -ffitype _ Nschar = SINT8 -ffitype _ Nuchar = UINT8 -ffitype _ Nsshort = SINT16 -ffitype _ Nushort = UINT16 -ffitype _ Nsint = SINT32 -ffitype _ Nuint = UINT32 -ffitype W32 Nslong = SINT32 -ffitype W64 Nslong = SINT64 -ffitype W32 Nulong = UINT32 -ffitype W64 Nulong = UINT64 -ffitype _ Nslonglong = SINT64 -ffitype _ Nulonglong = UINT64 -ffitype _ Nfloat = FLOAT -ffitype _ Ndouble = DOUBLE - -sizeof :: FFIType -> Int -sizeof SINT8 = 1 -sizeof UINT8 = 1 -sizeof SINT16 = 2 -sizeof UINT16 = 2 -sizeof SINT32 = 4 -sizeof UINT32 = 4 -sizeof SINT64 = 8 -sizeof UINT64 = 8 -sizeof FLOAT = 4 -sizeof DOUBLE = 8 - --- What's the Obj-C encoding for a given NType? For example: unsigned char -> 'C' -encoding nt = fromJust $ lookup nt $ - [(NBOOL, 'B'), (Nschar, 'c'), (Nuchar, 'C'), (Nsshort, 's'), - (Nushort, 'S'), (Nsint, 'i'), (Nuint, 'I'), (Nslong, 'l'), - (Nulong, 'L'), (Nslonglong, 'q'), (Nulonglong, 'Q'), - (Nfloat, 'f'), (Ndouble, 'd')] - --- What's the JPrim for a given NType? For example: native signed long long -> java long -ntype2jprim nt = fromJust $ lookup nt $ - [(NBOOL, Jboolean), (Nschar, Jbyte), (Nuchar, Jbyte), - (Nsshort, Jshort), (Nushort, Jshort), (Nsint, Jint), (Nuint, Jint), - (Nslong, Jlong), (Nulong, Jlong), - (Nslonglong, Jlong), (Nulonglong, Jlong), - (Nfloat, Jfloat), (Ndouble, Jdouble)] - --- What's the JClass for a given JPrim? For example: int -> Integer -jprim2jclass jp = fromJust $ lookup jp $ - [(Jboolean, JBoolean), (Jbyte, JByte), (Jchar, JCharacter), - (Jshort, JShort), (Jint, JInteger), (Jlong, JLong), - (Jfloat, JFloat), (Jdouble, JDouble)] - --- Convert a type to something suitable for Java code. For example: Jboolean -> boolean -ntype2js nt = tail $ show nt -jclass2js t = tail $ show t -jprim2js p = tail $ show p -ffitype2js f = "FFI_" ++ (show f) - --- Capitalize the first letter of a String -capitalize [] = [] -capitalize s = [toUpper $ head s] ++ tail s - --- Given an Width and NType, return the Java code for reading said NType from memory. -popAddr :: Width -> NType -> String -popAddr _ NBOOL = "rt.unsafe.getByte(addr) != 0" -popAddr _ Nschar = "rt.unsafe.getByte(addr)" -popAddr _ Nuchar = "rt.unsafe.getByte(addr)" -popAddr W32 Nslong = "rt.unsafe.getInt(addr)" -popAddr W32 Nulong = "rt.unsafe.getInt(addr)" -popAddr _ ntype = "rt.unsafe.get" ++ (capitalize.jprim2js.ntype2jprim $ ntype) ++ "(addr)" - --- Given an Width and NType, return the Java code for writing said NType to memory. -pushAddr :: Width -> NType -> String -pushAddr _ NBOOL = "rt.unsafe.putByte(addr, (byte) (x ? 1 : 0));" -pushAddr _ Nschar = "rt.unsafe.putByte(addr, x);" -pushAddr _ Nuchar = "rt.unsafe.putByte(addr, x);" -pushAddr W32 Nslong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr W32 Nulong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr _ ntype = "rt.unsafe.put" ++ (capitalize jprimS) ++ "(addr, (" ++ jprimS ++ ") x);" - where jprimS = jprim2js.ntype2jprim $ ntype - --- Helpers for generating Java ternarnies and conditionals. -archExpr x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "(JObjCRuntime.IS64 ? (" ++ x64 ++ ") : (" ++ x32 ++ "))" - -archStmt x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "if(JObjCRuntime.IS64){ " ++ x64 ++ " }else{ " ++ x32 ++ " }" - --- Get a Java expression for the correct FFIType at runtime. For example: (JObjCRuntime.IS64 ? FFI_SINT64 : FFI_SINT32) -ffitypeVal nt = archExpr (ffitype2js $ ffitype W32 nt) - (ffitype2js $ ffitype W64 nt) - --- Similar to ffiTypeVal. Get the correct pop expression and push statement. -popAddrVal nt = archExpr (popAddr W32 nt) (popAddr W64 nt) -pushAddrVal nt = archStmt (pushAddr W32 nt) (pushAddr W64 nt) - --- What's the Coder class name we're using for a given NType? -coderName nt = aux nt ++ "Coder" - where - aux NBOOL = "Bool" - aux Nschar = "SChar" - aux Nuchar = "UChar" - aux Nsshort = "SShort" - aux Nushort = "UShort" - aux Nsint = "SInt" - aux Nuint = "UInt" - aux Nslong = "SLong" - aux Nulong = "ULong" - aux Nslonglong = "SLongLong" - aux Nulonglong = "ULongLong" - aux Nfloat = "Float" - aux Ndouble = "Double" - --- Operation for converting between primitives. Usually it just casts, but booleans are special. -jconvertPrims sym Jboolean Jboolean = sym -jconvertPrims sym Jboolean b = "((" ++ jprim2js b ++ ")(" ++ sym ++ " ? 1 : 0))" -jconvertPrims sym a Jboolean = "(" ++ sym ++ " != 0)" -jconvertPrims sym a b = if a == b then sym else "((" ++ jprim2js b ++ ")" ++ sym ++ ")" - -sizeofRet nt = - let ffitypes = map (\w -> ffitype w nt) widths - sizes = map sizeof ffitypes in - if (length $ nub sizes) == 1 - then "\t\treturn " ++ (show.head $ sizes) ++ ";" - else unlines [ - "\t\tswitch(w){", - (unlines $ map casestmt widths), - "\t\tdefault: return -1;", - "\t\t}"] - where - casestmt w = "\t\t\tcase " ++ (show w) ++ ": return " ++ - (show.sizeof $ ffitype w nt) ++ ";" - --- Generate a coder class for a given NType. -c2java ntype = - unlines [ - "// native " ++ ntypeS ++ " -> java " ++ jprimS, - "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{", - "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();", - "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }", - "\t// compile time", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){", - "\t\t" ++ pushAddrVal ntype, - "\t}", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){", - "\t\treturn " ++ popAddrVal ntype ++ ";", - "\t}", - "\t// for runtime coding", - "\t@Override public int sizeof(Width w){", - sizeofRet ntype, - "\t}", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jclassS ++ " x){ " ++ - "push(rt, addr, (" ++ jprimS ++ ") x); }", - "\t@Override public " ++ jclassS ++ " pop(JObjCRuntime rt, long addr){ " ++ - "return pop" ++ capitalize jprimS ++ "(rt, addr); }", - "\t// proxies for mixed encoding", - makeProxyMethods ntype, - "}" - ] - where - jprim = ntype2jprim ntype - jclass = jprim2jclass jprim - jprimS = jprim2js jprim - jclassS = jclass2js jclass - ntypeS = ntype2js ntype - className = coderName ntype - --- Generate push and pop methods that convert and proxy to actual implementation. -makeProxyMethods nt = unlines $ map aux jprims - where - targetJPrim = ntype2jprim nt - targetJPrimS = jprim2js targetJPrim - aux jprim = if targetJPrim == jprim then "" else unlines [ - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){ " ++ - "push(rt, addr, " ++ pushConversion "x" ++ "); }", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){ " ++ - "return " ++ (popConversion ("pop" ++ capitalize targetJPrimS ++ "(rt, addr)")) ++ "; }" - ] - where - jprimS = jprim2js jprim - pushConversion sym = jconvertPrims sym jprim targetJPrim - popConversion sym = jconvertPrims sym targetJPrim jprim - -main = do - putStrLn "package com.apple.jobjc;" - - putStrLn "import com.apple.jobjc.JObjCRuntime.Width;" - - putStrLn "// Auto generated by PrimitiveCoder.hs" - putStrLn "// Do not edit by hand." - - putStrLn "public abstract class PrimitiveCoder extends Coder{" - - putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){" - putStrLn "\t\tsuper(ffiTypeCode, objCEncoding, jclass, jprim);" - putStrLn "\t}" - - mapM_ (\p -> putStrLn $ unlines [makePopI p, makePushI p]) jprims - - mapM_ (putStrLn . c2java) ntypes - - putStrLn "}" - where - makePopI jprim = unlines ["\tpublic final " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) - ++ "(NativeArgumentBuffer args){\n" - ++ "\t\treturn pop" ++ (capitalize.jprim2js $ jprim) ++ "(args.runtime, args.retValPtr);\n" - ++ "\t}", - "\tpublic abstract " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) ++ "(JObjCRuntime runtime, long addr);"] - makePushI jprim = unlines ["\tpublic final void push" - ++ "(NativeArgumentBuffer args, " ++ jprim2js jprim ++ " x){\n" - ++ "\t\tpush(args.runtime, args.argValuesPtr, x);\n" - ++ "\t\targs.didPutArgValue(sizeof());\n" - ++ "\t}", - "\tpublic abstract void push(JObjCRuntime runtime, long addr, " ++ jprim2js jprim ++ " x);"] --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java 2014-07-01 15:13:05.579350272 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class CFType extends Pointer { - protected CFType(long ptr) { super(ptr); } - protected CFType(Pointer ptr) { super(ptr.ptr); } - - protected ID getTollFreeBridge(JObjCRuntime runtime){ - return ID.getObjCObjectFor(runtime, super.ptr); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java 2014-07-01 15:13:05.891350272 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - -class CIF { - private static native int getSizeofCIF(); - private static final int SIZEOF = getSizeofCIF(); - private static native boolean prepCIF(long cifPtr, int nargs, long retFFITypePtr, long argsPtr); - - public static CIF createCIFFor(final NativeArgumentBuffer args, final Coder returnCoder, final Coder ... argCoders) { - NativeBuffer cifBuf = new NativeBuffer(SIZEOF + (argCoders.length * JObjCRuntime.PTR_LEN)); - final long argsPtr = cifBuf.bufferPtr + SIZEOF; - - { - long argsIterPtr = argsPtr; - for(final Coder coder : argCoders){ - PrimitivePointerCoder.INST.push(args.runtime, argsIterPtr, coder.getFFITypePtr()); - argsIterPtr += JObjCRuntime.PTR_LEN; - } - } - - boolean ok = prepCIF(cifBuf.bufferPtr, argCoders.length, returnCoder.getFFITypePtr(), argsPtr); - if(!ok) - throw new RuntimeException("ffi_prep_cif failed."); - - return new CIF(cifBuf, returnCoder, argCoders); - } - - final NativeBuffer cif; - // CIF needs to keep refs to the Coders, so they don't get finalized and their FFITypes freed. - final Coder returnCoder; - final Coder[] argCoders; - - private CIF(final NativeBuffer cif, Coder returnCoder, Coder... argCoders) { - this.cif = cif; - this.returnCoder = returnCoder; - this.argCoders = argCoders; - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java 2014-07-01 15:13:06.195350271 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; - -import com.apple.jobjc.JObjCRuntime.Width; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; - -public abstract class Coder { - private static native long getNativeFFITypePtrForCode(final int code); - - static final int FFI_VOID = 0; - static final int FFI_PTR = FFI_VOID+1; - - static final int FFI_SINT8 = FFI_PTR+1; - static final int FFI_UINT8 = FFI_SINT8+1; - static final int FFI_SINT16 = FFI_UINT8+1; - static final int FFI_UINT16 = FFI_SINT16+1; - static final int FFI_SINT32 = FFI_UINT16+1; - static final int FFI_UINT32 = FFI_SINT32+1; - static final int FFI_SINT64 = FFI_UINT32+1; - static final int FFI_UINT64 = FFI_SINT64+1; - - static final int FFI_FLOAT = FFI_UINT64+1; - static final int FFI_DOUBLE = FFI_FLOAT+1; - static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; - - private static long[] ffiCodesToFFITypePtrs; - static{ - System.loadLibrary("JObjC"); - ffiCodesToFFITypePtrs = new long[FFI_LONGDOUBLE + 1]; - for (int i = 0; i < FFI_LONGDOUBLE + 1; i++) ffiCodesToFFITypePtrs[i] = getNativeFFITypePtrForCode(i); - } - - long getFFITypePtr() { - return ffiCodesToFFITypePtrs[getTypeCode()]; - } - - // runtime coding - public abstract void push(final JObjCRuntime runtime, final long addr, final T x); - public abstract T pop(final JObjCRuntime runtime, final long addr); - - public void push(final NativeArgumentBuffer args, final T x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - - public T pop(final NativeArgumentBuffer args){ - return pop(args.runtime, args.retValPtr); - } - - public abstract int sizeof(Width w); - final public int sizeof(){ return sizeof(JObjCRuntime.WIDTH); } - - // - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim) { - this.ffiTypeCode = ffiTypeCode; - this.objCEncoding = objCEncoding; - this.jclass = jclass; - this.jprim = jprim; - } - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass) { - this(ffiTypeCode, objCEncoding, jclass, null); - } - - private final int ffiTypeCode; - private final String objCEncoding; - private final Class jclass; - private final Class jprim; - - final int getTypeCode() { return ffiTypeCode; } - final String getObjCEncoding(){ return objCEncoding; } - public final Class getJavaClass() { return jclass; } - public final Class getJavaPrimitive() { return jprim; } - - // runtime coding - - private static Coder[] runtimeCoders; - static public Coder getCoderAtRuntimeForType(Class cls){ - if(runtimeCoders == null) runtimeCoders = new Coder[]{ - NSClassCoder.INST, IDCoder.INST, PointerCoder.INST, - DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST, - SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST, - VoidCoder.INST - }; - - for(Coder c : runtimeCoders) - if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) || - (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls))) - return c; - - if(Struct.class.isAssignableFrom(cls)){ - try { - Method m = cls.getDeclaredMethod("getStructCoder"); - m.setAccessible(true); - return (Coder) m.invoke(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - throw new RuntimeException("Could not find suitable coder for " + cls); - } - - static public Coder getCoderAtRuntime(Object inst){ - if(inst == null) return PointerCoder.INST; - if(inst instanceof Struct) return ((Struct) inst).getCoder(); - return getCoderAtRuntimeForType(inst.getClass()); - } - - // - - public static final class VoidCoder extends Coder{ - public static final VoidCoder INST = new VoidCoder(); - public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); } - @Override public int sizeof(Width w) { return -1; } - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Trying to pop a Void."); } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); } - } - - public static final class UnknownCoder extends Coder { - public static final UnknownCoder INST = new UnknownCoder(); - public UnknownCoder(){ super(-1, "?", null, null); } - @Override public int sizeof(Width w) { return -1; } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Coder not implemented");} - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); } - } - - public static final class PrimitivePointerCoder extends Coder { - public static final PrimitivePointerCoder INST = new PrimitivePointerCoder(); - public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); } - @Override public int sizeof(Width w) { return JObjCRuntime.PTR_LEN; } - - public void push(JObjCRuntime runtime, long addr, long x) { - if(JObjCRuntime.IS64) - runtime.unsafe.putLong(addr, x); - else - runtime.unsafe.putInt(addr, (int) x); - } - - public void push(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf, final long ptr) { - push(runtime, argBuf.argValuesPtr, ptr); - argBuf.didPutArgValue(sizeof()); - } - - public long popPtr(final JObjCRuntime runtime, final long addr) { - return JObjCRuntime.IS64 ? runtime.unsafe.getLong(addr) : runtime.unsafe.getInt(addr); - } - - public long popPtr(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf) { - return popPtr(runtime, argBuf.retValPtr); - } - - @Override public Long pop(JObjCRuntime runtime, long addr) { return popPtr(runtime, addr); } - @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); } - } - - public static final class PointerCoder extends Coder { - public static final PointerCoder INST = new PointerCoder(); - public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public Pointer pop(JObjCRuntime runtime, long addr) { - return new Pointer(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - @Override public void push(JObjCRuntime runtime, long addr, Pointer x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.ptr); - } - } - - public static final class SELCoder extends Coder { - public static final SELCoder INST = new SELCoder(); - public SELCoder(){ super(FFI_PTR, ":", SEL.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public void push(JObjCRuntime runtime, long addr, SEL x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.selPtr); - } - @Override public SEL pop(JObjCRuntime runtime, long addr) { - return new SEL(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - } - - public static abstract class StructCoder extends Coder { - private final FFIType ffiType; - final int sizeof; - - public StructCoder(final int sizeof, final Coder... elementCoders){ - super(-1, objCEncoding(elementCoders), null); - this.ffiType = new FFIType(elementCoders); - this.sizeof = sizeof; - } - - @Override public int sizeof(Width w) { return sizeof; } - - private static String objCEncoding(final Coder[] elementCoders) { - StringWriter str = new StringWriter(); - str.append("{?="); - for(Coder c : elementCoders) - str.append(c.getObjCEncoding()); - str.append("}"); - return str.toString(); - } - - @Override long getFFITypePtr() { return ffiType.getPtr(); } - - @Override public void push(NativeArgumentBuffer argBuf, Struct x) { - // Just point to the instance on the heap instead of copying it onto the arg buf. - argBuf.doPutArgPtr(x.raw.bufferPtr); - } - - @Override public void push(JObjCRuntime rt, long addr, Struct x) { - rt.unsafe.copyMemory(x.raw.bufferPtr, addr, sizeof); - } - - protected abstract Struct newInstance(JObjCRuntime runtime); - - @Override public Struct pop(final JObjCRuntime runtime, final long addr) { - Struct s = newInstance(runtime); - runtime.unsafe.copyMemory(addr, s.raw.bufferPtr, sizeof); - return s; - } - } - - public static final class IDCoder extends Coder{ - public static final IDCoder INST = new IDCoder(); - public IDCoder(){ super(FFI_PTR, "@", ID.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - public T newID(final JObjCRuntime runtime, final long objPtr) { - return (T) ID.getObjCObjectFor(runtime, objPtr); - } - - @Override public ID pop(final JObjCRuntime runtime, final long addr) { - return newID(runtime, PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - - @Override public void push(final JObjCRuntime runtime, final long addr, final ID x) { - PointerCoder.INST.push(runtime, addr, x); - } - } - - public static final class NSClassCoder extends Coder{ - public static final NSClassCoder INST = new NSClassCoder(); - public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public NSClass pop(JObjCRuntime runtime, long addr) { - final long clsPtr = PrimitivePointerCoder.INST.popPtr(runtime, addr); - if (clsPtr == 0) return null; - return NSClass.getObjCClassFor(runtime, clsPtr); - } - @Override public void push(JObjCRuntime runtime, long addr, NSClass x) { - PointerCoder.INST.push(runtime, addr, x); - } - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java 2014-07-01 15:13:06.503350270 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -class FFIType{ - private static native void makeFFIType(long ffi_type_buf, long elements_buf); - private static native int getFFITypeSizeof(); - private static int FFI_TYPE_SIZEOF = getFFITypeSizeof(); - final NativeBuffer ffi_type; - final NativeBuffer elements; - final Coder[] elementCoders; - - public FFIType(final Coder... elementCoders){ - final JObjCRuntime runtime = JObjCRuntime.inst(); - this.elementCoders = elementCoders; - this.ffi_type = new NativeBuffer(FFI_TYPE_SIZEOF); - this.elements = new NativeBuffer(JObjCRuntime.PTR_LEN * (elementCoders.length + 1)); - - long elIterPtr = elements.bufferPtr; - for(Coder c : elementCoders){ - PrimitivePointerCoder.INST.push(runtime, elIterPtr, c.getFFITypePtr()); - elIterPtr += PrimitivePointerCoder.INST.sizeof(); - } - PrimitivePointerCoder.INST.push(runtime, elIterPtr, 0); - - makeFFIType(ffi_type.bufferPtr, elements.bufferPtr); - } - - public long getPtr(){ - return ffi_type.bufferPtr; - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java 2014-07-01 15:13:06.807350269 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class Function { - private static native long getFxnPtrForFunctionName(final String functionName); - private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName); - - final long fxnPtr; - - Function(final long fxnPtr) { - this.fxnPtr = fxnPtr; - } - - public Function(final String name) { - this(getFxnPtr(name)); - } - - public Function(final MacOSXFramework framework, final String name) { - this(getFxnPtr(name, framework)); - } - - static long getFxnPtr(final String name){ - long fxnPtr = getFxnPtrForFunctionName(name); - if(fxnPtr == 0) throw new RuntimeException("Function pointer for " + name + " not found in runtime."); - return fxnPtr; - } - - static long getFxnPtr(final String name, final MacOSXFramework framework){ - long fxnPtr = 0; - for(int i = 0; fxnPtr == 0 && i < framework.nativeLibPtrs.length; i++){ - fxnPtr = getFxnPtrForFunctionNameAndLib(framework.nativeLibPtrs[i], name); - if(fxnPtr != 0) return fxnPtr; - } - throw new RuntimeException("Function pointer for " + name + " not found in framework " + framework + "."); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java 2014-07-01 15:13:07.115350268 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; -import java.util.LinkedHashMap; -import java.util.Map; - - -public class ID extends Pointer{ - static native String getNativeDescription(final long objPtr); - - final JObjCRuntime runtime; - - static final Class[] CTOR_ARGS = { long.class, JObjCRuntime.class }; - protected ID(final long objPtr, final JObjCRuntime runtime) { - super(objPtr); - runtime.assertOK(); - this.runtime = runtime; - } - - protected ID(final ID obj, final JObjCRuntime runtime) { - this(obj.ptr, runtime); - } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.CFRetainRelease.INST; - } - - protected final JObjCRuntime getRuntime() { return runtime; } - - @Override public String toString(){ - String s = super.toString(); - return s + " (ObjC: " + ptr + " / " + Long.toHexString(ptr) + ")"; - } - - // - - public static T getInstance(final long ptr, final JObjCRuntime runtime){ - return (T) getObjCObjectFor(runtime, ptr); - } - - static T getObjCObjectFor(final JObjCRuntime runtime, final long objPtr){ - if (objPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(objPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final long clsPtr = NSClass.getClass(objPtr); - - final T newObj = (T) (runtime.subclassing.isUserClass(clsPtr) ? - Subclassing.getJObjectFromIVar(objPtr) - : createNewObjCObjectFor(runtime, objPtr, clsPtr)); - - objectCache.get().put(objPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCObjectFor(final JObjCRuntime runtime, final long objPtr, final long clsPtr) { - final Constructor ctor = getConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, objPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Constructor cachedCtor = (Constructor) constructorCache.get().get(clazzPtr); - if(cachedCtor != null) return cachedCtor; - - final Class clazz = getClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - constructorCache.get().put(clazzPtr, (Constructor) ctor); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } - - static T createNewObjCObjectForConstructor(final Constructor ctor, final long objPtr, final JObjCRuntime runtime) { - try { - final T newInstance = (T) ctor.newInstance(new Object[] { Long.valueOf(objPtr), runtime }); - objectCache.get().put(objPtr, new WeakReference(newInstance)); - return newInstance; - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - static T createNewObjCObjectForClass(final Class clazz, final long objPtr, final JObjCRuntime runtime) { - try { - final Constructor constructor = clazz.getDeclaredConstructor(CTOR_ARGS); - constructor.setAccessible(true); - return (T) createNewObjCObjectForConstructor(constructor, objPtr, runtime); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - // - - static final ThreadLocal> constructorCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES; - } - }; - } - }; - - static final ThreadLocal> objectCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES || eldest.getValue().get() == null; - } - }; - } - }; -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java 2014-07-01 15:13:07.423350268 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.StructCoder; - - -public abstract class Invoke { - public abstract void invoke(NativeArgumentBuffer argBuf); - public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct); - - // - - public static final class FunCall extends Invoke{ - static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr); - - final long fxnPtr; - final CIF cif; - - FunCall(long fxnPtr, CIF cif) { - this.fxnPtr = fxnPtr; - this.cif = cif; - } - - public FunCall(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name), CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, argCoders)); - } - - public FunCall(final MacOSXFramework framework, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name, framework), CIF.createCIFFor(framework.getRuntime().getThreadLocalState(), returnCoder, argCoders)); - } - - public void init(final NativeArgumentBuffer argBuf) { - argBuf.reset(); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - invoke(argBuf, argBuf.retValPtr); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - invoke(buffer, retvalStruct.raw.bufferPtr); - } - - void invoke(final NativeArgumentBuffer argBuf, final long retValPtr) { - invoke(cif.cif.bufferPtr, fxnPtr, retValPtr, argBuf.buffer.bufferPtr); - } - } - - public static final class MsgSend extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_FXN_PTR = new Function("objc_msgSend").fxnPtr; - private static final long OBJC_MSG_SEND_FPRET_FXN_PTR = new Function("objc_msgSend_fpret").fxnPtr; - private static final long OBJC_MSG_SEND_STRET_FXN_PTR = new Function("objc_msgSend_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSend(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer nativeBuffer, final ID obj) { - funCall.init(nativeBuffer); - IDCoder.INST.push(nativeBuffer, obj); - PrimitivePointerCoder.INST.push(nativeBuffer.runtime, nativeBuffer, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // support - - static Coder[] getSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = IDCoder.INST; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendFxnPtr(final Coder returnCoder) { - if(returnCoder instanceof StructCoder){ - StructCoder scoder = (StructCoder) returnCoder; - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_STRET_FXN_PTR; - case i386: - switch(scoder.sizeof){ - case 1: case 2: case 4: case 8: - return OBJC_MSG_SEND_FXN_PTR; - } - return OBJC_MSG_SEND_STRET_FXN_PTR; - case x86_64: - if(scoder.sizeof > 16) - return OBJC_MSG_SEND_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - - final int typeCode = returnCoder.getTypeCode(); - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_FXN_PTR; - case i386: - switch(typeCode) { - case Coder.FFI_FLOAT: case Coder.FFI_DOUBLE: case Coder.FFI_LONGDOUBLE: - return OBJC_MSG_SEND_FPRET_FXN_PTR; - } - return OBJC_MSG_SEND_FXN_PTR; - case x86_64: - if(typeCode == Coder.FFI_LONGDOUBLE) - return OBJC_MSG_SEND_FPRET_FXN_PTR; - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - } - - public static final class MsgSendSuper extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_SUPER_FXN_PTR = new Function("objc_msgSendSuper").fxnPtr; - private static final long OBJC_MSG_SEND_SUPER_STRET_FXN_PTR = new Function("objc_msgSendSuper_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSendSuper(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendSuperFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSuperSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer argBuf, final ID obj, final NSClass cls) { - funCall.init(argBuf); - - // Instead of mallocing a struct, or keeping another thread local, - // let's write objc_super out to the argbuf, and then point an argument - // to the data. - - final long valPtr = argBuf.argValuesPtr; - final int ptrLen = JObjCRuntime.PTR_LEN; - - IDCoder .INST.push(argBuf.runtime, valPtr, obj); - NSClassCoder.INST.push(argBuf.runtime, valPtr + ptrLen, cls); - argBuf.argValuesPtr += ptrLen + ptrLen; - - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, valPtr); - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // - - private final static StructCoder objc_super_coder = new StructCoder(JObjCRuntime.PTR_LEN*2, IDCoder.INST, NSClassCoder.INST){ - @Override protected Struct newInstance(JObjCRuntime runtime) { return null; }}; - - static Coder[] getSuperSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = objc_super_coder; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendSuperFxnPtr(final Coder returnCoder){ - long normal = MsgSend.getMsgSendFxnPtr(returnCoder); - if(normal == MsgSend.OBJC_MSG_SEND_STRET_FXN_PTR) - return OBJC_MSG_SEND_SUPER_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_SUPER_FXN_PTR; - } - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java 2014-07-01 15:13:07.731350267 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.lang.reflect.Field; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.List; - -import sun.misc.Unsafe; - - -public final class JObjCRuntime { - static { System.loadLibrary("JObjC"); } - - public static enum Arch{ ppc, i386, x86_64 }; - public static enum Width{ W32, W64 }; - - public static final Arch ARCH = getArch(); - public static final Width WIDTH = getWidth(); - - private static Arch getArch(){ - String arch = System.getProperty("os.arch"); - if("ppc".equals(arch)) return Arch.ppc; - if("i386".equals(arch)) return Arch.i386; - if("x86_64".equals(arch)) return Arch.x86_64; - if("amd64".equals(arch)) return Arch.x86_64; - if("universal".equals(arch)) return Arch.x86_64; - throw new RuntimeException("Did not recognize os.arch system property: '" + arch + "'"); - } - - private static Width getWidth(){ - String width = System.getProperty("sun.arch.data.model"); - if("32".equals(width)) return Width.W32; - if("64".equals(width)) return Width.W64; - throw new RuntimeException("Did not recognize sun.arch.data.model system property: '" + width + "'"); - } - - public static final boolean IS32 = System.getProperty("sun.arch.data.model").equals("32"); - public static final boolean IS64 = System.getProperty("sun.arch.data.model").equals("64"); - public static final int PTR_LEN = IS64 ? 8 : 4; - public static final boolean IS_BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; - static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("JObjC.debug")); - - static void checkPermission(){ - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkPermission(new RuntimePermission("canProcessApplicationEvents")); - } - - public final void assertOK(){ - if(this != instance) - throw new SecurityException("runtime"); - } - - private JObjCRuntime(){} - - private static JObjCRuntime instance; - static JObjCRuntime inst() { - if (instance == null) instance = new JObjCRuntime(); - return instance; - } - - public static JObjCRuntime getInstance() { - checkPermission(); - return inst(); - } - - public final NativeArgumentBuffer getThreadLocalState() { - return NativeArgumentBuffer.getThreadLocalBuffer(this); - } - - final Unsafe unsafe = getUnsafe(); - final Subclassing subclassing = new Subclassing(this); - final List registeredPackages = new ArrayList(); - - @SuppressWarnings("unchecked") - Class getClassForNativeClassName(final String className) { - for (final String pkg : registeredPackages) { - try { - final Class clazz = Class.forName(pkg + "." + className); - if (clazz != null) return (Class)clazz; - } catch (final ClassNotFoundException e) { } - } - - return null; - } - - private final static Unsafe getUnsafe() { - Unsafe inst = null; - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - inst = (Unsafe) f.get(null); - if(inst == null) throw new NullPointerException("Unsafe.theUnsafe == null"); - } catch (Exception e) { - throw new RuntimeException("Unable to get instance of Unsafe.", e); - } - return inst; - } - - public void registerPackage(final String pkg) { - registeredPackages.add(pkg); - } - - /** - * Register a subclass of NSObject to allow the native side to send - * messages which in turn call java methods declared on the class. - * If a native class by the same name already exists, registerClass - * will simply return without doing anything. - * - * For a usage example, see the SubclassingTest. - */ - public boolean registerUserClass(Class clazz, Class clazzClazz) { - return subclassing.registerUserClass(clazz, clazzClazz); - } - -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java 2014-07-01 15:13:08.051350266 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - - -public class MacOSXFramework { - private static native long retainFramework(final String frameworkName); - private static native void releaseFramework(final long frameworkPtr); - private static native void getConstant(final long frameworkPtr, String symbol, final long bufferPtr, final int size); - - private final JObjCRuntime runtime; - protected final long[] nativeLibPtrs; - - final long getFrameworkPtr() { return nativeLibPtrs.length > 0 ? nativeLibPtrs[0] : 0; } - - private static long[] createFrameworkPtrsFromPaths(final String[] frameworkLibPaths) { - final long[] libPtrs = new long[frameworkLibPaths.length]; - for(int i = 0; i < libPtrs.length; i++){ - libPtrs[i] = retainFramework(frameworkLibPaths[i]); - if(libPtrs[i] == 0) throw new RuntimeException("Could not open library at " + frameworkLibPaths[i]); - } - return libPtrs; - } - - protected MacOSXFramework(final JObjCRuntime runtime, final String[] nativeLibPaths) { - runtime.assertOK(); - this.runtime = runtime; - this.nativeLibPtrs = createFrameworkPtrsFromPaths(nativeLibPaths); - } - - @Override protected final synchronized void finalize() throws Throwable { - for(long lib : nativeLibPtrs) - if(lib != 0) releaseFramework(lib); - } - - protected final JObjCRuntime getRuntime(){ return runtime; } - - protected void getConstant(final String symbol, final long retValPtr, final int size){ - assert size >= 0; - assert retValPtr != 0; - getConstant(getFrameworkPtr(), symbol, retValPtr, size); - } - - protected void getConstant(final String symbol, final NativeArgumentBuffer out, final int size){ - getConstant(symbol, out.retValPtr, size); - } - - protected void getConstant(final String symbol, final Struct out, final int size){ - getConstant(symbol, out.raw.bufferPtr, size); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java 2014-07-01 15:13:08.367350265 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; - - -public class NSClass extends ID { - public static class NSClassNotFoundException extends RuntimeException{ - public NSClassNotFoundException(String m){ super(m); } - public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); } - } - - static native long getNativeClassByName(String name); - static native long getSuperClassOfClass(long classPtr); - static native String getClassNameOfClass(long classPtr); - static native long getClass(long objPtr); - - public NSClass(final long ptr, final JObjCRuntime runtime) { - super(ptr, runtime); - } - - public NSClass(final String name, final JObjCRuntime runtime) { - this(getNativeClassByName(name), runtime); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - protected NSClass(final JObjCRuntime runtime){ - super(0, runtime); - final String sn = getClass().getSimpleName(); - final String name = sn.substring(0, sn.lastIndexOf("Class")); - ptr = getNativeClassByName(name); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - NSClass getSuperClass() { - return new NSClass(getSuperClassOfClass(ptr), runtime); - } - - String getClassName() { return getClassNameOfClass(ptr); } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o){ - return (o instanceof NSClass) && (this.ptr == ((NSClass) o).ptr); - } - - // - - static T getObjCClassFor(final JObjCRuntime runtime, final long clsPtr){ - if (clsPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(clsPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final T newObj = (T) createNewObjCClassFor(runtime, clsPtr); - objectCache.get().put(clsPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCClassFor(final JObjCRuntime runtime, final long clsPtr) { - final Constructor ctor = getNSClassConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, clsPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getNSClassConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Class clazz = getNSClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getNSClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className + "Class"); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getNSClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java 2014-07-01 15:13:08.675350265 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.nio.ByteOrder; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -public final class NativeArgumentBuffer{ - private static final ThreadLocal threadLocal = new ThreadLocal(); - - static NativeArgumentBuffer getThreadLocalBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - final NativeArgumentBuffer alreadyCreated = threadLocal.get(); - if (alreadyCreated != null) return alreadyCreated; - - final NativeArgumentBuffer newThreadLocalState = new NativeArgumentBuffer(runtime); - threadLocal.set(newThreadLocalState); - return newThreadLocalState; - } - - final JObjCRuntime runtime; - - final NativeBuffer buffer; - - long argPtrsPtr; - long argValuesPtr; - final long retValPtr; - - private static final int MAX_ARGS = 512; - private static final int BUF_SIZE = MAX_ARGS * 8 * 2; - private static final int ARG_VALS_OFFSET = BUF_SIZE/2; - - private NativeArgumentBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - this.runtime = runtime; - this.buffer = new NativeBuffer(BUF_SIZE); - this.buffer.buffer.order(ByteOrder.nativeOrder()); - - reset(); - this.retValPtr = buffer.bufferPtr; - } - - - // Call before each new call - public void reset() { - argPtrsPtr = buffer.bufferPtr; - argValuesPtr = buffer.bufferPtr + ARG_VALS_OFFSET; - assert buffer.ptrInBounds(argValuesPtr); - } - - // Push a pointer to a block of memory - public void doPutArgPtr(long ptr) { - assert buffer.ptrInBounds(argPtrsPtr); - PrimitivePointerCoder.INST.push(runtime, argPtrsPtr, ptr); - argPtrsPtr += JObjCRuntime.PTR_LEN; - } - - // Call this after having written a value of size `sizeof` to `argValuesPtr`. - public void didPutArgValue(int sizeof) { - assert buffer.ptrInBounds(argValuesPtr); - doPutArgPtr(argValuesPtr); - argValuesPtr += sizeof; - } - - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - final long bptr = buffer.bufferPtr; - - for(long i = bptr; i < bptr + ARG_VALS_OFFSET; i += JObjCRuntime.PTR_LEN){ - if(argPtrsPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - builder.append("\n"); - - for(long i = bptr + ARG_VALS_OFFSET; i < bptr + BUF_SIZE; i += JObjCRuntime.PTR_LEN){ - if(argValuesPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - return builder.toString(); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java 2014-07-01 15:13:08.991350264 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -/** - * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer - */ -public class NativeBuffer { - static native long getPtrOfBuffer(final ByteBuffer byteBuffer); - - public final ByteBuffer buffer; - public final long bufferPtr; - - public NativeBuffer(final int capacity){ - this(ByteBuffer.allocateDirect(capacity)); - } - - /** - * Wrap a ByteBuffer and set the ByteOrder to nativeOrder. - */ - public NativeBuffer(ByteBuffer buffer){ - this.buffer = buffer; - this.bufferPtr = getPtrOfBuffer(buffer); - assert buffer != null; - assert bufferPtr != 0; - this.buffer.order(ByteOrder.nativeOrder()); - } - - public byte get() { return buffer.get(); } - public char getChar() { return buffer.getChar(); } - public double getDouble() { return buffer.getDouble(); } - public float getFloat() { return buffer.getFloat(); } - public int getInt() { return buffer.getInt(); } - public long getLong() { return buffer.getLong(); } - public short getShort() { return buffer.getShort(); } - public NativeBuffer put(byte b) { buffer.put(b); return this; } - public NativeBuffer put(NativeBuffer src) { buffer.put(src.buffer); return this; } - public NativeBuffer putChar(char c) { buffer.putChar(c); return this; } - public NativeBuffer putDouble(double d) { buffer.putDouble(d); return this; } - public NativeBuffer putFloat(float f) { buffer.putFloat(f); return this; } - public NativeBuffer putInt(int i) { buffer.putInt(i); return this; } - public NativeBuffer putLong(long l) { buffer.putLong(l); return this; } - public NativeBuffer putShort(short s) { buffer.putShort(s); return this; } - - public int capacity() { return buffer.capacity(); } - public int position() { return buffer.position(); } - public NativeBuffer position(int newPosition) { buffer.position(newPosition); return this; } - public NativeBuffer rewind(){ buffer.rewind(); return this; } - - public int limit() { return buffer.limit(); } - public NativeBuffer limit(final int sizeof) { buffer.limit(sizeof); return this; } - - public int remaining() { return buffer.remaining(); } - - public NativeBuffer slice(){ return new NativeBuffer(buffer.slice()); } - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - - for(int i = 0; i < limit(); i += JObjCRuntime.PTR_LEN){ - if(position() == i) - builder.append("*"); - if(JObjCRuntime.IS32) - builder.append(buffer.getInt(i)); - else - builder.append(buffer.getLong(i)); - builder.append(" "); - } - - return builder.toString(); - } - - public long positionPtr() { - return bufferPtr + position(); - } - - /** - * bufferPtr <= ptr && ptr < bufferPtr + capacity(); - */ - public boolean ptrInBounds(final long ptr){ - return bufferPtr <= ptr && ptr < bufferPtr + capacity(); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java 2014-07-01 15:13:09.299350263 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public abstract class NativeObjectLifecycleManager { - private static native void retainNativeObject(final long ptr); - private static native void releaseNativeObject(final long ptr); - private static native void freeNativeObject(final long ptr); - - abstract void begin(final long ptr); - abstract void end(final long ptr); - boolean shouldPreRetain() { return false; } - - public static class CFRetainRelease extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new CFRetainRelease(); - @Override void begin(final long ptr) { retainNativeObject(ptr); } - @Override void end(final long ptr) { releaseNativeObject(ptr); } - @Override boolean shouldPreRetain() { return true; } - } - - public static class Free extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Free(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { freeNativeObject(ptr); } - } - - public static class Nothing extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Nothing(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { } - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java 2014-07-01 15:13:09.599350262 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class Opaque extends Pointer { - protected Opaque(long ptr) { super(ptr); } - protected Opaque(Pointer ptr) { super(ptr.ptr); } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java 2014-07-01 15:13:09.899350262 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class Pointer implements Comparable>{ - long ptr; - - protected Pointer(final long ptr) { - this.ptr = ptr; - getNativeObjectLifecycleManager().begin(ptr); - } - - @Override protected final synchronized void finalize() throws Throwable { - long pptr = ptr; - ptr = 0; - if (pptr != 0) getNativeObjectLifecycleManager().end(pptr); - } - - protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o) { - return o instanceof Pointer && ptr == ((Pointer) o).ptr; - } - - @Override public int hashCode() { return (int)(ptr^(ptr>>>32)); } - - public int compareTo(Pointer o) { - if(this==o || ptr==o.ptr) return 0; - if(ptr < o.ptr) return -1; - return 1; - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java 2014-07-01 15:13:10.223350261 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,700 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; -import com.apple.jobjc.JObjCRuntime.Width; -// Auto generated by PrimitiveCoder.hs -// Do not edit by hand. -public abstract class PrimitiveCoder extends Coder{ - public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){ - super(ffiTypeCode, objCEncoding, jclass, jprim); - } - public final boolean popBoolean(NativeArgumentBuffer args){ - return popBoolean(args.runtime, args.retValPtr); - } - public abstract boolean popBoolean(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, boolean x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, boolean x); - - - public final byte popByte(NativeArgumentBuffer args){ - return popByte(args.runtime, args.retValPtr); - } - public abstract byte popByte(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, byte x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, byte x); - - - public final char popChar(NativeArgumentBuffer args){ - return popChar(args.runtime, args.retValPtr); - } - public abstract char popChar(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, char x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, char x); - - - public final short popShort(NativeArgumentBuffer args){ - return popShort(args.runtime, args.retValPtr); - } - public abstract short popShort(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, short x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, short x); - - - public final int popInt(NativeArgumentBuffer args){ - return popInt(args.runtime, args.retValPtr); - } - public abstract int popInt(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, int x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, int x); - - - public final long popLong(NativeArgumentBuffer args){ - return popLong(args.runtime, args.retValPtr); - } - public abstract long popLong(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, long x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, long x); - - - public final float popFloat(NativeArgumentBuffer args){ - return popFloat(args.runtime, args.retValPtr); - } - public abstract float popFloat(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, float x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, float x); - - - public final double popDouble(NativeArgumentBuffer args){ - return popDouble(args.runtime, args.retValPtr); - } - public abstract double popDouble(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, double x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, double x); - - -// native BOOL -> java boolean -public static final class BoolCoder extends PrimitiveCoder{ - public static final BoolCoder INST = new BoolCoder(); - public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, boolean x){ - rt.unsafe.putByte(addr, (byte) (x ? 1 : 0)); - } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr) != 0; - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Boolean x){ push(rt, addr, (boolean) x); } - @Override public Boolean pop(JObjCRuntime rt, long addr){ return popBoolean(rt, addr); } - // proxies for mixed encoding - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, (x != 0)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, (x != 0)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, (x != 0)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, (x != 0)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, (x != 0)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, (x != 0)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, (x != 0)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)(popBoolean(rt, addr) ? 1 : 0)); } - - -} - -// native schar -> java byte -public static final class SCharCoder extends PrimitiveCoder{ - public static final SCharCoder INST = new SCharCoder(); - public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native uchar -> java byte -public static final class UCharCoder extends PrimitiveCoder{ - public static final UCharCoder INST = new UCharCoder(); - public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native sshort -> java short -public static final class SShortCoder extends PrimitiveCoder{ - public static final SShortCoder INST = new SShortCoder(); - public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native ushort -> java short -public static final class UShortCoder extends PrimitiveCoder{ - public static final UShortCoder INST = new UShortCoder(); - public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native sint -> java int -public static final class SIntCoder extends PrimitiveCoder{ - public static final SIntCoder INST = new SIntCoder(); - public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native uint -> java int -public static final class UIntCoder extends PrimitiveCoder{ - public static final UIntCoder INST = new UIntCoder(); - public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native slong -> java long -public static final class SLongCoder extends PrimitiveCoder{ - public static final SLongCoder INST = new SLongCoder(); - public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulong -> java long -public static final class ULongCoder extends PrimitiveCoder{ - public static final ULongCoder INST = new ULongCoder(); - public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native slonglong -> java long -public static final class SLongLongCoder extends PrimitiveCoder{ - public static final SLongLongCoder INST = new SLongLongCoder(); - public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulonglong -> java long -public static final class ULongLongCoder extends PrimitiveCoder{ - public static final ULongLongCoder INST = new ULongLongCoder(); - public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native float -> java float -public static final class FloatCoder extends PrimitiveCoder{ - public static final FloatCoder INST = new FloatCoder(); - public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, float x){ - rt.unsafe.putFloat(addr, (float) x); - } - @Override public float popFloat(JObjCRuntime rt, long addr){ - return rt.unsafe.getFloat(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Float x){ push(rt, addr, (float) x); } - @Override public Float pop(JObjCRuntime rt, long addr){ return popFloat(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((float)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popFloat(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((float)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((float)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((float)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((float)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((float)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popFloat(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((float)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popFloat(rt, addr)); } - - -} - -// native double -> java double -public static final class DoubleCoder extends PrimitiveCoder{ - public static final DoubleCoder INST = new DoubleCoder(); - public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, double x){ - rt.unsafe.putDouble(addr, (double) x); - } - @Override public double popDouble(JObjCRuntime rt, long addr){ - return rt.unsafe.getDouble(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Double x){ push(rt, addr, (double) x); } - @Override public Double pop(JObjCRuntime rt, long addr){ return popDouble(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((double)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popDouble(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((double)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((double)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((double)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((double)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((double)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((double)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popDouble(rt, addr)); } - - - -} - -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java 2014-07-01 15:13:10.535350260 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class SEL { - static native long getSelectorPtr(String selectorName); - static native String getSelectorName(long ptr); - - final long selPtr; - - SEL(long ptr) { - this.selPtr = ptr; - } - - public SEL(final String name) { - this(getSelectorPtr(name)); - } - - @Override public String toString(){ - return ((int)selPtr) + " / " + selPtr + " : " + getSelectorName(selPtr); - } - - /** - * Converts something like "performSelectorOnMainThread_withObject_wait" - * to "performSelectorOnMainThread:withObject:wait:" - */ - public static String selectorName(String jMethodName, boolean hasArgs){ - String b = jMethodName.replaceAll("_", ":"); - return hasArgs ? b + ":" : b; - } - - public static String jMethodName(String selectorName){ - return selectorName.replaceAll(":", "_").replaceAll("_$", ""); - } - - public static boolean validName(String selectorName){ - return selectorName.matches("^[a-zA-Z_][a-zA-Z0-9_:]*$"); - } -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java 2014-07-01 15:13:10.847350259 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -/** - * A struct is malloced on the C heap and accessed in Java through a ByteBuffer. - */ -public abstract class Struct{ - protected final NativeBuffer raw; - private final JObjCRuntime runtime; - protected final JObjCRuntime getRuntime(){ return runtime; } - - /** - * Create a brand new struct from nothing. - */ - protected Struct(final JObjCRuntime runtime, final int SIZEOF){ - this(runtime, new NativeBuffer(SIZEOF), SIZEOF); - } - - /** - * Create a struct by taking ownership of an existing buffer. - * Used for struct fields of type struct. For example, the origin and size fields - * in NSRect would be initialized with this constructor. - */ - protected Struct(final JObjCRuntime runtime, final NativeBuffer buffer, final int SIZEOF){ - if(runtime == null) throw new NullPointerException("runtime"); - this.runtime = runtime; - this.raw = buffer; - this.raw.limit(SIZEOF); - } - - abstract public Coder getCoder(); -} --- old/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java 2014-07-01 15:13:11.147350258 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; - - -final class Subclassing { - static native long allocateClassPair(long superClass, String name); - static native boolean addIVarForJObj(long clazz); - static native boolean patchAlloc(long classPtr); - static native boolean addMethod(long cls, String name, Method jMethod, CIF cif, long cifPtr, String objCEncodedType); - static native void registerClassPair(long clazz); - - static native T getJObjectFromIVar(long objPtr); - static native void initJObjectToIVar(long objPtr, ID object); - - final Set registeredUserSubclasses = new HashSet(); - final JObjCRuntime runtime; - - Subclassing(JObjCRuntime runtime){ - this.runtime = runtime; - } - - boolean registerUserClass(final Class clazz, final Class clazzClazz) { - final String nativeClassName = clazz.getSimpleName(); - // Is it already registered? - if(0 != NSClass.getNativeClassByName(nativeClassName)) - return false; - - if(clazz.isAnonymousClass()) - throw new RuntimeException("JObjC cannot register anonymous classes."); - - // Verify superclass - long superClass = NSClass.getNativeClassByName(clazz.getSuperclass().getSimpleName()); - if(0 == superClass) - throw new RuntimeException(clazz.getSuperclass() + ", the superclass of " + clazz + ", must be a registered class."); - - runtime.registerPackage(clazz.getPackage().getName()); - - // Create class - long classPtr = Subclassing.allocateClassPair(superClass, nativeClassName); - if(classPtr == 0) throw new RuntimeException("objc_allocateClassPair returned 0."); - - // Add ivar to hold jobject - boolean addedI = Subclassing.addIVarForJObj(classPtr); - if(!addedI) throw new RuntimeException("class_addIvar returned false."); - - // Verify constructor - try { - clazz.getConstructor(ID.CTOR_ARGS); - } catch (Exception e) { - throw new RuntimeException("Could not access required constructor: " + ID.CTOR_ARGS, e); - } - - // Patch alloc to create corresponding jobject on invoke - patchAlloc(classPtr); - - // Add methods - Set takenSelNames = new HashSet(); - for(Method method : clazz.getDeclaredMethods()){ - // No overloading - String selName = SEL.selectorName(method.getName(), method.getParameterTypes().length > 0); - if(takenSelNames.contains(selName)) - throw new RuntimeException("Obj-C does not allow method overloading. The Objective-C selector '" - + selName + "' appears more than once in class " + clazz.getCanonicalName() + " / " + nativeClassName + "."); - - method.setAccessible(true); - - // Divine CIF - Coder returnCoder = Coder.getCoderAtRuntimeForType(method.getReturnType()); - Class[] paramTypes = method.getParameterTypes(); - Coder[] argCoders = new Coder[paramTypes.length]; - for(int i = 0; i < paramTypes.length; i++) - argCoders[i] = Coder.getCoderAtRuntimeForType(paramTypes[i]); - - CIF cif = new MsgSend(runtime, selName, returnCoder, argCoders).funCall.cif; - - // .. and objc encoding - StringWriter encType = new StringWriter(); - encType.append(returnCoder.getObjCEncoding()); - encType.append("@:"); - for(int i = 0; i < argCoders.length; i++) - encType.append(argCoders[i].getObjCEncoding()); - - // Add it! - boolean addedM = Subclassing.addMethod(classPtr, selName, method, cif, cif.cif.bufferPtr, encType.toString()); - if(!addedM) throw new RuntimeException("Failed to add method."); - takenSelNames.add(selName); - } - - // Seal it - Subclassing.registerClassPair(classPtr); - registeredUserSubclasses.add(classPtr); - - return true; - } - - boolean isUserClass(long clsPtr) { - return registeredUserSubclasses.contains(clsPtr); - } - - // Called from JNI - - private static void initJObject(final long objPtr){ -// System.err.println("initJObject " + objPtr + " / " + Long.toHexString(objPtr)); - ID newObj = ID.createNewObjCObjectFor(JObjCRuntime.inst(), objPtr, NSClass.getClass(objPtr)); -// System.err.println("... " + newObj); - initJObjectToIVar(objPtr, newObj); - } - - private static void invokeFromJNI(ID obj, Method method, CIF cif, long result, long args){ - assert obj != null; - assert obj.getClass().equals(method.getDeclaringClass()) : - obj.getClass().toString() + " != " + method.getDeclaringClass().toString(); - - final int argCount = method.getParameterTypes().length; - - // The first two args & coders are for objc id and sel. Skip them. - final Object[] argObjects = new Object[argCount]; - for(int i = 0; i < argCount; i++){ - final long argAddrAddr = args + ((i+2) * JObjCRuntime.PTR_LEN); - final long argAddr = PrimitivePointerCoder.INST.popPtr(obj.runtime, argAddrAddr); - argObjects[i] = cif.argCoders[i + 2].pop(obj.runtime, argAddr); - } - - Object retVal; - try { - retVal = method.invoke(obj, argObjects); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - - if(!(cif.returnCoder instanceof VoidCoder)) - cif.returnCoder.push(obj.runtime, result, retVal); - } -} --- old/src/macosx/native/jobjc/src/core/native/CIF.m 2014-07-01 15:13:11.459350258 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_CIF.h" - -#define MACOSX -#include -#include - -#include "NativeBuffer.h" - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_CIF_getSizeofCIF -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_cif); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_CIF_prepCIF -(JNIEnv *env, jclass clazz, jlong jCIFPtr, jint jNargs, jlong jRetTypePtr, jlong jArgsPtr) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - unsigned int nargs = jNargs; - ffi_type *rtype = jlong_to_ptr(jRetTypePtr); - ffi_type **atypes = jlong_to_ptr(jArgsPtr); - -// NSLog(@"rtype->(size: %d, alignment: %d, type: %d)", rtype->size, rtype->alignment, rtype->type); - return (jboolean) (FFI_OK == ffi_prep_cif(cif, FFI_DEFAULT_ABI, nargs, rtype, atypes)); -} --- old/src/macosx/native/jobjc/src/core/native/Coder.m 2014-07-01 15:13:11.783350257 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Coder.h" - -#include -#define MACOSX -#include -#include - -/* - * Class: com_apple_jobjc_Coder - * Method: getNativeFFITypeCodeForCode - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Coder_getNativeFFITypePtrForCode -(JNIEnv *env, jclass clazz, jint code) -{ - switch ((long)code) { - case com_apple_jobjc_Coder_FFI_VOID: return ptr_to_jlong(&ffi_type_void); - case com_apple_jobjc_Coder_FFI_PTR: return ptr_to_jlong(&ffi_type_pointer); - case com_apple_jobjc_Coder_FFI_SINT8: return ptr_to_jlong(&ffi_type_sint8); - case com_apple_jobjc_Coder_FFI_UINT8: return ptr_to_jlong(&ffi_type_uint8); - case com_apple_jobjc_Coder_FFI_SINT16: return ptr_to_jlong(&ffi_type_sint16); - case com_apple_jobjc_Coder_FFI_UINT16: return ptr_to_jlong(&ffi_type_uint16); - case com_apple_jobjc_Coder_FFI_SINT32: return ptr_to_jlong(&ffi_type_sint32); - case com_apple_jobjc_Coder_FFI_UINT32: return ptr_to_jlong(&ffi_type_uint32); - case com_apple_jobjc_Coder_FFI_SINT64: return ptr_to_jlong(&ffi_type_sint64); - case com_apple_jobjc_Coder_FFI_UINT64: return ptr_to_jlong(&ffi_type_uint64); - case com_apple_jobjc_Coder_FFI_FLOAT: return ptr_to_jlong(&ffi_type_float); - case com_apple_jobjc_Coder_FFI_DOUBLE: return ptr_to_jlong(&ffi_type_double); - case com_apple_jobjc_Coder_FFI_LONGDOUBLE: return ptr_to_jlong(&ffi_type_longdouble); - } - - return ptr_to_jlong(NULL); -} --- old/src/macosx/native/jobjc/src/core/native/FFIType.m 2014-07-01 15:13:12.087350256 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include -#include - -#include "com_apple_jobjc_FFIType.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_FFIType_makeFFIType -(JNIEnv *env, jclass clazz, jlong ffi_type_jlong, jlong ffi_type_elements_jlong) -{ - ffi_type *type = jlong_to_ptr(ffi_type_jlong); - type->elements = jlong_to_ptr(ffi_type_elements_jlong); - type->type = FFI_TYPE_STRUCT; - type->size = type->alignment = 0; -} - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_FFIType_getFFITypeSizeof -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_type); -} --- old/src/macosx/native/jobjc/src/core/native/Function.m 2014-07-01 15:13:12.395350255 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Function.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionName -(JNIEnv *env, jclass clazz, jstring fxnName) -{ - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(RTLD_SELF, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - return ptr_to_jlong(fxnPtr); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionNameAndLib -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring fxnName) -{ - void *frameworkHandle = jlong_to_ptr(frameworkPtr); - - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(frameworkHandle, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - - return ptr_to_jlong(fxnPtr); -} --- old/src/macosx/native/jobjc/src/core/native/ID.m 2014-07-01 15:13:12.695350255 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_ID.h" - -#include - -#include -#include - -/* - * Class: com_apple_jobjc_ID - * Method: getNativeDescription - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_ID_getNativeDescription -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - jstring ret = NULL; - -JNF_COCOA_ENTER(env); - - NSString *desc = [((id)jlong_to_ptr(objPtr)) description]; - ret = JNFNSToJavaString(env, desc); - -JNF_COCOA_EXIT(env); - - return ret; -} --- old/src/macosx/native/jobjc/src/core/native/Invoke.m 2014-07-01 15:13:12.999350254 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Invoke_FunCall.h" -#include -#include -#include - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Invoke_00024FunCall_invoke -(JNIEnv *env, jclass clazz, jlong cifPtr, jlong fxnPtr, jlong retValPtr, jlong argsPtr) -{ - ffi_cif *cif = jlong_to_ptr(cifPtr); - void *fxn = jlong_to_ptr(fxnPtr); - void *retVal = jlong_to_ptr(retValPtr); - void **args = jlong_to_ptr(argsPtr); - - ffi_call(cif, fxn, retVal, args); -} --- old/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m 2014-07-01 15:13:13.287350253 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "Cocoa/Cocoa.h" - --- old/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m 2014-07-01 15:13:13.595350252 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_MacOSXFramework.h" - -#include -#include - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: retainFramework - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_MacOSXFramework_retainFramework -(JNIEnv *env, jclass clazz, jstring frameworkName) -{ - if (frameworkName == NULL) return ptr_to_jlong(NULL); - const char *frameworkNameCStr = (*env)->GetStringUTFChars(env, frameworkName, JNI_FALSE); - const void *library = dlopen(frameworkNameCStr, RTLD_LOCAL); - (*env)->ReleaseStringUTFChars(env, frameworkName, frameworkNameCStr); - return ptr_to_jlong(library); -} - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: releaseFramework - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_releaseFramework -(JNIEnv *env, jclass clazz, jlong frameworkPtr) -{ - dlclose(jlong_to_ptr(frameworkPtr)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_getConstant -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring constSymbol, jlong retBuffer, jint size) -{ - const char *symbol = (*env)->GetStringUTFChars(env, constSymbol, JNI_FALSE); - void *handle = frameworkPtr ? jlong_to_ptr(frameworkPtr) : RTLD_DEFAULT; - void *data = dlsym(handle, symbol); - (*env)->ReleaseStringUTFChars(env, constSymbol, symbol); - - if(!data) - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), dlerror()); - else - memcpy(jlong_to_ptr(retBuffer), data, (size_t) size); -} --- old/src/macosx/native/jobjc/src/core/native/NSClass.m 2014-07-01 15:13:13.899350252 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NSClass.h" -#include - -#include - -/* - * Class: com_apple_jobjc_NSClass - * Method: getNativeClassByName - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getNativeClassByName -(JNIEnv *env, jclass clazz, jstring className) -{ - if (className == NULL) return ptr_to_jlong(NULL); - const char *classNameCStr = (*env)->GetStringUTFChars(env, className, JNI_FALSE); - const id obj = objc_getClass(classNameCStr); - (*env)->ReleaseStringUTFChars(env, className, classNameCStr); - - if (obj == nil) return ptr_to_jlong(NULL); - return ptr_to_jlong(obj); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getSuperClass - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getSuperClassOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - if (clazzPtr == 0L) return ptr_to_jlong(NULL); - const Class objClazz = (Class)jlong_to_ptr(clazzPtr); - return ptr_to_jlong(class_getSuperclass(objClazz)); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getClassName - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_NSClass_getClassNameOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - const char *clazzName = (char *)class_getName((Class)jlong_to_ptr(clazzPtr)); - return (*env)->NewStringUTF(env, clazzName); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getClass -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - id obj = (id)jlong_to_ptr(objPtr); - return ptr_to_jlong(object_getClass(obj)); -} --- old/src/macosx/native/jobjc/src/core/native/NativeBuffer.h 2014-07-01 15:13:14.207350251 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * NativeBuffer.h - * Copyright 2007 Apple Inc. All rights reserved. - * - */ - -#define BUFFER_AT(buffer, offset) (((UInt8 *)buffer) + offset) -#define GET_VALUE(type, buffer, offset) (*((type *)BUFFER_AT(buffer, offset))) -#define PUT_VALUE(type, buffer, offset, value) (*((type *)BUFFER_AT(buffer, offset)) = value) - -#define GET_INT_AT(buffer, offset) GET_VALUE(jint, buffer, offset) -#define GET_LONG_AT(buffer, offset) GET_VALUE(jlong, buffer, offset) - -#define PUT_INT_AT(buffer, offset, value) PUT_VALUE(jint, buffer, offset, value) -#define PUT_LONG_AT(buffer, offset, value) PUT_VALUE(jlong, buffer, offset, value) --- old/src/macosx/native/jobjc/src/core/native/NativeBuffer.m 2014-07-01 15:13:14.515350250 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NativeBuffer.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NativeBuffer_getPtrOfBuffer -(JNIEnv *env, jclass clazz, jobject buffer) -{ - if (buffer == NULL) return ptr_to_jlong(0); - return ptr_to_jlong((*env)->GetDirectBufferAddress(env, buffer)); -} --- old/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m 2014-07-01 15:13:14.819350249 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_NativeObjectLifecycleManager.h" - -#include - - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: retainNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_retainNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRetain(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: releaseNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_releaseNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRelease(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: freeNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_freeNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - free(jlong_to_ptr(ptr)); -} --- old/src/macosx/native/jobjc/src/core/native/SEL.m 2014-07-01 15:13:15.123350249 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_SEL.h" - -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_SEL_getSelectorPtr -(JNIEnv *env, jclass jclazz, jstring selName) -{ - const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName, JNI_FALSE); - const SEL sel = sel_registerName(selNameAsChars); - (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars); - return ptr_to_jlong((void*)sel); -} - -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName -(JNIEnv *env, jclass jclazz, jlong selPtr) -{ - return (*env)->NewStringUTF(env, sel_getName(jlong_to_ptr(selPtr))); -} --- old/src/macosx/native/jobjc/src/core/native/Subclassing.m 2014-07-01 15:13:15.435350248 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Subclassing.h" - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -// Subclassing of Obj-C classes in Java -// -// See: -// - Objective-C Runtime documentation -// - man ffi_prep_closure -// - Subclassing.java - - -#pragma mark Accessing object in IVar - -#define JOBJ_IVAR_NAME "jObjWrapper" -static jobject getJObjectFromIVar(id obj); - -jobject getJObjectFromIVar(id obj) -{ - JNFJObjectWrapper *wrapper = NULL; - object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper); - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Subclassing_getJObjectFromIVar -(JNIEnv *env, jclass jClass, jlong jPtr) -{ - id obj = (id) jlong_to_ptr(jPtr); - if(obj == NULL){ - (*env)->ThrowNew(env, (*env)->FindClass(env, - "java/lang/NullPointerException"), "obj"); - return NULL; - } - - JNFJObjectWrapper *wrapper; - - if(!object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return NULL; - } - - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_initJObjectToIVar -(JNIEnv *env, jclass jClass, jlong jPtr, jobject jObject) -{ - id obj = (id) jlong_to_ptr(jPtr); - JNFJObjectWrapper *wrapper = [[JNFJObjectWrapper alloc] - initWithJObject:jObject withEnv:env]; - [wrapper retain]; - - if(!object_setInstanceVariable(obj, JOBJ_IVAR_NAME, wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return; - } -} - -#pragma mark Registering class - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Subclassing_allocateClassPair -(JNIEnv *env, jclass clazz, jlong jSuperClass, jstring jName) -{ - const Class superClass = (Class)jlong_to_ptr(jSuperClass); - assert(superClass); - - const char *name = (*env)->GetStringUTFChars(env, jName, JNI_FALSE); - const Class newClass = objc_allocateClassPair(superClass, name, 0); - (*env)->ReleaseStringUTFChars(env, jName, name); - - return ptr_to_jlong(newClass); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addIVarForJObj -(JNIEnv *env, jclass clazz, jlong jSynthClass) -{ - return class_addIvar( - jlong_to_ptr(jSynthClass), - JOBJ_IVAR_NAME, - sizeof(id), - (uint8_t)log2((double)sizeof(id)), - "@"); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_registerClassPair -(JNIEnv *env, jclass clazz, jlong jClass) -{ - Class c = jlong_to_ptr(jClass); -// NSLog(@"Registering class pair %p / %s", c, class_getName(c)); - objc_registerClassPair(c); -} - - -#pragma mark Patching +alloc - -static id patchedAllocIMP(id obj, SEL sel); -static void addJavaInstance(id obj); - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_patchAlloc -(JNIEnv *env, jclass clazz, jlong jNativeClass) -{ - Class metaClass = object_getClass(jlong_to_ptr(jNativeClass)); - return class_addMethod(metaClass, - sel_registerName("alloc"), - (IMP) patchedAllocIMP, - "@@:"); -} - -static id patchedAllocIMP(id cls, SEL sel){ - id inst = class_createInstance(cls, 0); - addJavaInstance(inst); - return inst; -} - -static void addJavaInstance(id obj){ -// NSLog(@"addJavaInstance %p", obj); -// NSLog(@"... calling up to Java"); - - static JNF_CLASS_CACHE(jc_Subclassing, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_Subclassing_initJObject, - jc_Subclassing, - "initJObject", - "(J)V"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - JNFCallStaticVoidMethod(env, jm_Subclassing_initJObject, - ptr_to_jlong(obj)); - - JNFReleaseEnv(env, &threadWasAttached); -} - - -#pragma mark Adding methods - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data); -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data); - -typedef struct closure_data_t{ - JNFJObjectWrapper *jMethod; - JNFJObjectWrapper *jCIF; -} closure_data_t; - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data){ - // Allocate a page to hold the closure with read and write permissions. - ffi_closure *closure; - if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, (off_t) 0)) == (void*)-1) - { - fprintf(stderr, "mmap failed with errno: %d", errno); - return NULL; - } - - // Prepare the ffi_closure structure. - ffi_status status; - if ((status = ffi_prep_closure(closure, cif, sel_closure_call, (void *)user_data)) != FFI_OK) - { - fprintf(stderr, "ffi_prep_closure failed with ffi_status: %d", status); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - - // Ensure that the closure will execute on all architectures. - if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) - { - fprintf(stderr, "mprotect failed with errno: %d", errno); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - return closure; -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addMethod -(JNIEnv *env, jclass clazz, jlong jClass, jstring jSelName, jobject jMethod, - jobject jCIF, jlong jCIFPtr, jstring jObjCEncodedType) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - - closure_data_t *user_data = malloc(sizeof(closure_data_t)); - user_data->jMethod = [[JNFJObjectWrapper alloc] initWithJObject:jMethod withEnv:env]; - user_data->jCIF = [[JNFJObjectWrapper alloc] initWithJObject:jCIF withEnv:env]; - - ffi_closure *closure;; - if(!(closure = make_closure(cif, user_data))){ - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - const Class objcClass = (Class)jlong_to_ptr(jClass); - - const char *selName = (*env)->GetStringUTFChars(env, jSelName, JNI_FALSE); - const char *objCEncodedType = (*env)->GetStringUTFChars(env, jObjCEncodedType, JNI_FALSE); - -// NSLog(@"Adding method '%s' :: '%s' to '%s' / %p", -// selName, -// objCEncodedType, -// class_getName(objcClass), -// objcClass); - - BOOL ret = class_addMethod(objcClass, sel_registerName(selName), (IMP) closure, objCEncodedType); - - (*env)->ReleaseStringUTFChars(env, jSelName, selName); - (*env)->ReleaseStringUTFChars(env, jObjCEncodedType, objCEncodedType); - - if(!ret){ - NSLog(@"class_addMethod failed"); - munmap(closure, sizeof(ffi_closure)); - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - return ret; -} - -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data) -{ - id obj = *(id*) args[0]; -// SEL sel = *(SEL*) args[1]; - -// NSLog(@"Subclassing: sel_closure_call: %p %p", obj, sel); -// NSLog(@"Subclassing: sel_closure_call: obj class: %@ sel name: %s", object_getClass(obj), sel_getName(sel)); - - jobject jObj = getJObjectFromIVar(obj); - - if(!jObj){ - addJavaInstance(obj); - jObj = getJObjectFromIVar(obj); - } - - closure_data_t *jmeta = user_data; - jobject jMethod = [jmeta->jMethod jObject]; - jobject jCIF = [jmeta->jCIF jObject]; - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - - if((*env)->ExceptionOccurred(env)) goto bail; - - static JNF_CLASS_CACHE(jc, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_invokeFromJNI, jc, "invokeFromJNI", - "(Lcom/apple/jobjc/ID;Ljava/lang/reflect/Method;Lcom/apple/jobjc/CIF;JJ)V"); - - JNFCallStaticVoidMethod(env, jm_invokeFromJNI, - jObj, - jMethod, - jCIF, - ptr_to_jlong(result), - ptr_to_jlong(args)); - -bail: - JNFReleaseEnv(env, &threadWasAttached); - - if((*env)->ExceptionOccurred(env)){ - NSLog(@"Exception!"); - (*env)->ExceptionDescribe(env); - } - JNFReleaseEnv(env, &threadWasAttached); -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java 2014-07-01 15:13:15.755350247 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -public class BootClassPathMinus { - - /* - * return the default boot class path with all parts mentioned in arguments removed - */ - public static void main(String[] args) { - String bootClassPath = System.getProperty("sun.boot.class.path"); - StringBuffer newPath = new StringBuffer(bootClassPath.length()); - String[] bootClassPathParts = bootClassPath.split(java.io.File.pathSeparator, 0); - for (String part : bootClassPathParts) { - boolean found = false; - for (String minus : args) { - if (part.endsWith(minus)) { - found = true; - } - } - if (!found) { - if (newPath.length() > 0) newPath.append(java.io.File.pathSeparatorChar); - newPath.append(part); - } - } - System.out.println(newPath.toString()); - } - -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java 2014-07-01 15:13:16.059350246 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassConsolidator { - private static String[] PREFERRED_FRAMEWORKS = { "Foundation", "AppKit" }; - - static void consolidateClassesForFrameworks(final List frameworks) throws Throwable { - System.out.println("--2-- Resolving duplicate classes:"); - final Map> allClasses = new HashMap>(); - - for (final Framework framework : frameworks) { - for (final Clazz clazz : framework.classes) { - final List existingClazzList = allClasses.get(clazz.name); - if(existingClazzList != null) - existingClazzList.add(clazz); - else - allClasses.put(clazz.name, new ArrayList(Arrays.asList(clazz))); - } - } - - final Map filteredClasses = new HashMap(); - final List> dreggs = new ArrayList>(); - - final Collection> clazzLists = allClasses.values(); - for (final List clazzList : clazzLists) { - if (clazzList.size() > 1) { - // add to the list for later analysis - dreggs.add(clazzList); - continue; - } - - // if there is only one class definition, go with it! - final Clazz clazz = clazzList.get(0); - filteredClasses.put(clazz.name, clazz); - } - - // figure out which class is the real class, and convert the rest to categories - for (final List dreg : dreggs) - deriveCategoriesFrom(dreg, filteredClasses); - - // patch up the inheritance hierarchy - System.out.println("Determining super classes:"); - for (final Framework framework : frameworks) - framework.resolveSuperClasses(filteredClasses); - } - - private static void deriveCategoriesFrom(final List clazzes, final Map filteredClasses) { - final List clazzesToDerive = new ArrayList(clazzes); - - for (final String preferredFrameworkName : PREFERRED_FRAMEWORKS) { - for (final Clazz clazz : clazzesToDerive) { - if (!preferredFrameworkName.equals(clazz.parent.name)) continue; - - System.out.print("\t" + clazz.parent.name + " owns \"" + clazz.name + "\", "); - addCategoriesAndPatchClasses(clazzes, clazz); - filteredClasses.put(clazz.name, clazz); - return; - } - } - - final List frameworkNameList = new ArrayList(clazzes.size()); - for (final Clazz clazz : clazzes) frameworkNameList.add(clazz.parent.name); - throw new RuntimeException("Could not derived a preferred framework for: " + clazzes.get(0).name + ", from (" + Utils.joinWComma(frameworkNameList) + ")"); - } - - private static void addCategoriesAndPatchClasses(final List clazzes, final Clazz clazz) { - final List fwNames = new ArrayList(clazzes.size()); - - for (final Clazz cls : clazzes) { - if (cls == clazz) continue; - fwNames.add(cls.parent.name); - cls.parent.classes.remove(cls); - cls.parent.categories.add(new Category(cls, clazz)); - } - - System.out.println("creating categories in: " + Utils.joinWComma(fwNames)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java 2014-07-01 15:13:16.359350245 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassGenerator { - public static final String JOBJC_PACKAGE = "com.apple.jobjc"; - - public static List generateClasses(final List frameworks) { - final List generatedClassFiles = new ArrayList(); - - generatedClassFiles.add(new RootJObjCClass(frameworks)); - for (final Framework f : frameworks) { - f.generateClasses(generatedClassFiles); - } - - return generatedClassFiles; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java 2014-07-01 15:13:16.675350245 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; - -public class FileCopier { - public static List addSourceFilesFrom(final String srcPath) { - final List outputFileList = new ArrayList(); - - final List fileList = getFileList(srcPath); - for (final File file : fileList) { - outputFileList.add(new CopiedFile(file, ClassGenerator.JOBJC_PACKAGE, file.getName().replace("\\.java", ""))); - } - - return outputFileList; - } - - private static List getFileList(final String srcPath) { - final File srcRoot = new File(srcPath); - if (!srcRoot.exists()) throw new RuntimeException("Source root " + srcRoot + " does not exist. Nowhere to copy base runtime objects from."); - - final File targetDir = new File(srcRoot, ClassGenerator.JOBJC_PACKAGE.replaceAll("\\.", "\\/")); - if (!targetDir.exists() || !targetDir.isDirectory()) throw new RuntimeException("Base runtime object source directory " + targetDir + " does not exist. No runtime class files to copy."); - - final List fileList = new ArrayList(); - final File[] targetDirFileList = targetDir.listFiles(); - for (final File file : targetDirFileList) { - if (!file.isFile()) continue; - if (!file.getName().endsWith(".java")) continue; - fileList.add(file); - } - - return fileList; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java 2014-07-01 15:13:16.991350244 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.StructOffsetResolverBigBang; -import com.apple.jobjc.JObjCRuntime; - -public class FrameworkGenerator { - private static final String BRIDGESUPPORT_FILE_EXTENSION = "Full.bridgesupport"; - private static final String FRAMEWORK_MATCH = "^.*Full\\.bridgesupport$"; - private static final String FRAMEWORK_PRUNE = "^.*(PyObjC|/Versions|\\.lproj|/Headers|/PrivateHeaders).*$"; - - static List findFrameworkFilesIn(final File file) throws IOException{ - final List bridgeSupportFiles = Utils.find(file, FRAMEWORK_MATCH, FRAMEWORK_PRUNE); - System.out.println("found " + bridgeSupportFiles.size() + " frameworks"); - return bridgeSupportFiles; - } - - static List parseFrameworksFrom(final List bridgeSupportFiles) { - final List frameworks = new ArrayList(); - - System.out.println("Parsing XML"); - for (final File file : bridgeSupportFiles){ - Framework f = new Framework(extractFrameworkNameFrom(file), file); - try{ - f.load(); - frameworks.add(f); - System.out.println("Generator@" + JObjCRuntime.ARCH + " loaded " - + f.name + " (" + Fp.join(":", f.binaries) + ")"); - } - catch(Exception x){ - System.out.println("!! Generator@" + JObjCRuntime.ARCH + " failed to load " - + f.name + " (" + Fp.join(":", f.binaries) + "). SKIPPING"); - } - } - - System.out.println("Parsing dependencies"); - for (final Framework f : frameworks) f.parseDependencies(frameworks); - - Set alreadyWarnedDependency = new HashSet(); - for(final Framework f : frameworks) - for(final FrameworkDependency dep : f.dependencies) - if(dep.object == null && !alreadyWarnedDependency.contains(dep.name)){ - System.out.println(String.format("Warning: unresolved dependency: %1$30s -> %2$s", f.name, dep.name)); - alreadyWarnedDependency.add(dep.name); - } - if(alreadyWarnedDependency.size() > 0) - System.out.println("Unresolved dependencies lead to unresolved types."); - - Utils.topologicalSort(frameworks); - List cycle = Utils.getDependencyCycle(frameworks); - if(cycle != null) - System.out.println("Warning: cycle found in framework dependencies: " + Fp.join(" -> ", cycle)); - - System.out.println("Parsing types"); - for (final Framework f : frameworks){ - f.parseCFTypes(); - f.parseOpaques(); - } - for (final Framework f : frameworks) f.parseStructs(); - - new StructOffsetResolverBigBang().resolve(frameworks); - - System.out.println("Parsing classes"); - for (final Framework f : frameworks) f.parseClasses(); - - System.out.println("Parsing constants"); - for (final Framework f : frameworks) f.parseConstants(); - - System.out.println("Parsing functions"); - for (final Framework f : frameworks) f.parseFunctions(); - - return frameworks; - } - - private static String extractFrameworkNameFrom(final File file) { - final String fileName = file.getName(); - return fileName.substring(0, fileName.lastIndexOf(BRIDGESUPPORT_FILE_EXTENSION)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java 2014-07-01 15:13:17.303350243 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.PrintStream; -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.Arg; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLTertiary; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Invoke; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class FunctionGenerator { - private final static String VARARGS_NAME = "varargs"; - - private static String createFieldCache(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - - JLField field = new JLField("private static", type.getCanonicalName(), identifier); - // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance. - JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier); - - JLCall createIt = new JLCall("new " + type.getCanonicalName()); - createIt.args.add(firstArg(fxn)); - createIt.args.add("\"" + fxn.name + "\""); - createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName()); - for (final Arg arg : fxn.args) - createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName()); - - getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";"); - - return field.toString() + getter.toString(); - } - - private static String createLocalForward(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - return new JLField("final", type.getCanonicalName(), identifier, new JLCall("get_" + identifier)).toString(); - } - - private static String createLocalNew(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - StringWriter out = new StringWriter(); - - out.append(String.format("%3$s[] argCoders = new %3$s[%1$d + %2$s.length];\n", fxn.args.size(), VARARGS_NAME, Coder.class.getCanonicalName())); - - for(int i = 0; i < fxn.args.size(); i++) - out.append(String.format("argCoders[%1$d] = %2$s;\n", i, fxn.args.get(0).type.getJType().getCoderDescriptor().getCoderInstanceName())); - - if(fxn.variadic){ - out.append(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)\n", fxn.args.size(), VARARGS_NAME)); - out.append(String.format("\targCoders[i] = %1$s.getCoderAtRuntime(%2$s[i - %3$s]);\n", Coder.class.getCanonicalName(), VARARGS_NAME, fxn.args.size())); - } - - out.append("final " + type.getCanonicalName() + " " + identifier + " = new " + type.getCanonicalName() + "(" + firstArg(fxn) + ", \"" + fxn.name + "\", " - + fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName() + ", argCoders);"); - - return out.toString(); - } - - private static final String CONTEXT_NAME = "nativeBuffer"; - - public static void writeOutFunction(final PrintStream out, final Class type, final Function fxn, final String initWithObj) { - final String instName = makeInstanceName(fxn); - final JType returnJavaType = fxn.returnValue.type.getJType(); - - if(!fxn.variadic){ - out.print(createFieldCache(type, fxn)); - out.println(); - } - - JLMethod meth = new JLMethod("public", returnJavaType.getJavaReturnTypeName(), fxn.getJavaName()); - - for(Arg arg : fxn.args) - meth.args.add("final " + arg.type.getJType().getTypeNameAsParam() + " " + arg.javaName); - - if(fxn.variadic) - meth.args.add("final Object... " + VARARGS_NAME); - - if(fxn instanceof Method && ((Method)fxn).ignore){ - String suggestion = ((Method)fxn).suggestion == null ? "" : (" Suggested work-around: " + ((Method)fxn).suggestion); - meth.jdoc.add("@deprecated The framework recommends that this method be ignored. (It may be deprecated.)" + suggestion); - meth.attrs.add("@Deprecated"); - } - - // type mismatch warning - { - { - String retMsg = fxn.returnValue.type.getJType().getCoderDescriptor().mismatchMessage(); - if(retMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (return value) " + retMsg); - meth.attrs.add("@Deprecated"); - } - } - - for(int i = 0; i < fxn.args.size(); i++){ - final Arg arg = fxn.args.get(i); - String argMsg = arg.type.getJType().getCoderDescriptor().mismatchMessage(); - if(argMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (arg" + i + ": " + arg.javaName + ") " + argMsg); - meth.attrs.add("@Deprecated"); - } - } - } - - if(fxn.variadic) - meth.body.add(createLocalNew(coreType(fxn), fxn)); - else - meth.body.add(createLocalForward(coreType(fxn), fxn)); - - meth.body.add(returnJavaType.createDeclareBuffer(CONTEXT_NAME)); - meth.body.add(returnJavaType.createInit(CONTEXT_NAME, instName, initWithObj)); - - for(final Arg arg : fxn.args) - meth.body.add(arg.type.getJType().getCoderDescriptor().getPushStatementFor(CONTEXT_NAME, arg.javaName)); - - if(fxn.variadic){ - meth.body.add(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)", fxn.args.size(), VARARGS_NAME)); - meth.body.add(String.format("\targCoders[i].push(%1$s, %2$s[i - %3$d]);", CONTEXT_NAME, VARARGS_NAME, fxn.args.size())); - } - - meth.body.add(returnJavaType.createInvoke(CONTEXT_NAME, instName)); - meth.body.add(returnJavaType.createPop(CONTEXT_NAME)); - meth.body.add(returnJavaType.createReturn()); - - out.print(meth.toString()); - out.println(); - } - - private static Class coreType(final Function fxn){ - return fxn instanceof Method ? MsgSend.class : FunCall.class; - } - - private static String firstArg(Function fxn){ - return fxn instanceof Method ? "getRuntime()" : "this"; - } - - private static String makeInstanceName(Function fxn){ - String ext; - if(fxn instanceof Method){ - if(((Method) fxn).isClassMethod) ext = "CMetInst"; - else ext = "IMetInst"; - } - else - ext = "FxnInst"; - - return fxn.getJavaName() + "_" + ext; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java 2014-07-01 15:13:17.611350242 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -public class Generator { - private static final String DEFAULT_FRAMEWORKS_PATH = "/System/Library/Frameworks"; - private static final String DEFAULT_OUTPUT_PATH = "/tmp/JObjC"; - - public static void main(final String...args) throws Throwable { - final Map argMap = Utils.getArgs(args); - - final String dst = get(argMap, "dst", DEFAULT_OUTPUT_PATH); - System.out.println("Cleaning up: " + dst); - final File dstLoc = new File(dst); - Utils.recDelete(dstLoc); - dstLoc.mkdirs(); - System.out.println("Outputting classes to: " + dst); - - final String frameworksPath = get(argMap, "frameworks", DEFAULT_FRAMEWORKS_PATH); - System.out.println("Searching for bridged frameworks in: " + frameworksPath); - - final List bridgeSupportFiles = FrameworkGenerator.findFrameworkFilesIn(new File(frameworksPath)); - final List frameworks = FrameworkGenerator.parseFrameworksFrom(bridgeSupportFiles); - - System.out.println("--1-- Generator: consolidateClassesForFrameworks"); - ClassConsolidator.consolidateClassesForFrameworks(frameworks); - - System.out.println("--1-- Generator: TypeCache load"); - TypeCache.inst().load(frameworks); - - System.out.println("--1-- Generator: disambiguateMethodNames"); - MethodDisambiguator.disambiguateMethodNames(); - - System.out.println("--1-- Generator: disambiguateFunctionsIn"); - MethodDisambiguator.disambiguateFunctionsIn(frameworks); - - System.out.println("--1-- Generator: generateClasses"); - final List sourceFiles = ClassGenerator.generateClasses(frameworks); - sourceFiles.add(new MixedPrimitiveCoderClassFile(ComplexCoderDescriptor.getMixedEncoders())); - - System.out.println("--1-- Generator: writing " + sourceFiles.size() + " files"); - for (final OutputFile sourceFile : sourceFiles) sourceFile.write(dstLoc); - - System.out.println("I have " + TypeCache.inst().getUnknownTypes().size() + " unresolved types."); - for (final Type type : TypeCache.inst().getUnknownTypes()) - System.out.println("[Warning] unknown type: " + type); - - for(Type type : TypeCache.inst().typesByNTypes.values()){ - if(!type.type32.getClass().equals(type.type64.getClass())){ - System.out.format("Type with differing NTypes: %1$15s: %2$s\n", type.name, new Pair(type.type32, type.type64)); - } - } - } - - private static String get(final Map defaults, final String key, final String defaultValue) { - final String value = defaults.get(key); - if (value != null) return value; - return defaultValue; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java 2014-07-01 15:13:17.907350242 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.List; - -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.types.TypeCache; - -public class MethodDisambiguator { - static void disambiguateMethodNames() { - // link all subclassers off their parents - for (final Clazz clazz : TypeCache.inst().getAllClasses()) { - final Clazz superClazz = clazz.superClass; - if (superClazz != null) superClazz.subClassers.add(clazz); - } - - // recursively call all subclassers, starting from NSObject on down - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSObject")); - - // NSProxy does not appear to subclass from NSObject, but it is still a real full class...? - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSProxy")); - } - - static void disambiguateMethodNamesFor(final Clazz clazz) { - clazz.disambiguateMethods(); - for (final Clazz subClazz : clazz.subClassers) { - disambiguateMethodNamesFor(subClazz); - } - } - - public static void disambiguateFunctionsIn(final List frameworks) { - for (final Framework framework : frameworks) { - disambiguateFunctionsInFramework(framework); - } - } - - static void disambiguateFunctionsInFramework(final Framework framework) { - for (final Function fxn : framework.functions) - fxn.disambiguateArgs(); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java 2014-07-01 15:13:18.203350241 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class RestrictedKeywords { - static final String[] JAVA_KEYWORD_CONFLICTS = { - "wait", "null", "class", "new", "toString", "finalize", "boolean", "interface", "final", "static" - }; - - static final Set originalRestrictedSet = new HashSet(Arrays.asList(JAVA_KEYWORD_CONFLICTS)); - - public static Set getNewRestrictedSet() { - return new HashSet(originalRestrictedSet); - } - - public static boolean isRestricted(String s){ - return originalRestrictedSet.contains(s); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java 2014-07-01 15:13:18.503350240 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; - -public class Utils { - public static boolean isLeopard = System.getProperty("os.version").startsWith("10.5"); - public static boolean isSnowLeopard = System.getProperty("os.version").startsWith("10.6"); - - @SuppressWarnings("unchecked") - public static List list(final Object...args) { - final ArrayList list = new ArrayList(args.length); - for (final Object arg : args) list.add(arg); - return (List)list; - } - - /** - * A small implementation of UNIX find. - * @param matchRegex Only collect paths that match this regex. - * @param pruneRegex Don't recurse down a path that matches this regex. May be null. - * @throws IOException if File.getCanonicalPath() fails. - */ - public static List find(final File startpath, final String matchRegex, final String pruneRegex) throws IOException{ - final Pattern matchPattern = Pattern.compile(matchRegex, Pattern.CASE_INSENSITIVE); - final Pattern prunePattern = pruneRegex == null ? null : Pattern.compile(pruneRegex, Pattern.CASE_INSENSITIVE); - final Set visited = new HashSet(); - final List found = new ArrayList(); - class Search{ - void search(final File path) throws IOException{ - if(prunePattern != null && prunePattern.matcher(path.getAbsolutePath()).matches()) return; - String cpath = path.getCanonicalPath(); - if(!visited.add(cpath)) return; - if(matchPattern.matcher(path.getAbsolutePath()).matches()) - found.add(path); - if(path.isDirectory()) - for(File sub : path.listFiles()) - search(sub); - } - } - new Search().search(startpath); - return found; - } - - public static String joinWComma(final List list) { return Fp.join(", ", list); } - public static String joinWComma(final Object[] list) { return Fp.join(", ", Arrays.asList(list)); } - - public static class Substituter { - String str; - - public Substituter(final String str) { - this.str = str.replaceAll("\\#", "\t").replaceAll("\\~", "\n"); - } - - public void replace(final String key, final String value) { - str = str.replaceAll("\\$" + key, value); - } - - /** - * Apply String.format first, and then pass through Substituter. - */ - public static String format(String format, Object... args){ - return new Substituter(String.format(format, args)).toString(); - } - - @Override public String toString() { - return str; - } - } - - static Map getArgs(final String...args) { - final Map argMap = new HashMap(); - for (final String arg : args) { - final String[] splitArg = arg.split("\\="); - if (splitArg.length != 2) continue; - argMap.put(splitArg[0], splitArg[1]); - } - return argMap; - } - - static void recDelete(final File file) { - if (!file.exists()) return; - if (file.isDirectory()) for (final File f : file.listFiles()) recDelete(f); - file.delete(); - } - - public static String capitalize(String s){ - if(s.length() == 0) return s; - return Character.toString(Character.toUpperCase(s.charAt(0))) + s.substring(1); - } - - /** - * Sort frameworks by dependencies. If A is a dependency of B, - * then A will come before B in the list. - */ - public static void topologicalSort(final List frameworks) { - final Set visited = new TreeSet(); - final List sorted = new ArrayList(frameworks.size()); - class Rec{ - void visit(final Framework fw){ - if(!visited.add(fw)) return; - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object); - sorted.add(fw); - } - } - for(Framework fw : frameworks) new Rec().visit(fw); - frameworks.clear(); - frameworks.addAll(sorted); - } - - /** - * If there is a cycle it is returned. Otherwise null is returned. - */ - public static List getDependencyCycle(List frameworks) { - @SuppressWarnings("serial") - class FoundCycle extends Throwable{ - public final List cycle; - public FoundCycle(List cycle){ - this.cycle = cycle; - } - }; - class Rec{ - void visit(final Framework fw, List visited) throws FoundCycle{ - visited = new LinkedList(visited); - if(visited.contains(fw)){ - visited.add(fw); - throw new FoundCycle(visited); - } - visited.add(fw); - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object, visited); - } - } - try{ for(Framework fw : frameworks){ new Rec().visit(fw, new LinkedList()); }} - catch(FoundCycle x){ return x.cycle; } - return null; - } - - public static String getCanonicalPath(File file) throws RuntimeException{ - try { - return file.getCanonicalPath(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java 2014-07-01 15:13:18.815350239 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import com.apple.internal.jobjc.generator.model.Clazz; - -public abstract class AbstractObjCClassFile extends GeneratedClassFile { - final Clazz clazz; - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String genericArgs, final String superClass) { - super(clazz.getPackage(), classname, genericArgs, superClass); - this.clazz = clazz; - } - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String superClass) { - super(clazz.getPackage(), classname, superClass); - this.clazz = clazz; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java 2014-07-01 15:13:19.127350239 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.jobjc.Pointer; - -public class CFTypeClassFile extends GeneratedClassFile { - final CFType cftype; - - public CFTypeClassFile(final CFType cftype) { - super(cftype.parent.pkg, cftype.type.getJType().getJavaClassName(), com.apple.jobjc.CFType.class.getCanonicalName()); - this.cftype = cftype; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - - @Override public void writeBody(PrintStream out){ - if(cftype.getTypeIdFunc != null){ - out.println("\tpublic static long getTypeId(){"); - out.println("\t\treturn " + RootJObjCClass.runtimeFrameworkInst(cftype.parent.name) + "." + cftype.getTypeIdFunc + "();"); - out.println("\t}"); - } - else - out.println("\t// getTypeIdFunc not found"); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java 2014-07-01 15:13:19.431350238 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class CategoryClassClassFile extends AbstractObjCClassFile { - final Category category; - - public CategoryClassClassFile(final Category category) { - super(category.category, category.category.name + "Class", - category.category.superClass.getFullPath() + "Class"); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\t%1$s(%2$s runtime) {\n" + - "\t\tsuper(\"%3$s\", runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName(), category.category.superClass.name); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } - - @Override protected boolean isFinal(){ return true; } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java 2014-07-01 15:13:19.739350237 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.jobjc.JObjCRuntime; - -public class CategoryClassFile extends JObjCClassFile { - private final Category category; - - public CategoryClassFile(final Category category) { - super(category.category); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - String targetCls = category.category.superClass.getFullPath(); - out.format("\tpublic %1$s(final %2$s obj, final %3$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, targetCls, JObjCRuntime.class.getCanonicalName()); - super.writeBeginning(out); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java 2014-07-01 15:13:20.047350236 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.*; - -public class CopiedFile extends OutputFile { - final File sourceFile; - - public CopiedFile(final File sourceFile, final String pkg, final String filename) { - super(pkg, filename); - this.sourceFile = sourceFile; - } - - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - final InputStream in = new FileInputStream(sourceFile); - - copy(in, out); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - private static void copy(final InputStream in, final PrintStream out) throws IOException { - int bit; - while (-1 != (bit = in.read())) { - out.write(bit); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java 2014-07-01 15:13:20.363350235 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Constant; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.NativeEnum; -import com.apple.internal.jobjc.generator.model.StringConstant; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLReturn; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.Invoke.FunCall; - -public class FrameworkClassFile extends GeneratedClassFile { - final Framework framework; - - public FrameworkClassFile(final Framework framework) { - super(framework.pkg, framework.name + "Framework", MacOSXFramework.class.getName()); - this.framework = framework; - } - - @Override public void writeBeginning(final PrintStream out) { - List binPaths = Fp.map(new Map1(){ - public String apply(File a) { return "\"" + a.getAbsolutePath() + "\""; }}, - framework.binaries); - out.println(new Utils.Substituter( - "#public " + className + "(" + JObjCRuntime.class.getName() + " runtime) {~" + - "##super(runtime, new String[]{" + Fp.join(", ", binPaths) + "});~" + - "#}~" - )); - } - - @Override public void writeBody(final PrintStream out) { - for(final Struct struct : new ArrayList(framework.structs)){ - out.println("\tpublic " + struct.name + " make" + struct.name + "(){"); - out.println("\t\treturn new " + struct.name + "(getRuntime());"); - out.println("\t}"); - out.println("\tpublic " + struct.name + " make" + struct.name + "(com.apple.jobjc.NativeBuffer base){"); - out.println("\t\treturn new " + struct.name + "(getRuntime(), base);"); - out.println("\t}"); - } - - for(final NativeEnum nenum : framework.enums){ - if(nenum.ignore){ - out.println("\t/**"); - out.println("\t * @deprecated Suggestion: " + nenum.suggestion); - out.println("\t */"); - out.println("\t@Deprecated"); - } - out.println(String.format("\tpublic final %3$s %1$s(){ return %2$s; }", - nenum.name, nenum.valueToString(), nenum.type.getJType().getJavaReturnTypeName())); - } - - for(final Constant konst : framework.constants){ - String cacheName = "_" + konst.name; - final JType jtype = konst.type.getJType(); - final String cast = jtype.getReturnTypeCast() == null ? "" : "(" + jtype.getReturnTypeCast() + ")"; - out.println(); - - out.print(new JLField("private", jtype.getJavaTypeName(), cacheName, jtype.getDefaultReturnValue())); - - JLMethod reader = new JLMethod("public final", jtype.getJavaReturnTypeName(), konst.name); - reader.body.add("if(" + cacheName + " != " + jtype.getDefaultReturnValue() + ") return " + cast + cacheName + ";"); - - String contextName = jtype instanceof JStruct ? "returnValue" : "nativeBuffer"; - - if(jtype instanceof JStruct) - reader.body.add(((JStruct)jtype).createReturnValue()); - else - reader.body.add(jtype.createDeclareBuffer(contextName)); - - reader.body.add("getConstant(\"" + konst.name + "\", " + contextName + ", " + jtype.getCoderDescriptor().getCoderInstanceName() + ".sizeof());"); - - reader.body.add(jtype.createPop(contextName)); - reader.body.add(cacheName + " = returnValue;"); - reader.body.add(jtype.createReturn()); - - out.print(reader); - } - - for(final StringConstant konst : framework.stringConstants){ - if(Fp.any(new Map1(){ public Boolean apply(Constant a) { - return a.name.equals(konst.name); - }}, new ArrayList(framework.constants))){ - System.out.println("Warning: [" + framework.name + "] String constant " + konst.name + " is already defined in constants. Skipping."); - } - else{ - out.println("\tpublic final String " + konst.name + "(){ return \"" + escapeQuotes(konst.value) + "\"; }"); - } - } - - /** - * Order classes to get stable output - */ - TreeSet sortedClasses = new TreeSet(framework.classes); - for (final Clazz clazz : sortedClasses) { - final String classClassName = clazz.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, clazz.name, classClassName, "getRuntime()")); - } - - for (final Category cat : framework.categories) { - final String classClassName = cat.category.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, cat.category.name, classClassName, "getRuntime()")); - - JLMethod jlm = new JLMethod("public", cat.category.name, cat.category.name, "final " + cat.category.superClass.getFullPath() + " obj"); - jlm.body.add(new JLReturn(new JLCall("new " + cat.category.name, "obj", "getRuntime()"))); - out.println(jlm); - } - - for (final Function fxn : framework.functions){ - FunctionGenerator.writeOutFunction(out, FunCall.class, fxn, null); - } - } - - private String escapeQuotes(String s){ - return s.replace("\"", "\\\""); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java 2014-07-01 15:13:20.655350235 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -public class GeneratedClassFile extends OutputFile { - protected final String className; - protected final String genericArgs; - protected final String superClass; - - public GeneratedClassFile(final String pkg, final String classname, final String superClass) { - this(pkg, classname, null, superClass); - } - - public GeneratedClassFile(final String pkg, final String classname, final String genericArgs, final String superClass) { - super(pkg, classname + ".java"); - this.className = classname; - this.genericArgs = genericArgs; - this.superClass = superClass; - } - - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - out.println("package " + pkg + ";"); - out.println(); - out.print("public " + (isFinal() ? "final" : "") + " class " + className); - if(genericArgs != null) out.print("<" + genericArgs + ">"); - if (superClass != null) out.print(" extends " + superClass); - out.println(" {"); - writeBeginning(out); - writeBody(out); - writeEnd(out); - out.println("}"); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - public void writeBeginning(final PrintStream out) { - - } - - public void writeBody(final PrintStream out) { - - } - - public void writeEnd(final PrintStream out) { - - } - - protected boolean isFinal(){ return false; } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java 2014-07-01 15:13:20.943350234 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassClassFile extends AbstractObjCClassFile { - public JObjCClassClassFile(final Clazz clazz) { - super(clazz, clazz.name + "Class", clazz.superClass != null ? clazz.superClass.getFullPath() + "Class" : ClassGenerator.JOBJC_PACKAGE + ".NSClass<" + clazz.name + ">"); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\tpublic %1$s(%2$s runtime) {\n" + - "\t\tsuper(runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(String name, %2$s runtime) {\n" + - "\t\tsuper(name, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(long ptr, %2$s runtime) {\n" + - "\t\tsuper(ptr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java 2014-07-01 15:13:21.235350233 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.NativeObjectLifecycleManager; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassFile extends AbstractObjCClassFile { - public JObjCClassFile(final Clazz clazz) { - super(clazz, clazz.name, - clazz.superClass == null ? "com.apple.jobjc.ID" - : clazz.superClass.getFullPath()); - } - - private static Map nolmForClass = - new TreeMap(); - static{ - nolmForClass.put("NSAutoreleasePool", NativeObjectLifecycleManager.Nothing.INST); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format("\tpublic %1$s(final long objPtr, final %2$s runtime) {\n" + - "\t\tsuper(objPtr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - out.format("\tpublic %1$s(final %1$s obj, final %2$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - NativeObjectLifecycleManager nolm = nolmForClass.get(clazz.name); - if(nolm != null) - out.format("\t@Override\n"+ - "\tprotected %1$s getNativeObjectLifecycleManager() {\n" + - "\t\treturn %2$s.INST;\n" + - "\t}\n", - NativeObjectLifecycleManager.class.getCanonicalName(), nolm.getClass().getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.instanceMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java 2014-07-01 15:13:21.551350232 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor.MixedEncodingDescriptor; -import com.apple.jobjc.PrimitiveCoder; - -public class MixedPrimitiveCoderClassFile extends GeneratedClassFile { - private static final String MULTI_CODER_CLASSNAME = "MixedPrimitiveCoder"; - public static final String FULL_MULTI_CODER_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + MULTI_CODER_CLASSNAME; - - final Collection coderDescs; - - public MixedPrimitiveCoderClassFile(final Collection coderDescs) { - super(ClassGenerator.JOBJC_PACKAGE, MULTI_CODER_CLASSNAME, "java.lang.Object"); - this.coderDescs = coderDescs; - } - - @Override - public void writeBody(final PrintStream out) { - for (final MixedEncodingDescriptor desc : coderDescs) { - out.println("\tpublic static final " + PrimitiveCoder.class.getCanonicalName() + " " + desc.getMixedName() + " = " + desc.getDefinition() + ";"); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java 2014-07-01 15:13:21.863350232 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.jobjc.Pointer; - -public class OpaqueClassFile extends GeneratedClassFile { - final Opaque opaque; - - public OpaqueClassFile(final Opaque opaque) { - super(opaque.parent.pkg, opaque.type.getJType().getJavaClassName(), com.apple.jobjc.Opaque.class.getCanonicalName()); - this.opaque = opaque; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\t// " + opaque.type); - out.println("\t// " + opaque.type.getJType()); - out.println(""); - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java 2014-07-01 15:13:22.179350231 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.*; - -public abstract class OutputFile { - final String pkg; - final String fileName; - - public OutputFile(final String pkg, final String filename) { - this.pkg = pkg; - this.fileName = filename; - } - - public PrintStream open(final File parentDir) throws IOException { - final File pkgDir = new File(parentDir, pkg.replace('.', '/')); - pkgDir.mkdirs(); - final File classFile = new File(pkgDir, fileName); - classFile.createNewFile(); - return new PrintStream(classFile); - } - - public void close(final PrintStream out) { - out.close(); - } - - public abstract void write(final File parentDir); - - public boolean isClass(final Class clazz) { - final String pkgName = clazz.getPackage().getName(); - if (!pkgName.equals(pkg)) return false; - - return fileName.contains(clazz.getSimpleName()); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java 2014-07-01 15:13:22.479350230 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.List; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCtor; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.jobjc.JObjCRuntime; - -public class RootJObjCClass extends GeneratedClassFile { - private static final String JOBJC_CLASSNAME = "JObjC"; - public static final String FULL_JOBJC_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + JOBJC_CLASSNAME; - public static final String JOBJC_RUNTIME_INST = FULL_JOBJC_CLASSNAME + ".getInstance()"; - public static final String JOBJC_RUNTIME_INST_R = FULL_JOBJC_CLASSNAME + ".getInstance(getRuntime())"; - - public static final String runtimeFrameworkInst(String fwname){ - return JOBJC_RUNTIME_INST + "." + fwname + "()"; - } - - public static final String runtimeFrameworkInstR(String fwname){ - return JOBJC_RUNTIME_INST_R + "." + fwname + "()"; - } - - final List frameworks; - - public RootJObjCClass(final List frameworks) { - super(ClassGenerator.JOBJC_PACKAGE, JOBJC_CLASSNAME, "java.lang.Object"); - this.frameworks = frameworks; - } - - @Override public void writeBeginning(final PrintStream out) { - out.print(new JLField("private static", JOBJC_CLASSNAME, "instance")); - out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime")); - - JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime"); - getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");"); - getInstR.body.add("if(instance == null) instance = new JObjC(runtime);"); - getInstR.body.add("return instance;"); - out.print(getInstR); - - JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance"); - getInst.body.add("return getInstance(JObjCRuntime.getInstance());"); - out.print(getInst); - - JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime"); - ctor.body.add("this.runtime = runtime;"); - for (final Framework f : frameworks) - ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");"); - out.print(ctor); - } - - @Override public void writeBody(final PrintStream out) { - for (final Framework f : frameworks) - out.println(JavaLang.makeSingleton("_" + f.name, f.name, f.pkg + "." + f.name + "Framework", "runtime")); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java 2014-07-01 15:13:22.787350229 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.Struct.Field; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Coder.StructCoder; - -public class StructClassFile extends GeneratedClassFile { - final Struct struct; - - public StructClassFile(final Struct struct) { - super(struct.parent.pkg, struct.name, com.apple.jobjc.Struct.class.getName()); - this.struct = struct; - } - - @Override public boolean isFinal(){ return true; } - - @Override public void writeBeginning(final PrintStream out) { - out.println(); - out.println("\tpublic static int SIZEOF = " + JObjCRuntime.class.getName() + ".IS64 ? " - + ((NStruct) struct.type.type64).sizeof64() + " : " + ((NStruct) struct.type.type32).sizeof32() + ";"); - out.println(); - out.format("\tpublic final static %1$s getStructCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\t@Override public final %1$s getCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\tprivate final static %1$s coder = new %1$s(SIZEOF%2$s%3$s){\n", StructCoder.class.getCanonicalName(), - (struct.fields.size() > 0 ? ",\n\t\t" : ""), - Fp.join(",\n\t\t", Fp.map(new Map1(){ - public String apply(Field a) { - return a.type.getJType().getCoderDescriptor().getCoderInstanceName(); - }}, struct.fields))); - out.format("\t\t@Override protected %1$s newInstance(%2$s runtime){ return new %1$s(runtime); }\n", - struct.name, - JObjCRuntime.class.getCanonicalName()); - out.println("\t};"); - out.println(); - out.println("\t" + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime){"); - out.println("\t\tsuper(runtime, SIZEOF);"); - out.println("\t}"); - out.println(); - out.println("\tpublic " + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime, final com.apple.jobjc.NativeBuffer buffer) {"); - out.println("\t\tsuper(runtime, buffer, SIZEOF);"); - out.println("\t}"); - } - - @Override public void writeBody(final PrintStream out) { - for(Struct.Field field : struct.fields){ - if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct) - writeStructField(field, out); - else - writeField(field, out); - } - } - - private void writeField(final Struct.Field field, final PrintStream out){ - if(field.type.type32 instanceof NBitfield){ - out.format("\t// Skipping bitfield '%1$s'\n", field.name); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JType jtype = field.type.getJType(); - String retType = jtype.getJavaReturnTypeName(); - CoderDescriptor cdesc = jtype.getCoderDescriptor(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() - + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\t//" + cdesc.getClass().toString()); - out.println("\tpublic " + retType + " " + getterName(field) + "(){"); - out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName)); - out.println(jtype.createReturn()); - out.println("\t}"); - out.println(); - out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){"); - out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName)); - out.println("\t}"); - } - - private void writeStructField(final Struct.Field field, final PrintStream out){ - if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){ - out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")"); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JStruct jstype = (JStruct) field.type.getJType(); - String retTypeName = jstype.getJavaReturnTypeName(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64" - + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\tprivate " + retTypeName + " " + privName + " = null;"); - out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){"); - out.println("\t\tif(null==" + privName + "){"); - out.println("\t\t\tthis.raw.position(" + offsetName + ");"); - out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());"); - out.println("\t\t}"); - out.println("\t\treturn " + privName + ";"); - out.println("\t}"); - } - - private String getterName(Struct.Field field) { - if(com.apple.internal.jobjc.generator.RestrictedKeywords.isRestricted(field.name)) - return field.name + field.type.getJType().getAppendableDescription(); - return field.name; - } - - private String setterName(String name) { - return "set" + name.substring(0, 1).toUpperCase() + name.substring(1); - } - - @Override public void writeEnd(final PrintStream out) { - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java 2014-07-01 15:13:23.095350229 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class Arg extends ElementWType{ - public String javaName; - - public Arg(final Node node, final Function parent) { - super(node, parent); - javaName = name; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java 2014-07-01 15:13:23.403350228 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.CFTypeClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class CFType extends TypeElement implements OutputFileGenerator { - public final String getTypeIdFunc; - public final String tollfree; - - public CFType(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); - getTypeIdFunc = getAttr(node, "gettypeid_func"); - tollfree = getAttr(node, "tollfree"); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new CFTypeClassFile(this)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java 2014-07-01 15:13:23.695350227 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import com.apple.internal.jobjc.generator.classes.CategoryClassClassFile; -import com.apple.internal.jobjc.generator.classes.CategoryClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class Category implements OutputFileGenerator{ - public final Clazz category; - - public Category(Clazz fromClass, Clazz target) { - this.category = new Clazz(fromClass.name + "Category", fromClass.classMethods, fromClass.instanceMethods, target, fromClass.parent); - } - - public void generateClasses(List generatedClassFiles) { - generatedClassFiles.add(new CategoryClassFile(this)); - generatedClassFiles.add(new CategoryClassClassFile(this)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java 2014-07-01 15:13:24.011350226 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; -import com.apple.internal.jobjc.generator.classes.JObjCClassClassFile; -import com.apple.internal.jobjc.generator.classes.JObjCClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.SuperClassExtractor; -import com.apple.jobjc.UnsafeRuntimeAccess; -import com.apple.jobjc.NSClass.NSClassNotFoundException; -import com.apple.jobjc.SEL; - -public class Clazz extends Element implements OutputFileGenerator { - private final Map instanceMethodsByName = new HashMap(); - private final Map classMethodsByName = new HashMap(); - - public final List classMethods; - public final List instanceMethods; - - public final List subClassers = new ArrayList(0); - public Clazz superClass; - - public Clazz(String name, List classMethods, List instanceMethods, Clazz superClass, Framework parent){ - super(name, parent); - this.classMethods = classMethods; - this.instanceMethods = instanceMethods; - this.superClass = superClass; - } - - public Clazz(final Node classNode, final Framework parent) { - super(classNode, parent); - this.classMethods = new ArrayList(); - this.instanceMethods = new ArrayList(); - - final NodeList methodNodes = classNode.getChildNodes(); - for (int i = 0; i < methodNodes.getLength(); i++) { - final Node node = methodNodes.item(i); - if (!"method".equals(node.getLocalName())) continue; - - final String selName = Element.getAttr(node, "selector"); - if(selName == null || !SEL.validName(selName)){ - System.err.format("Warning: Discarding method %1$s:%2$s:%3$s" - + " -- Invalid selector name. Verify.\n", - parent.name, name, selName); - continue; - } - - final Method method = new Method(node, parent); - if (method.isClassMethod) { - classMethods.add(method); - } else { - instanceMethods.add(method); - } - } - } - - public String getPackage() { - return parent.pkg; - } - - public String getFullPath(){ - return parent.pkg + "." + name; - } - - @Override - public String toString() { - return super.toString() + " " + classMethods + " " + instanceMethods; - } - - public boolean doesActuallyExist(){ - try{ - UnsafeRuntimeAccess.getNSClass(parent.load(), name); - }catch(NSClassNotFoundException x){ - return false; - } - return true; - } - - void resolveSuperClass(final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - superClass = SuperClassExtractor.getSuperClassFor(name, nativeFramework, allClasses); - } - - public void disambiguateMethods() { - disambiguateMethods(instanceMethods, instanceMethodsByName); - disambiguateMethods(classMethods, classMethodsByName); - } - - private void disambiguateMethods(final List methods, final Map methodMap) { - final Set existingMethodNames = RestrictedKeywords.getNewRestrictedSet(); - for (final Method method : methods) { - method.disambiguateNameAndArgs(this, existingMethodNames); - methodMap.put(method.javaName, method); - } - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new JObjCClassClassFile(this)); - generatedClassFiles.add(new JObjCClassFile(this)); - } - - Method getParentMethodMatchingName(final String methodName) { - if(superClass == null) return null; - Method m = superClass.getMethodNamed(methodName); - if(m != null) return m; - return superClass.getParentMethodMatchingName(methodName); - } - - private Method getMethodNamed(final String methodName) { - final Method instanceMethod = instanceMethodsByName.get(methodName); - if (instanceMethod != null) return instanceMethod; - - final Method classMethod = classMethodsByName.get(methodName); - if (classMethod != null) return classMethod; - - return null; - } - - int compareTo(Clazz o) { - return toString().compareTo(o.toString()); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java 2014-07-01 15:13:24.323350226 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class Constant extends ElementWType { - public Constant(final Node node, final Framework parent) { - super(node, parent); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java 2014-07-01 15:13:24.639350225 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.ObjectInspector; - -/** - * Subclasses must implement ctor(Node, P) - */ -public class Element

> implements Comparable>{ - public final String name; - public final P parent; - - public Element(final String name, final P parent) { - this.name = Type.cleanName(name); - this.parent = parent; - } - - public Element(final Node node, final P parent) { - this(getAttr(node, "name"), parent); - } - - public static String getAttr(final Node node, final String key) { - final NamedNodeMap attrs = node.getAttributes(); - if (attrs == null) return null; - final Node name = attrs.getNamedItem(key); - if (name == null) return null; - return name.getNodeValue(); - } - - static

, T extends Element

> List getNodesFor(final Node parentNode, final String selection, final Class clazz, final P parent) { - Constructor ctor; - try { - ctor = clazz.getConstructor(new Class[] { Node.class, parent.getClass() }); - } catch (Exception e) { - throw new RuntimeException(e); - } - - final NodeList childNodes = parentNode.getChildNodes(); - final List nodes = new ArrayList(); - for (int i = 0; i < childNodes.getLength(); i++) { - final Node node = childNodes.item(i); - if (!selection.equals(node.getLocalName())) continue; - - T obj; - try { - obj = ctor.newInstance(new Object[] { node, parent }); - } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); - } catch (Exception e) { - throw new RuntimeException(e); - } - nodes.add(obj); - } - - return nodes; - } - - @Override public String toString() { - return name; - } - - public String reflectOnMySelf() { - return ObjectInspector.inspect(this); - } - - public int compareTo(Element o) { - return name.compareTo(o.name); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java 2014-07-01 15:13:24.963350224 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import com.apple.internal.jobjc.generator.model.types.NType; -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -/** - * An ElementWType has a type but does not necessarily represent a type. Examples are constants, enums, arguments, return values. - */ -public class ElementWType

> extends Element

{ - public final Type type; - - public ElementWType(final String name, final Type t, final P parent) { - super(name, parent); - this.type = t; - } - - public ElementWType(final Node node, final Type t, final P parent) { - super(node, parent); - this.type = t; - } - - public ElementWType(final Node node, final String declType, final P parent) { - super(node, parent); - final String type32 = getAttr(node, "type"); - final String type64 = getAttr(node, "type64"); - this.type = Type.getType(declType, - type32 == null ? NType.NUnknown.inst() : NTypeParser.parseFrom(type32), - type64 == null ? null : NTypeParser.parseFrom(type64)); - } - - public ElementWType(final Node node, final P parent){ - this(node, getAttr(node, "declared_type"), parent); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java 2014-07-01 15:13:25.259350223 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.classes.FrameworkClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.UnsafeRuntimeAccess; - -public class Framework extends Element> implements OutputFileGenerator { - public final String path; - public final String pkg; - public final List binaries; - public MacOSXFramework nativeFramework; - - public MacOSXFramework load(){ - if(nativeFramework == null){ - String[] bins = new String[binaries.size()]; - for(int i = 0; i < binaries.size(); ++i) - bins[i] = Utils.getCanonicalPath(binaries.get(i)); - nativeFramework = UnsafeRuntimeAccess.getFramework(bins); - } - return nativeFramework; - } - - public File getMainFrameworkBinary(){ return binaries.get(0); } - - final Node rootNode; - - public Set classes; - public List structs; - public List cfTypes; - public List opaques; - public List constants; - public List stringConstants; - public List enums; - public List functions; - public List functionAliases; - public List informalProtocols; - public List protocols; - public List categories; - public List dependencies; - - public static class FrameworkDependency extends Element{ - final String path; - public Framework object = null; - - public FrameworkDependency(final Node node, final Framework parent) { - super(getAttr(node, "path").replaceFirst("^.*/([^/]+)\\.framework$", "$1"), parent); - this.path = getAttr(node, "path"); - } - } - - public static final XPath XPATH = XPathFactory.newInstance().newXPath(); - public Framework(final String name, final File bsFile) { - super(name, null); - try { - final File pathf = bsFile.getCanonicalFile().getParentFile().getParentFile().getParentFile(); - path = pathf.getParentFile().getParentFile().getCanonicalPath(); - } catch (IOException x) { - throw new RuntimeException(x); - } - binaries = findBinaries(path, name); - - pkg = ClassGenerator.JOBJC_PACKAGE + "." + name.toLowerCase(); - try { - rootNode = (Node)XPATH.evaluate("signatures", new InputSource(bsFile.getAbsolutePath()), XPathConstants.NODE); - } catch (final XPathExpressionException e) { throw new RuntimeException(e); } - protocols = new ArrayList(); - categories = new ArrayList(); - } - - private static List findBinaries(final String rootPath, final String name){ - List bins = new ArrayList(2); - - File mainBin = new File(rootPath, name); - if(mainBin.exists()) bins.add(mainBin); - - File bsBin = new File(rootPath, "Resources/BridgeSupport/" + name + ".dylib"); - if(bsBin.exists()) bins.add(bsBin); - - return bins; - } - - public void parseDependencies(final Collection frameworks) { - // Parse - dependencies = getNodesFor(rootNode, "depends_on", FrameworkDependency.class, this); - // Resolve - for(final FrameworkDependency dep : dependencies) - dep.object = Fp.find(new Map1(){ - public Boolean apply(Framework f) { - return f.path.equals(dep.path); - }}, frameworks); - } - - public void parseStructs() { - structs = getNodesFor(rootNode, "struct", Struct.class, this); - - // HACK BS bug #6100313 - if(Utils.isSnowLeopard && name.equals("IOBluetooth")) - structs.remove(getStructByName("BluetoothHCIRequestNotificationInfo")); - - // GLIFunctionDispatch is frequently out of sync in BS / system - if(name.equals("OpenGL")) - structs.remove(getStructByName("GLIFunctionDispatch")); - } - - public void parseCFTypes() { - cfTypes = getNodesFor(rootNode, "cftype", CFType.class, this); - } - - public void parseOpaques() { - opaques = getNodesFor(rootNode, "opaque", Opaque.class, this); - } - - public void parseConstants() { - constants = getNodesFor(rootNode, "constant", Constant.class, this); - stringConstants = getNodesFor(rootNode, "string_constant", StringConstant.class, this); - enums = getNodesFor(rootNode, "enum", NativeEnum.class, this); - } - - public void parseFunctions() { - functions = getNodesFor(rootNode, "function", Function.class, this); - functionAliases = getNodesFor(rootNode, "function_alias", FunctionAlias.class, this); - } - - public void parseClasses() { - classes = new HashSet(getNodesFor(rootNode, "class", Clazz.class, this)); - classes = Fp.filterSet(new Map1(){ - public Boolean apply(Clazz a) { - if(a.doesActuallyExist()) - return true; - else{ - System.out.println("Could not find class " + name + ":" + a.name + " in runtime. Discarding."); - return false; - } - }}, classes); - informalProtocols = getNodesFor(rootNode, "informal_protocol", InformalProtocol.class, this); - } - - public void resolveSuperClasses(final Map allClasses) throws Throwable { - load(); - for (final Clazz clazz : classes) - clazz.resolveSuperClass(nativeFramework, allClasses); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new FrameworkClassFile(this)); - - final List> generatorLists = - Utils.list(new ArrayList(classes), structs, cfTypes, opaques, categories); - for (final List generators : generatorLists) { - for (final OutputFileGenerator generator : generators) - generator.generateClasses(generatedClassFiles); - } - } - - @Override public String toString() { return reflectOnMySelf(); } - - public Struct getStructByName(final String stname) { - return Fp.find(new Fp.Map1(){ - public Boolean apply(Struct a) { - return stname.equals(a.name); - }}, structs); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java 2014-07-01 15:13:25.551350223 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.*; - -import org.w3c.dom.*; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; - -public class Function extends Element { - public final boolean variadic; - public final List args; - public final ReturnValue returnValue; - - public Function(final Node node, final Framework parent) { - this(node, getAttr(node, "name"), parent); - } - - public Function(final Node node, final String name, final Framework parent) { - super(name, parent); - - this.variadic = "true".equals(getAttr(node, "variadic")); - this.args = new ArrayList(); - - ReturnValue returnValue = null; - - final NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - final Node child = children.item(i); - final String childName = child.getLocalName(); - - if ("retval".equals(childName)) { - returnValue = new ReturnValue(child, this); - } - - if ("arg".equals(childName)) { - final Arg arg = new Arg(child, this); - if (arg.name == null || "".equals(arg.name)) { - arg.javaName = "arg" + i; - } - args.add(arg); - } - } - - if (returnValue == null) returnValue = ReturnValue.VOID; - this.returnValue = returnValue; - } - - public String getJavaName(){ return name; } - - public void disambiguateArgs() { - final Set priorArgs = RestrictedKeywords.getNewRestrictedSet(); - for (int i = 0; i < args.size(); i++) { - final Arg arg = args.get(i); - if (priorArgs.contains(arg.name)) arg.javaName = arg.javaName + i; - priorArgs.add(arg.javaName); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java 2014-07-01 15:13:25.871350222 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class FunctionAlias extends Element { - public FunctionAlias(final Node node, final Framework parent) { - super(node, parent); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java 2014-07-01 15:13:26.179350221 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class InformalProtocol extends Element { - public InformalProtocol(final Node node, final Framework parent) { - super(node, parent); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java 2014-07-01 15:13:26.475350220 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.Set; -import org.w3c.dom.Node; -import com.apple.jobjc.SEL; -import com.apple.internal.jobjc.generator.Utils; - -public class Method extends Function { - public final boolean isClassMethod; - - public String javaName; - - public boolean ignore; - public String suggestion; - - public Method(final Node node, final Framework fw) { - super(node, getAttr(node, "selector"), fw); - this.javaName = SEL.jMethodName(name); - this.isClassMethod = "true".equals(getAttr(node, "class_method")); - this.ignore = "true".equals(getAttr(node, "ignore")); - this.suggestion = getAttr(node, "suggestion"); - } - - @Override public String getJavaName(){ return javaName; } - - @Override public String toString() { - return returnValue + " " + super.toString() + args; - } - - public boolean returnTypeEquals(final ReturnValue returnValueIn) { - return returnValue.type.getJType().getJavaReturnTypeName().equals(returnValueIn.type.getJType().getJavaReturnTypeName()); - } - - public void disambiguateNameAndArgs(final Clazz parentClazz, final Set existingMethodNames) { - javaName = getDisambiguatedNameFor(parentClazz, javaName, existingMethodNames); - disambiguateArgs(); - } - - private String getDisambiguatedNameFor(final Clazz parentClazz, final String proposedName, final Set existingNames) { - // Does this method override a parent class method and change the return type? Example: IOBlueToothSDPUUID length - { - final Method superClassMethod = parentClazz.getParentMethodMatchingName(proposedName); - if (superClassMethod != null && !superClassMethod.returnValue.equals(returnValue)) { - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - } - } - - if(existingNames.add(proposedName)) - return proposedName; - - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - - throw new RuntimeException("Unable to disambiguate method: " + this); - } - - private String createMethodNameAppendingReturnType(final String proposedName) { - return proposedName + Utils.capitalize(returnValue.type.getJType().getAppendableDescription().replaceAll(".+\\.", "")); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java 2014-07-01 15:13:26.783350219 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.Arrays; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.jobjc.JObjCRuntime; - -public class NativeEnum extends ElementWType { - public final String value, value64, le_value, be_value; - public boolean ignore; - public String suggestion; - public NativeEnum(final Node node, final Framework parent) { - super(node, typeForEnum(getAttr(node, "name"), - getAttr(node, "value"), getAttr(node, "value64"), - getAttr(node, "le_value"), getAttr(node, "be_value"), - getAttr(node, "ignore")), parent); - this.value = getAttr(node, "value"); - this.value64 = getAttr(node, "value64"); - this.le_value = getAttr(node, "le_value"); - this.be_value = getAttr(node, "be_value"); - String ignoreS = getAttr(node, "ignore"); - this.ignore = ignoreS == null ? false : Boolean.parseBoolean(ignoreS); - this.suggestion = getAttr(node, "suggestion"); - assert valueToString() != null; - } - - private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){ - if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null); - - NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()}; - for(NumTest t : tests) - if(t.confirm(value32, value64, le_value, be_value)) - return t.getType(); - - throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n", - name, value32, value64, le_value, be_value)); - } - - public String valueToString(){ - if(ignore == true) return "0"; - JPrimitive jprim = (JPrimitive) type.getJType(); - if(le_value == null && be_value == null){ - if(value == null && value64 != null) - return value64 + jprim.getLiteralSuffix(); - else if(value != null && value64 == null) - return value + jprim.getLiteralSuffix(); - else - return String.format("(%1$s.IS64 ? %2$s%4$s : %3$s%4$s)", JObjCRuntime.class.getName(), - value64, value, jprim.getLiteralSuffix()); - } - else if(value == null && value64 == null){ - return String.format("(%1$s.IS_BIG_ENDIAN ? %2$s%4$s : %3$s%4$s)", - JObjCRuntime.class.getName(), be_value, le_value, jprim.getLiteralSuffix()); - } - - throw new RuntimeException("Unable to produce a value for enum " + name); - } - - // Used to find the best type to use for the enum. - - static abstract class NumTest{ - public boolean confirm(String... values){ - return Fp.all(new Fp.Map1(){ - public Boolean apply(String a) { - try{ return a == null || confirm(a); } - catch(Exception x){ return false; } - }}, - Arrays.asList(values)); - } - - public abstract boolean confirm(String v); - public abstract Type getType(); - } - - static class IntTest extends NumTest{ - @Override public boolean confirm(String v) { - Integer.parseInt(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('i'), null); } - } - - static class LongTest extends NumTest{ - @Override public boolean confirm(String v) { - Long.parseLong(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('l'), null); } - } - - static class FloatTest extends NumTest{ - @Override public boolean confirm(String v) { - return Float.parseFloat(v) == Double.parseDouble(v); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('f'), null); } - } - - static class DoubleTest extends NumTest{ - @Override public boolean confirm(String v) { - double d = Double.parseDouble(v); - return !Double.isInfinite(d) && !Double.isNaN(d); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('d'), null); } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java 2014-07-01 15:13:27.095350219 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.OpaqueClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class Opaque extends TypeElement implements OutputFileGenerator { - public Opaque(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new OpaqueClassFile(this)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/OutputFileGenerator.java 2014-07-01 15:13:27.387350218 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public interface OutputFileGenerator { - public void generateClasses(final List generatedClassFiles); -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java 2014-07-01 15:13:27.707350217 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -public class Protocol { - - public Protocol(final Clazz protocol) { - - } - -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ReturnValue.java 2014-07-01 15:13:27.995350216 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; - -public class ReturnValue extends ElementWType{ - public static ReturnValue VOID = new ReturnValue(Type.VOID); - - public ReturnValue(final Node node, final Function parent) { - super(node, parent); - } - - public ReturnValue(Type type) { - super("return value", type, null); // TODO bad style, the null might lead to trouble - } - - @Override public boolean equals(Object o){ - return o instanceof ReturnValue && type.equals(((ReturnValue)o).type); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java 2014-07-01 15:13:28.307350216 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class StringConstant extends Element { - public final String value; - - public StringConstant(final Node node, final Framework parent) { - super(node, parent); - this.value = getAttr(node, "value"); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java 2014-07-01 15:13:28.607350215 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.classes.StructClassFile; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; - -/** - * A struct has the following restrictions: - * - * - type32.fields.count == type64.fields.count - * - forAll i: type32.field[i].name == type64.field[i].name - * - forAll i: type32.field[i].class == type64.field[i].class - */ -public class Struct extends TypeElement implements OutputFileGenerator { - public final List fields; - public static class Field{ - public final String name; - public final Type type; - public final NField field32, field64; - public Field(String name, NField field32, NField field64) { - QA.nonNull(name); - this.name = name; - // TODO really should have a declared_type attr. See if BS patch is possible. - this.type = Type.getType(null, field32.type, field64.type); - this.field32 = field32; - this.field64 = field64; - } - } - - public Struct(final Node node, final Framework parent) throws Throwable { - super(node, getAttr(node, "name"), parent); - NStruct nstruct32 = (NStruct) type.type32; - NStruct nstruct64 = (NStruct) type.type64; - this.fields = Fp.map2(new Map2(){ - public Field apply(NField f32, NField f64) { - assert f32.name.equals(f64.name); - return new Field(f32.name, f32, f64); - } - }, nstruct32.fields, nstruct64.fields); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new StructClassFile(this)); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/TypeElement.java 2014-07-01 15:13:28.907350214 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; - -/** - * A TypeElement represents a Type, such as a struct or cftype. - */ -public abstract class TypeElement

> extends ElementWType

{ - public TypeElement(String name, Type type, final P parent) { - super(name, type, parent); - } - - public TypeElement(final Node node, final String declType, final P parent) { - super(node, declType, parent); - } - - public TypeElement(final Node node, final P parent) { - super(node, parent); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java 2014-07-01 15:13:29.219350213 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.UnknownCoder; -import com.apple.jobjc.Coder.VoidCoder; - -public class CoderDescriptor { - public static final CoderDescriptor VOID_DESC = new CoderDescriptor(VoidCoder.INST, null, null); - - final Coder coder; - private final String coderInstanceName; - final String pushName; - final String popName; - - public String mismatchMessage(){ return null; } - - public CoderDescriptor(final Coder coder, final String pushName, final String popName) { - this.coder = coder; - this.coderInstanceName = coder.getClass().getCanonicalName() + ".INST"; - if (coderInstanceName == null) throw new NullPointerException(); - - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final String pushName, final String popName) { - this.coder = null; - this.coderInstanceName = null; - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final Coder coder) { this(coder, "push", "pop"); } - public CoderDescriptor(){ this("push", "pop"); } - - public String getPopStatementFor(final String contextName, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + contextName + "));"; - } - - public final String getPushStatementFor(final String contextName, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + contextName + ", " + argumentName + ");"; - } - - public String getPopAddrStatementFor(final String runtime, final String addr, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + runtime + ", " + addr + "));"; - } - - public final String getPushAddrStatementFor(final String runtime, final String addr, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + runtime + ", " + addr + ", " + argumentName + ");"; - } - - public String getCoderInstanceName() { return coderInstanceName; } - public Coder getCoder() { return coder; } - public String getDefaultReturnValue() { return "null"; } - - // - // Specialized - // - - static public class UnknownCoderDescriptor extends CoderDescriptor { - public static final CoderDescriptor UNKNOWN_DESC = new UnknownCoderDescriptor(); - public UnknownCoderDescriptor() { super(UnknownCoder.INST); } - } - - static public class PrimitivePointerCoderDescriptor extends CoderDescriptor { - public static final PrimitivePointerCoderDescriptor POINTER_DESC = new PrimitivePointerCoderDescriptor(); - public PrimitivePointerCoderDescriptor() { super(PrimitivePointerCoder.INST, "push", "popPtr"); } - } - - static public class PointerCoderDescriptor extends CoderDescriptor { - public static final PointerCoderDescriptor INST = new PointerCoderDescriptor(); - public PointerCoderDescriptor() { super(PointerCoder.INST); } - } - - static public class SELCoderDescriptor extends CoderDescriptor { - public static final SELCoderDescriptor INST = new SELCoderDescriptor(); - public SELCoderDescriptor() { super(SELCoder.INST); } - } - - static public class IDCoderDescriptor extends CoderDescriptor { - public static final IDCoderDescriptor INST = new IDCoderDescriptor(); - public IDCoderDescriptor() { super(IDCoder.INST); } - } - - static public class NSClassCoderDescriptor extends CoderDescriptor { - public static final NSClassCoderDescriptor INST = new NSClassCoderDescriptor(); - public NSClassCoderDescriptor() { super(NSClassCoder.INST); } - } - - static public class StructCoderDescriptor extends CoderDescriptor { - public final JStruct jstruct; - public StructCoderDescriptor(JStruct jst) { this.jstruct = jst; } - @Override public String getCoderInstanceName(){ return jstruct.getJavaTypeName() + ".getStructCoder()"; } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java 2014-07-01 15:13:29.535350213 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.TreeSet; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.jobjc.JObjCRuntime; - -/** - * Used to code two primitives of different 32/64 types. - */ -public class ComplexCoderDescriptor extends CoderDescriptor { - static Map, ComplexCoderDescriptor> cache = new HashMap, ComplexCoderDescriptor>(); - static Set mixedEncodingDescriptors = new TreeSet(); - - public static Set getMixedEncoders() { return mixedEncodingDescriptors; } - - public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) { - Pair cacheKey = new Pair(nt32, nt64); - if(cache.containsKey(cacheKey)) return cache.get(cacheKey); - - final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32); - final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64); - - final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64); - cache.put(cacheKey, newDesc); - if(newDesc instanceof MixedEncodingDescriptor) - mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc); - - return newDesc; - } - - protected final PrimitiveCoderDescriptor desc64; - - public ComplexCoderDescriptor(final PrimitiveCoderDescriptor desc64) { - super(desc64.coder, desc64.pushName, desc64.popName); - this.desc64 = desc64; - } - - public String getName() { return desc64.javaPrimitiveClazz.getName(); } - @Override public String getDefaultReturnValue() { return desc64.defaultReturnValue; } - public String getJavaObjectClass() { return desc64.javaObjectClazz.getName(); } - public String getDefinition() { return get64CoderName(); } - public String getCoderAccessor() { return get64CoderName(); } - String get64CoderName() { return desc64.getCoderInstanceName(); } - - // ** Subclasses - // ------------- - - public static class MixedEncodingDescriptor extends ComplexCoderDescriptor implements java.lang.Comparable { - protected final PrimitiveCoderDescriptor desc32; - - public MixedEncodingDescriptor(final PrimitiveCoderDescriptor desc32, final PrimitiveCoderDescriptor desc64) { - super(desc64); - this.desc32 = desc32; - } - - @Override public String getDefinition() { return JObjCRuntime.class.getName() + ".IS64 ? " + get64CoderName() + " : " + get32CoderName(); } - @Override public String getCoderAccessor() { return MixedPrimitiveCoderClassFile.FULL_MULTI_CODER_CLASSNAME + "." + getMixedName(); } - String get32CoderName() { return desc32.getCoderInstanceName(); } - @Override public String getCoderInstanceName(){ return getCoderAccessor(); } - @Override public String toString() { return getMixedName(); } - - public String getMixedName() { - final String coder32Name = getBaseNameOfCoder(desc32.primitiveCoderName); - final String coder64Name = getBaseNameOfCoder(desc64.primitiveCoderName); - return coder32Name + coder64Name + "Coder"; - } - - static String getBaseNameOfCoder(final String coderName) { return coderName.substring(0, coderName.indexOf("Coder")); } - public int compareTo(Object _o) { MixedEncodingDescriptor o = (MixedEncodingDescriptor)_o; return getMixedName().compareTo(o.getMixedName()); } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java 2014-07-01 15:13:29.843350212 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.Coder; -import com.apple.jobjc.PrimitiveCoder; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; -import com.apple.jobjc.PrimitiveCoder.UCharCoder; -import com.apple.jobjc.PrimitiveCoder.UIntCoder; -import com.apple.jobjc.PrimitiveCoder.ULongCoder; -import com.apple.jobjc.PrimitiveCoder.ULongLongCoder; -import com.apple.jobjc.PrimitiveCoder.UShortCoder; -import com.apple.internal.jobjc.generator.Utils; - -public class PrimitiveCoderDescriptor extends CoderDescriptor { - static Map descriptors = new HashMap(); - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(NPrimitive nt) { - return getCoderDescriptorFor(nt.type); - } - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(char c) { - final PrimitiveCoderDescriptor desc = descriptors.get(c); - if (desc != null) return desc; - final PrimitiveCoderDescriptor newDesc = createCoderDescriptorFor(c); - descriptors.put(c, newDesc); - return newDesc; - } - - public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) { - switch(encoding) { - case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false"); - - case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0"); - case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0"); - - case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0"); - case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0"); - - case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0"); - case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0"); - - case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0"); - case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long."); - case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0"); - case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long."); - - case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0"); - case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0"); - default: throw new RuntimeException("unknown encoding: " + encoding); - } - } - - public final Class javaPrimitiveClazz; - final Class javaObjectClazz; - final String defaultReturnValue; - final String primitiveCoderName; - final String _mismatchMessage; - - public PrimitiveCoderDescriptor(final Coder coder, final String defaultRetVal) { - this(coder, defaultRetVal, null); - } - - public PrimitiveCoderDescriptor(final Coder coder, - final String defaultReturnValue, final String mismatchMessage) { - super(coder, "push", "pop" + Utils.capitalize(coder.getJavaPrimitive().getSimpleName())); - this.javaPrimitiveClazz = coder.getJavaPrimitive(); - this.javaObjectClazz = coder.getJavaClass(); - this.defaultReturnValue = defaultReturnValue; - this.primitiveCoderName = coder.getClass().getSimpleName(); - this._mismatchMessage = mismatchMessage; - } - - @Override public PrimitiveCoder getCoder(){ return (PrimitiveCoder) super.getCoder(); } - @Override public String mismatchMessage(){ return _mismatchMessage; } - @Override public String getDefaultReturnValue() { return defaultReturnValue; } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java 2014-07-01 15:13:30.155350211 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.classes.RootJObjCClass; -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.IDCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.NSClassCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.PointerCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.SELCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.StructCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.UnknownCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.ID; -import com.apple.jobjc.NSClass; -import com.apple.jobjc.NativeArgumentBuffer; -import com.apple.jobjc.Pointer; -import com.apple.jobjc.SEL; - -public abstract class JType { - public abstract String getJavaTypeName(); - public String getJavaClassName() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - public String getJavaReturnTypeName() { return getJavaTypeName(); } - public String getReturnTypeCast() { return null; } - public String getTypeNameAsParam() { return getJavaTypeName(); } - - public abstract CoderDescriptor getCoderDescriptor(); - public String getDefaultReturnValue() { return "null"; } - public String getAppendableDescription() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - - /** - * Used for primitive types (like int) that can't be used as generic arguments. This returns an appropriate Java class (like Integer). - */ - public JType getParameterizableType() { return this; } - - // - // Writer ops - // - - public String createDeclareBuffer(String contextName) { - return "final " + NativeArgumentBuffer.class.getName() + " " + contextName + " = getRuntime().getThreadLocalState();"; - } - - public String createInit(final String contextName, final String functionIdentifier, final String initWithObj) { - return functionIdentifier + ".init(" + contextName + (initWithObj != null ? ", " + initWithObj : "") + ");"; - } - - public String createInvoke(final String contextName, final String functionIdentifier) { - return functionIdentifier + ".invoke(" + contextName + ");"; - } - - public String createPop(final String contextName) { - return getCoderDescriptor().getPopStatementFor(contextName, getJavaTypeName(), "returnValue", null); - } - - public String createPopAddr(final String runtime, final String addr) { - return getCoderDescriptor().getPopAddrStatementFor(runtime, addr, getJavaTypeName(), "returnValue", null); - } - - public String createReturn() { - final String preCast = getReturnTypeCast(); - return "return " + (preCast == null ? "" : "(" + preCast + ")") + "returnValue;"; - } - - // - // Specialized - // - - static public class JUnknown extends JType { - final Type type; - protected JUnknown(final Type type) { - this.type = type; - TypeCache.inst().getUnknownTypes().add(type); - } - @Override public String getJavaTypeName() { return "Object /* " + type + " */"; } - @Override public String getAppendableDescription() { return "Unknown"; } - @Override public CoderDescriptor getCoderDescriptor() { return UnknownCoderDescriptor.UNKNOWN_DESC; } - } - - static class JVoid extends JType { - public static JVoid INST = new JVoid(); - @Override public String getJavaTypeName() { return "Void"; } - @Override public String getJavaReturnTypeName() { return "void"; } - @Override public CoderDescriptor getCoderDescriptor(){ return CoderDescriptor.VOID_DESC; } - @Override public String createPop(final String contextName){ return ""; } - @Override public String createReturn(){ return ""; } - }; - - static class JSelector extends JType { - public static JSelector INST = new JSelector(); - @Override public String getJavaTypeName() { return SEL.class.getName(); } - @Override public CoderDescriptor getCoderDescriptor() { return SELCoderDescriptor.INST; } - }; - - static class JCFType extends JType{ - final CFType cfType; - public JCFType(final CFType cfType){ this.cfType = cfType; } - @Override public String getJavaTypeName() { return cfType.parent.pkg + "." + cfType.name + "CFType"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JOpaque extends JType{ - final Opaque opaque; - public JOpaque(final Opaque opaque){ this.opaque = opaque; } - @Override public String getJavaTypeName() { return opaque.parent.pkg + "." + opaque.name + "Opaque"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JPointer extends JType { - static JType VOID_PTR = new JPointer(JVoid.INST); - - final JType subject; - protected JPointer(final JType javaType) { this.subject = javaType; } - - @Override public String getJavaTypeName() { return Pointer.class.getName() + "<" + subject.getParameterizableType().getJavaTypeName() + ">"; } - @Override public String getAppendableDescription() { return "PointerTo" + subject.getAppendableDescription(); } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - } - - static class JObject extends JType { - public static JType ID_TYPE = new JType() { - @Override public String getJavaTypeName() { return ID.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - }; - - final Type type; - final Clazz clazz; - - public JObject(final Type type, final Clazz clazz) { - this.type = type; - this.clazz = clazz; - } - - @Override public String getJavaTypeName() { return clazz.getFullPath();} - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - } - - static class JClass extends JType { - public static JClass INST = new JClass(); - @Override public String getJavaTypeName() { return NSClass.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getTypeNameAsParam() { return super.getTypeNameAsParam(); } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return NSClassCoderDescriptor.INST; } - }; - - public static class JStruct extends JType { - public final Struct struct; - public JStruct(final Struct struct) { this.struct = struct; } - - @Override public String getJavaTypeName() { return struct.parent.pkg + "." + struct.name; } - @Override public String getJavaReturnTypeName() { return getJavaTypeName(); } - - StructCoderDescriptor coderDescriptor = new StructCoderDescriptor(this); - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - public String createReturnValue() { - return "\t\t" + getJavaReturnTypeName() + " returnValue = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) - + ".make" + struct.name + "();"; - } - - @Override public String createInvoke(final String contextName, final String functionIdentifier) { - return createReturnValue() + "\n\t\t" + functionIdentifier + ".invoke(" + contextName + ", returnValue);"; - } - - @Override public String createPop(final String contextName){ return ""; } - } - - public static class JPrimitive extends JType { - final Type type; - final ComplexCoderDescriptor coderDescriptor; - final JType parameterizable; - - public JPrimitive(final Type type, final ComplexCoderDescriptor coderDesc) { - this.type = type; - this.coderDescriptor = coderDesc; - - this.parameterizable = new JType() { - @Override public String getJavaTypeName() { return coderDescriptor.getJavaObjectClass(); } - @Override public CoderDescriptor getCoderDescriptor() { throw new RuntimeException(); } - }; - } - - @Override public String getJavaTypeName() { return coderDescriptor.getName(); } - @Override public String getDefaultReturnValue() { return coderDescriptor.getDefaultReturnValue(); } - @Override public JType getParameterizableType() { return parameterizable; } - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - /** - * Return the suffix placed on java literals to indicate the type. If none applies, return ' '. - */ - public char getLiteralSuffix() { - char t = ((NPrimitive)type.type64).type; - switch(t){ - case 'l': case 'L': case 'f': case 'd': return t; - case 'q': case 'Q': return 'L'; - } - return ' '; - } - } - -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java 2014-07-01 15:13:30.479350210 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.coders.PrimitiveCoderDescriptor; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.NTypePrinter; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * NType (Native Type) bridges the type and type64 attributes in BridgeSupport. - * - * For example: - * - *

- *   type="c"                 // BridgeSupport attribute
- *   (NPrimitive type: 'c')   // Java object (in sexp form here, for readability)
- *
- *   type="^v"
- *   (NPointer subject: (NVoid))
- *
- *   type="{foo_t="a"c"b"b8"c"[32^v]}"
- *   (NStruct
- *     name: "foo_t"
- *     fields:
- *       (List
- *         0: (NField name:"a" type: (NPrimitive type: 'c'))
- *         1: (NField name:"b" type: (NBitfield size: 8))
- *         2: (NField name:"c" type:
- *              (NArray size: 32
- *                      type: (NPointer subject: (NVoid))))))
- * 
- */ -public abstract class NType implements Comparable{ - public final Map sizeof; - - public NType(Map sizeof) { - this.sizeof = sizeof; - } - - public NType(){ - this(new HashMap()); - } - - public NType(int sz32, int sz64){ - this(); - this.sizeof.put(Width.W32, sz32); - this.sizeof.put(Width.W64, sz32); - } - - public int sizeof32(){ return sizeof.get(Width.W32); } - public int sizeof64(){ return sizeof.get(Width.W64); } - - protected abstract boolean equals2(NType nt); - - private String _toString; - @Override public String toString(){ return _toString != null ? _toString : (_toString = NTypePrinter.inst().print(this)); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || (getClass().isInstance(o) - && this.sizeof.equals(((NType) o).sizeof) - && equals2((NType) o))); - } - public int compareTo(NType o){ return toString().compareTo(o.toString()); } - - // ** NType subclasses - // ------------------- - - public static class NBitfield extends NType{ - public final int length; - - public NBitfield(int length){ - super(-1, -1); - this.length = length; - } - - @Override protected boolean equals2(NType nt) { return ((NBitfield) nt).length == length; } - @Override public int hashCode() { return Integer.valueOf(length).hashCode(); } - } - - public static class NPrimitive extends NType{ - public static Collection CODES = Arrays.asList( - 'B', 'c', 'C', 's', 'S', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'); - - public final char type; - - protected NPrimitive(char c){ - super(PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W32), - PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W64)); - type = c; - } - private static final Map cache = new HashMap(); - public static final NPrimitive inst(final char c){ - if(!cache.containsKey(c)) cache.put(c, new NPrimitive(c)); - return cache.get(c); - } - - @Override protected boolean equals2(NType nt) { return ((NPrimitive)nt).type == type; } - @Override public int hashCode() { return Character.valueOf(type).hashCode(); } - } - - public static class NVoid extends NType{ - protected NVoid(){ super(); } - private final static NVoid INST = new NVoid(); - public static NVoid inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NPointer extends NType{ - public final NType subject; - - public NPointer(NType subject){ - super(4, 8); - QA.nonNull(subject); - this.subject = subject; - } - - @Override protected boolean equals2(NType nt) { return ((NPointer)nt).subject.equals(subject); } - @Override public int hashCode() { return subject.hashCode(); } - } - - public static class NObject extends NType{ - protected NObject(){ super(4, 8); } - private final static NObject INST = new NObject(); - public static NObject inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NClass extends NType{ - protected NClass(){ super(4, 8); } - private final static NClass INST = new NClass(); - public static NClass inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NSelector extends NType{ - protected NSelector(){ super(4, 8); } - private final static NSelector INST = new NSelector(); - public static NSelector inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } - - public static class NField{ - public final Map offset; - public final String name; - public final NType type; - - public NField(String name, NType type, Map offset) { - QA.nonNull(name, type, offset); - this.name = name; - this.type = type; - this.offset = offset; - } - - public NField(String name, NType type) { - this(name, type, new HashMap()); - } - - public int offset32(){ return offset.get(Width.W32); } - public int offset64(){ return offset.get(Width.W64); } - - @Override public int hashCode() { return name.hashCode() + type.hashCode(); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || - (o instanceof NField - && this.offset.equals(((NField) o).offset) - && ((NField) o).name.equals(this.name) - && ((NField) o).type.equals(this.type))); - } - } - - public static class NStruct extends NType{ - public final String name; - public final List fields; - - public NStruct(String name, List fields, Map sizeof){ - super(sizeof); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - public NStruct(String name, List fields){ - super(); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - @Override protected boolean equals2(NType nt) { - return ((NStruct)nt).name.equals(name) && ((NStruct)nt).fields.equals(fields); - } - - @Override public int hashCode() { return name.hashCode() + fields.hashCode(); } - } - - // A Union is like a Struct, but the offset of every field is 0. - public static class NUnion extends NStruct{ - public NUnion(String concreteName, List fields){ - super(concreteName, fields); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public NUnion(String name, List fields, Map sizeof) { - super(name, fields, sizeof); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public static final Fp.Map1 hasZeroOffsets = new Fp.Map1(){ - public Boolean apply(NField a) { - for(int i : a.offset.values()) - if(i != 0) - return false; - return true; - }}; - public static final Fp.Map1 zeroOffsets = new Fp.Map1(){ - public NField apply(NField a) { - Map off = new HashMap(); - for(Width w : a.offset.keySet()) - off.put(w, 0); - return new NField(a.name, a.type, off); - }}; - } - - public static class NArray extends NType{ - public final int length; - public final NType type; - - public NArray(int length, NType type){ - QA.nonNull(type); - this.length = length; - this.type = type; - } - - @Override protected boolean equals2(NType nt) { return ((NArray)nt).length == length && ((NArray)nt).type.equals(type); } - @Override public int hashCode(){ return Long.valueOf(length).hashCode() + type.hashCode(); } - } - - // Seems to be used for callbacks - public static class NUnknown extends NType{ - protected NUnknown(){ super(); } - private final static NUnknown INST = new NUnknown(); - public static NUnknown inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java 2014-07-01 15:13:30.791350209 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.ArrayList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.internal.jobjc.generator.utils.NTypeMerger.MergeFailed; - -public class Type implements Comparable{ - public static Type VOID = Type.getType("void", NVoid.inst(), null); - public static Type VOID_PTR = Type.getType("void*", new NPointer(NVoid.inst()), null); - - final public String name; - final public NType type32; - final public NType type64; - - // HACK BS bug where some types have inconsistent definitions in the metadata, - // e.g. (l / i) in some places and just (l) (and thus (l / l)) in others. - // This is a mapping from the type name to a Type object with the correct definition. - private static final Map exceptions; - static { - exceptions = new HashMap(); - exceptions.put("OSStatus", getType("OSStatus", new NPrimitive('l'), new NPrimitive('i'))); // (l / i) vs. (l) - exceptions.put("CGFloat", getType("CGFloat", new NPrimitive('f'), new NPrimitive('d'))); // (f / d) vs. (f) - exceptions.put("NSRect", getType("NSRect", getNSRectType(), getCGRectType())); // ({{_NSPoint}{_NSSize}} / {{CGPoint}{CGSize}}) vs. ({{_NSPoint}{_NSSize}}) - exceptions.put("NSPoint", getType("NSPoint", getNSPointType(), getCGPointType())); // (_NSPoint / CGPoint) vs. (_NSPoint) - exceptions.put("NSSize", getType("NSSize", getNSSizeType(), getCGSizeType())); // (_NSSize / CGSize) vs. (_NSSize) - exceptions.put("NSInteger", getType("NSInteger", new NPrimitive('i'), new NPrimitive('q'))); // (i / q) vs. (i) - exceptions.put("NSPointArray", getType("NSPointArray", new NPointer(getNSPointType()), new NPointer(getCGPointType()))); // (^_NSPoint / ^CGPoint) vs. (^_NSPoint) - exceptions.put("NSMultibyteGlyphPacking", getType("NSMultibyteGlyphPacking", new NPrimitive('I'), new NPrimitive('Q'))); // (I / Q) vs. (I) - exceptions.put("CFTypeRef", getType("CFTypeRef", new NPointer(NVoid.inst()), new NPointer(NVoid.inst()))); // (^v, ^v) vs. (@, @) - } - - public static Type getType(final String name, final NType t32, final NType t64){ - return TypeCache.inst().pingType(new Type(name, t32, t64)); - } - - private Type(final String name, final NType t32, final NType t64) { - QA.nonNull(t32); - this.name = cleanName(name); - this.type32 = t32; - this.type64 = t64 == null || t32.equals(t64) ? t32 : t64; - } - - private JType _getJType; - public JType getJType() { - return _getJType!=null ? _getJType : (_getJType = TypeToJType.inst().getJTypeFor(TypeCache.inst().pingType(this))); - } - - private String _toString; - @Override public String toString() { - return _toString != null ? _toString : (_toString = name + " " + new Pair(type32, type64).toString()); - } - - @Override public boolean equals(Object o){ - if(o==null || !(o instanceof Type)) return false; - Type t = (Type) o; - return QA.bothNullOrEquals(t.name, this.name) - && t.type32.equals(this.type32) - && t.type64.equals(this.type64); - } - - @Override public int hashCode(){ - return (name == null ? 0 : name.hashCode()) - + type32.hashCode() + type64.hashCode(); - } - - public int compareTo(Type o) { return toString().compareTo(o.toString()); } - - public static Type merge(Type a, Type b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(QA.bothNullOrEquals(a, b)) return a; - if (exceptions.containsKey(a.name)) return exceptions.get(a.name); // HACK BS bug - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("Merging:"); - System.out.println("\ta.....: " + a.toString()); - System.out.println("\tb.....: " + b.toString()); - } - final Type merged = new Type(NTypeMerger.inst().mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type32, b.type32), - NTypeMerger.inst().merge(a.type64, b.type64)); - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("\tmerged: " + merged.toString()); - } - return merged; - } - - // HACK BS bug where sometimes the name is declared as "id fields = new ArrayList(); - fields.add(new NField("origin", getCGPointType())); - fields.add(new NField("size", getCGSizeType())); - return new NStruct("CGRect", fields); - } - - private static NType getNSRectType() { - List fields = new ArrayList(); - fields.add(new NField("origin", getNSPointType())); - fields.add(new NField("size", getNSSizeType())); - return new NStruct("_NSRect", fields); - } - - private static NType getCGPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('d'))); - fields.add(new NField("y", new NPrimitive('d'))); - return new NStruct("CGPoint", fields); - } - - private static NType getNSPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('f'))); - fields.add(new NField("y", new NPrimitive('f'))); - return new NStruct("_NSPoint", fields); - } - - private static NType getCGSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('d'))); - fields.add(new NField("height", new NPrimitive('d'))); - return new NStruct("CGSize", fields); - } - - private static NType getNSSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('f'))); - fields.add(new NField("height", new NPrimitive('f'))); - return new NStruct("_NSSize", fields); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java 2014-07-01 15:13:31.103350209 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -/** - * Central store for types found in the frameworks. - */ -public class TypeCache { - private static TypeCache INST = new TypeCache(); - public static TypeCache inst(){ return INST; } - protected TypeCache(){} - - /** - * When a new Type is discovered, pass it through here to - * hit the cache, potentially merge with other types, etc. - * - * Always do: - * - * Type type = TypeCache.inst().pingType(new Type(a,b,c)); - * - * because this should return a better merge for you. - */ - public Type pingType(final Type type_){ - Type typex = type_; - - // XXX Exception for void* clashes: void* (^{OpaqueCMProfileRef}), void* (^{X}), etc - if("void*".equals(typex.name) && getTypeByName(typex.name)!=null) - return getTypeByName(typex.name); - - if(typex.name != null) - typex = Type.merge(typex, getTypeByName(typex.name)); - else // type.name == null - typex = Type.merge(typex, getTypeByNTypes(new Pair(typex.type32, typex.type64))); - putTypeByName(typex.name, typex); - putTypeByNTypes(new Pair(typex.type32, typex.type64), typex); - return typex; - } - - public final Map typesByName = new HashMap(); - public Type getTypeByName(final String name) { return typesByName.get(Type.cleanName(name)); } - public void putTypeByName(String name, Type type) { if(name!=null) typesByName.put(name, type); } - - public final Map, Type> typesByNTypes = new HashMap, Type>(); - public Type getTypeByNTypes(Pair pair) { return typesByNTypes.get(pair); } - public void putTypeByNTypes(Pair pair, Type type) { if(pair!=null) typesByNTypes.put(pair, type); } - - private final Map classesByName = new HashMap(); - private final Map structsByName = new HashMap(); - private final Map cfTypesByName = new HashMap(); - private final Map opaquesByName = new HashMap(); - - public void load(final List frameworks) { - for (final Framework framework : frameworks) { - for (final Clazz obj : framework.classes) { - final Clazz previous = classesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: class name: %1$-10s -- framework1: %2$-10s -- framework2: %3$-10s \n", - obj.name, obj.parent.name, previous.parent.name)); - } - - for (final Struct obj : framework.structs) { - final Struct previous = structsByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final CFType obj : framework.cfTypes) { - final CFType previous = cfTypesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final Opaque obj : framework.opaques) { - final Opaque previous = opaquesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - } - } - - public Collection getAllClasses() { return classesByName.values(); } - public Clazz getClassForName(final String className) { return classesByName.get(className); } - public Struct getStructForName(final String declaredType) { return structsByName.get(declaredType); } - public CFType getCFTypeForName(final String declaredType) { return cfTypesByName.get(declaredType); } - public Opaque getOpaqueForName(final String declaredType) { return opaquesByName.get(declaredType); } - - final Set unknownTypes = new TreeSet(); - public Set getUnknownTypes() { return unknownTypes; } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java 2014-07-01 15:13:31.419350208 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType.JCFType; -import com.apple.internal.jobjc.generator.model.types.JType.JClass; -import com.apple.internal.jobjc.generator.model.types.JType.JObject; -import com.apple.internal.jobjc.generator.model.types.JType.JOpaque; -import com.apple.internal.jobjc.generator.model.types.JType.JPointer; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.JType.JSelector; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.JType.JUnknown; -import com.apple.internal.jobjc.generator.model.types.JType.JVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.CacheMap; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map0; - -public class TypeToJType { - private static TypeToJType INST = new TypeToJType(); - public static TypeToJType inst(){ return INST; } - - private CacheMap cache = new CacheMap(); - public JType getJTypeFor(final Type type){ - return cache.get(type, new Map0(){ - public JType apply() { - try { - return Dispatcher.dispatch(TypeToJType.this.getClass(), TypeToJType.this, "accept", type, type.type32, type.type64); - } catch (NoSuchMethodException e) { - return new JUnknown(type); - } - }}); - } - - protected JType accept(Type type, NObject nt32, NObject nt64){ - if ("id".equals(type.name)) return JObject.ID_TYPE; - - final String className = type.name.replaceAll("\\*$", ""); - assert !className.endsWith("*"); - - final Clazz clazz = TypeCache.inst().getClassForName(className); - if (clazz == null) return new JUnknown(type); - // TODO Instead of JUnknown, ID_TYPE might be more appropriate. Investigate. - - return new JObject(type, clazz); - } - - protected JType accept(Type type, NPointer nt32, NPointer nt64){ - final CFType cfType = TypeCache.inst().getCFTypeForName(type.name); - if(cfType != null) return new JCFType(cfType); - - final Opaque opaque = TypeCache.inst().getOpaqueForName(type.name); - if(opaque != null) return new JOpaque(opaque); - - if("void*".equals(type.name)) return JPointer.VOID_PTR; - - if(type.name != null && type.name.endsWith("*")){ - final String subDeclaredType = type.name.substring(0, type.name.length() - 1); - final Type subType = TypeCache.inst().getTypeByName(subDeclaredType); - if (subType == null) return new JUnknown(type); - // TODO Instead of JUnknown, VOID_PTR might be a good fallback. Investigate. - - final JType javaType = TypeToJType.inst().getJTypeFor(subType).getParameterizableType(); - - final JPointer pointer = new JPointer(javaType); - return pointer; - } - - return new JUnknown(type); - } - - protected JType accept(Type type, NPrimitive nt32, NPrimitive nt64){ - final ComplexCoderDescriptor coderDesc = ComplexCoderDescriptor.getCoderDescriptorFor(type.type32, type.type64); - if (coderDesc == null) return null; - return new JPrimitive(type, coderDesc); - } - - protected JType accept(Type type, NVoid nt32, NVoid nt64){ - return JVoid.INST; - } - - protected JType accept(Type type, NSelector nt32, NSelector nt64){ - return JSelector.INST; - } - - protected JType accept(Type type, NClass nt32, NClass nt64){ - return JClass.INST; - } - - protected JType accept(Type type, NStruct nt32, NStruct nt64){ - Struct st = TypeCache.inst().getStructForName(type.name); - return st != null ? new JStruct(st) : new JUnknown(type); - // TODO We could probably generate a struct here based on the type. But we need access to its parent framework. - // Maybe we could use a fallback anonymous struct, but we need the SIZEOF. - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java 2014-07-01 15:13:31.711350207 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * Functional programming constructs and utilities. Java for Lisp and Haskell nerds. - */ -public abstract class Fp { - /** - * Multiple dynamic dispatch (multi-methods) for Java. - * - * This is implemented with Java reflection: - * Class.getDeclaredMethod and Method.invoke. - * It is about 20-40 times slower than chains of - * "if instanceof" statements. - */ - public static abstract class Dispatcher{ - /** - * Shorthand, works only if no arg is null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object... args) throws NoSuchMethodException{ - Class[] types = new Class[args.length]; - for(int i = 0; i < args.length; i++) types[i] = args[i].getClass(); - return (R) dispatch(clazz, instance, method, args, types); - } - - /** - * Dispatch `args` of `types` to `method` on `clazz` for `instance`. If `method` is static, `instance` should be null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object[] args, Class[] types) throws NoSuchMethodException{ - try{ - java.lang.reflect.Method m = clazz.getDeclaredMethod(method, types); - m.setAccessible(true); - return (R) m.invoke(instance, args); - } - catch(NoSuchMethodException x){ - if(clazz.getSuperclass() != null) return (R) dispatch(clazz.getSuperclass(), instance, method, args, types); - else throw x; - } - catch(Exception x){ - throw new RuntimeException(x); - } - } - } - - /** - * The "Maybe" type encapsulates an optional value. A value of type - * "Maybe a" either contains a value of type "a" (represented as "Just a"), - * or it is empty (represented as "Nothing"). - * - * http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Maybe.html - */ - public static abstract class Maybe{ - public abstract boolean isJust(); - public abstract boolean isNothing(); - public abstract A fromJust() throws ClassCastException; - public abstract A fromMaybe(final A fallback); - - public static class Nothing extends Maybe{ - @Override public A fromJust() throws ClassCastException { throw new ClassCastException("Cannot extract value from Nothing."); } - @Override public A fromMaybe(A fallback) { return fallback; } - @Override public boolean isJust() { return false; } - @Override public boolean isNothing() { return true; } - } - public static class Just extends Maybe{ - public final A a; - public Just(A a){ this.a = a; } - @Override public A fromJust(){ return a; } - @Override public A fromMaybe(A fallback) { return a; } - @Override public boolean isJust() { return true; } - @Override public boolean isNothing() { return false; } - } - } - - public static class NonNull{ - public final A obj; - public NonNull(A o){ - if(o==null) throw new RuntimeException("o may not be null."); - this.obj = o; - } - } - - // Closures - public static interface Map0{ A apply(); } - public static interface Map1{ B apply(final A a); } - public static interface Map2{ C apply(final A a, final B b); } - - public static class CacheMap,V>{ - private Map cache = new TreeMap(); - public V get(K key, Map0 create){ - if(cache.containsKey(key)) return cache.get(key); - V value = create.apply(); - cache.put(key, value); - return value; - } - } - - public static class Curry2to1 implements Map1{ - private Map2 target; private A a; - public Curry2to1(Map2 targett, A aa) { target = targett; a = aa; } - public C apply(B b) { return target.apply(a, b); } - } - - // Tuple - public static class Pair implements Comparable>{ - public final A a; public final B b; - public Pair(final A aa, final B bb){ a=aa; b=bb; } - @Override public int hashCode(){ return (a==null ? 0 : a.hashCode()) + (b==null ? 0 : b.hashCode()); } - @Override public boolean equals(Object o){ - if(!(o instanceof Pair)) return false; - Pair p = (Pair) o; - return QA.bothNullOrEquals(a, p.a) && QA.bothNullOrEquals(b, p.b); - } - @Override public String toString(){ return "(" + a + ", " + b + ")"; } - public int compareTo(Pair o){ return toString().compareTo(o.toString()); } - } - - /** - * @return [fn(x) | x <- items] - */ - public static List map(Map1 fn, final Collection xs){ - ArrayList rs = new ArrayList(xs.size()); - for(A x : xs) rs.add(fn.apply(x)); - return rs; - } - - public static List map2(Map2 fn, final Collection as, final Collection bs){ - assert as.size() == bs.size(); - ArrayList cs = new ArrayList(as.size()); - Iterator aiter = as.iterator(); - Iterator biter = bs.iterator(); - while(aiter.hasNext() && biter.hasNext()) - cs.add(fn.apply(aiter.next(), biter.next())); - return cs; - } - - /** - * Same as map, but does not retain results. - */ - public static void each(Map1 fn, final Collection xs){ - for(A x : xs) fn.apply(x); - } - - /** - * @return [x | x <- items, take(x)] - */ - public static List filter(Map1 take, final Collection xs){ - List rs = new ArrayList(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return [x | x <- items, take(x)] - */ - public static Set filterSet(Map1 take, final Collection xs){ - Set rs = new HashSet(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return the first x in items that satisfies take(x), or null if none - */ - public static X find(Map1 take, final Collection xs){ - for(X x : xs) if(take.apply(x)) return x; - return null; - } - - public static A foldl(final Map2 f, A a, final Collection xs){ - for(B b : xs) a = f.apply(a, b); - return a; - } - - /** - * @return All x : p(x) == true - */ - public static boolean all(Map1 p, Collection xs) { - for(A x : xs) if(!p.apply(x)) return false; - return true; - } - - /** - * @return Any x : p(x) == true - */ - public static boolean any(Map1 p, Collection xs) { - for(A x : xs) if(p.apply(x)) return true; - return false; - } - - public static String join(final String sep, final Collection xs) { - if(xs.size() == 0) return ""; - if(xs.size() == 1) return xs.iterator().next().toString(); - return Fp.foldl(new Fp.Map2(){ - public String apply(String a, A b) { - String sb = b==null? "null" : b.toString(); - return a == null ? sb : a + sep + sb; - }}, null, xs); - } - - public static Map2 operatorPlus = new Map2(){ - public Integer apply(Integer a, Integer b) { return (int)a + (int)b;} - }; - - public static int sum(Collection xs){ return foldl(operatorPlus, 0, xs); } - - public static List append(Collection xs, Collection ys) { - List rs = new ArrayList(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Set appendSet(Collection xs, Collection ys) { - Set rs = new HashSet(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Map litMap(K key, V value, Object... pairs){ - Map ret = new HashMap(1 + pairs.length/2); - ret.put(key, value); - for(int i = 0; i < pairs.length; i += 2) - ret.put(pairs[i], pairs[i+1]); - return ret; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java 2014-07-01 15:13:32.027350206 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.Utils.Substituter; - -/** - * Utility for generating Java source code. - */ -public abstract class JavaLang { - - public static String makeSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private $CLASS $IVAR = null;~" + - "#public $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - public static String makeStaticSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private static $CLASS $IVAR = null;~" + - "#public static $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - private static String generateSingleton(final Substituter singleton, final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - singleton.replace("IVAR", instanceVariable); - singleton.replace("METHOD", methodName); - singleton.replace("CLASS", className); - singleton.replace("CTORARGS", Utils.joinWComma(constructorArgs)); - return singleton.toString(); - } - - /// - - public static class JLTertiary{ - public Object cond, tExp, fExp; - public JLTertiary(){} - public JLTertiary(Object cond, Object tExp, Object fExp){ - this.cond = cond; - this.tExp = tExp; - this.fExp = fExp; - } - @Override public String toString() { - return "((" + cond + ")\n\t? (" + tExp + ")\n\t: (" + fExp + "))"; - } - } - - public static class JLCall{ - public String fun; - public List args = new ArrayList(); - public JLCall(String fun, Object... args){ - this.fun = fun; - this.args.addAll(Arrays.asList(args)); - } - @Override public String toString(){ - return fun + "(" + Fp.join(", ", args) + ")"; - } - } - - public static class JLField{ - public Set mods = new TreeSet(); - public String type; - public String name; - public Object value; - - public JLField(String mods, String type, String name){ - this(mods, type, name, null); - } - - public JLField(String mods, String type, String name, Object value){ - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.value = value; - } - - @Override public String toString(){ - return "\t" + Fp.join(" ", mods) + " " + type + " " + name + (value==null ? "" : " = " + value) + ";\n"; - } - } - - public static class JLCtor extends JLMethod{ - public JLCtor(String mods, String name, Object... args) { - super(mods, "", name, args); - } - - @Override public String toString(){ - this.type = ""; - return super.toString(); - } - } - - public static class JLReturn{ - public Object target; - public JLReturn(Object target){ - this.target = target; - } - @Override public String toString(){ - return "return " + target + ";"; - } - } - - public static class JLMethod{ - public List jdoc = new ArrayList(); - public Set attrs = new TreeSet(); - public Set mods = new TreeSet(); - public String type; - public String name; - public List args = new ArrayList(); - public List body = new ArrayList(); - - public JLMethod(){} - public JLMethod(String mods, String type, String name, Object... args) { - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.args.addAll(Arrays.asList(args)); - } - - @Override public String toString(){ - StringWriter out = new StringWriter(); - if(jdoc.size() > 0){ - out.append("\t/**\n"); - out.append("\t * " + Fp.join("\n\t * ", jdoc)); - out.append("\t */\n"); - } - out.append("\t" + Fp.join(" ", attrs) + " " + Fp.join(" ", mods) + " " + type + " " + name + "(" + Fp.join(", ", args) + "){\n"); - out.append("\t\t" + Fp.join("\n\t\t", body) + "\n"); - out.append("\t}\n"); - return out.toString(); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java 2014-07-01 15:13:32.339350206 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Merges two NTypes. All merge does is fill out missing information. It doesn't choose the larger primitive when there's a conflict or anything like that. - * - * Example: - *
- * a: {_NSRect={_NSPoint="x"f"y"f}"size"{_NSSize=ff}}
- * b: {_NSRect="origin"{_NSPoint=ff}{_NSSize="width"f"height"f}}
- * c: {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}}
- *
- */ -public class NTypeMerger { - public static class MergeFailed extends RuntimeException{ - public MergeFailed(String reason, Object a, Object b){ - super(reason - + " -- (" + a.getClass().getSimpleName() + ") a: " + a - + " -- (" + b.getClass().getSimpleName() + ") b: " + b); - } - } - - private static NTypeMerger INST = new NTypeMerger(); - public static NTypeMerger inst(){ return INST; } - - /** - * Merge a and b. - */ - public NType merge(NType a, NType b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(a==null && b==null) return null; - if(a.equals(b)) return a; - try { - return Dispatcher.dispatch(getClass(), this, "accept", a, b); - } catch (NoSuchMethodException e) { - throw new MergeFailed("a and b are of different NType", a, b); - } - } - - private static Collection emptyNames = Arrays.asList(null, "", "?"); - /** - * Merge two identifiers: - * - If they're equal, return one. - * - If one is null, "", "?", return the other one. - * - else throw MergeFailed - * - * Exception: Due to a bug in BridgeSupport, this will return - * a (the first arg) instead of throwing MergeFailed. - */ - public String mergeName(String a, String b) throws MergeFailed{ - if(QA.bothNullOrEquals(a, b)) return a; - if(emptyNames.contains(a) && !emptyNames.contains(b)) return b; - if(emptyNames.contains(b) && !emptyNames.contains(a)) return a; - return a; // HACK BS bug #5954843 -// throw new MergeFailed("a and b have different names"); - } - - private Map mergeMap(Map a, Map b) throws MergeFailed{ - if(a.equals(b)) return a; - Map ret = new HashMap(); - Set keys = new HashSet(Fp.append(a.keySet(), b.keySet())); - for(Object key : keys){ - Object ai = a.get(key); - Object bi = b.get(key); - if(ai != null && bi == null) ret.put(key, ai); - else if(ai == null && bi != null) ret.put(key, bi); - else if(ai.equals(bi)) ret.put(key, ai); - else throw new MergeFailed("a and b are different", ai, bi); - } - return ret; - } - - public Map mergeSizeOf(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - public Map mergeOffset(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - // - - private void mustEqual(NType a, NType b){ - if(!a.equals(b)) throw new MergeFailed("a must equal b", a, b); - } - - protected NType accept(NBitfield a, NBitfield b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPrimitive a, NPrimitive b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPointer a, NPointer b) { - return new NPointer(NTypeMerger.inst().merge(a.subject, b.subject)); - } - - // Merge structs - - protected NField mergeNFields(NField a, NField b) { - return new NField(mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type, b.type), - mergeOffset(a.offset, b.offset)); - } - - protected NStruct mergeStructs(NStruct a, NStruct b){ - if(a.fields.size() != b.fields.size()) - throw new MergeFailed("a and b have different numbers of fields", a, b); - - List fields = Fp.map2(new Map2(){ - public NField apply(NField f32, NField f64) { return mergeNFields(f32, f64); } - }, a.fields, b.fields); - - return new NStruct(mergeName(a.name, b.name), - fields, mergeSizeOf(a.sizeof, b.sizeof)); - } - - protected NType accept(NStruct a, NStruct b) { - return mergeStructs(a, b); - } - - protected NType accept(NUnion a, NUnion b) { - NStruct nst = mergeStructs(a, b); - return new NUnion(nst.name, Fp.map(NUnion.zeroOffsets, nst.fields), nst.sizeof); - } - - protected NType accept(NArray a, NArray b) { - if(a.length != b.length) - throw new MergeFailed("a and b are of different sizes", a, b); - return new NArray(a.length, NTypeMerger.inst().merge(a.type, b.type)); - } - - protected NType accept(NVoid a, NVoid b) { return NVoid.inst(); } - protected NType accept(NObject a, NObject b) { return NObject.inst(); } - protected NType accept(NClass a, NClass b) { return NClass.inst(); } - protected NType accept(NSelector a, NSelector b) { return NSelector.inst(); } - protected NType accept(NUnknown a, NUnknown b) { return NUnknown.inst(); } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java 2014-07-01 15:13:32.647350205 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; - -/** - * NTypeParser (Native Type Parser) parses type & type64 attributes from BridgeSupport. - * - * See Obj-C Language: Type Encodings - */ -public abstract class NTypeParser { - // ** Parser entry point - - private static Map cached = new HashMap(); - public static NType parseFrom(String s) { - if(!cached.containsKey(s)) cached.put(s, parseFrom(new StringStream(s))); - return cached.get(s); - } - - // ** Parser driver - - private static List PARSERS = new ArrayList( - Arrays.asList(new NBitfieldParser(), new NPrimitiveParser(), new NVoidParser(), - new NPointerParser(), new NStructParser(), new NUnionParser(), - new NObjectParser(), new NClassParser(), new NSelectorParser(), - new NArrayParser(), new NUnknownParser(), new NSpecifierParser())); - - protected static NType parseFrom(StringStream ss) { - if(ss.left() == 0) - return null; - try{ - for(NTypeParser nt : PARSERS) - if(nt.parsePossible(ss)) - return nt.parse(ss); - } - catch(RuntimeException x){ - throw new RuntimeException("Exception while parsing '" + ss.remainingToString() - + "' from '" + ss.toString() + "'", x); - } - throw new RuntimeException("Found no parser for '" + ss.remainingToString() - + "' from '" + ss.toString() + "'"); - } - - // ** Methods for parsers - - protected abstract boolean parsePossible(StringStream ss); - protected abstract NType parse(StringStream ss); - - // ** Individual parsers - - public static class NBitfieldParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peekAt(0) == 'b' && Character.isDigit(ss.peekAt(1)); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.eat('b'); - return new NBitfield(Integer.parseInt(ss.readWhileDigits())); - } - } - - public static class NPrimitiveParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return NPrimitive.CODES.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - return NPrimitive.inst(ss.read()); - } - } - - public static class NVoidParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == 'v'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('v'); - return NVoid.inst(); - } - } - - public static class NPointerParser extends NTypeParser{ - private static NPointer CHAR_PTR = new NPointer(NPrimitive.inst('C')); - - @Override protected boolean parsePossible(StringStream ss) { - return (ss.left() >= 2 && ss.peek() == '^') || (ss.peek() == '*'); - } - - @Override protected NType parse(StringStream ss) { - if(ss.peek() == '*'){ - ss.eat('*'); - return CHAR_PTR; - } - else{ - ss.eat('^'); - return new NPointer(NTypeParser.parseFrom(ss)); - } - } - } - - public static class NStructParser extends NTypeParser{ - protected char getOpen(){ return '{'; }; - protected char getClose(){ return '}'; }; - - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peek() == getOpen(); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - ss.eat(getOpen()); - String cname = ss.readUntilEither("=" + getClose()); - List fields = new ArrayList(); - if(ss.peek() == '='){ - ss.eat('='); - while(ss.peek() != getClose()){ - String fname = ""; - if(ss.peek() == '"'){ - ss.eat('"'); - fname = ss.readUntil('"'); - ss.eat('"'); - } - NType type = NTypeParser.parseFrom(ss); - fields.add(new NStruct.NField(fname, type)); - } - } - ss.eat(getClose()); - return getNew(cname, fields); - } - - protected NType getNew(String cname, List fields){ - return new NStruct(cname, fields); - } - } - - // A Union is very much like a Struct. - public static class NUnionParser extends NStructParser{ - @Override protected char getOpen(){ return '('; }; - - @Override protected char getClose(){ return ')'; }; - - @Override protected NType getNew(String cname, List fields){ - return new NUnion(cname, Fp.map(NUnion.zeroOffsets, fields)); - } - } - - public static class NArrayParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '['; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('['); - int size = Integer.parseInt(ss.readWhileDigits()); - NType type = NTypeParser.parseFrom(ss); - ss.eat(']'); - return new NArray(size, type); - } - } - - public static class NObjectParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '@'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('@'); - return NObject.inst(); - } - } - - public static class NClassParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '#'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('#'); - return NClass.inst(); - } - } - - public static class NSelectorParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == ':'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat(':'); - return NSelector.inst(); - } - } - - public static class NUnknownParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '?'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('?'); - return NUnknown.inst(); - } - } - - /** - * Specifier Encoding - * const r - * in n - * inout N - * out o - * bycopy O - * oneway V - */ - public static class NSpecifierParser extends NTypeParser{ - private static Collection SPECS = Arrays.asList('r', 'n', 'N', 'o', 'O', 'V'); - @Override protected boolean parsePossible(StringStream ss) { - return SPECS.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.seek(); // XXX Just ignore specs for now and return the affected type. - return NTypeParser.parseFrom(ss); - } - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java 2014-07-01 15:13:32.955350204 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; - -/** - * Print an NType to the BridgeSupport encoding. - */ -public class NTypePrinter{ - private static NTypePrinter INST = new NTypePrinter(); - public static NTypePrinter inst(){ return INST; } - - public String print(NType nt){ - try { - return Dispatcher.dispatch(getClass(), this, "accept", nt); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - protected String accept(NBitfield nt) { - return "b" + nt.length; - } - - protected String accept(NPrimitive nt) { - return Character.toString(nt.type); - } - - protected String accept(NPointer nt) { - if(nt.subject instanceof NPrimitive && ((NPrimitive) nt.subject).type == 'C') - return "*"; - else - return "^" + print(nt.subject); - } - - protected String printStruct(NStruct nt, char open, char close){ - StringWriter sw = new StringWriter(); - sw.append(open); - sw.append(nt.name); - if(nt.fields.size() > 0){ - sw.append('='); - for(NField f : nt.fields){ - if(f.name != null && f.name.length() > 0) - sw.append("\"" + f.name + "\""); - sw.append(print(f.type)); - } - } - sw.append(close); - return sw.toString(); - } - - protected String accept(NStruct nt) { - return printStruct(nt, '{', '}'); - } - - protected String accept(NUnion nt) { - return printStruct(nt, '(', ')'); - } - - protected String accept(NArray nt) { - return "[" + nt.length + print(nt.type) + "]"; - } - - protected String accept(NObject nt) { return "@"; } - protected String accept(NVoid nt) { return "v"; } - protected String accept(NClass nt) { return "#"; } - protected String accept(NSelector nt) { return ":"; } - protected String accept(NUnknown nt) { return "?"; } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java 2014-07-01 15:13:33.263350203 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.lang.reflect.Field; - -public abstract class ObjectInspector { - /** - * @return a string representation of object internals. - */ - public static String inspect(Object obj) { - StringWriter sw = new StringWriter(); - inspectForClass(obj, obj.getClass(), sw); - return sw.toString(); - } - - private static void inspectForClass(Object instance, Class clazz, StringWriter sw){ - boolean willGoSuper = clazz.getSuperclass() != null && !clazz.getSuperclass().getName().equals("java.lang.Object"); - - sw.append(clazz.getSimpleName()); - sw.append("{"); - Field[] fs = clazz.getDeclaredFields(); - for(int i = 0; i < fs.length; i++){ - Field f = fs[i]; - f.setAccessible(true); - sw.append(f.getName()); - sw.append(": "); - try { - Object o = f.get(instance); - sw.append(o == null ? "null" : o.toString()); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } - if(i < fs.length - 1 || willGoSuper) - sw.append(", "); - } - - if(willGoSuper){ - sw.append("super: "); - inspectForClass(instance, clazz.getSuperclass(), sw); - } - - sw.append("}"); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/QA.java 2014-07-01 15:13:33.575350202 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import com.apple.internal.jobjc.generator.Utils; - -public class QA { - public static void nonNull(Object... os){ - for(Object o : os) if(o == null) throw new NullPointerException(Utils.joinWComma(os)); - } - - public static boolean bothNullOrEquals(Object a, Object b) { - if(a == null && b == null) return true; - if(a == null || b == null) return false; - return a.equals(b); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java 2014-07-01 15:13:33.883350202 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -/** - * Stream-like class backed by a string. Useful for parsers. - */ -public class StringStream{ - private String data; - private int pos; - - public StringStream(String s){ - QA.nonNull(s); - this.data = s; - this.pos = 0; - } - - /** - * Number of characters left. - */ - public int left(){ return data.length() - pos; } - - /** - * Are there any characters left? - */ - public boolean atEOF(){ return left() <= 0; } - - /** - * Read next character. - */ - public char read(){ return data.charAt(pos++); } - - /** - * Read n characters and return string. - */ - public String readN(int n){ - String s = data.substring(pos, pos + n); - pos += n; - return s; - } - - /** - * Read until the next char is c, and return the string. - */ - public String readUntil(char c){ - int ix = data.indexOf(c, pos); - if(ix == -1) throw new RuntimeException("readUntil did not find character '" + c + "'"); - return readN(data.indexOf(c, pos) - pos); - } - - /** - * Read until the next char is one in s, and return the string. - */ - public String readUntilEither(String s) { - int ix = Integer.MAX_VALUE; - - for(char c : s.toCharArray()){ - int ixx = data.indexOf(c, pos); - if(ixx >= 0 && ixx < ix) - ix = ixx; - } - - if(ix == -1) throw new RuntimeException("readUntilEither did not find any character in '" + s + "'"); - return readN(ix - pos); - } - - public String readWhile(String s) { - StringWriter sw = new StringWriter(); - while(s.indexOf(peek()) != -1) - sw.append(read()); - return sw.toString(); - } - - public String readWhileDigits() { - return readWhile("0123456789"); - } - - /** - * @return the nth char from the current position. - */ - public char peekAt(int n){ return data.charAt(pos + n); } - - /** - * @return the next n chars. - */ - public String peekN(int n){ return data.substring(pos, pos + n); } - - /** - * @return the next char. - */ - public char peek(){ return peekAt(0); } - - /** - * Skip n chars ahead. - */ - public void seekN(int n){ pos += n; } - - /** - * Skip 1 char ahead. - */ - public void seek(){ seekN(1); } - - /** - * If the next character is c, seek over it. Otherwise throw RuntimeException. - */ - public void eat(char c) { - if(peek() != c) throw new RuntimeException("Parser expected '" + c + "' but got '" + peek() + "'."); - seek(); - } - - /** - * If the next characters are the same as those in s, seek over them. Otherwise throw RuntimeException. - */ - public void eat(String s) { - String pn = peekN(s.length()); - if(!pn.equals(s)) throw new RuntimeException("Parser expected '" + s + "' but got '" + pn + "'."); - seekN(s.length()); - } - - @Override - public String toString(){ - return data; - } - - /** - * @return the remaining characters as a String. - */ - public String remainingToString() { - return data.substring(pos); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java 2014-07-01 15:13:34.191350201 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileWriter; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; -import java.util.Date; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - */ -public class StructOffsetResolver { - public void resolve(Collection fws){ - try { - _resolve(fws); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected void _resolve(final Collection fws) throws Exception{ - for(final Framework fw : fws){ - for(final Width width : Width.values()){ - System.out.println("SOR -- Getting Struct offsets @" + width + " for " + fw.name); - String nativeSrc = generateFileForFramework(fw, width); - String executable = compileObjC(nativeSrc, width); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, width); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - } - - static Set alwaysHeaders_shared = new TreeSet(Arrays.asList( - "", - "\"/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/HIToolbox.h\"")); - static Map> alwaysHeaders = Fp.litMap( - Width.W32, alwaysHeaders_shared, - Width.W64, alwaysHeaders_shared); - - static Set bannedHeaders_shared = new TreeSet(Arrays.asList( - "NSJavaSetup.h", "IMKInputController.h", "NSSimpleHorizontalTypesetter.h", "NSSpellServer.h", "IMKServer.h", "IKImageBrowserCell.h")); - static Map> bannedHeaders = Fp.litMap( - Width.W32, bannedHeaders_shared, - Width.W64, Fp.appendSet(bannedHeaders_shared, - Arrays.asList("npapi.h", "npruntime.h", "npfunctions.h"))); - - // We can cache the last accessed framework because, 99% of the time, - // the caller will ask for the same one, over and over again. - protected Framework cachedFw; - protected Framework findFrameworkByName(Collection fws, String name){ - if(cachedFw != null && cachedFw.name.equals(name)) - return cachedFw; - cachedFw = null; - for(Framework fw : fws) - if(fw.name.equals(name)){ - cachedFw = fw; - break; - } - return cachedFw; - } - - protected void processLine(String ln, Collection fws, Width arch) throws Exception{ - System.out.println("\tSOR '" + ln + "'"); - if(ln.trim().length() == 0) return; - Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$"); - Matcher m = stinfo.matcher(ln); - if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln); - String fwname = m.group(1); - String stname = m.group(2); - int stsize = Integer.parseInt(m.group(3)); - - Framework fw = findFrameworkByName(fws, fwname); - - Struct st = fw.getStructByName(stname); - NStruct nst = wget(arch, st.type.type32, st.type.type64); - nst.sizeof.put(arch, stsize); - -// System.out.println(st.name + " : " + stsize); - - Pattern finfo = Pattern.compile(" (-?\\d+)"); - Matcher fm = finfo.matcher(ln); - int fi = 0; - while(fm.find()){ - NField sf = nst.fields.get(fi++); - sf.offset.put(arch, Integer.parseInt(fm.group(1))); -// System.out.println("\t" + sf.name + " : " + off); - } - - TypeCache.inst().pingType(st.type); - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - private String generateFileForFramework(Framework fw, Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SOR-" + fw.name + "-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - out.println("#include"); - printHeaderLines(fw, arch, out); - out.println(""); - out.println("int main(int argc, char** argv){"); - printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - out.close(); - return tempfile.getAbsolutePath(); - } - - protected void execute(String executable, Fp.Map1 lineProcessor) throws Exception { -// System.out.println(">>>> Executing " + new Date().toString()); - Process p = Runtime.getRuntime().exec(new String[]{executable}); - - if(lineProcessor != null){ - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - String line; - while ((line = stdout.readLine()) != null) - lineProcessor.apply(line); - stdout.close(); - } - p.waitFor(); - if(p.exitValue() != 0) - throw new RuntimeException(executable + " did not execute successfully: " + p.exitValue()); - } - - private static Map gccFlag = Fp.litMap(Width.W32, "-m32", Width.W64, "-m64"); - - static boolean isDone(Process p){ - try{ - p.exitValue(); - return true; - } - catch(Exception x){ - return false; - } - } - - protected static String compileObjC(String nativeSrc, Width arch) throws Exception { - String execPath = nativeSrc.replace(".mm", ""); - Process p = Runtime.getRuntime().exec(new String[]{ - "llvm-g++", "-Wall", gccFlag.get(arch), "-ObjC++", "-framework", "Foundation", "-o", execPath, nativeSrc - }); - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream())); - while(!isDone(p)){ - while(stdout.ready()) System.out.println(stdout.readLine()); - while(stderr.ready()) System.out.println(stderr.readLine()); - } - p.waitFor(); - while(stdout.ready() || stderr.ready()){ - if(stdout.ready()) System.out.println(stdout.readLine()); - if(stderr.ready()) System.out.println(stderr.readLine()); - } - if(p.exitValue() != 0) - throw new RuntimeException("gcc did not compile '" + nativeSrc + "' successfully: " + p.exitValue()); - return execPath; - } - - static void printStructInfos(Framework fw, Width arch, PrintWriter out){ - for(Struct st : fw.structs){ - NStruct nst = wget(arch, st.type.type32, st.type.type64); - out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")"); - for(NField sf : nst.fields){ - out.print("\t<< ' ' << "); - out.println(sf.type instanceof NType.NBitfield - ? "-1" - : "offsetof("+st.name+","+sf.name+")"); - } - out.println("\t<< std::endl;"); - } - } - - static void printHeaderLines(Framework fw, Width arch, PrintWriter out) throws Exception { - Collection always = alwaysHeaders.get(arch); - Collection banned = bannedHeaders.get(arch); - out.println("#define COREFOUNDATION_CFPLUGINCOM_SEPARATE 0"); - for(String header : always) - out.println("#import " + header); - - out.println("#undef COREFOUNDATION_CFPLUGINCOM_SEPARATE"); - String umbrella = fw.path + "/Headers/" + fw.name; - if(new File(umbrella).exists()) - out.println("#import \"" + umbrella + "\""); - - for(File header : getHeaders(fw)) - if(!banned.contains(header.getName())) - out.println("#import \"" + header.getAbsolutePath() + "\""); - } - - static A wget(Width arch, B x32, B x64){ - switch(arch){ - case W32: return (A) x32; - case W64: return (A) x64; - default: throw new RuntimeException(); - } - } - - /** - * Gets the absolute path to every header in FOO.framework/Headers - */ - static Collection getHeaders(Framework fw) throws Exception { - String hpath = fw.path + "/Headers"; - return Utils.find(new File(hpath), "^.*\\.h$", ""); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java 2014-07-01 15:13:34.499350200 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - * - * BigBang significantly speeds up the process by - * compiling all frameworks as one big Objective-C file. - */ -public class StructOffsetResolverBigBang extends StructOffsetResolver{ - - @Override protected void _resolve(final Collection fws) throws Exception{ - for(final Width arch : Width.values()){ - System.out.println("SORBB -- Getting Struct offsets @" + arch.toString()); - String nativeSrc = generateFileForFrameworks(fws, arch); - String executable = compileObjC(nativeSrc, arch); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, arch); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - protected String generateFileForFrameworks(final Collection fws, final Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SORBB-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - - out.println("#include"); - for(Framework fw : fws) printHeaderLines(fw, arch, out); - out.println("int main(int argc, char** argv){"); - for(Framework fw : fws) printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - - out.close(); - return tempfile.getAbsolutePath(); - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java 2014-07-01 15:13:34.791350199 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Clazz; - -/* - * Isolating all the reflection trickery to hijack the runtime into giving up its secrets - * without actually having a full working version of JObjC. Below is a bunch of evil reflection, - * but it allows the generated output to have a cleaner design. - */ -public class SuperClassExtractor { - public static Clazz getSuperClassFor(final String className, final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - final NSClass nativeClass = new NSClass(className, nativeFramework.getRuntime()); - final NSClass nativeSuperClass = UnsafeRuntimeAccess.getSuperClass(nativeClass); - final String superClassName = UnsafeRuntimeAccess.getClassNameFor(nativeSuperClass); - if ("nil".equals(superClassName)) return null; - - final Clazz superClazz = allClasses.get(superClassName); - if (superClazz != null) return superClazz; - - final Clazz superClazzX = getSuperClassFor(superClassName, nativeFramework, allClasses); - System.out.print("[Warning] class \"" + superClassName + "\" not found in bridge support files, "); - System.out.println("using \"" + superClazzX.name + "\" as superclass for \"" + className + "\""); - return superClazzX; - } -} --- old/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java 2014-07-01 15:13:35.111350199 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class UnsafeRuntimeAccess { - public static NativeArgumentBuffer getNativeBuffer() { - return NativeArgumentBuffer.getThreadLocalBuffer(JObjCRuntime.getInstance()); - } - - public static String getClassNameFor(final long obj) { - return NSClass.getClassNameOfClass(obj); - } - - public static String getClassNameFor(final NSClass cls) { - return NSClass.getClassNameOfClass(cls.ptr); - } - - public static NSClass getSuperClass(final NSClass clazz) { - return clazz.getSuperClass(); - } - - public static String getDescriptionForPtr(final long objPtr) { - return ID.getNativeDescription(objPtr); - } - - public static MacOSXFramework getFramework(final String[] frameworkLibs) { - return new MacOSXFramework(JObjCRuntime.getInstance(), frameworkLibs); - } - - public static FunCall createFunCall(final MacOSXFramework framework, final String fxnName, final Coder returnCoder, final Coder ... argCoders) { - return new FunCall(framework, fxnName, returnCoder, argCoders); - } - - public static MsgSend createMsgSend(final NSClass clazz, final String selName, final Coder returnCoder, final Coder ... argCoders) { - return new MsgSend(clazz.getRuntime(), selName, returnCoder, argCoders); - } - - public static NSClass getNSClass(final MacOSXFramework framework, final String name) { - return new NSClass(name, framework.getRuntime()); - } - - public static long getObjPtr(final ID obj) { - return obj.ptr; - } -} --- old/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java 2014-07-01 15:13:35.427350198 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSNumber; -import com.apple.jobjc.foundation.NSString; - -public class Utils { - JObjCRuntime runtime; - Utils(JObjCRuntime runtime){ this.runtime = runtime; } - - private static Utils utils; - public static Utils get() { - JObjCRuntime runtime = JObjCRuntime.getInstance(); // enforce security check - return utils != null ? utils : (utils = new Utils(runtime)); - } - - private Strings strings_; - public Strings strings() { - return strings_ != null ? strings_ : (strings_ = new Strings(runtime)); - } - - private Numbers numbers_; - public Numbers numbers() { - return numbers_ != null ? numbers_ : (numbers_ = new Numbers(runtime)); - } - - private Threads threads_; - public Threads threads() { - return threads_ != null ? threads_ : (threads_ = new Threads(runtime)); - } - - public static class Strings { - private static native long getNativeNSStringForJavaString(final String javaString); - private static native String getNativeJavaStringForNSString(final long nsString); - - JObjCRuntime runtime; - Strings(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSString nsString(final String str) { - if (str == null) return null; - final long nsString = getNativeNSStringForJavaString(str); - return ID.createNewObjCObjectForClass(NSString.class, nsString, runtime); - } - - public String javaString(final NSString str) { - if (str == null) return null; - return getNativeJavaStringForNSString(((ID)str).ptr); - } - -// static public CString cStringForJavaString(final String str) { -// return null; -// } - } - - public static class Numbers { - private static native long getNativeNSNumberForJavaNumber(final Number num); - private static native Number getNativeJavaNumberForNSNumber(final long num); - - JObjCRuntime runtime; - Numbers(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSNumber nsNumber(final Number num) { - if (num == null) return null; - final long nsNumber = getNativeNSNumberForJavaNumber(num); - return ID.createNewObjCObjectForClass(NSNumber.class, nsNumber, runtime); - } - - public Number javaNumber(final NSNumber num) { - if (num == null) return null; - return getNativeJavaNumberForNSNumber(((ID)num).ptr); - } - } - - public static class Threads { - private static native void performRunnableOnMainThread(final Runnable runnable, final boolean wait); - private static native V performCallableOnMainThread(final Callable callable) throws Exception; - - JObjCRuntime runtime; - Threads(JObjCRuntime runtime) { this.runtime = runtime; } - - /** - * Perform callable on main thread. Exceptions that are thrown on the main thread are ignored. - */ - public void performOnMainThread(final Runnable runnable, final boolean wait) { - performRunnableOnMainThread(runnable, wait); - } - - /** - * Perform callable on main thread, block until done, and return the result. - * This also catches any exceptions on the main thread, brings them back and throws them to the caller. - */ - public V performOnMainThread(final Callable callable) throws Exception{ - return performCallableOnMainThread(callable); - } - } -} --- old/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m 2014-07-01 15:13:35.747350197 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Numbers.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeNSNumberForJavaNumber - * Signature: (Ljava/lang/Number;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeNSNumberForJavaNumber -(JNIEnv *env, jclass clazz, jobject javaNumber) -{ - return ptr_to_jlong(JNFJavaToNSNumber(env, javaNumber)); -} - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeJavaNumberForNSNumber - * Signature: (J)Ljava/lang/Number; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeJavaNumberForNSNumber -(JNIEnv *env, jclass clazz, jlong nativeNumber) -{ - return JNFNSToJavaNumber(env, (NSNumber *)jlong_to_ptr(nativeNumber)); -} --- old/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m 2014-07-01 15:13:36.063350196 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Strings.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeNSStringForJavaString - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeNSStringForJavaString -(JNIEnv *env, jclass clazz, jstring javaString) -{ - return ptr_to_jlong(JNFJavaToNSString(env, javaString)); -} - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeJavaStringForNSString - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeJavaStringForNSString -(JNIEnv *env, jclass clazz, jlong nativeString) -{ - return JNFNSToJavaString(env, (NSString *)jlong_to_ptr(nativeString)); -} --- old/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m 2014-07-01 15:13:36.371350196 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "com_apple_jobjc_Utils_Threads.h" - -#import -#import - - -@interface JObjCCallable : NSObject { - @public jobject returnValue; - @public jthrowable exception; -} -@property jobject returnValue; -@property jthrowable exception; -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper; -@end - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performRunnableOnMainThreadNative - * Signature: (Ljava/lang/Runnable;Z)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_Utils_00024Threads_performRunnableOnMainThread -(JNIEnv *env, jclass clazz, jobject runnable, jboolean jWaitUntilDone) -{ -JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:jWaitUntilDone - withBlock:[JNFRunnable blockWithRunnable:runnable - withEnv:env]]; -JNF_COCOA_EXIT(env); -} - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performCallableOnMainThreadNative - * Signature: (Ljava/util/concurrent/Callable;)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Threads_performCallableOnMainThread -(JNIEnv *env, jclass clazz, jobject callable) -{ - jobject returnValue = NULL; - -JNF_COCOA_ENTER(env); - JNFJObjectWrapper *callableWrapper = [[JNFJObjectWrapper alloc] initWithJObject:callable withEnv:env]; - JObjCCallable *ncallable = [JObjCCallable alloc]; - - [ncallable performSelectorOnMainThread:@selector(performCallable:) - withObject:callableWrapper - waitUntilDone:true]; - - returnValue = ncallable.returnValue; - jthrowable exception = ncallable.exception; - - [ncallable release]; - if(exception) (*env)->Throw(env, exception); - -JNF_COCOA_EXIT(env); - - return returnValue; -} - - -@implementation JObjCCallable -@synthesize returnValue; -@synthesize exception; - -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper { - static JNF_CLASS_CACHE(jc_Callable, "java/util/concurrent/Callable"); - static JNF_MEMBER_CACHE(jm_Callable_call, jc_Callable, "call", "()Ljava/lang/Object;"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - jobject callable = [callableWrapper jObject]; - - @try{ - self.returnValue = JNFCallObjectMethod(env, callable, jm_Callable_call); - } @catch (JNFException *x) { - [x raiseToJava:env]; - } - - self.exception = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - - [callableWrapper release]; - JNFReleaseEnv(env, &threadWasAttached); -} - -@end --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java 2014-07-01 15:13:36.683350195 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import sun.misc.Unsafe; - -public class BaseBench extends PooledTestCase { - protected final static JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - protected final static JObjC JOBJC = JObjC.getInstance(); - protected final static Unsafe UNSAFE = JObjCRuntime.getInstance().unsafe; - protected final static NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - public abstract static class Task{ - final String name; - public Task(String name){ this.name = name; } - public abstract void run(); - } - - public void bench(final String title, final long warmup, final long runs, final long iterations, final Task... tasks){ - final long[] runtimes = new long[tasks.length]; - - for(int t = 0; t < tasks.length; ++t){ - long runtime = 0; - for(int i = 0; i < warmup; ++i) - singleBench(iterations, tasks[t]); - for(int i = 0; i < runs; ++i) - runtime = runtime + singleBench(iterations, tasks[t]); - runtimes[t] = runtime; - } - - final float[] relatives = new float[tasks.length]; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = ((float) runtimes[t] / (float) runs); - - float min = relatives[0]; - for(float t : relatives) - if(t < min) - min = t; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = relatives[t] / min; - - System.out.format("\n* %1$s\n", title); - for(int t = 0; t < tasks.length; ++t) - System.out.format("%1$60s : %2$.1f\n", tasks[t].name, relatives[t]); - } - - public long singleBench(final long iterations, final Task task){ - long start = System.currentTimeMillis(); - for(long i = 0; i < iterations; ++i) - task.run(); - long end = System.currentTimeMillis(); - return end - start; - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java 2014-07-01 15:13:36.975350194 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; - -public final class BenchFunCall extends BaseBench{ - final static int ITERS = 1000; - final static FunCall fc = new FunCall(JObjCRuntime.getInstance(), "sin", DoubleCoder.INST, DoubleCoder.INST); - final static double ARG = 3.14159265 / 2.0; - final static double RET = 1.0; - - private static native double jniSin(double arg); - - public void testBench(){ - this.bench("Calling functions", 5, 3, 10000L, - - new Task("JNI Invoke"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i) - jniSin(ARG); - }}, - - new Task("JObjC FunCall"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - fc.init(ARGS); - DoubleCoder.INST.push(ARGS, ARG); - fc.invoke(ARGS); - DoubleCoder.INST.pop(ARGS); - } - }}, - - new Task("JObjC FunCall (inlined)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - // init - ARGS.argPtrsPtr = ARGS.buffer.bufferPtr; - ARGS.argValuesPtr = ARGS.buffer.bufferPtr + 256; - // push double - //// push arg ptr - if(JObjCRuntime.IS64) - UNSAFE.putLong(ARGS.argPtrsPtr, ARGS.argValuesPtr); - else - UNSAFE.putInt(ARGS.argPtrsPtr, (int) ARGS.argValuesPtr); - ARGS.argPtrsPtr += JObjCRuntime.PTR_LEN; - //// push arg value - UNSAFE.putDouble(ARGS.argValuesPtr, ARG); - ARGS.argValuesPtr += 8; - // invoke - FunCall.invoke(fc.cif.cif.bufferPtr, fc.fxnPtr, ARGS.retValPtr, ARGS.buffer.bufferPtr); - // pop - UNSAFE.getDouble(ARGS.retValPtr); - } - }} - ); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java 2014-07-01 15:13:37.287350193 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; - -public class BenchIDPop extends BaseBench{ - static native long jniNSStringAlloc(); - static native long jniNSStringAllocAndRetain(); - static native long jniNSStringCached(); - static native void jniCFRetain(long x); - static native void jniCFRelease(long x); - - final static int ITERS = 1000; - final static FoundationFramework FND = JOBJC.Foundation(); - - private static class LongWrap{ - long l; - public LongWrap(long l){ this.l = l; } - } - - public void testIt(){ - bench("Alloc, retain, pop a new NSString", 2, 3, 2000, - new Task("jniNSStringAllocAndRetain()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniNSStringAllocAndRetain(); - }}, - - new Task("new LongWrap(jniNSStringAllocAndRetain())"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new LongWrap(jniNSStringAllocAndRetain()); - }}, - - new Task("FND.NSString().alloc()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - FND.NSString().alloc(); - }}, - - new Task("new NSString(jniNSStringAlloc(), RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new NSString(jniNSStringAlloc(), RUNTIME); - }} - ); - - final long nsstringPtr = jniNSStringAlloc(); - - bench("Get and hold an existing object", 2, 3, 2000, - new Task("jniCFRetain(nsstringPtr)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(nsstringPtr); - }}, - - new Task("jniCFRetain(new LongWrap(nsstringPtr).l"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(new LongWrap(nsstringPtr).l); - }}, - - new Task("ID.getInstance(nsstringPtr, RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - ID.getInstance(nsstringPtr, RUNTIME); - }} - ); - } - -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java 2014-07-01 15:13:37.575350193 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.StructCoder; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; - -public class BenchStructCoding extends BaseBench { - final static FoundationFramework FND = JOBJC.Foundation(); - final static int ITERS = 1000; - final static PrimitiveCoder CODER = com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder; - final static StructCoder RCODER = NSRect.getStructCoder(); - final static FunCall nsMakePoint = - new com.apple.jobjc.Invoke.FunCall(FND, "NSMakeRect", com.apple.jobjc.foundation.NSRect.getStructCoder(), - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder); - - public void testFoo(){ - bench("NSMakeRect", 3, 3, 10, - new Task("FND.NSMakeRect"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - NSRect s = FND.NSMakeRect(0, 1, 2, 3); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..., s)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - NSRect s = FND.makeNSRect(); - nsMakePoint.invoke(ARGS, s); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..); NSRect r = pop(..);"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - nsMakePoint.invoke(ARGS); - NSRect s = (NSRect) RCODER.pop(ARGS); -// assertEquals(1.0D, s.origin().y()); - } - }} - ); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java 2014-07-01 15:13:37.883350192 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.nio.ByteBuffer; - -public class BenchUnsafe extends BaseBench{ - final static int ITERS = 1000000; - - final static NativeBuffer NBUF = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF = NBUF.buffer; - final static long ADDR = NBUF.bufferPtr; - final static long ADDR_MAX = NBUF.bufferPtr + ITERS; - - final static NativeBuffer NBUF2 = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF2 = NBUF2.buffer; - final static long ADDR2 = NBUF2.bufferPtr; - final static long ADDR2_MAX = NBUF2.bufferPtr + ITERS; - - final static long ARG = 345; - - final static long BUFSIZE = BBUF.limit(); - - public void testIt(){ - this.bench("Memory writes", 5, 3, 100L, - - new Task("buffer.putLong"){ - @Override public void run() { - for(long i = 0; i < ITERS; i++) - BBUF.putLong((int) i, ARG); - }}, - - new Task("unsafe.putLong"){ - @Override public void run() { - for(long i = ADDR; i < ADDR_MAX; i++) - UNSAFE.putLong(i, ARG); - }}); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java 2014-07-01 15:13:38.175350191 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSStringCategory; -import com.apple.jobjc.foundation.NSSize; -import com.apple.jobjc.foundation.NSString; - -public class CategoryTest extends PooledTestCase { - public void testAppKit_NSString(){ - AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - NSString nstr = Utils.get().strings().nsString("mirzapirza"); - NSStringCategory nstrx = APPKIT.NSStringCategory(nstr); - NSSize sz = nstrx.sizeWithAttributes(null); - - assertEquals(57.0, sz.width()); - assertEquals(15.0, sz.height()); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(CategoryTest.class); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java 2014-07-01 15:13:38.483350190 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.FunCall; - -public class FunctionTest extends PooledTestCase { - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testInvokeNoParamNoReturn() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSBeep", VoidCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - } - - public void testInvokeNoParams() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - - final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr)); - } - - public void testInvokeOneParam() throws Throwable { - final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST); - - getHomeDirFxn.init(nativeBuffer); - getHomeDirFxn.invoke(nativeBuffer); - - final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr)); - - final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST); - getTypeOfFxn.init(nativeBuffer); - PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr); - getTypeOfFxn.invoke(nativeBuffer); - - // long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer); - // System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr)); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(FunctionTest.class); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java 2014-07-01 15:13:38.791350189 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Utils.Strings; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSButton; -import com.apple.jobjc.appkit.NSDrawer; -import com.apple.jobjc.appkit.NSMenu; -import com.apple.jobjc.appkit.NSWindow; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSSize; - -class MyDelegate extends NSObject{ - static final JObjC objc = JObjC.getInstance(); - static final Strings str = Utils.get().strings(); - - public MyDelegate(long ptr, JObjCRuntime r) { super(ptr, r); } - - private NSWindow myWindow; - private NSDrawer myDrawer; - - public void printHello(ID sender){ - System.out.println("Hello!"); - myDrawer.toggle(this); - } - - public void createMenu(){ - NSMenu menu = objc.AppKit().NSMenu().newID(); - menu.addItemWithTitle_action_keyEquivalent( - str.nsString("Quit"), - new SEL("terminate:"), - str.nsString("q")); - NSApplication app = objc.AppKit().NSApp(); - app.setMainMenu(menu); - } - - public void createWindow(){ - NSRect rect; - int styleMask = objc.AppKit().NSTitledWindowMask() | objc.AppKit().NSMiniaturizableWindowMask(); - NSButton myButton; - NSSize buttonSize; - myButton = objc.AppKit().NSButton().newID(); - myButton.setTitle(str.nsString("Print Hello!")); - myButton.sizeToFit(); - myButton.setTarget(this); - myButton.setAction(new SEL("printHello:")); - buttonSize = myButton.frame().size(); - rect = objc.Foundation().NSMakeRect(100, 100, 2*buttonSize.width(), 2*buttonSize.height()); - myWindow = objc.AppKit().NSWindow().alloc(); - myWindow = myWindow.initWithContentRect_styleMask_backing_defer( - rect, styleMask, objc.AppKit().NSBackingStoreBuffered(), false); - myWindow.setTitle(str.nsString("This is a test window.")); - myWindow.setContentView(myButton); - - myDrawer = objc.AppKit().NSDrawer().alloc(); - myDrawer = myDrawer.initWithContentSize_preferredEdge( - objc.Foundation().NSMakeSize(100, 40), objc.Foundation().NSMinYEdge()); - myDrawer.setParentWindow(myWindow); - } - - public void applicationWillFinishLaunching(ID not){ - createMenu(); - createWindow(); - } - - public void applicationDidFinishLaunching(ID not){ - myWindow.makeKeyAndOrderFront(null); - } -} - -class MyDelegateClass extends NSObjectClass{ - public MyDelegateClass(JObjCRuntime r){ super(r); } -} - -public class GUIDemo{ - static final JObjC objc = JObjC.getInstance(); - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class); - - objc.AppKit().NSApplication().sharedApplication(); - NSApplication app = objc.AppKit().NSApp(); - - NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc(); - pool = pool.init(); - app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID()); - app.run(); - pool.drain(); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java 2014-07-01 15:13:39.087350189 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * To locate the nib correctly, this demo must run from - * a .app (created with Jar Bundler...). - * - * TODO Add .app/Jar Bundler as ant task - */ - -package com.apple.jobjc; - -import java.awt.Toolkit; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSView; -import com.apple.jobjc.appkit.NSViewClass; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSString; - -class MyView extends NSView{ - static final AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - public MyView(long objPtr, JObjCRuntime runtime) { super(objPtr, runtime); } - - @Override public void drawRect(NSRect r){ - APPKIT.NSColor().redColor().set(); - APPKIT.NSBezierPath().fillRect(r); - } -} - -class MyViewClass extends NSViewClass{ - protected MyViewClass(String name, JObjCRuntime runtime) { super(name, runtime); } - public MyViewClass(JObjCRuntime runtime){ this(MyView.class.getSimpleName(), runtime); } -} - -public class IBDemo{ - final static FoundationFramework FOUNDATION = JObjC.getInstance().Foundation(); - final static AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - // Works if the JVM is launched on the main thread, - // but JavaApplicationStub does not understand -XstartOnFirstThread - public static void mainWithAppMain(String[] args){ - APPKIT.NSApplicationMain(0, null); - } - - // Work around: let someone else init, and then - // get on the main thread to load the nib. - public static void mainWithoutAppMain(String[] args){ - Toolkit.getDefaultToolkit(); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - APPKIT.NSApplication().sharedApplication(); - NSApplication APP = APPKIT.NSApp(); - - NSString nibName = Utils.get().strings().nsString("MainMenu"); - boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP); - if(!loadedNib) throw new RuntimeException("Failed to load nib."); - }}, false); - } - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyView.class, MyViewClass.class); - mainWithoutAppMain(args); - //mainWithAppMain(args); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java 2014-07-01 15:13:39.395350188 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSApplicationClass; -import com.apple.jobjc.appkit.NSColorPanel; -import com.apple.jobjc.appkit.NSWorkspace; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class IntroTest extends TestCase{ - // The low-level core makes function calls, sends messages, marshals data, etc. - public void testCore(){ - // pass security check and get ahold of a runtime (should cache this) - final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - // create a funcall (should cache this) - final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); - - // start function call - fc.init(ARGS); - // push an arg - DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); - // make the call - fc.invoke(ARGS); - // read the return value - double ret = DoubleCoder.INST.pop(ARGS); - - assertEquals(1.0, ret); - } - - // Frameworks bridge the Mac OS X frameworks - public void testFrameworks(){ - // First, get an instance of JObjC: - final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance(); - - // It's your gateway to the frameworks. - final FoundationFramework FND = JOBJC.Foundation(); - final AppKitFramework APP = JOBJC.AppKit(); - - // From which you can then access... - - // enums, defines, constants - int nsmye = FND.NSMaxYEdge(); - boolean debug = FND.NSDebugEnabled(); - - // structs - NSPoint p = FND.makeNSPoint(); - p.setX(3); - assertEquals(3.0, p.x()); - - // C functions - NSPoint p2 = FND.NSMakePoint(12, 34); - assertEquals(12.0, p2.x()); - - // ... Let's create an AutoreleasePool before we go on - NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init(); - - // Objective-C classes - NSStringClass nsc = FND.NSString(); - - // class-methods - NSString nsStringClassDescr = nsc.description(); - - // instances - NSString nsi = ((NSString) FND.NSString().alloc()).init(); - - // instance methods - NSString d = nsi.description(); - - // The bridge marshals some types for you, but it doesn't - // convert between NSString and Java String automatically. - // For that we use Utils.get().strings().nsString(String) - // and Utils.get().strings().javaString(NSString); - - assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr)); - - NSString format = Utils.get().strings().nsString("Foo bar %d baz"); - - NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34); - String jformatted = Utils.get().strings().javaString(formatted); - - assertEquals("Foo bar 34 baz", jformatted); - - // Reveal in Finder -// NSString file = Utils.get().strings().nsString( -// "/Applications/Calculator.app/Contents/Resources/Calculator.icns"); -// APP.NSWorkspace().sharedWorkspace() -// .selectFile_inFileViewerRootedAtPath(file, null); - - pool.drain(); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java 2014-07-01 15:13:39.711350187 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class NSClassTest extends PooledTestCase{ - JObjC JOBJC = JObjC.getInstance(); - FoundationFramework FND = JOBJC.Foundation(); - - public void testNSClassName(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSString cname = s.className(); - String jcname = Utils.get().strings().javaString(cname); - assertEquals("NSCFString", jcname); - } - - public void testNSClassPop(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSStringClass c = s.classNSClass(); - String jdescr = Utils.get().strings().javaString(c.description()); - assertEquals("NSCFString", jdescr); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java 2014-07-01 15:13:39.995350186 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -public class NativeBufferTest extends TestCase{ - public void testSlicePtrs(){ - JObjC.getInstance(); - - NativeBuffer b = new NativeBuffer(123); - b.position(1); - NativeBuffer c = b.slice(); - assertEquals(b.bufferPtr + 1, c.bufferPtr); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java 2014-07-01 15:13:40.299350186 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -public class NativeTypeTest extends PooledTestCase{ - - private NType doParse(String type){ - NType nt = NTypeParser.parseFrom(type); - String printed = nt.toString(); - System.out.println("Original: " + type); - System.out.println("Printed.: " + printed); - assertEquals(type, printed); - return nt; - } - - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - public void testStruct(){ - doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - } - - // {IOBluetoothL2CAPChannelEvent= - // "eventType"i - // "u"(?= - // "data"{IOBluetoothL2CAPChannelDataBlock= - // "dataPtr"^v - // "dataSize"I} - // "writeRefCon"^v - // "padding"[32C]) - // "status"i} - public void testUnion(){ - doParse("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - } - - public void testUnknown(){ - doParse("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - } - - public void testEmptyStruct(){ - doParse("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testCharPtr(){ - doParse("^*"); - } - - public void doEquals(final String s){ - assertEquals(doParse(s), doParse(s)); - } - - public void testEquals(){ - doEquals("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - doEquals("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - doEquals("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - doEquals("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testMerge(){ - NType a = doParse("{_NSRect={_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=ff}}"); - NType b = doParse("{_NSRect=\"origin\"{_NSPoint=ff}{_NSSize=\"width\"f\"height\"f}}"); - NType c = NTypeMerger.inst().merge(a, b); - NType expected = doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - System.out.println("Merge results:"); - System.out.println("\ta: " + a.toString()); - System.out.println("\tb: " + b.toString()); - System.out.println("\tc: " + c.toString()); - System.out.println("\tx: " + expected.toString()); - assertEquals(expected, c); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java 2014-07-01 15:13:40.619350185 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; - -public class PooledTestCase extends TestCase { - static{ - System.loadLibrary("JObjC-tests"); - } - NSAutoreleasePool pool; - - @Override public void setUp() throws Exception { - FoundationFramework foundation = JObjC.getInstance().Foundation(); - pool = foundation.NSAutoreleasePool().alloc(); - pool.init(); - } - - @Override public void tearDown() throws Exception { - pool.drain(); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java 2014-07-01 15:13:40.923350184 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Invoke.MsgSend; - -public class SELTest extends PooledTestCase { - - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testGetBlackColor() throws Throwable { - final MacOSXFramework appKit = TestUtils.getAppKit(); - final NSClass clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor"); - final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST); - - sel.init(nativeBuffer, clazz); - sel.invoke(nativeBuffer); - - final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr); - - System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr); - assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(SELTest.class); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java 2014-07-01 15:13:41.223350183 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.io.StringWriter; - -import com.apple.jobjc.coreaudio.AudioBuffer; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSRect; - -public class StructTest extends PooledTestCase { - public void testSimpleStruct(){ - AudioBuffer b = JObjC.getInstance().CoreAudio().makeAudioBuffer(); - assertEquals(0, b.mNumberChannels()); - assertEquals(0, b.mDataByteSize()); - b.setMNumberChannels(1); - b.setMDataByteSize(3); - assertEquals(1, b.mNumberChannels()); - assertEquals(3, b.mDataByteSize()); - } - - public void testNestedStruct(){ - NSRect r = JObjC.getInstance().Foundation().makeNSRect(); - assertTrue(0f == r.size().width()); - r.size().setWidth(3f); - assertTrue(3f == r.size().width()); - assertTrue(r.size() == r.size()); - } - - public void testSTRET(){ - NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4); - assertTrue(point.x() == 3); - assertTrue(point.y() == 4); - - NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3); - assertTrue(rect.origin().x() == 0); - assertTrue(rect.origin().y() == 1); - assertTrue(rect.size().width() == 2); - assertTrue(rect.size().height() == 3); - } - - // - - private char halfByteToHex(int b){ - return (b >= 0x0 && b < 0xA) ? (char) ('0' + b) : (char) ('A' + (b-0xA)); - } - - private String byteToHexString(Byte b){ - StringWriter sw = new StringWriter(); - sw.append(halfByteToHex(b & 0xF)); - sw.append(halfByteToHex((b & 0xF0) >> 4)); - return sw.toString(); - } - - String print(Struct st){ - StringWriter sw = new StringWriter(); - st.raw.position(0); - sw.append(st.getClass().getSimpleName() + ":" + st.raw.limit() + " @ " + Long.toHexString(st.raw.bufferPtr) + " : "); - for(int i = 0; i < st.raw.limit(); i++){ - sw.append(byteToHexString(st.raw.get()) + " "); - if((i+1) % 4 == 0) - sw.append(" "); - } - System.out.println(sw.toString().trim()); - return sw.toString().trim(); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(StructTest.class); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java 2014-07-01 15:13:41.511350183 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; -import com.apple.jobjc.Invoke.MsgSendSuper; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; - -public class SubclassingTest extends PooledTestCase{ - JObjCRuntime runtime; - NativeArgumentBuffer ctx; - - @Override public void setUp() throws Exception{ - super.setUp(); - this.runtime = JObjCRuntime.getInstance(); - this.ctx = runtime.getThreadLocalState(); - - runtime.registerUserClass(MyObject.class, MyObjectClass.class); - } - - public void testClass(){ - final MyObjectClass cls = new MyObjectClass(runtime); - assertEquals(MyObject.class.getSimpleName(), UnsafeRuntimeAccess.getClassNameFor(cls)); - } - - public void testInst(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject instObj = cls.alloc(); - final MyObject retrievedObj = Subclassing.getJObjectFromIVar(UnsafeRuntimeAccess.getObjPtr(instObj)); - assertTrue(instObj == retrievedObj); - } - - public void testVoidVoidMethod(){ - final MyObject instObj = new MyObjectClass(runtime).alloc(); - - assertEquals(0, instObj.myMethodHits); - MsgSend sel = new MsgSend(runtime, "myMethod", VoidCoder.INST); - sel.init(ctx, instObj); - sel.invoke(ctx); - assertEquals(1, instObj.myMethodHits); - } - - public void testMsgSendSuper(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject obj = ((MyObject) cls.alloc()).init(); - - // direct descr - - assertEquals("foo", Utils.get().strings().javaString(obj.description())); - - // indirect (from native) descr - { - MsgSend msgSend = new MsgSend(runtime, "description", IDCoder.INST); - msgSend.init(ctx, obj); - msgSend.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // indirect (from native) descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, cls); - msgSendSuper.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // nso descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, JObjC.getInstance().Foundation().NSObject()); - msgSendSuper.invoke(ctx); - - final NSString nsod = (NSString) IDCoder.INST.pop(ctx); - String jde = Utils.get().strings().javaString(nsod); - assertEquals(jde.substring(0, 9), " 0) - js2 += jss; - return Utils.get().strings().nsString(js2); - } - - public double add_and_and(int a, long b, float c){ - return a + b + c; - } - - public NSPoint doubleIt(NSPoint p){ - System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ")."); - p.setX(p.x() * 2); - p.setY(p.y() * 2); - return p; - } - - @Override public NSString description(){ - return Utils.get().strings().nsString("foo"); - } -} - -class MyObjectClass extends NSObjectClass{ - protected MyObjectClass(String name, JObjCRuntime runtime) { - super(name, runtime); - } - - public MyObjectClass(JObjCRuntime runtime){ - this("MyObject", runtime); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/TestUtils.java 2014-07-01 15:13:41.831350182 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - - -public class TestUtils { - static MacOSXFramework getAppKit() { - return UnsafeRuntimeAccess.getFramework(new String[]{"/System/Library/Frameworks/AppKit.framework/AppKit"}); - } - - static MacOSXFramework getFoundation() { - return UnsafeRuntimeAccess.getFramework(new String[]{"/System/Library/Frameworks/Foundation.framework/Foundation"}); - } -} --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java 2014-07-01 15:13:42.135350181 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSString; - -public class UtilsTest extends PooledTestCase{ - public void testStrings(){ - String s = "fooBarBazDazzle"; - NSString ns = Utils.get().strings().nsString(s); - String t = Utils.get().strings().javaString(ns); - assertEquals(s, t); - } - - public void testThreadsPerformRunnableOnMainThread(){ - final long testThreadId = Thread.currentThread().getId(); - class Wrap{ public long x = testThreadId; } - final Wrap wrap = new Wrap(); - assertTrue(testThreadId == wrap.x); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - wrap.x = Thread.currentThread().getId(); - } - }, true); - - assertTrue(testThreadId != wrap.x); - } - - public void testThreadsPerformCallableOnMainThread() throws Exception{ - final long testThreadId = Thread.currentThread().getId(); - final long mainThreadId = Utils.get().threads().performOnMainThread(new Callable(){ - public Long call() { return Thread.currentThread().getId(); } - }); - assertTrue(testThreadId != mainThreadId); - } - - public void testThreadsPerformCallableOnMainThreadException() throws Exception{ - class FooException extends RuntimeException{} - try { - Utils.get().threads().performOnMainThread(new Callable(){ - public Object call() { throw new FooException(); } - }); - } catch (FooException e) { - return; - } - fail("Failed to catch exception."); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(UtilsTest.class); - } -} - --- old/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java 2014-07-01 15:13:42.431350180 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSDictionary; -import com.apple.jobjc.foundation.NSString; - -public class VarArgsTest extends PooledTestCase { - FoundationFramework FND = JObjC.getInstance().Foundation(); - - public void testNSString_initWithFormat(){ - String expected = "1 + 0.2 = 1.2 abracadabra"; - NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@"); - - NSString abra = Utils.get().strings().nsString("abracadabra"); - - NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra); - String actual = Utils.get().strings().javaString(nstr); - - assertEquals(expected, actual); - } - - public void testNSDictionary(){ - NSString v1 = Utils.get().strings().nsString("value1"); - NSString v2 = Utils.get().strings().nsString("value2"); - NSString k1 = Utils.get().strings().nsString("key1"); - NSString k2 = Utils.get().strings().nsString("key2"); - - NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null); - - NSString nsdescr = dict.description(); - String jdescr = Utils.get().strings().javaString(nsdescr); - - assertEquals("{\n key1 = value1;\n key2 = value2;\n}", jdescr); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(VarArgsTest.class); - } -} --- old/src/macosx/native/jobjc/src/tests/native/FunCallBench.m 2014-07-01 15:13:42.755350180 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -#include -#include - -#include "com_apple_jobjc_BenchFunCall.h" -#include - -JNIEXPORT jdouble JNICALL Java_com_apple_jobjc_BenchFunCall_jniSin -(JNIEnv *env, jclass clazz, jdouble x) -{ - return (jdouble) sin((double) x); -} - - -#include "com_apple_jobjc_BenchIDPop.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRetain -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRetain(jlong_to_ptr(x)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRelease -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRelease(jlong_to_ptr(x)); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAlloc -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong([NSString alloc]); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAllocAndRetain -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong(CFRetain([NSString alloc])); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringCached -(JNIEnv *env, jclass clazz) -{ - static jlong str = 0; - if(!str) str = ptr_to_jlong([NSString alloc]); - return str; -}