--- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 = "<absolute>";
- };
- 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}}";
- };
- };
-}
--- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 = "<group>"; };
- 890FBACA0C6F781000902C32 /* JavaVM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaVM.framework; path = /System/Library/Frameworks/JavaVM.framework; sourceTree = "<absolute>"; };
- 890FBACC0C6F782C00902C32 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
- 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaNativeFoundation.framework; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework; sourceTree = "<absolute>"; };
- 896D91230CC2ED34005625F5 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = "<group>"; };
- 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 = "<group>"; };
- 89D7C9ED0CDB900E00472EA2 /* Coder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Coder.m; sourceTree = "<group>"; };
- 89D7C9EE0CDB900E00472EA2 /* Function.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Function.m; sourceTree = "<group>"; };
- 89D7C9EF0CDB900E00472EA2 /* ID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ID.m; sourceTree = "<group>"; };
- 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JObjCRuntime.m; sourceTree = "<group>"; };
- 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacOSXFramework.m; sourceTree = "<group>"; };
- 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeBuffer.h; sourceTree = "<group>"; };
- 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeBuffer.m; sourceTree = "<group>"; };
- 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeObjectLifecycleManager.m; sourceTree = "<group>"; };
- 89D7C9F50CDB900E00472EA2 /* NSClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSClass.m; sourceTree = "<group>"; };
- 89D7C9F60CDB900E00472EA2 /* SEL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SEL.m; sourceTree = "<group>"; };
- 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 = "<group>"; };
- 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeNumber.m; sourceTree = "<group>"; };
- 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeThread.m; sourceTree = "<group>"; };
- 89E437680C97A7F200C756EE /* libffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libffi.dylib; path = /usr/lib/libffi.dylib; sourceTree = "<absolute>"; };
- C5742F6B0E316EFA00093838 /* Subclassing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Subclassing.m; sourceTree = "<group>"; };
- C5D196C80DF9E43C006F9FB9 /* FFIType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFIType.m; sourceTree = "<group>"; };
- C5E454790E36729F0046D3E8 /* Invoke.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invoke.m; sourceTree = "<group>"; };
- C5F3B1370E398F8E00B771AE /* FunCallBench.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunCallBench.m; sourceTree = "<group>"; };
- 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 = "<absolute>"; };
- C5F3B2630E3AB0F300B771AE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
- EB9FD8720AEECD83008E157E /* build.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = build.xml; sourceTree = "<group>"; };
-/* 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 = "<group>";
- };
- 890FBAC90C6F77B700902C32 /* frameworks */ = {
- isa = PBXGroup;
- children = (
- 890FBACC0C6F782C00902C32 /* Foundation.framework */,
- 890FBACA0C6F781000902C32 /* JavaVM.framework */,
- 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */,
- 89E437680C97A7F200C756EE /* libffi.dylib */,
- );
- name = frameworks;
- sourceTree = "<group>";
- };
- 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 = "<group>";
- };
- 89D7CA020CDB902200472EA2 /* native-additions */ = {
- isa = PBXGroup;
- children = (
- 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */,
- 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */,
- 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */,
- );
- name = "native-additions";
- path = "src/runtime-additions/native";
- sourceTree = "<group>";
- };
- 89D7CA030CDB903000472EA2 /* products */ = {
- isa = PBXGroup;
- children = (
- 89736E5F0CE819E5008C4205 /* JObjC.jar */,
- 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */,
- );
- name = products;
- path = "src/runtime-additions/native";
- sourceTree = "<group>";
- };
- C5A9597F0E398F050057C96D /* native-tests */ = {
- isa = PBXGroup;
- children = (
- C5F3B1370E398F8E00B771AE /* FunCallBench.m */,
- );
- name = "native-tests";
- path = src/tests/native;
- sourceTree = "<group>";
- };
-/* 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 */;
-}
--- a/jdk/src/macosx/native/jobjc/README.txt Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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.
-
-<src>
-ant test
-ant bench
-BENCH_MATCH=Foo ant bench
-</src>
-
-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.
--- a/jdk/src/macosx/native/jobjc/TODOS Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/src/macosx/native/jobjc/bridgesupport.gmk Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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)
--- a/jdk/src/macosx/native/jobjc/build.xml Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,520 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-#
-# 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.
-#
-#
--->
-<project name="JObjC" default="install" basedir=".">
- <property environment="env"/>
- <echoproperties/>
-
- <target name="installhdrs">
- <echo>Nothing to do for install-headers build phase</echo>
- </target>
-
- <target name="installsrc">
- <echo>Nothing to do for install-source build phase</echo>
- </target>
-
- <property name="redirection-target-defined" value="${env.PRODUCT_NAME}"/>
-
- <target name="install" description="Redirects to the target specified in $PRODUCT_NAME">
- <fail unless="env.PRODUCT_NAME" status="-1">
- This Ant build file depends on the native Xcode project to invoke
- targets by defining $PRODUCT_NAME to specify the target.
- </fail>
-
- <echo>--- Redirecting to target "${env.PRODUCT_NAME}"</echo>
- <antcall target="${env.PRODUCT_NAME}"/>
- </target>
-
- <property name="compile.debug" value="true"/>
-
- <!-- building from the command line / xcode b&i -->
- <condition property="src" value="." else="${env.SRCROOT}">
- <not><isset property="env.SRCROOT"/></not>
- </condition>
-
- <condition property="cfg" value="Debug" else="${env.CONFIGURATION}">
- <not><isset property="env.CONFIGURATION"/></not>
- </condition>
-
- <condition property="obj" value="build/JObjC.build/${cfg}" else="${env.OBJROOT}">
- <not><isset property="env.OBJROOT"/></not>
- </condition>
-
- <condition property="dst" value="build/${cfg}" else="${env.DSTROOT}/${cfg}">
- <not><isset property="env.DSTROOT"/></not>
- </condition>
-
- <condition property="ARCHS" value="ppc i386 x86_64" else="${env.RC_ARCHS}">
- <not><isset property="env.RC_ARCHS"/></not>
- </condition>
-
- <!-- -/- -->
-
- <property name="bin" location="${obj}/bin"/>
- <property name="gendoc" location="${obj}/doc"/>
-
- <condition property="nativelib.dir" value="${dst}">
- <not><isset property="env.CONFIGURATION_BUILD_DIR"/></not>
- </condition>
- <condition property="nativelib.dir" value="${env.CONFIGURATION_BUILD_DIR}">
- <isset property="env.CONFIGURATION_BUILD_DIR"/>
- </condition>
- <property name="nativelib.file" location="${nativelib.dir}/libJObjC.dylib" />
-
- <property name="jniheaders" location="${obj}/src/jni_headers"/>
-
- <property name="core.src" location="${src}/src/core/java"/>
- <property name="core.bin" location="${bin}/core"/>
- <property name="core.jniheaders" location="${jniheaders}/core"/>
- <property name="core.nativelib.dir" location="${nativelib.dir}"/>
-
- <property name="generator.src" location="${src}/src/generator/java"/>
- <property name="generator.bin" location="${bin}/generator"/>
-
- <property name="generated.src" location="${obj}/src/jobjc"/>
- <property name="generated.bin" location="${bin}/generated"/>
-
- <property name="additions.src" location="${src}/src/runtime-additions"/>
- <property name="additions.bin" location="${bin}/additions"/>
- <property name="additions.jniheaders" location="${jniheaders}/additions"/>
- <property name="additions.nativelib.dir" location="${nativelib.dir}"/>
-
- <property name="test.src" location="${src}/src/tests/java"/>
- <property name="test.bin" location="${bin}/test"/>
- <property name="test.jniheaders" location="${jniheaders}/test"/>
- <property name="test.reports" location="${obj}/test-reports"/>
-
- <condition property="product.target_path"
- value="/System/Library/Java/Extensions"
- else="${env.INSTALL_PATH}">
- <not><isset property="env.INSTALL_PATH"/></not>
- </condition>
-
- <echo message="(Settings :src '${src}' :cfg '${cfg}' :obj '${obj}' :dst '${dst}')"/>
-
- <path id="test.lib.path.id">
- <fileset dir="/usr/share/java">
- <include name="**/*.jar"/>
- </fileset>
- </path>
-
- <property name="product.jarfile.dir" location="${obj}"/>
- <property name="product.jarfile.name" value="JObjC.jar"/>
- <property name="product.jarfile" location="${product.jarfile.dir}/${product.jarfile.name}"/>
-
- <target name="gen-pcoder" description="Generate PrimitiveCoder.java">
- <exec executable="ruby" failonerror="true">
- <arg value="${src}/run-and-write-if-okay"/>
- <arg value="${src}/src/core/PrimitiveCoder.hs"/>
- <arg value="${src}/src/core/java/com/apple/jobjc/PrimitiveCoder.java"/>
- </exec>
- </target>
-
- <target name="build-core" depends="gen-pcoder" description="Compile the core runtime classes">
- <mkdir dir="${core.bin}" />
- <!-- Compile PrimitiveCoder first to work around javac bug. -->
- <javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}"
- includes="**/PrimitiveCoder.java"
- includeantruntime="false">
- <classpath>
- <path location="${obj}/../langtools/dist/lib/classes.jar"/>
- </classpath>
- </javac>
- <javac srcdir="${core.src}" destdir="${core.bin}" source="1.5" target="1.5" debug="${compile.debug}" includeantruntime="false">
- <classpath>
- <path location="${obj}/../langtools/dist/lib/classes.jar"/>
- </classpath>
- </javac>
-
- <exec executable="/usr/bin/perl" outputproperty="core.classes" failonerror="true">
- <arg value="${src}/extract_classes.pl"/>
- <arg path="${core.bin}"/>
- </exec>
-
- <mkdir dir="${core.jniheaders}" />
- <javah destdir="${core.jniheaders}" class="${core.classes}">
- <classpath path="${core.bin}"/>
- </javah>
- </target>
-
- <target name="build-core-native" depends="build-core">
- <exec executable="xcodebuild" failonerror="true">
- <env key="CC" value=""/>
- <env key="CXX" value=""/>
- <arg value="-configuration"/>
- <arg value="${cfg}"/>
- <arg value="-target"/>
- <arg value="build-core-native"/>
- <arg value="SRCROOT=${src}"/>
- <arg value="OBJROOT=${obj}"/>
- <arg value="DSTROOT=${dst}"/>
- <arg value="TARGET_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="PROJECT_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="BUILD_DIR=${env.DSTROOT}"/>
- </exec>
- </target>
-
- <!-- macosx jdk 7 puts jobjc core classes on the bootclasspath by default -->
- <target name="build-generator" description="Compile and assemble the generator">
- <mkdir dir="${generator.bin}"/>
- <javac srcdir="${generator.src}" destdir="${generator.bin}" source="1.5" target="1.5" debug="${compile.debug}" includeantruntime="false">
- <compilerarg value="-version"/>
- <compilerarg value="-Xbootclasspath/p:${core.bin}"/>
- </javac>
- </target>
-
- <!-- Use this indirection hack to work around buildit lockup when
- running the generator. -->
- <target name="run-generator" depends="build-generator" description="Invoke the assembled generator">
- <mkdir dir="${generated.src}"/>
- <exec executable="ruby" failonerror="true">
- <arg value="${src}/rungen"/>
- <arg value="install"/>
- <arg value="${product.jarfile.name}"/>
- <arg value="${nativelib.dir}"/>
- <arg value="${obj}"/>
- <arg value="${ARCHS}"/>
- <arg value="${env.STABLE_GEN_DIR}"/>
- </exec>
- </target>
-
- <target name="run-generator-old" depends="build-generator" description="Invoke the assembled generator">
- <mkdir dir="${generated.src}"/>
- <java classname="com.apple.internal.jobjc.generator.Generator" fork="true" failonerror="true">
- <jvmarg value="-Xms128m" />
- <jvmarg value="-Xmx512m" />
- <assertions><enable/></assertions>
- <classpath>
- <path location="${core.bin}"/>
- <path location="${generator.bin}"/>
- </classpath>
- <sysproperty key="java.library.path" value="${core.nativelib.dir}"/>
- <arg value="dst=${generated.src}"/>
- </java>
- </target>
-
- <target name="build-generated" description="Build and assemble the JObjC core and all generated frameworks">
- <mkdir dir="${generated.bin}"/>
- <javac srcdir="${generated.src}" destdir="${generated.bin}" source="1.5" target="1.5" fork="yes" memoryMaximumSize="512m" debug="${compile.debug}" includeantruntime="false">
- <classpath>
- <path location="${core.bin}"/>
- </classpath>
- <compilerarg value="-version"/>
- </javac>
- </target>
-
- <target name="build-additions" depends="build-generated">
- <mkdir dir="${additions.bin}"/>
- <javac srcdir="${additions.src}" destdir="${additions.bin}" source="1.5" target="1.5" debug="${compile.debug}" includeantruntime="false">
- <classpath>
- <path location="${core.bin}"/>
- <path location="${generated.bin}"/>
- </classpath>
- <compilerarg value="-version"/>
- </javac>
-
- <exec executable="/usr/bin/perl" outputproperty="additions.classes" failonerror="true">
- <arg value="${src}/extract_classes.pl"/>
- <arg path="${additions.bin}"/>
- </exec>
-
- <mkdir dir="${additions.jniheaders}"/>
- <javah destdir="${additions.jniheaders}" class="${additions.classes}">
- <classpath>
- <path location="${core.bin}"/>
- <path location="${generated.bin}"/>
- <path location="${additions.bin}"/>
- </classpath>
- </javah>
- </target>
-
- <target name="build-additions-native">
- <exec executable="xcodebuild" failonerror="true">
- <env key="CC" value=""/>
- <env key="CXX" value=""/>
- <arg value="-configuration"/>
- <arg value="${cfg}"/>
- <arg value="-target"/>
- <arg value="build-additions-native"/>
- <arg value="SRCROOT=${src}"/>
- <arg value="OBJROOT=${obj}"/>
- <arg value="DSTROOT=${dst}"/>
- <arg value="TARGET_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="PROJECT_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="BUILD_DIR=${env.DSTROOT}"/>
- </exec>
- </target>
-
- <target name="assemble-product">
- <mkdir dir="${product.jarfile.dir}"/>
- <jar jarfile="${product.jarfile}" level="9" index="true">
- <fileset dir="${core.bin}"/>
- <fileset dir="${generated.bin}"/>
- <fileset dir="${additions.bin}"/>
- </jar>
-
- <mkdir dir="${dst}/${product.target_path}"/>
- <copy file="${product.jarfile}" toDir="${dst}/${product.target_path}" failonerror="true" verbose="true"/>
- <copy file="${nativelib.file}" toDir="${dst}/${product.target_path}" failonerror="true" verbose="true"/>
- </target>
-
- <target name="doc-core">
- <mkdir dir="${gendoc}"/>
- <javadoc destdir="${gendoc}" access="protected">
- <fileset dir="${src}/src" includes="**/*.java"/>
- </javadoc>
- </target>
-
- <target name="build-test" description="compile unit tests">
- <mkdir dir="${test.bin}"/>
- <javac srcdir="${test.src}" destdir="${test.bin}" debug="false" includeantruntime="false">
- <classpath>
- <pathelement location="${core.bin}"/>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
- <compilerarg value="-version"/>
- </javac>
-
- <exec executable="/usr/bin/perl" outputproperty="test.classes" failonerror="true">
- <arg value="${src}/extract_classes.pl"/>
- <arg path="${test.bin}"/>
- </exec>
-
- <mkdir dir="${test.jniheaders}"/>
- <javah destdir="${test.jniheaders}" class="${test.classes}">
- <classpath>
- <path location="${core.bin}"/>
- <path location="${generated.bin}"/>
- <path location="${additions.bin}"/>
- <path location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
- </javah>
- </target>
-
- <target name="build-test-installed" description="compile unit tests">
- <mkdir dir="${test.bin}"/>
- <javac srcdir="${test.src}" destdir="${test.bin}" debug="false" includeantruntime="false">
- <compilerarg value="-verbose"/>
- <classpath>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
- <compilerarg value="-version"/>
- </javac>
-
- <exec executable="/usr/bin/perl" outputproperty="test.classes" failonerror="true">
- <arg value="${src}/extract_classes.pl"/>
- <arg path="${test.bin}"/>
- </exec>
-
- <mkdir dir="${test.jniheaders}"/>
- <javah destdir="${test.jniheaders}" class="${test.classes}">
- <classpath>
- <path location="${generated.bin}"/>
- <path location="${additions.bin}"/>
- <path location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
- </javah>
- </target>
-
- <target name="build-test-native" depends="build-test">
- <exec executable="xcodebuild" failonerror="true">
- <env key="CC" value=""/>
- <env key="CXX" value=""/>
- <arg value="-configuration"/>
- <arg value="${cfg}"/>
- <arg value="-target"/>
- <arg value="build-test-native"/>
- <arg value="SRCROOT=${src}"/>
- <arg value="OBJROOT=${obj}"/>
- <arg value="DSTROOT=${dst}"/>
- <arg value="TARGET_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="PROJECT_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="BUILD_DIR=${env.DSTROOT}"/>
- </exec>
- </target>
-
- <target name="build-test-native-installed" depends="build-test-installed">
- <exec executable="xcodebuild" failonerror="true">
- <env key="CC" value=""/>
- <env key="CXX" value=""/>
- <arg value="-configuration"/>
- <arg value="${cfg}"/>
- <arg value="-target"/>
- <arg value="build-test-native"/>
- <arg value="SRCROOT=${src}"/>
- <arg value="OBJROOT=${obj}"/>
- <arg value="DSTROOT=${dst}"/>
- <arg value="TARGET_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="PROJECT_TEMP_DIR=${env.DSTROOT}"/>
- <arg value="BUILD_DIR=${env.DSTROOT}"/>
- </exec>
- </target>
-
- <target name="test" depends="build-test-native" description="run unit tests">
- <mkdir dir="${test.reports}"/>
- <junit fork="yes" printsummary="yes">
- <assertions>
- <enable/>
- </assertions>
- <jvmarg value="-server" />
-
- <sysproperty key="java.library.path" value="${nativelib.dir}" />
- <classpath>
- <pathelement location="${core.bin}"/>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- <pathelement location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
-
- <formatter type="plain"/>
-
- <batchtest fork="yes" todir="${test.reports}">
- <fileset dir="${test.src}">
- <include name="**/*Test.java"/>
- <exclude name="**/AllTests.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="test-installed" depends="build-test-native-installed" description="run unit tests">
- <mkdir dir="${test.reports}"/>
- <junit fork="yes" printsummary="yes">
- <assertions>
- <enable/>
- </assertions>
- <jvmarg value="-server" />
-
- <sysproperty key="java.library.path" value="${nativelib.dir}" />
- <classpath>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- <pathelement location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
-
- <formatter type="plain"/>
-
- <batchtest fork="yes" todir="${test.reports}">
- <fileset dir="${test.src}">
- <include name="**/*Test.java"/>
- <exclude name="**/AllTests.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
-
- <condition property="bench_match" value="*" else="${env.BENCH_MATCH}">
- <not><isset property="env.BENCH_MATCH"/></not>
- </condition>
-
- <target name="bench" depends="build-test-native" description="run benchmarks">
- <mkdir dir="${test.reports}"/>
- <junit fork="yes" printsummary="yes">
- <sysproperty key="java.library.path" value="${nativelib.dir}" />
- <classpath>
- <pathelement location="${core.bin}"/>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- <pathelement location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
-
- <jvmarg value="-Xms256m" />
- <jvmarg value="-Xmx1024m" />
- <jvmarg value="-server" />
-
- <formatter type="plain"/>
-
- <batchtest fork="yes" todir="${test.reports}">
- <fileset dir="${test.src}">
- <include name="**/Bench*${bench_match}*.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="bench-installed" depends="build-test-native-installed" description="run benchmarks">
- <mkdir dir="${test.reports}"/>
- <junit fork="yes" printsummary="yes">
- <sysproperty key="java.library.path" value="${nativelib.dir}" />
- <classpath>
- <pathelement location="${generator.bin}"/>
- <pathelement location="${generated.bin}"/>
- <pathelement location="${additions.bin}"/>
- <pathelement location="${test.bin}"/>
- </classpath>
- <classpath refid="test.lib.path.id"/>
-
- <jvmarg value="-Xms256m" />
- <jvmarg value="-Xmx1024m" />
- <jvmarg value="-server" />
-
- <formatter type="plain"/>
-
- <batchtest fork="yes" todir="${test.reports}">
- <fileset dir="${test.src}">
- <include name="**/Bench*${bench_match}*.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="clean">
- <delete dir="build"/>
- <delete dir="${obj}"/>
- <delete dir="${dst}"/>
- <delete dir="${gendoc}"/>
- <delete dir="${test.reports}"/>
- </target>
-
-
- <target name="clean-all" depends="clean,build-core,build-core-native,build-generator,run-generator,build-generated,build-additions,build-additions-native,assemble-product">
- </target>
- <target name="all" depends="build-core,build-core-native,build-generator,run-generator,build-generated,build-additions,build-additions-native,assemble-product">
- </target>
- <target name="all-test" depends="build-core,build-core-native,build-generator,run-generator,build-generated,build-additions,build-additions-native,assemble-product,test-installed">
- </target>
- <target name="clean-all-test" depends="clean,build-core,build-core-native,build-generator,run-generator,build-generated,build-additions,build-additions-native,assemble-product,test-installed">
- </target>
- <target name="all-but-gen" depends="clean,build-core,build-core-native,build-generator,build-generated,build-additions,build-additions-native,assemble-product">
- </target>
-</project>
--- a/jdk/src/macosx/native/jobjc/extract_classes.pl Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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,";
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/run-and-write-if-okay Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <<EOF
-Expects two args: EXEC and OUTPATH. First, it runs and prints
-`EXEC 2>&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
--- a/jdk/src/macosx/native/jobjc/rungen Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/src/macosx/native/jobjc/runjava Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 $@
--- a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<T> extends Coder<T>{"
-
- 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);"]
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Void> {
- protected CFType(long ptr) { super(ptr); }
- protected CFType(Pointer<?> ptr) { super(ptr.ptr); }
-
- protected ID getTollFreeBridge(JObjCRuntime runtime){
- return ID.getObjCObjectFor(runtime, super.ptr);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<T> {
- 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<Object>{
- 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<Object> {
- 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<Long> {
- 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<Pointer> {
- 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<SEL> {
- 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<Struct> {
- 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<ID>{
- 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 extends ID> 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<NSClass>{
- 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);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 + ".");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Void>{
- 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 extends ID> T getInstance(final long ptr, final JObjCRuntime runtime){
- return (T) getObjCObjectFor(runtime, ptr);
- }
-
- static <T extends ID> 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 extends ID> T createNewObjCObjectFor(final JObjCRuntime runtime, final long objPtr, final long clsPtr) {
- final Constructor<T> ctor = getConstructorForClassPtr(runtime, clsPtr);
- return (T) createNewObjCObjectForConstructor(ctor, objPtr, runtime);
- }
-
- @SuppressWarnings("unchecked")
- static <T extends ID> Constructor<T> getConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){
- final Constructor<T> cachedCtor = (Constructor<T>) constructorCache.get().get(clazzPtr);
- if(cachedCtor != null) return cachedCtor;
-
- final Class<T> clazz = getClassForClassPtr(runtime, clazzPtr);
- Constructor<T> 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<ID>) ctor);
- return ctor;
- }
-
- @SuppressWarnings("unchecked")
- static <T extends ID> Class<T> getClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){
- final String className = NSClass.getClassNameOfClass(clazzPtr);
- final Class<T> clazz = (Class<T>) runtime.getClassForNativeClassName(className);
- if(clazz == null){
- final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr);
- if(superClazzPtr != 0)
- return getClassForClassPtr(runtime, superClazzPtr);
- }
- return clazz;
- }
-
- static <T extends ID> 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 extends ID> T createNewObjCObjectForClass(final Class<T> clazz, final long objPtr, final JObjCRuntime runtime) {
- try {
- final Constructor<T> 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<LinkedHashMap<Long, Constructor>> constructorCache = new ThreadLocal<LinkedHashMap<Long, Constructor>>(){
- @Override protected LinkedHashMap<Long, Constructor> initialValue(){
- final int MAX_ENTRIES = 1000;
- final float LOAD_FACTOR = 0.75f;
- return new LinkedHashMap<Long, Constructor>((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) {
- @Override protected boolean removeEldestEntry(Map.Entry<Long, Constructor> eldest) {
- return size() > MAX_ENTRIES;
- }
- };
- }
- };
-
- static final ThreadLocal<LinkedHashMap<Long, WeakReference>> objectCache = new ThreadLocal<LinkedHashMap<Long, WeakReference>>(){
- @Override protected LinkedHashMap<Long, WeakReference> initialValue(){
- final int MAX_ENTRIES = 1000;
- final float LOAD_FACTOR = 0.75f;
- return new LinkedHashMap<Long, WeakReference>((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) {
- @Override protected boolean removeEldestEntry(Map.Entry<Long, WeakReference> eldest) {
- return size() > MAX_ENTRIES || eldest.getValue().get() == null;
- }
- };
- }
- };
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> registeredPackages = new ArrayList<String>();
-
- @SuppressWarnings("unchecked")
- Class<? extends ID> getClassForNativeClassName(final String className) {
- for (final String pkg : registeredPackages) {
- try {
- final Class<?> clazz = Class.forName(pkg + "." + className);
- if (clazz != null) return (Class<? extends ID>)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<? extends ID> clazz, Class<? extends NSClass> clazzClazz) {
- return subclassing.registerUserClass(clazz, clazzClazz);
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<T extends ID> 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<? super T> getSuperClass() {
- return new NSClass<T>(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 extends NSClass> 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 extends NSClass> T createNewObjCClassFor(final JObjCRuntime runtime, final long clsPtr) {
- final Constructor<T> ctor = getNSClassConstructorForClassPtr(runtime, clsPtr);
- return (T) createNewObjCObjectForConstructor(ctor, clsPtr, runtime);
- }
-
- @SuppressWarnings("unchecked")
- static <T extends NSClass> Constructor<T> getNSClassConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){
- final Class<T> clazz = getNSClassForClassPtr(runtime, clazzPtr);
- Constructor<T> 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 <T extends ID> Class<T> getNSClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){
- final String className = NSClass.getClassNameOfClass(clazzPtr);
- final Class<T> clazz = (Class<T>) runtime.getClassForNativeClassName(className + "Class");
- if(clazz == null){
- final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr);
- if(superClazzPtr != 0)
- return getNSClassForClassPtr(runtime, superClazzPtr);
- }
- return clazz;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<NativeArgumentBuffer> threadLocal = new ThreadLocal<NativeArgumentBuffer>();
-
- 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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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) { }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Void> {
- protected Opaque(long ptr) { super(ptr); }
- protected Opaque(Pointer<?> ptr) { super(ptr.ptr); }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <T> implements Comparable<Pointer<T>>{
- 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<T> o) {
- if(this==o || ptr==o.ptr) return 0;
- if(ptr < o.ptr) return -1;
- return 1;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<T> extends Coder<T>{
- 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<Boolean>{
- 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<Byte>{
- 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<Byte>{
- 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<Short>{
- 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<Short>{
- 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<Integer>{
- 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<Integer>{
- 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<Long>{
- 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<Long>{
- 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<Long>{
- 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<Long>{
- 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<Float>{
- 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<Double>{
- 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)); }
-
-
-
-}
-
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_:]*$");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-}
--- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 extends ID> T getJObjectFromIVar(long objPtr);
- static native void initJObjectToIVar(long objPtr, ID object);
-
- final Set<Long> registeredUserSubclasses = new HashSet<Long>();
- final JObjCRuntime runtime;
-
- Subclassing(JObjCRuntime runtime){
- this.runtime = runtime;
- }
-
- boolean registerUserClass(final Class<? extends ID> clazz, final Class<? extends NSClass> 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<String> takenSelNames = new HashSet<String>();
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/CIF.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <ffi/ffi.h>
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-#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));
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/Coder.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-#define MACOSX
-#include <ffi/ffi.h>
-#include <AppKit/AppKit.h>
-
-/*
- * 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);
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-#include <ffi/ffi.h>
-
-#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);
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/Function.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <dlfcn.h>
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-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);
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/ID.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-
-#include <objc/runtime.h>
-#include <objc/message.h>
-
-/*
- * 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;
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <ffi/ffi.h>
-#include <objc/message.h>
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-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);
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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"
-
--- a/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <dlfcn.h>
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-/*
- * 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);
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <objc/runtime.h>
-
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-/*
- * 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));
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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)
--- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <ffi/ffi.h>
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-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));
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-
-
-/*
- * 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));
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-#include <objc/message.h>
-
-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)));
-}
--- a/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <math.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <objc/runtime.h>
-#include <objc/message.h>
-
-#include <ffi/ffi.h>
-#include <sys/mman.h>
-
-#include <JavaNativeFoundation/JavaNativeFoundation.h>
-
-// 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);
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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());
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> frameworks) throws Throwable {
- System.out.println("--2-- Resolving duplicate classes:");
- final Map<String, List<Clazz>> allClasses = new HashMap<String, List<Clazz>>();
-
- for (final Framework framework : frameworks) {
- for (final Clazz clazz : framework.classes) {
- final List<Clazz> existingClazzList = allClasses.get(clazz.name);
- if(existingClazzList != null)
- existingClazzList.add(clazz);
- else
- allClasses.put(clazz.name, new ArrayList<Clazz>(Arrays.asList(clazz)));
- }
- }
-
- final Map<String, Clazz> filteredClasses = new HashMap<String, Clazz>();
- final List<List<Clazz>> dreggs = new ArrayList<List<Clazz>>();
-
- final Collection<List<Clazz>> clazzLists = allClasses.values();
- for (final List<Clazz> 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<Clazz> 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<Clazz> clazzes, final Map<String, Clazz> filteredClasses) {
- final List<Clazz> clazzesToDerive = new ArrayList<Clazz>(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<String> frameworkNameList = new ArrayList<String>(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<Clazz> clazzes, final Clazz clazz) {
- final List<String> fwNames = new ArrayList<String>(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));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<OutputFile> generateClasses(final List<Framework> frameworks) {
- final List<OutputFile> generatedClassFiles = new ArrayList<OutputFile>();
-
- generatedClassFiles.add(new RootJObjCClass(frameworks));
- for (final Framework f : frameworks) {
- f.generateClasses(generatedClassFiles);
- }
-
- return generatedClassFiles;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<OutputFile> addSourceFilesFrom(final String srcPath) {
- final List<OutputFile> outputFileList = new ArrayList<OutputFile>();
-
- final List<File> 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<File> 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<File> fileList = new ArrayList<File>();
- 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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<File> findFrameworkFilesIn(final File file) throws IOException{
- final List<File> bridgeSupportFiles = Utils.find(file, FRAMEWORK_MATCH, FRAMEWORK_PRUNE);
- System.out.println("found " + bridgeSupportFiles.size() + " frameworks");
- return bridgeSupportFiles;
- }
-
- static List<Framework> parseFrameworksFrom(final List<File> bridgeSupportFiles) {
- final List<Framework> frameworks = new ArrayList<Framework>();
-
- 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<String> alreadyWarnedDependency = new HashSet<String>();
- 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<Framework> 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));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<? extends Invoke> 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<? extends Invoke> 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<? extends Invoke> 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<? extends Invoke> 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<? extends Invoke> 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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String, String> 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<File> bridgeSupportFiles = FrameworkGenerator.findFrameworkFilesIn(new File(frameworksPath));
- final List<Framework> 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<OutputFile> 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<String, String> defaults, final String key, final String defaultValue) {
- final String value = defaults.get(key);
- if (value != null) return value;
- return defaultValue;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> frameworks) {
- for (final Framework framework : frameworks) {
- disambiguateFunctionsInFramework(framework);
- }
- }
-
- static void disambiguateFunctionsInFramework(final Framework framework) {
- for (final Function fxn : framework.functions)
- fxn.disambiguateArgs();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> originalRestrictedSet = new HashSet<String>(Arrays.asList(JAVA_KEYWORD_CONFLICTS));
-
- public static Set<String> getNewRestrictedSet() {
- return new HashSet<String>(originalRestrictedSet);
- }
-
- public static boolean isRestricted(String s){
- return originalRestrictedSet.contains(s);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <T> List<T> list(final Object...args) {
- final ArrayList<Object> list = new ArrayList<Object>(args.length);
- for (final Object arg : args) list.add(arg);
- return (List<T>)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<File> 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<String> visited = new HashSet<String>();
- final List<File> found = new ArrayList<File>();
- 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<String, String> getArgs(final String...args) {
- final Map<String, String> argMap = new HashMap<String, String>();
- 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<Framework> frameworks) {
- final Set<Framework> visited = new TreeSet<Framework>();
- final List<Framework> sorted = new ArrayList<Framework>(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<Framework> getDependencyCycle(List<Framework> frameworks) {
- @SuppressWarnings("serial")
- class FoundCycle extends Throwable{
- public final List<Framework> cycle;
- public FoundCycle(List<Framework> cycle){
- this.cycle = cycle;
- }
- };
- class Rec{
- void visit(final Framework fw, List<Framework> visited) throws FoundCycle{
- visited = new LinkedList<Framework>(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<Framework>()); }}
- 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);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> written = new HashSet<String>();
- 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; }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> binPaths = Fp.map(new Map1<File,String>(){
- 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<Struct>(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<Constant,Boolean>(){ public Boolean apply(Constant a) {
- return a.name.equals(konst.name);
- }}, new ArrayList<Constant>(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<Clazz> sortedClasses = new TreeSet<Clazz>(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("\"", "\\\"");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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; }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> written = new HashSet<String>();
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String, NativeObjectLifecycleManager> nolmForClass =
- new TreeMap<String, NativeObjectLifecycleManager>();
- 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<String> written = new HashSet<String>();
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<MixedEncodingDescriptor> coderDescs;
-
- public MixedPrimitiveCoderClassFile(final Collection<MixedEncodingDescriptor> 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() + ";");
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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}");
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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());
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> frameworks;
-
- public RootJObjCClass(final List<Framework> 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"));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Field,String>(){
- 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) {
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Function>{
- public String javaName;
-
- public Arg(final Node node, final Function parent) {
- super(node, parent);
- javaName = name;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> 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<OutputFile> generatedClassFiles) {
- generatedClassFiles.add(new CFTypeClassFile(this));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<OutputFile> generatedClassFiles) {
- generatedClassFiles.add(new CategoryClassFile(this));
- generatedClassFiles.add(new CategoryClassClassFile(this));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> implements OutputFileGenerator {
- private final Map<String, Method> instanceMethodsByName = new HashMap<String, Method>();
- private final Map<String, Method> classMethodsByName = new HashMap<String, Method>();
-
- public final List<Method> classMethods;
- public final List<Method> instanceMethods;
-
- public final List<Clazz> subClassers = new ArrayList<Clazz>(0);
- public Clazz superClass;
-
- public Clazz(String name, List<Method> classMethods, List<Method> 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<Method>();
- this.instanceMethods = new ArrayList<Method>();
-
- 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<String, Clazz> allClasses) throws Throwable {
- superClass = SuperClassExtractor.getSuperClassFor(name, nativeFramework, allClasses);
- }
-
- public void disambiguateMethods() {
- disambiguateMethods(instanceMethods, instanceMethodsByName);
- disambiguateMethods(classMethods, classMethodsByName);
- }
-
- private void disambiguateMethods(final List<Method> methods, final Map<String, Method> methodMap) {
- final Set<String> existingMethodNames = RestrictedKeywords.getNewRestrictedSet();
- for (final Method method : methods) {
- method.disambiguateNameAndArgs(this, existingMethodNames);
- methodMap.put(method.javaName, method);
- }
- }
-
- public void generateClasses(final List<OutputFile> 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());
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- public Constant(final Node node, final Framework parent) {
- super(node, parent);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <P extends Element<?>> implements Comparable<Element<?>>{
- 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 <P extends Element<?>, T extends Element<P>> List<T> getNodesFor(final Node parentNode, final String selection, final Class<T> clazz, final P parent) {
- Constructor<T> 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<T> nodes = new ArrayList<T>();
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<P extends Element<?>> extends Element<P> {
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Element<?>> implements OutputFileGenerator {
- public final String path;
- public final String pkg;
- public final List<File> 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<Clazz> classes;
- public List<Struct> structs;
- public List<CFType> cfTypes;
- public List<Opaque> opaques;
- public List<Constant> constants;
- public List<StringConstant> stringConstants;
- public List<NativeEnum> enums;
- public List<Function> functions;
- public List<FunctionAlias> functionAliases;
- public List<InformalProtocol> informalProtocols;
- public List<Protocol> protocols;
- public List<Category> categories;
- public List<FrameworkDependency> dependencies;
-
- public static class FrameworkDependency extends Element<Framework>{
- 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<Protocol>();
- categories = new ArrayList<Category>();
- }
-
- private static List<File> findBinaries(final String rootPath, final String name){
- List<File> bins = new ArrayList<File>(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<Framework> frameworks) {
- // Parse
- dependencies = getNodesFor(rootNode, "depends_on", FrameworkDependency.class, this);
- // Resolve
- for(final FrameworkDependency dep : dependencies)
- dep.object = Fp.find(new Map1<Framework,Boolean>(){
- 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<Clazz>(getNodesFor(rootNode, "class", Clazz.class, this));
- classes = Fp.filterSet(new Map1<Clazz,Boolean>(){
- 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<String, Clazz> allClasses) throws Throwable {
- load();
- for (final Clazz clazz : classes)
- clazz.resolveSuperClass(nativeFramework, allClasses);
- }
-
- public void generateClasses(final List<OutputFile> generatedClassFiles) {
- generatedClassFiles.add(new FrameworkClassFile(this));
-
- final List<List<OutputFileGenerator>> generatorLists =
- Utils.list(new ArrayList<Clazz>(classes), structs, cfTypes, opaques, categories);
- for (final List<OutputFileGenerator> 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<Struct,Boolean>(){
- public Boolean apply(Struct a) {
- return stname.equals(a.name);
- }}, structs);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- public final boolean variadic;
- public final List<Arg> 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<Arg>();
-
- 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<String> 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);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- public FunctionAlias(final Node node, final Framework parent) {
- super(node, parent);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- public InformalProtocol(final Node node, final Framework parent) {
- super(node, parent);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String> existingMethodNames) {
- javaName = getDisambiguatedNameFor(parentClazz, javaName, existingMethodNames);
- disambiguateArgs();
- }
-
- private String getDisambiguatedNameFor(final Clazz parentClazz, final String proposedName, final Set<String> 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(".+\\.", ""));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- 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<String,Boolean>(){
- 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); }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> implements OutputFileGenerator {
- public Opaque(final Node node, final Framework parent) {
- super(node, getAttr(node, "name"), parent);
- }
-
- public void generateClasses(final List<OutputFile> generatedClassFiles) {
- generatedClassFiles.add(new OpaqueClassFile(this));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/OutputFileGenerator.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<OutputFile> generatedClassFiles);
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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) {
-
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ReturnValue.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Function>{
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> {
- public final String value;
-
- public StringConstant(final Node node, final Framework parent) {
- super(node, parent);
- this.value = getAttr(node, "value");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> implements OutputFileGenerator {
- public final List<Field> 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 <field> 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<NField,NField,Field>(){
- 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<OutputFile> generatedClassFiles) {
- generatedClassFiles.add(new StructClassFile(this));
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/TypeElement.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<P extends Element<?>> extends ElementWType<P> {
- 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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()"; }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Pair<NType,NType>, ComplexCoderDescriptor> cache = new HashMap<Pair<NType,NType>, ComplexCoderDescriptor>();
- static Set<MixedEncodingDescriptor> mixedEncodingDescriptors = new TreeSet<MixedEncodingDescriptor>();
-
- public static Set<MixedEncodingDescriptor> getMixedEncoders() { return mixedEncodingDescriptors; }
-
- public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) {
- Pair<NType,NType> 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()); }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Character, PrimitiveCoderDescriptor> descriptors = new HashMap<Character, PrimitiveCoderDescriptor>();
-
- 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; }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 extends " + getJavaTypeName() + "> 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 extends " + super.getJavaReturnTypeName() + "> 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 ' ';
- }
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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:
- *
- * <pre>
- * 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<NField>
- * 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))))))
- * </pre>
- */
-public abstract class NType implements Comparable<NType>{
- public final Map<Width, Integer> sizeof;
-
- public NType(Map<Width, Integer> sizeof) {
- this.sizeof = sizeof;
- }
-
- public NType(){
- this(new HashMap<Width, Integer>());
- }
-
- 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<Character> 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<Character, NPrimitive> cache = new HashMap<Character, NPrimitive>();
- 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<Width,Integer> offset;
- public final String name;
- public final NType type;
-
- public NField(String name, NType type, Map<Width,Integer> 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<NField> fields;
-
- public NStruct(String name, List<NField> fields, Map<Width,Integer> sizeof){
- super(sizeof);
- QA.nonNull(name, fields);
- this.name = name;
- this.fields = fields;
- }
-
- public NStruct(String name, List<NField> 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<NField> fields){
- super(concreteName, fields);
- assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields);
- }
-
- public NUnion(String name, List<NField> fields, Map<Width,Integer> sizeof) {
- super(name, fields, sizeof);
- assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields);
- }
-
- public static final Fp.Map1<NField,Boolean> hasZeroOffsets = new Fp.Map1<NField,Boolean>(){
- public Boolean apply(NField a) {
- for(int i : a.offset.values())
- if(i != 0)
- return false;
- return true;
- }};
- public static final Fp.Map1<NField,NField> zeroOffsets = new Fp.Map1<NField,NField>(){
- public NField apply(NField a) {
- Map<Width,Integer> 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;}
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Type>{
- 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<String, Type> exceptions;
- static {
- exceptions = new HashMap<String, Type>();
- 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 <A, B..." and sometimes it's "id<A,B..."
- public static String cleanName(String name){ return name == null ? null : name.replaceAll("\\s+", ""); }
-
- // HACK BS bug where NSRect has inconsistent definitions in the metadata
- // Methods return NTypes created according to the correct definitions below:
- //
- // {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}} *** 32-bit
- // {CGRect="origin"{CGPoint="x"d"y"d}"size"{CGSize="width"d"height"d}} *** 64-bit
-
- private static NType getCGRectType() {
- List<NField> fields = new ArrayList<NField>();
- fields.add(new NField("origin", getCGPointType()));
- fields.add(new NField("size", getCGSizeType()));
- return new NStruct("CGRect", fields);
- }
-
- private static NType getNSRectType() {
- List<NField> fields = new ArrayList<NField>();
- fields.add(new NField("origin", getNSPointType()));
- fields.add(new NField("size", getNSSizeType()));
- return new NStruct("_NSRect", fields);
- }
-
- private static NType getCGPointType() {
- List<NField> fields = new ArrayList<NField>();
- 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<NField> fields = new ArrayList<NField>();
- 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<NField> fields = new ArrayList<NField>();
- 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<NField> fields = new ArrayList<NField>();
- fields.add(new NField("width", new NPrimitive('f')));
- fields.add(new NField("height", new NPrimitive('f')));
- return new NStruct("_NSSize", fields);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String, Type> typesByName = new HashMap<String, Type>();
- 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<Pair<NType,NType>, Type> typesByNTypes = new HashMap<Pair<NType,NType>, Type>();
- public Type getTypeByNTypes(Pair<NType,NType> pair) { return typesByNTypes.get(pair); }
- public void putTypeByNTypes(Pair<NType,NType> pair, Type type) { if(pair!=null) typesByNTypes.put(pair, type); }
-
- private final Map<String, Clazz> classesByName = new HashMap<String, Clazz>();
- private final Map<String, Struct> structsByName = new HashMap<String, Struct>();
- private final Map<String, CFType> cfTypesByName = new HashMap<String, CFType>();
- private final Map<String, Opaque> opaquesByName = new HashMap<String, Opaque>();
-
- public void load(final List<Framework> 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<Clazz> 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<Type> unknownTypes = new TreeSet<Type>();
- public Set<Type> getUnknownTypes() { return unknownTypes; }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Type,JType> cache = new CacheMap<Type,JType>();
- public JType getJTypeFor(final Type type){
- return cache.get(type, new Map0<JType>(){
- 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.
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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> 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> 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<A>{
- 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<A> extends Maybe<A>{
- @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<A> extends Maybe<A>{
- 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<A>{
- 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>{ A apply(); }
- public static interface Map1<A,B>{ B apply(final A a); }
- public static interface Map2<A,B,C>{ C apply(final A a, final B b); }
-
- public static class CacheMap<K extends Comparable<K>,V>{
- private Map<K,V> cache = new TreeMap<K,V>();
- public V get(K key, Map0<V> create){
- if(cache.containsKey(key)) return cache.get(key);
- V value = create.apply();
- cache.put(key, value);
- return value;
- }
- }
-
- public static class Curry2to1<A,B,C> implements Map1<B,C>{
- private Map2<A,B,C> target; private A a;
- public Curry2to1(Map2<A, B, C> targett, A aa) { target = targett; a = aa; }
- public C apply(B b) { return target.apply(a, b); }
- }
-
- // Tuple
- public static class Pair <A,B> implements Comparable<Pair<A,B>>{
- 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<A, B> o){ return toString().compareTo(o.toString()); }
- }
-
- /**
- * @return [fn(x) | x <- items]
- */
- public static <A,B> List<B> map(Map1<A,B> fn, final Collection<A> xs){
- ArrayList<B> rs = new ArrayList<B>(xs.size());
- for(A x : xs) rs.add(fn.apply(x));
- return rs;
- }
-
- public static <A,B,C> List<C> map2(Map2<A,B,C> fn, final Collection<A> as, final Collection<B> bs){
- assert as.size() == bs.size();
- ArrayList<C> cs = new ArrayList<C>(as.size());
- Iterator<A> aiter = as.iterator();
- Iterator<B> 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 <A> void each(Map1<A,?> fn, final Collection<A> xs){
- for(A x : xs) fn.apply(x);
- }
-
- /**
- * @return [x | x <- items, take(x)]
- */
- public static <A> List<A> filter(Map1<A,Boolean> take, final Collection<A> xs){
- List<A> rs = new ArrayList<A>(xs.size());
- for(A x : xs) if(take.apply(x)) rs.add(x);
- return rs;
- }
-
- /**
- * @return [x | x <- items, take(x)]
- */
- public static <A> Set<A> filterSet(Map1<A,Boolean> take, final Collection<A> xs){
- Set<A> rs = new HashSet<A>(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> X find(Map1<X,Boolean> take, final Collection<X> xs){
- for(X x : xs) if(take.apply(x)) return x;
- return null;
- }
-
- public static <A,B> A foldl(final Map2<A,B,A> f, A a, final Collection<B> xs){
- for(B b : xs) a = f.apply(a, b);
- return a;
- }
-
- /**
- * @return All x : p(x) == true
- */
- public static <A> boolean all(Map1<A,Boolean> p, Collection<A> xs) {
- for(A x : xs) if(!p.apply(x)) return false;
- return true;
- }
-
- /**
- * @return Any x : p(x) == true
- */
- public static <A> boolean any(Map1<A,Boolean> p, Collection<A> xs) {
- for(A x : xs) if(p.apply(x)) return true;
- return false;
- }
-
- public static <A> String join(final String sep, final Collection<A> xs) {
- if(xs.size() == 0) return "";
- if(xs.size() == 1) return xs.iterator().next().toString();
- return Fp.foldl(new Fp.Map2<String, A, String>(){
- 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<Integer,Integer,Integer> operatorPlus = new Map2<Integer, Integer, Integer>(){
- public Integer apply(Integer a, Integer b) { return (int)a + (int)b;}
- };
-
- public static int sum(Collection<Integer> xs){ return foldl(operatorPlus, 0, xs); }
-
- public static <A> List<A> append(Collection<A> xs, Collection<A> ys) {
- List<A> rs = new ArrayList<A>(xs.size() + ys.size());
- rs.addAll(xs);
- rs.addAll(ys);
- return rs;
- }
-
- public static <A> Set<A> appendSet(Collection<A> xs, Collection<A> ys) {
- Set<A> rs = new HashSet<A>(xs.size() + ys.size());
- rs.addAll(xs);
- rs.addAll(ys);
- return rs;
- }
-
- public static <K,V> Map<K,V> 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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Object> args = new ArrayList<Object>();
- 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<String> mods = new TreeSet<String>();
- 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<String> jdoc = new ArrayList<String>();
- public Set<String> attrs = new TreeSet<String>();
- public Set<String> mods = new TreeSet<String>();
- public String type;
- public String name;
- public List<Object> args = new ArrayList<Object>();
- public List<Object> body = new ArrayList<Object>();
-
- 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();
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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:
- *<pre>
- * 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}}
- *</pre>
- */
-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<String> 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<Width,Integer> mergeSizeOf(Map<Width,Integer> a, Map<Width,Integer> b) throws MergeFailed{
- return mergeMap(a, b);
- }
-
- public Map<Width,Integer> mergeOffset(Map<Width,Integer> a, Map<Width,Integer> 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<NField> fields = Fp.map2(new Map2<NField,NField,NField>(){
- 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(); }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String, NType> cached = new HashMap<String, NType>();
- 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<NTypeParser> PARSERS = new ArrayList<NTypeParser>(
- 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<NStruct.NField> fields = new ArrayList<NStruct.NField>();
- 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<NStruct.NField> 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<NStruct.NField> 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<Character> 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);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 "?"; }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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("}");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/QA.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> fws){
- try {
- _resolve(fws);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void _resolve(final Collection<Framework> 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<String,Object>(){
- public Object apply(String ln) {
- try {
- processLine(ln, fws, width);
- return null;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- }
- }
- }
-
- static Set<String> alwaysHeaders_shared = new TreeSet<String>(Arrays.asList(
- "<Cocoa/Cocoa.h>",
- "\"/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/HIToolbox.h\""));
- static Map<Width,Set<String>> alwaysHeaders = Fp.litMap(
- Width.W32, alwaysHeaders_shared,
- Width.W64, alwaysHeaders_shared);
-
- static Set<String> bannedHeaders_shared = new TreeSet<String>(Arrays.asList(
- "NSJavaSetup.h", "IMKInputController.h", "NSSimpleHorizontalTypesetter.h", "NSSpellServer.h", "IMKServer.h", "IKImageBrowserCell.h"));
- static Map<Width,Set<String>> 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<Framework> 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<Framework> 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<iostream>");
- 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<String,Object> 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<Width,String> 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<String> always = alwaysHeaders.get(arch);
- Collection<String> 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,B> 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<File> getHeaders(Framework fw) throws Exception {
- String hpath = fw.path + "/Headers";
- return Utils.find(new File(hpath), "^.*\\.h$", "");
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Framework> 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<String,Object>(){
- 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<Framework> fws, final Width arch) throws Exception{
- File tempfile = File.createTempFile("JObjC-SORBB-" + arch + "-", ".mm");
- PrintWriter out = new PrintWriter(new FileWriter(tempfile));
-
- out.println("#include<iostream>");
- 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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<String, Clazz> allClasses) throws Throwable {
- final NSClass<ID> nativeClass = new NSClass<ID>(className, nativeFramework.getRuntime());
- final NSClass<? extends ID> 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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<? extends ID> 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<ID> getNSClass(final MacOSXFramework framework, final String name) {
- return new NSClass<ID>(name, framework.getRuntime());
- }
-
- public static long getObjPtr(final ID obj) {
- return obj.ptr;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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> V performCallableOnMainThread(final Callable<V> 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> V performOnMainThread(final Callable<V> callable) throws Exception{
- return performCallableOnMainThread(callable);
- }
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-
-/*
- * 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));
-}
--- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-
-/*
- * 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));
-}
--- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <AppKit/AppKit.h>
-#import <JavaNativeFoundation/JavaNativeFoundation.h>
-
-
-@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
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
- }}
- );
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }}
- );
- }
-
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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());
- }
- }}
- );
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }});
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<? extends ID> 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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), "<MyObject");
- }
- }
-
- public void testPerformSelector(){
- final MyObject instObj = new MyObjectClass(runtime).alloc();
-
- assertEquals(0, instObj.myMethodHits);
- instObj.performSelector(new SEL("myMethod"));
- assertEquals(1, instObj.myMethodHits);
-
- instObj.performSelectorOnMainThread_withObject_waitUntilDone(
- new SEL("myMethod"), null, true);
- assertEquals(2, instObj.myMethodHits);
- }
-
- public void testVoidIntMethod(){
- final MyObject instObj = new MyObjectClass(runtime).alloc();
-
- MsgSend sel2 = new MsgSend(runtime, "intMethod", SIntCoder.INST);
- sel2.init(ctx, instObj);
- sel2.invoke(ctx);
- int ret = SIntCoder.INST.popInt(ctx);
- assertEquals(3, ret);
- }
-
- public void testStructStructMethod(){
- final MyObject instObj = new MyObjectClass(runtime).alloc();
-
- NSPoint p = JObjC.getInstance().Foundation().NSMakePoint(3, 3);
-
- MsgSend sel2 = new MsgSend(runtime, "doubleIt:", p.getCoder(), p.getCoder());
- sel2.init(ctx, instObj);
- p.getCoder().push(ctx, p);
- sel2.invoke(ctx, p);
-
- assertEquals(6.0, p.x());
- }
-
- public void testNSStringNSStringMethod(){
- final MyObject instObj = new MyObjectClass(runtime).alloc();
-
- final NSString orig = Utils.get().strings().nsString("foobar");
- final String expected = "foobarfoobarfoobar";
-
- final MsgSend sel = new MsgSend(runtime, "stringTimesThree:", IDCoder.INST, IDCoder.INST);
- sel.init(ctx, instObj);
- IDCoder.INST.push(ctx, orig);
- sel.invoke(ctx);
- NSString ret = (NSString) IDCoder.INST.pop(ctx);
- assertEquals(expected, Utils.get().strings().javaString(ret));
- }
-
- public void testDoubleIntLongMethod(){
- final MyObject instObj = new MyObjectClass(runtime).alloc();
-
- final int arg1 = 3;
- final long arg2 = 4;
- final float arg3 = 5.5F;
- final double expected = 12.5D;
-
- final MsgSend sel = new MsgSend(runtime, "add:and:and:", DoubleCoder.INST,
- SIntCoder.INST, SLongLongCoder.INST, FloatCoder.INST);
- sel.init(ctx, instObj);
- SIntCoder.INST.push(ctx, arg1);
- SLongLongCoder.INST.push(ctx, arg2);
- FloatCoder.INST.push(ctx, arg3);
- sel.invoke(ctx);
- final double ret = DoubleCoder.INST.pop(ctx);
- assertEquals(expected, ret);
- }
-
- public static void main(String[] args){
- junit.textui.TestRunner.run(SubclassingTest.class);
- }
-}
-
-class MyObject extends NSObject{
- public MyObject(long objPtr, JObjCRuntime runtime) {
- super(objPtr, runtime);
- }
-
- public int myMethodHits = 0;
-
- public void myMethod(){
- myMethodHits++;
- }
-
- public int intMethod(){
- return 3;
- }
-
- public NSString stringTimesThree(NSString nss){
- int count = 3;
- String jss = Utils.get().strings().javaString(nss);
- String js2 = "";
- while(count-- > 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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/TestUtils.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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"});
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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<Long>(){
- 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<Object>(){
- 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);
- }
-}
-
--- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
- }
-}
--- a/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m Wed Jul 02 17:03:47 2014 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 <JavaNativeFoundation/JavaNativeFoundation.h>
-#include <Cocoa/Cocoa.h>
-
-#include "com_apple_jobjc_BenchFunCall.h"
-#include <math.h>
-
-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;
-}