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