1 module options; 2 3 /* 4 * The MIT License 5 * 6 * Copyright (c) 2016-2021 DOML 7 @#$#@@ Translated by jordan4ibanez 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a copy 10 * of this software and associated documentation files (the "Software"), to deal 11 * in the Software without restriction, including without limitation the rights 12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 * copies of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 * THE SOFTWARE. 26 */ 27 28 // import std.format: format; 29 //#ifndef __GWT__ 30 //#endif 31 32 /** 33 * Utility class for reading system properties. 34 * 35 * @author Kai Burjack 36 */ 37 38 public static struct Options { 39 /** 40 * Whether certain debugging checks should be made, such as that only direct NIO Buffers are used when Unsafe is active, 41 * and a proxy should be created on calls to readOnlyView(). 42 */ 43 public static const bool DEBUG = false;//hasOption(System.getProperty("DOML.debug", "false")); 44 45 //#ifdef __HAS_UNSAFE__ 46 /** 47 * Whether <i>not</i> to use sun.misc.Unsafe when copying memory with MemUtil. 48 */ 49 public static const bool NO_UNSAFE = false;//hasOption(System.getProperty("DOML.nounsafe", "false")); 50 /** 51 * Whether to <i>force</i> the use of sun.misc.Unsafe when copying memory with MemUtil. 52 */ 53 public static const bool FORCE_UNSAFE = false; //hasOption(System.getProperty("DOML.forceUnsafe", "false")); 54 //#endif 55 56 /** 57 * Whether fast approximations of some java.lang.Math operations should be used. 58 */ 59 public static const bool FASTMATH = false;//hasOption(System.getProperty("DOML.fastmath", "false")); 60 61 /** 62 * When {@link #FASTMATH} is <code>true</code>, whether to use a lookup table for sin/cos. 63 */ 64 public static const bool SIN_LOOKUP = false;//hasOption(System.getProperty("DOML.sinLookup", "false")); 65 66 /** 67 * When {@link #SIN_LOOKUP} is <code>true</code>, this determines the table size. 68 */ 69 public static const int SIN_LOOKUP_BITS = 14;//Integer.parseInt(System.getProperty("DOML.sinLookup.bits", "14")); 70 71 //#ifndef __GWT__ 72 /** 73 * Whether to use a {@link NumberFormat} producing scientific notation output when formatting matrix, 74 * vector and quaternion components to strings. 75 */ 76 public static const bool useNumberFormat = true;// hasOption(System.getProperty("DOML.format", "true")); 77 //#endif 78 79 //#ifdef __HAS_MATH_FMA__ 80 /** 81 * Whether to try using java.lang.Math.fma() in most matrix/vector/quaternion operations if it is available. 82 * If the CPU does <i>not</i> support it, it will be a lot slower than `a*b+c` and potentially generate a lot of memory allocations 83 * for the emulation with `java.util.BigDecimal`, though. 84 */ 85 public static const bool USE_MATH_FMA = false;//hasOption(System.getProperty("DOML.useMathFma", "false")); 86 //#endif 87 88 //#ifndef __GWT__ 89 /** 90 * When {@link #useNumberFormat} is <code>true</code> then this determines the number of decimal digits 91 * produced in the formatted numbers. 92 */ 93 //#else 94 /** 95 * Determines the number of decimal digits produced in the formatted numbers. 96 */ 97 //#endif 98 public static const int numberFormatDecimals = 3;//Integer.parseInt(System.getProperty("DOML.format.decimals", "3")); 99 100 /** 101 * The {@link NumberFormat} used to format all numbers throughout all DOML classes. 102 */ 103 // public const NumberFormat NUMBER_FORMAT = decimalFormat(); 104 /* 105 private Options(){ 106 } 107 108 private static NumberFormat decimalFormat() { 109 NumberFormat df; 110 //#ifndef __GWT__ 111 if (useNumberFormat) { 112 //#endif 113 char[] prec = new char[numberFormatDecimals]; 114 Arrays.fill(prec, '0'); 115 df = new DecimalFormat(" 0." + new String(prec) + "E0;-"); 116 //#ifndef __GWT__ 117 } else { 118 df = NumberFormat.getNumberInstance(Locale.ENGLISH); 119 df.setGroupingUsed(false); 120 } 121 //#endif 122 return df; 123 } 124 125 private static boolean hasOption(String v) { 126 if (v == null) 127 return false; 128 if (v.trim().length() == 0) 129 return true; 130 return Boolean.valueOf(v).booleanValue(); 131 } 132 */ 133 }