--- old/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java 2014-07-01 15:13:32.339350206 +0100 +++ /dev/null 2014-06-03 15:57:55.089376995 +0100 @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.apple.internal.jobjc.generator.utils; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Merges two NTypes. All merge does is fill out missing information. It doesn't choose the larger primitive when there's a conflict or anything like that. - * - * Example: - *
- * a: {_NSRect={_NSPoint="x"f"y"f}"size"{_NSSize=ff}} - * b: {_NSRect="origin"{_NSPoint=ff}{_NSSize="width"f"height"f}} - * c: {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}} - *- */ -public class NTypeMerger { - public static class MergeFailed extends RuntimeException{ - public MergeFailed(String reason, Object a, Object b){ - super(reason - + " -- (" + a.getClass().getSimpleName() + ") a: " + a - + " -- (" + b.getClass().getSimpleName() + ") b: " + b); - } - } - - private static NTypeMerger INST = new NTypeMerger(); - public static NTypeMerger inst(){ return INST; } - - /** - * Merge a and b. - */ - public NType merge(NType a, NType b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(a==null && b==null) return null; - if(a.equals(b)) return a; - try { - return Dispatcher.dispatch(getClass(), this, "accept", a, b); - } catch (NoSuchMethodException e) { - throw new MergeFailed("a and b are of different NType", a, b); - } - } - - private static Collection