1 /* 2 * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 * 25 */ 26 27 package jdk.internal.clang; 28 29 import java.util.HashMap; 30 import java.util.Map; 31 import java.util.NoSuchElementException; 32 import static jdk.internal.clang.libclang.Index_h.*; 33 34 public enum PrintingPolicyProperty { 35 Indentation(CXPrintingPolicy_Indentation()), 36 SuppressSpecifiers(CXPrintingPolicy_SuppressSpecifiers()), 37 SuppressTagKeyword(CXPrintingPolicy_SuppressTagKeyword()), 38 IncludeTagDefinition(CXPrintingPolicy_IncludeTagDefinition()), 39 SuppressScope(CXPrintingPolicy_SuppressScope()), 40 SuppressUnwrittenScope(CXPrintingPolicy_SuppressUnwrittenScope()), 41 SuppressInitializers(CXPrintingPolicy_SuppressInitializers()), 42 ConstantArraySizeAsWritten(CXPrintingPolicy_ConstantArraySizeAsWritten()), 43 AnonymousTagLocations(CXPrintingPolicy_AnonymousTagLocations()), 44 SuppressStrongLifetime(CXPrintingPolicy_SuppressStrongLifetime()), 45 SuppressLifetimeQualifiers(CXPrintingPolicy_SuppressLifetimeQualifiers()), 46 SuppressTemplateArgsInCXXConstructors(CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors()), 47 Bool(CXPrintingPolicy_Bool()), 48 Restrict(CXPrintingPolicy_Restrict()), 49 Alignof(CXPrintingPolicy_Alignof()), 50 UnderscoreAlignof(CXPrintingPolicy_UnderscoreAlignof()), 51 UseVoidForZeroParams(CXPrintingPolicy_UseVoidForZeroParams()), 52 TerseOutput(CXPrintingPolicy_TerseOutput()), 53 PolishForDeclaration(CXPrintingPolicy_PolishForDeclaration()), 54 Half(CXPrintingPolicy_Half()), 55 MSWChar(CXPrintingPolicy_MSWChar()), 56 IncludeNewlines(CXPrintingPolicy_IncludeNewlines()), 57 MSVCFormatting(CXPrintingPolicy_MSVCFormatting()), 58 ConstantsAsWritten(CXPrintingPolicy_ConstantsAsWritten()), 59 SuppressImplicitBase(CXPrintingPolicy_SuppressImplicitBase()), 60 FullyQualifiedName(CXPrintingPolicy_FullyQualifiedName()), 61 LastProperty(CXPrintingPolicy_LastProperty()); 62 63 private final int value; 64 65 PrintingPolicyProperty(int value) { 66 this.value = value; 67 } 68 69 public int value() { 70 return value; 71 } 72 73 private final static Map<Integer, PrintingPolicyProperty> lookup; 74 75 static { 76 lookup = new HashMap<>(); 77 for (PrintingPolicyProperty e: PrintingPolicyProperty.values()) { 78 lookup.put(e.value(), e); 79 } 80 } 81 82 public final static PrintingPolicyProperty valueOf(int value) { 83 PrintingPolicyProperty x = lookup.get(value); 84 if (null == x) { 85 throw new NoSuchElementException("Invalid PrintingPolicyProperty value: " + value); 86 } 87 return x; 88 } 89 }