code
stringlengths
3
10M
language
stringclasses
31 values
module cucumber.keywords; import std.string; struct Match { string reg; ulong line; this(in string reg, in ulong line = __LINE__) { this.reg = reg; this.line = line; } } alias Given = Match; alias When = Match; alias Then = Match; alias And = Match; alias But = Match; string stripCucumberKeywords(string str) { string stripImpl(string str, in string keyword) { import std.array; str = str.stripLeft; if(str.startsWith(keyword)) { return std.array.replace(str, keyword, ""); } else { return str; } } foreach(keyword; ["Given", "When", "Then", "And", "But"]) { str = stripImpl(str, keyword); } return str.stripLeft; }
D
/* * Hello Object DLL Self-Registering Server * Heavily modified from: */ /* * SELFREG.CPP * Server Self-Registrtation Utility, Chapter 5 * * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved * * Kraig Brockschmidt, Microsoft * Internet : [email protected] * Compuserve: >INTERNET:[email protected] */ import core.stdc.stdio; import core.stdc.stdlib; import core.stdc.string; import std.string; import core.sys.windows.windows; import core.sys.windows.com; import chello; // This class factory object creates Hello objects. class CHelloClassFactory : ComObject, IClassFactory { public: this() { printf("CHelloClassFactory()\n"); } ~this() { printf("~CHelloClassFactory()"); } extern (Windows) : // IUnknown members override HRESULT QueryInterface(const (IID)*riid, LPVOID *ppv) { printf("CHelloClassFactory.QueryInterface()\n"); if (IID_IUnknown == *riid) { printf("IUnknown\n"); *ppv = cast(void*) cast(IUnknown) this; } else if (IID_IClassFactory == *riid) { printf("IClassFactory\n"); *ppv = cast(void*) cast(IClassFactory) this; } else { *ppv = null; return E_NOINTERFACE; } AddRef(); return NOERROR; } // IClassFactory members override HRESULT CreateInstance(IUnknown pUnkOuter, IID*riid, LPVOID *ppvObj) { CHello pObj; HRESULT hr; printf("CHelloClassFactory.CreateInstance()\n"); *ppvObj = null; hr = E_OUTOFMEMORY; // Verify that a controlling unknown asks for IUnknown if (null !is pUnkOuter && memcmp(&IID_IUnknown, riid, IID.sizeof)) return CLASS_E_NOAGGREGATION; // Create the object passing function to notify on destruction. pObj = new CHello(pUnkOuter, &ObjectDestroyed); if (!pObj) return hr; if (pObj.Init()) { hr = pObj.QueryInterface(riid, ppvObj); } // Kill the object if initial creation or Init failed. if (FAILED(hr)) delete pObj; else g_cObj++; return hr; } HRESULT LockServer(BOOL fLock) { printf("CHelloClassFactory.LockServer(%d)\n", fLock); if (fLock) g_cLock++; else g_cLock--; return NOERROR; } }; // Count number of objects and number of locks. ULONG g_cObj =0; ULONG g_cLock=0; import core.sys.windows.dll; HINSTANCE g_hInst; extern (Windows): BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { switch (ulReason) { case DLL_PROCESS_ATTACH: g_hInst = hInstance; dll_process_attach( hInstance, true ); printf("ATTACH\n"); version(CRuntime_DigitalMars) _fcloseallp = null; // https://issues.dlang.org/show_bug.cgi?id=1550 break; case DLL_PROCESS_DETACH: printf("DETACH\n"); dll_process_detach( hInstance, true ); break; case DLL_THREAD_ATTACH: dll_thread_attach( true, true ); printf("THREAD_ATTACH\n"); break; case DLL_THREAD_DETACH: dll_thread_detach( true, true ); printf("THREAD_DETACH\n"); break; default: assert(0); } return true; } /* * DllGetClassObject * * Purpose: * Provides an IClassFactory for a given CLSID that this DLL is * registered to support. This DLL is placed under the CLSID * in the registration database as the InProcServer. * * Parameters: * clsID REFCLSID that identifies the class factory * desired. Since this parameter is passed this * DLL can handle any number of objects simply * by returning different class factories here * for different CLSIDs. * * riid REFIID specifying the interface the caller wants * on the class object, usually IID_ClassFactory. * * ppv LPVOID * in which to return the interface * pointer. * * Return Value: * HRESULT NOERROR on success, otherwise an error code. */ HRESULT DllGetClassObject(CLSID*rclsid, IID*riid, LPVOID *ppv) { HRESULT hr; CHelloClassFactory pObj; printf("DllGetClassObject()\n"); if (CLSID_Hello != *rclsid) return E_FAIL; pObj = new CHelloClassFactory(); if (!pObj) return E_OUTOFMEMORY; hr = pObj.QueryInterface(riid, ppv); if (FAILED(hr)) delete pObj; return hr; } /* * Answers if the DLL can be freed, that is, if there are no * references to anything this DLL provides. * * Return Value: * BOOL true if nothing is using us, false otherwise. */ HRESULT DllCanUnloadNow() { SCODE sc; printf("DllCanUnloadNow()\n"); // Any locks or objects? sc = (0 == g_cObj && 0 == g_cLock) ? S_OK : S_FALSE; return sc; } /* * Instructs the server to create its own registry entries * * Return Value: * HRESULT NOERROR if registration successful, error * otherwise. */ HRESULT DllRegisterServer() { char[128] szID; char[128] szCLSID; char[512] szModule; printf("DllRegisterServer()\n"); // Create some base key strings. StringFromGUID2(&CLSID_Hello, cast(LPOLESTR) szID, 128); unicode2ansi(szID.ptr); strcpy(szCLSID.ptr, "CLSID\\"); strcat(szCLSID.ptr, szID.ptr); // Create ProgID keys SetKeyAndValue("Hello1.0", null, "Hello Object"); SetKeyAndValue("Hello1.0", "CLSID", szID.ptr); // Create VersionIndependentProgID keys SetKeyAndValue("Hello", null, "Hello Object"); SetKeyAndValue("Hello", "CurVer", "Hello1.0"); SetKeyAndValue("Hello", "CLSID", szID.ptr); // Create entries under CLSID SetKeyAndValue(szCLSID.ptr, null, "Hello Object"); SetKeyAndValue(szCLSID.ptr, "ProgID", "Hello1.0"); SetKeyAndValue(szCLSID.ptr, "VersionIndependentProgID", "Hello"); SetKeyAndValue(szCLSID.ptr, "NotInsertable", null); GetModuleFileNameA(g_hInst, szModule.ptr, szModule.length); SetKeyAndValue(szCLSID.ptr, "InprocServer32", szModule.ptr); return NOERROR; } /* * Purpose: * Instructs the server to remove its own registry entries * * Return Value: * HRESULT NOERROR if registration successful, error * otherwise. */ HRESULT DllUnregisterServer() { char[128] szID; char[128] szCLSID; char[256] szTemp; printf("DllUnregisterServer()\n"); // Create some base key strings. StringFromGUID2(&CLSID_Hello, cast(LPOLESTR) szID, 128); unicode2ansi(szID.ptr); strcpy(szCLSID.ptr, "CLSID\\"); strcat(szCLSID.ptr, szID.ptr); RegDeleteKeyA(HKEY_CLASSES_ROOT, "Hello\\CurVer"); RegDeleteKeyA(HKEY_CLASSES_ROOT, "Hello\\CLSID"); RegDeleteKeyA(HKEY_CLASSES_ROOT, "Hello"); RegDeleteKeyA(HKEY_CLASSES_ROOT, "Hello1.0\\CLSID"); RegDeleteKeyA(HKEY_CLASSES_ROOT, "Hello1.0"); strcpy(szTemp.ptr, szCLSID.ptr); strcat(szTemp.ptr, "\\"); strcat(szTemp.ptr, "ProgID"); RegDeleteKeyA(HKEY_CLASSES_ROOT, szTemp.ptr); strcpy(szTemp.ptr, szCLSID.ptr); strcat(szTemp.ptr, "\\"); strcat(szTemp.ptr, "VersionIndependentProgID"); RegDeleteKeyA(HKEY_CLASSES_ROOT, szTemp.ptr); strcpy(szTemp.ptr, szCLSID.ptr); strcat(szTemp.ptr, "\\"); strcat(szTemp.ptr, "NotInsertable"); RegDeleteKeyA(HKEY_CLASSES_ROOT, szTemp.ptr); strcpy(szTemp.ptr, szCLSID.ptr); strcat(szTemp.ptr, "\\"); strcat(szTemp.ptr, "InprocServer32"); RegDeleteKeyA(HKEY_CLASSES_ROOT, szTemp.ptr); RegDeleteKeyA(HKEY_CLASSES_ROOT, szCLSID.ptr); return NOERROR; } /* * SetKeyAndValue * * Purpose: * Private helper function for DllRegisterServer that creates * a key, sets a value, and closes that key. * * Parameters: * pszKey LPTSTR to the name of the key * pszSubkey LPTSTR ro the name of a subkey * pszValue LPTSTR to the value to store * * Return Value: * BOOL true if successful, false otherwise. */ BOOL SetKeyAndValue(LPCSTR pszKey, LPCSTR pszSubkey, LPCSTR pszValue) { HKEY hKey; char[256] szKey; BOOL result; strcpy(szKey.ptr, pszKey); if (pszSubkey) { strcat(szKey.ptr, "\\"); strcat(szKey.ptr, pszSubkey); } result = true; int regresult = RegCreateKeyExA(HKEY_CLASSES_ROOT, szKey.ptr, 0, null, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, null, &hKey, null); if (ERROR_SUCCESS != regresult) { result = false; // If the value is 5, you'll need to run the program with Administrator privileges printf("RegCreateKeyExA() failed with 0x%x\n", regresult); } else { if (null != pszValue) { if (RegSetValueExA(hKey, null, 0, REG_SZ, cast(BYTE *) pszValue, cast(int)((strlen(pszValue) + 1) * char.sizeof)) != ERROR_SUCCESS) result = false; } if (RegCloseKey(hKey) != ERROR_SUCCESS) result = false; } if (!result) printf("SetKeyAndValue() failed\n"); return result; } /* * ObjectDestroyed * * Purpose: * Function for the Hello object to call when it gets destroyed. * Since we're in a DLL we only track the number of objects here, * letting DllCanUnloadNow take care of the rest. */ extern (D) void ObjectDestroyed() { printf("ObjectDestroyed()\n"); g_cObj--; } void unicode2ansi(char *s) { wchar *w; for (w = cast(wchar *) s; *w; w++) *s++ = cast(char)*w; *s = 0; }
D
// Lookup table template getRange(string fun, T = double) { static if(fun == "Pow") enum T[2] getRange = [0.0, PI]; else static if(fun == "Sqrt" || fun == "Log" || fun == "Log10" || fun == "Log2") enum T[2] getRange = [0.0, 1000.0]; else enum T[2] getRange = [-PI, PI]; } template getClassTemplate(Type: Base!Args, alias Base, Args...) { enum getClassTemplate = Base.stringof[0..($ - 3)]; } enum funcsOne = ["cos", "exp", "exp2", "fabs", "log", "log10", "log2", "round", "sin", "sqrt"]; enum funcsOneNames = ["Cos", "Exp", "Exp2", "Fabs", "Log", "Log10", "Log2", "Round", "Sin", "Sqrt"]; enum funcsTwo = ["fmax", "fmin", "pow"]; enum funcsTwoNames = ["Fmax", "Fmin", "Pow"]; template FunReprOne(string fun, string funName) { enum FunReprOne = "class " ~ funName ~ "(A) { public: A opCall(A arg) const { return " ~ fun ~ "(arg); } } "; } static foreach(i, fun; funcsOne) mixin(FunReprOne!(fun, funcsOneNames[i])); template FunReprTwo(string fun, string funName) { enum FunReprTwo = "class " ~ funName ~ "(A) { public: A opCall(A arg1, A arg2) const { return " ~ fun ~ "(arg1, arg2); } } "; } static foreach(i, fun; funcsTwo) mixin(FunReprTwo!(fun, funcsTwoNames[i])); // For include import std.conv: to; import std.parallelism; import std.range : iota; import std.stdio: File, write, writeln; import std.algorithm : sum; import std.random: uniform; import std.typecons: tuple, Tuple; import std.datetime.stopwatch: AutoStart, StopWatch; auto rand(T, T lower, T upper)(size_t n) { auto arr = new T[n]; //foreach(ref el; arr) foreach(i; taskPool.parallel(iota(n))) arr[i] = uniform!("()")(lower, upper); return arr; } /* For functions with a single input and a single output */ auto applyOne(T, alias F)(F!T fun, T[] rarr) { auto n = rarr.length; auto arr = new T[n]; auto sw = StopWatch(AutoStart.no); sw.start(); foreach(i; taskPool.parallel(iota(n))) arr[i] = fun(rarr[i]); sw.stop(); return cast(double)(sw.peek.total!"nsecs"/1000_000_000.0); } auto benchOne(T, T lower, T upper, alias F)(F!T fun, long[] n) { auto times = new double[n.length]; foreach(i; 0..n.length) { double[3] _times; auto rarr = rand!(T, lower, upper)(n[i]); foreach(ref t; _times) { t = applyOne(fun, rarr); } times[i] = sum(_times[])/_times.length; version(verbose) { writeln("Average time for n = ", n[i], ", ", times[i], " seconds."); writeln("Detailed times: ", _times, "\n"); } } return tuple(F.stringof[0..($-3)], T.stringof, n, times); } auto runBenchOne(T, FS)(FS funcs, long[] n) { enum _range = getRange!(typeof(funcs[0]).stringof, T); version(verbose) { writeln("Running benchmarks for ", funcs[0]); } writeln("Range: ", _range); auto tmp = benchOne!(T, _range[0], _range[1])(funcs[0], n); alias R = typeof(tmp); R[] results = new R[funcs.length]; results[0] = tmp; static foreach(i; 1..funcs.length) {{ enum range = getRange!(getClassTemplate!(typeof(funcs[i]))); results[i] = benchOne!(T, range[0], range[1])(funcs[i], n); version(verbose) { writeln("Running benchmarks for ", funcs[i]); writeln("Range: ", range); } }} return results; } /* For fmin and fmax */ auto applyTwoA(T, alias F)(F!T fun, T[] rarr) { auto n = rarr.length; auto arr = new T[n]; auto sw = StopWatch(AutoStart.no); sw.start(); //for(size_t i = 0; i < (n - 1); ++i) foreach(i; taskPool.parallel(iota(n - 1))) arr[i] = fun(rarr[i], rarr[i + 1]); sw.stop(); return cast(double)(sw.peek.total!"nsecs"/1000_000_000.0); } auto benchTwoA(T, T lower, T upper, alias F)(F!T fun, long[] n) { auto times = new double[n.length]; foreach(i; 0..n.length) { double[3] _times; auto rarr = rand!(T, lower, upper)(n[i] + 1); foreach(ref t; _times) { t = applyTwoA(fun, rarr); } times[i] = sum(_times[])/_times.length; version(verbose) { writeln("Average time for n = ", n[i], ", ", times[i], " seconds."); writeln("Detailed times: ", _times, "\n"); } } return tuple(F.stringof[0..($ - 3)], T.stringof, n, times); } auto runBenchTwoA(T, FS)(FS funcs, long[] n) { enum _range = getRange!(typeof(funcs[0]).stringof, T); version(verbose) { writeln("Running benchmarks for ", funcs[0]); writeln("Range: ", _range); } auto tmp = benchTwoA!(T, _range[0], _range[1])(funcs[0], n); alias R = typeof(tmp); R[] results = new R[funcs.length]; results[0] = tmp; static foreach(i; 1..funcs.length) {{ enum range = getRange!(getClassTemplate!(typeof(funcs[i]))); results[i] = benchTwoA!(T, range[0], range[1])(funcs[i], n); version(verbose) { writeln("Running benchmarks for ", funcs[i]); writeln("Range: ", range); } }} return results; } /* For pow function */ auto applyTwoB(T, alias F)(F!T fun, T[] rarr, T exponent) { auto n = rarr.length; auto arr = new T[n]; auto sw = StopWatch(AutoStart.no); sw.start(); //foreach(size_t i, el; rarr) foreach(i; taskPool.parallel(iota(n))) arr[i] = fun(rarr[i], exponent); sw.stop(); return cast(double)(sw.peek.total!"nsecs"/1000_000_000.0); } auto benchTwoB(T, T lower, T upper, alias F)(F!T fun, long[] n, T exponent) { auto times = new double[n.length]; foreach(i; 0..n.length) { double[3] _times; auto rarr = rand!(T, lower, upper)(n[i]); foreach(ref t; _times) { t = applyTwoB(fun, rarr, exponent); } times[i] = sum(_times[])/_times.length; version(verbose) { writeln("Average time for n = ", n[i], ", ", times[i], " seconds."); writeln("Detailed times: ", _times, "\n"); } } return tuple(F.stringof[0..($ - 3)], T.stringof, exponent, n, times); } /* This time we run this benchmark for only one function but multiple exponents */ auto runBenchTwoB(F, A: T[N], T, alias N)(F func, long[] n, A exponents) { enum range = getRange!(typeof(func).stringof, T); version(verbose) { writeln("Running benchmarks for ", func, ", exponent: ", exponents[0]); writeln("Range: ", range); } auto tmp = benchTwoB!(T, range[0], range[1])(func, n, exponents[0]); alias R = typeof(tmp); R[] results = new R[N]; results[0] = tmp; static foreach(i; 1..N) { results[i] = benchTwoB!(T, range[0], range[1])(func, n, exponents[i]); version(verbose) { writeln("Running benchmarks for ", func, ", exponent: ", exponents[i]); } } return results; } void writeRow(File file, string[] row) { string line = ""; foreach(i; 0..(row.length - 1)) line ~= row[i] ~ ","; line ~= row[row.length - 1] ~ "\n"; file.write(line); return; } void runMathBench(T)(string mathLib) { auto n = [100_000L, 500_000L, 1000_000L, 5000_000L, 10_000_000L, 100_000_000L]; auto tupleFuncOne = tuple(new Cos!(T), new Exp!(T), new Exp2!(T), new Fabs!(T), new Log!(T), new Log10!(T),new Log2!(T), new Round!(T), new Sin!(T), new Sqrt!(T)); auto results = runBenchOne!(T)(tupleFuncOne, n); auto tupleFuncTwoA = tuple(new Fmax!(T), new Fmin!(T)); results ~= runBenchTwoA!(T)(tupleFuncTwoA, n); T[17] exponents = [cast(T)-1.0, cast(T)-0.75, cast(T)-0.5, cast(T)-0.25, cast(T)0.0, cast(T)0.25, cast(T)0.5, cast(T)0.75, cast(T)1.0, cast(T)1.25, cast(T)1.5, cast(T)1.75, cast(T)2.0, cast(T)2.25, cast(T)2.5, cast(T)2.75, cast(T)3.0]; auto resultsTwoB = runBenchTwoB(new Pow!(T), n, exponents); string[][] table; foreach(result; results) { foreach(i; 0..n.length) { table ~= [mathLib, result[0], result[1], "", to!(string)(result[2][i]), to!(string)(result[3][i])]; } } foreach(result; resultsTwoB) { foreach(i; 0..n.length) { table ~= [mathLib, result[0], result[1], to!(string)(result[2]), to!(string)(result[3][i]), to!(string)(result[4][i])]; } } version(fastmath) { auto file = File("../fastmathdata/" ~ mathLib ~ "_" ~ T.stringof ~ ".csv", "w"); }else{ auto file = File("../data/" ~ mathLib ~ "_" ~ T.stringof ~ ".csv", "w"); } foreach(row; table) file.writeRow(row); return; }
D
/Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/Objects-normal/x86_64/PinchEvent.o : /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/export/MacawView+PDF.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MDisplayLink_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MBezierPath+Extension_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Common_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Graphics_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MView_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MDisplayLink_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Common_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Graphics_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MView_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Arc.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/AnimationSequence.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Node.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/UIImage2Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/AnimationCache.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stroke.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/Touchable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/NodeHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/TransformHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Variable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimatableVariable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/Interpolable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Disposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/GroupDisposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Drawable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CGFloat+Double.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Circle.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Line.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Baseline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polyline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Shape.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegmentType.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/NSTimer+Closure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CAAnimationClosure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Ellipse.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Size.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Easing.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Path.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/MDisplayLink.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Fill.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationImpl.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawZoom.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Transform.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Align.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineJoin.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polygon.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/FillInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/TransformInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/LocusInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Animation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/CombineAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ShapeAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/MorphingAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/TransformAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ContentsAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/OpacityAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TimingFunction.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Pattern.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/MoveTo.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AspectRatio.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineCap.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stop.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Group.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationProducer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathBuilder.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/NodeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ImageRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ShapeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/GroupRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/TextRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/CSSParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/ShapeLayer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGSerializer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Color.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParserError.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/MorphingGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TransformGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/OpacityGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/GaussianBlur.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGCanvas.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/FuncBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/CGMappings.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/SceneUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/GeomUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/BoundsUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/DescriptionExtensions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathFunctions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/AnimOperators.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Insets.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGConstants.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Locus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/TransformedLocus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Rect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/RoundRect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Effect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AlphaEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/BlendEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/OffsetEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrixEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Gradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/RadialGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LinearGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegment.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/Event.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/RotateEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PinchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TouchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PanEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TapEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Point.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Font.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGNodeLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/layout/ContentLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Text.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderContext.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrix.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Modules/SWXMLHash.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/SWXMLHash/SWXMLHash-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/Macaw/Macaw-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Headers/SWXMLHash-Swift.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/unextended-module.modulemap /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/SWXMLHash.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/Objects-normal/x86_64/PinchEvent~partial.swiftmodule : /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/export/MacawView+PDF.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MDisplayLink_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MBezierPath+Extension_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Common_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Graphics_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MView_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MDisplayLink_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Common_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Graphics_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MView_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Arc.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/AnimationSequence.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Node.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/UIImage2Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/AnimationCache.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stroke.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/Touchable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/NodeHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/TransformHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Variable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimatableVariable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/Interpolable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Disposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/GroupDisposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Drawable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CGFloat+Double.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Circle.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Line.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Baseline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polyline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Shape.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegmentType.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/NSTimer+Closure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CAAnimationClosure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Ellipse.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Size.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Easing.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Path.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/MDisplayLink.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Fill.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationImpl.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawZoom.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Transform.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Align.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineJoin.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polygon.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/FillInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/TransformInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/LocusInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Animation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/CombineAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ShapeAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/MorphingAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/TransformAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ContentsAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/OpacityAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TimingFunction.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Pattern.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/MoveTo.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AspectRatio.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineCap.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stop.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Group.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationProducer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathBuilder.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/NodeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ImageRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ShapeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/GroupRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/TextRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/CSSParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/ShapeLayer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGSerializer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Color.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParserError.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/MorphingGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TransformGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/OpacityGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/GaussianBlur.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGCanvas.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/FuncBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/CGMappings.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/SceneUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/GeomUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/BoundsUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/DescriptionExtensions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathFunctions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/AnimOperators.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Insets.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGConstants.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Locus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/TransformedLocus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Rect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/RoundRect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Effect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AlphaEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/BlendEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/OffsetEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrixEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Gradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/RadialGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LinearGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegment.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/Event.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/RotateEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PinchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TouchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PanEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TapEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Point.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Font.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGNodeLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/layout/ContentLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Text.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderContext.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrix.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Modules/SWXMLHash.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/SWXMLHash/SWXMLHash-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/Macaw/Macaw-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Headers/SWXMLHash-Swift.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/unextended-module.modulemap /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/SWXMLHash.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/Objects-normal/x86_64/PinchEvent~partial.swiftdoc : /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/export/MacawView+PDF.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MDisplayLink_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MBezierPath+Extension_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Common_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/Graphics_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/macOS/MView_macOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFillMode_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAMediaTimingFunctionName_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MDisplayLink_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineJoin_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Common_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/MCAShapeLayerLineCap_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/Graphics_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/iOS/MView_iOS.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Arc.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/AnimationSequence.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Node.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/UIImage2Image.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/AnimationCache.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stroke.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/Touchable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/NodeHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/Cache/TransformHashable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Variable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimatableVariable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/Interpolable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/Disposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/bindings/GroupDisposable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Drawable.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CGFloat+Double.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Circle.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Line.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Baseline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polyline.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Shape.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegmentType.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/NSTimer+Closure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/thirdparty/CAAnimationClosure.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Ellipse.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Size.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Easing.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Path.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/platform/MDisplayLink.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Fill.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationImpl.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawZoom.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Transform.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Align.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineJoin.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Polygon.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/FillInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/TransformInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/LocusInterpolation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/Animation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/CombineAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ShapeAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/MorphingAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/TransformAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/ContentsAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/OpacityAnimation.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TimingFunction.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Pattern.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/MoveTo.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AspectRatio.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LineCap.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Stop.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Group.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationProducer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathBuilder.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/NodeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ImageRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/ShapeRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/GroupRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/TextRenderer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/CSSParser.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/ShapeLayer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGSerializer.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Color.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGParserError.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/MorphingGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/TransformGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/ShapeAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/CombinationAnimationGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/types/animation_generators/OpacityGenerator.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/GaussianBlur.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGCanvas.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/FuncBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathBounds.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/CGMappings.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/SceneUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/GeomUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/AnimationUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/BoundsUtils.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/utils/DescriptionExtensions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/PathFunctions.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/animation/layer_animation/Extensions/AnimOperators.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Insets.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGConstants.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Locus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/TransformedLocus.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Rect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/RoundRect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Effect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/AlphaEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/BlendEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/OffsetEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrixEffect.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Gradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/RadialGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/LinearGradient.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/PathSegment.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/Event.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/RotateEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PinchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TouchEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/PanEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/events/TapEvent.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/geom2d/Point.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/Font.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGNodeLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/layout/ContentLayout.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/scene/Text.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/render/RenderContext.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/svg/SVGView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/views/MacawView.swift /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Macaw/Source/model/draw/ColorMatrix.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Modules/SWXMLHash.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/SWXMLHash/SWXMLHash-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/Pods/Target\ Support\ Files/Macaw/Macaw-umbrella.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Debug-iphonesimulator/SWXMLHash/SWXMLHash.framework/Headers/SWXMLHash-Swift.h /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/Macaw.build/unextended-module.modulemap /Users/mac/Documents/Bhupendra/RedialAnimateMenuBar/build/Pods.build/Debug-iphonesimulator/SWXMLHash.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
instance DIA_RodDJG_EXIT(C_Info) { npc = DJG_702_Rod; nr = 999; condition = DIA_RodDJG_EXIT_Condition; information = DIA_RodDJG_EXIT_Info; permanent = TRUE; description = Dialog_Ende; }; func int DIA_RodDJG_EXIT_Condition() { return TRUE; }; func void DIA_RodDJG_EXIT_Info() { AI_StopProcessInfos(self); }; instance DIA_RodDJG_HALLO(C_Info) { npc = DJG_702_Rod; condition = DIA_RodDJG_HALLO_Condition; information = DIA_RodDJG_HALLO_Info; description = "Jsi v pořádku?"; }; func int DIA_RodDJG_HALLO_Condition() { if(DJG_SwampParty == FALSE) { return TRUE; }; }; func void DIA_RodDJG_HALLO_Info() { AI_Output(other,self,"DIA_RodDJG_HALLO_15_00"); //Jsi v pořádku? AI_Output(self,other,"DIA_RodDJG_HALLO_06_01"); //Ty boty mě zabijou! Ta nová zbroj je výborná, ale proč je to řemení na botách tak natěsno? AI_Output(self,other,"DIA_RodDJG_HALLO_06_02"); //Když jsem je rozvázal, zase mi málem spadly. if((Npc_IsDead(SwampDragon) == FALSE) && (DJG_SwampParty == FALSE)) { Info_AddChoice(DIA_RodDJG_HALLO,"Na co čekáš?",DIA_RodDJG_HALLO_warten); }; Info_AddChoice(DIA_RodDJG_HALLO,"Kdes sebral ty boty?",DIA_RodDJG_HALLO_Woher); }; func void DIA_RodDJG_HALLO_Woher() { AI_Output(other,self,"DIA_RodDJG_HALLO_Woher_15_00"); //Kdes sebral ty boty? AI_Output(self,other,"DIA_RodDJG_HALLO_Woher_06_01"); //Ten starej skunk Bennet je udělal pro drakobijce a nechal si za ty škrpály královsky zaplatit. AI_Output(self,other,"DIA_RodDJG_HALLO_Woher_06_02"); //Až se mi někdy dostane do rukou, nechám ho nejdřív ty věci sežrat a pak z něj vymlátim svoje prachy. }; func void DIA_RodDJG_HALLO_warten() { AI_Output(other,self,"DIA_RodDJG_HALLO_warten_15_00"); //Na co čekáš? Info_ClearChoices(DIA_RodDJG_HALLO); if(Npc_IsDead(DJG_Cipher) == FALSE) { AI_Output(self,other,"DIA_RodDJG_HALLO_warten_06_01"); //Na to, až se Cipher uráčí přinejmenším zvednout ten svůj zadek. Už je načase, abychom vypadli. AI_StopProcessInfos(self); } else { AI_Output(self,other,"DIA_RodDJG_HALLO_warten_06_02"); //Přemýšlel jsem o tom, že bychom měli blíž prozkoumat tamtu bažinatou oblast. AI_Output(self,other,"DIA_RodDJG_HALLO_warten_06_03"); //Myslíš že tam můžeme jít spolu? Podívat se, co by se tam dalo najít? Info_AddChoice(DIA_RodDJG_HALLO,"Zajdu tam sám.",DIA_RodDJG_HALLO_warten_allein); Info_AddChoice(DIA_RodDJG_HALLO,"Co víš o těch bažinách?",DIA_RodDJG_HALLO_warten_wasweisstdu); Info_AddChoice(DIA_RodDJG_HALLO,"Tak jdeme.",DIA_RodDJG_HALLO_warten_zusammen); }; }; func void DIA_RodDJG_HALLO_warten_zusammen() { AI_Output(other,self,"DIA_RodDJG_HALLO_warten_zusammen_15_00"); //Tak jdeme. AI_Output(self,other,"DIA_RodDJG_HALLO_warten_zusammen_06_01"); //Dobrá, tak jdeme. AI_StopProcessInfos(self); self.aivar[AIV_PARTYMEMBER] = TRUE; Npc_ExchangeRoutine(self,"SwampWait2"); }; func void DIA_RodDJG_HALLO_warten_wasweisstdu() { AI_Output(other,self,"DIA_RodDJG_HALLO_warten_wasweisstdu_15_00"); //Co víš o těch bažinách? AI_Output(self,other,"DIA_RodDJG_HALLO_warten_wasweisstdu_06_01"); //Jen to, že smrdí až do nebe a že je tam možná hora zlata. To by mohlo stačit, ne? }; func void DIA_RodDJG_HALLO_warten_allein() { AI_Output(other,self,"DIA_RodDJG_HALLO_warten_allein_15_00"); //Zajdu tam sám. AI_Output(self,other,"DIA_RodDJG_HALLO_warten_allein_06_01"); //Fajn, tak ti přeju hodně štěstí. AI_StopProcessInfos(self); }; instance DIA_RodDJG_WARTEMAL(C_Info) { npc = DJG_702_Rod; condition = DIA_RodDJG_WARTEMAL_Condition; information = DIA_RodDJG_WARTEMAL_Info; permanent = TRUE; description = "Co to s tebou je?"; }; func int DIA_RodDJG_WARTEMAL_Condition() { if(Npc_KnowsInfo(other,DIA_RodDJG_HALLO) || (DJG_SwampParty == TRUE)) { return TRUE; }; }; func void DIA_RodDJG_WARTEMAL_Info() { AI_Output(other,self,"DIA_RodDJG_WARTEMAL_15_00"); //Co to s tebou je? if(((DJG_SwampParty == TRUE) || (Npc_GetDistToWP(self,"OW_DJG_SWAMP_WAIT2_02") < 1000)) && Npc_IsDead(DJG_Cipher)) { AI_Output(self,other,"DIA_RodDJG_WARTEMAL_06_01"); //Hele, chlape. Mám dojem, že se nám tahle věc začíná vymykat z rukou. Prostě odsud potichoučku mizím. DJG_SwampParty = FALSE; self.aivar[AIV_PARTYMEMBER] = FALSE; AI_StopProcessInfos(self); Npc_ExchangeRoutine(self,"Start"); } else { AI_Output(self,other,"DIA_RodDJG_WARTEMAL_06_02"); //(Kleje) Tyhle boty! Tyhle zpropadený boty! }; if(Npc_IsDead(SwampDragon)) { AI_Output(other,self,"DIA_RodDJG_WARTEMAL_15_03"); //A co budeš dělat teď? AI_Output(self,other,"DIA_RodDJG_WARTEMAL_06_04"); //Ty se teda dokážeš ptát! Ze všeho nejdřív si koupím nějaký nový boty, chlape! self.aivar[AIV_PARTYMEMBER] = FALSE; AI_StopProcessInfos(self); Npc_ExchangeRoutine(self,"Start"); }; AI_StopProcessInfos(self); }; instance DIA_Rod_PICKPOCKET(C_Info) { npc = DJG_702_Rod; nr = 900; condition = DIA_Rod_PICKPOCKET_Condition; information = DIA_Rod_PICKPOCKET_Info; permanent = TRUE; description = PICKPOCKET_COMM; }; func int DIA_Rod_PICKPOCKET_Condition() { return C_Beklauen(16,320); }; func void DIA_Rod_PICKPOCKET_Info() { Info_ClearChoices(DIA_Rod_PICKPOCKET); Info_AddChoice(DIA_Rod_PICKPOCKET,Dialog_Back,DIA_Rod_PICKPOCKET_BACK); Info_AddChoice(DIA_Rod_PICKPOCKET,DIALOG_PICKPOCKET,DIA_Rod_PICKPOCKET_DoIt); }; func void DIA_Rod_PICKPOCKET_DoIt() { B_Beklauen(); Info_ClearChoices(DIA_Rod_PICKPOCKET); }; func void DIA_Rod_PICKPOCKET_BACK() { Info_ClearChoices(DIA_Rod_PICKPOCKET); }; instance DIA_ROD_FUCKOFF(C_Info) { npc = DJG_702_Rod; nr = 2; condition = dia_rod_fuckoff_condition; information = dia_rod_fuckoff_info; permanent = TRUE; important = TRUE; }; func int dia_rod_fuckoff_condition() { if(Npc_IsInState(self,ZS_Talk) && (DGJREFUSEPALADIN == TRUE)) { return TRUE; }; }; func void dia_rod_fuckoff_info() { B_Say(self,other,"$NOTNOW"); AI_StopProcessInfos(self); Npc_SetRefuseTalk(self,300); };
D
/Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/Objects-normal/x86_64/TabBar.o : /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BarView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomNavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomTabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CapturePreview.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureSession.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ControlView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ErrorTextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FabButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FlatButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Grid.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/IconButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ImageCardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Layout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+Obj-C.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+String.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Blank.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Color.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Crop.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+FilterBlur.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Network.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Resize.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Size.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+TintColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBasicAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBorder.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionReusableView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDataSource.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDelegate.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewLayout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDataSourceItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDepth.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDevice.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialEdgeInset.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialGravity.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialIcon.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialKeyframeAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLabel.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialRadius.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialShape.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSpacing.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSwitch.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTableViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTextLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTransitionAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Menu.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationDrawerController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RaisedButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RobotoFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RootController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/StatusBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Text.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextStorage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Toolbar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ToolbarController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/sameersiddiqui/Projects/Test\ Code/SwiftTest/Pods/Google/Headers/module.modulemap /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Target\ Support\ Files/Material/Material-umbrella.h /Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/Objects-normal/x86_64/TabBar~partial.swiftmodule : /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BarView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomNavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomTabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CapturePreview.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureSession.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ControlView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ErrorTextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FabButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FlatButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Grid.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/IconButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ImageCardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Layout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+Obj-C.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+String.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Blank.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Color.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Crop.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+FilterBlur.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Network.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Resize.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Size.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+TintColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBasicAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBorder.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionReusableView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDataSource.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDelegate.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewLayout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDataSourceItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDepth.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDevice.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialEdgeInset.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialGravity.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialIcon.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialKeyframeAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLabel.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialRadius.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialShape.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSpacing.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSwitch.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTableViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTextLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTransitionAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Menu.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationDrawerController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RaisedButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RobotoFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RootController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/StatusBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Text.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextStorage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Toolbar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ToolbarController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/sameersiddiqui/Projects/Test\ Code/SwiftTest/Pods/Google/Headers/module.modulemap /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Target\ Support\ Files/Material/Material-umbrella.h /Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule /Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/Objects-normal/x86_64/TabBar~partial.swiftdoc : /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BarView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomNavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/BottomTabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CapturePreview.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureSession.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CaptureView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/CardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ControlView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ErrorTextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FabButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/FlatButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Grid.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/IconButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ImageCardView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Layout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+Obj-C.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+String.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Blank.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Color.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Crop.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+FilterBlur.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Network.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Resize.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+Size.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage+TintColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Material+UIImage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBasicAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialBorder.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionReusableView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDataSource.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewDelegate.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialCollectionViewLayout.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialColor.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDataSourceItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDepth.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialDevice.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialEdgeInset.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialGravity.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialIcon.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialKeyframeAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLabel.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialPulseView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialRadius.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialShape.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSpacing.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialSwitch.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTableViewCell.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTextLayer.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialTransitionAnimation.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MaterialView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Menu.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/MenuView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationDrawerController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/NavigationItem.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RaisedButton.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RobotoFont.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/RootController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/SearchBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/StatusBarController.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TabBar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Text.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextField.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextStorage.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/TextView.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/Toolbar.swift /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Material/Sources/iOS/ToolbarController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/sameersiddiqui/Projects/Test\ Code/SwiftTest/Pods/Google/Headers/module.modulemap /Users/sameersiddiqui/Projects/HafsaInspectorApp/Pods/Target\ Support\ Files/Material/Material-umbrella.h /Users/sameersiddiqui/Projects/HafsaInspectorApp/Build/Intermediates/Pods.build/Debug-iphonesimulator/Material.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreAudio.swiftmodule
D
import std.stdio; import mod; void main() { writeln("Hello from D, value is ", Klass.VAL, "!"); }
D
/Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Intermediates/FareDeal.build/Debug-iphonesimulator/FareDeal.build/Objects-normal/x86_64/Restaurant.o : /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/StoreVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileModel.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteVenue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealDetaislVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealDetailsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesTVController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DataSaving.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FoodCategories.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardOverlayView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/GradientView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDetailController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SavedDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/VenueDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/InitialScreenVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/APICalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Deals.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Restaurant.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Venue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC2.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/HomeSwipeViewController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CustomActivityView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessHome.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AuthenticationCalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AppDelegate.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardContentView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Constants.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Validation.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealCardCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC3.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Reachability.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/FareDeal-Bridging-Header.h /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTTAttributedLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTCounterLabel.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMResults_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Dynamic.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealmUtil.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMProperty_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObject_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectStore.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMMigration_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMListBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMArray_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMResults.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMRealm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMPlatform.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObject.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMMigration.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMCollection.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMArray.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/Realm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/SWActionSheet.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetStringPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetLocalePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/DistancePickerView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDistancePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDatePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPickerDelegate.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/AbstractActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker-3.0-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/AssetsLibrary.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/Koloda.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPLayerExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDecayAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPCustomAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPBasicAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimator.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPPropertyAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPSpringAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPGeometry.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationEvent.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationTracer.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimatableProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POP.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/pop-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/KeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+IQKeyboardToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTitleBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTextView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQSegmentedNextPrevious.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardReturnKeyHandler.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstantsInternal.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIWindow+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIViewController+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUITextFieldView+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQNSArray+Sort.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Intermediates/FareDeal.build/Debug-iphonesimulator/FareDeal.build/Objects-normal/x86_64/Restaurant~partial.swiftmodule : /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/StoreVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileModel.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteVenue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealDetaislVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealDetailsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesTVController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DataSaving.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FoodCategories.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardOverlayView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/GradientView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDetailController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SavedDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/VenueDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/InitialScreenVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/APICalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Deals.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Restaurant.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Venue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC2.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/HomeSwipeViewController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CustomActivityView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessHome.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AuthenticationCalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AppDelegate.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardContentView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Constants.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Validation.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealCardCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC3.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Reachability.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/FareDeal-Bridging-Header.h /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTTAttributedLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTCounterLabel.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMResults_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Dynamic.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealmUtil.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMProperty_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObject_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectStore.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMMigration_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMListBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMArray_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMResults.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMRealm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMPlatform.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObject.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMMigration.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMCollection.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMArray.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/Realm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/SWActionSheet.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetStringPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetLocalePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/DistancePickerView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDistancePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDatePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPickerDelegate.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/AbstractActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker-3.0-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/AssetsLibrary.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/Koloda.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPLayerExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDecayAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPCustomAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPBasicAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimator.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPPropertyAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPSpringAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPGeometry.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationEvent.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationTracer.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimatableProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POP.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/pop-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/KeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+IQKeyboardToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTitleBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTextView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQSegmentedNextPrevious.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardReturnKeyHandler.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstantsInternal.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIWindow+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIViewController+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUITextFieldView+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQNSArray+Sort.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Intermediates/FareDeal.build/Debug-iphonesimulator/FareDeal.build/Objects-normal/x86_64/Restaurant~partial.swiftdoc : /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/StoreVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileModel.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteVenue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDealDetaislVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoriteHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealDetailsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesTVController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ProfileVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DataSaving.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FoodCategories.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardOverlayView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/GradientView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RestaurantDetailController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/ForgotPasswordVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SavedDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/VenueDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/InitialScreenVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/APICalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/FavoritesCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealsCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Deals.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Restaurant.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessDeal.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Venue.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC2.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/HomeSwipeViewController.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CustomActivityView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/BusinessHome.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AuthenticationCalls.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/AppDelegate.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/CardContentView.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/SignInUserVC.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealHeaderCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Constants.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Validation.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/DealCardCell.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/RegisterRestaurantVC3.swift /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/FareDeal/Reachability.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/FareDeal-Bridging-Header.h /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTTAttributedLabel.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Users/angelasmith/Desktop/Develop/FareDeal/FareDeal/TTCounterLabel.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMResults_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealm_Dynamic.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMRealmUtil.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMProperty_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObject_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectStore.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMObjectSchema_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMMigration_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMListBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/PrivateHeaders/RLMArray_Private.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMResults.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMRealm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMPlatform.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectSchema.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObjectBase.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMObject.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMMigration.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMCollection.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/RLMArray.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Headers/Realm.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Realm.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Headers/RealmSwift-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/RealmSwift.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/SwiftyJSON.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/SWActionSheet.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetStringPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetLocalePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/DistancePickerView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDistancePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetDatePicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPickerDelegate.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetCustomPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/AbstractActionSheetPicker.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Headers/ActionSheetPicker-3.0-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/ActionSheetPicker_3_0.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/AssetsLibrary.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/Koloda.swiftmodule/x86_64.swiftmodule /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-Swift.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Headers/Koloda-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/Koloda.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPLayerExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDecayAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPCustomAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPBasicAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimator.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPPropertyAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPSpringAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPDefines.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationExtras.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPGeometry.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationEvent.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimationTracer.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimation.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POPAnimatableProperty.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/POP.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Headers/pop-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/pop.framework/Modules/module.modulemap /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/KeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+IQKeyboardToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQToolbar.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTitleBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQBarButtonItem.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQTextView.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQSegmentedNextPrevious.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardReturnKeyHandler.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstantsInternal.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIWindow+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIViewController+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManagerConstants.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUIView+Hierarchy.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQUITextFieldView+Additions.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQNSArray+Sort.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Headers/IQKeyboardManager-umbrella.h /Users/angelasmith/Desktop/SourceTree/Develop2/FareDeal/Build/Intermediates/IBDesignables/Products/Debug-iphonesimulator/IQKeyboardManager.framework/Modules/module.modulemap
D
a Polynesian native or inhabitant of Tonga the Polynesian language spoken by the Tongan people of or relating to the island monarchy of Tonga or its people
D
/Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Intermediates/DemoClass.build/Debug-iphonesimulator/DemoClass.build/Objects-normal/x86_64/ManipulateArray.o : /Users/admin/Desktop/Day4/DemoClass/DemoClass/ReverseFile.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PropertyDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoPolymorphism.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoDictionary.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Circle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/MainScreen.swift /Users/admin/Desktop/Day4/DemoClass/DogMating.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/CatHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AccessLevel.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ProtocolDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Rectangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AnimalHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Animal.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogTom.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoShape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogMike.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManualSort.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManipulateArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Student.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoFunction.swift /Users/admin/Desktop/Day4/DemoClass/Vector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendString.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/OptionalUnwrap.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DogHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FindMidMinMax.swift /Users/admin/Desktop/Day4/DemoClass/DemoVector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendDouble.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Dogs.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ConsoleScreen.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FilterMapReduce.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Square.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Cats.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/TigerHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/HorseHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoAnimalInForest.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Complex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoClosure.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoComplex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PantherHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Triangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoStruct.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AppDelegate.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Shape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/BootLogic.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIkit.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/ShareUILib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/module.modulemap /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/CoolLib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKIt.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Intermediates/DemoClass.build/Debug-iphonesimulator/DemoClass.build/Objects-normal/x86_64/ManipulateArray~partial.swiftmodule : /Users/admin/Desktop/Day4/DemoClass/DemoClass/ReverseFile.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PropertyDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoPolymorphism.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoDictionary.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Circle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/MainScreen.swift /Users/admin/Desktop/Day4/DemoClass/DogMating.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/CatHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AccessLevel.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ProtocolDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Rectangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AnimalHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Animal.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogTom.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoShape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogMike.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManualSort.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManipulateArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Student.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoFunction.swift /Users/admin/Desktop/Day4/DemoClass/Vector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendString.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/OptionalUnwrap.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DogHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FindMidMinMax.swift /Users/admin/Desktop/Day4/DemoClass/DemoVector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendDouble.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Dogs.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ConsoleScreen.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FilterMapReduce.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Square.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Cats.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/TigerHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/HorseHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoAnimalInForest.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Complex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoClosure.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoComplex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PantherHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Triangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoStruct.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AppDelegate.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Shape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/BootLogic.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIkit.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/ShareUILib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/module.modulemap /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/CoolLib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKIt.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Intermediates/DemoClass.build/Debug-iphonesimulator/DemoClass.build/Objects-normal/x86_64/ManipulateArray~partial.swiftdoc : /Users/admin/Desktop/Day4/DemoClass/DemoClass/ReverseFile.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PropertyDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoPolymorphism.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoDictionary.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Circle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/MainScreen.swift /Users/admin/Desktop/Day4/DemoClass/DogMating.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/CatHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AccessLevel.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ProtocolDemo.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Rectangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AnimalHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Animal.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogTom.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoShape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/dogMike.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManualSort.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ManipulateArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Student.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoFunction.swift /Users/admin/Desktop/Day4/DemoClass/Vector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendString.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/OptionalUnwrap.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DogHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FindMidMinMax.swift /Users/admin/Desktop/Day4/DemoClass/DemoVector.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendDouble.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Dogs.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ConsoleScreen.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/FilterMapReduce.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Square.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Cats.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/TigerHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/HorseHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoAnimalInForest.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Complex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoClosure.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoArray.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoComplex.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/PantherHw.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Triangle.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/DemoStruct.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/AppDelegate.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/Shape.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/BootLogic.swift /Users/admin/Desktop/Day4/DemoClass/DemoClass/ExtendArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIkit.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/ShareUILib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Headers/ShareUILib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/ShareUILib.framework/Modules/module.modulemap /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/CoolLib.swiftmodule/x86_64.swiftmodule /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib-Swift.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Headers/CoolLib.h /Users/admin/Desktop/Day4/DemoClass/DerivedData/DemoClass/Build/Products/Debug-iphonesimulator/CoolLib.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/UIKIt.swiftmodule
D
// Compiler implementation of the D programming language // Copyright (c) 1999-2016 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt module ddmd.traits; import core.stdc.stdio; import core.stdc.string; import ddmd.aggregate; import ddmd.arraytypes; import ddmd.attrib; import ddmd.canthrow; import ddmd.dclass; import ddmd.declaration; import ddmd.denum; import ddmd.dimport; import ddmd.dscope; import ddmd.dstruct; import ddmd.dsymbol; import ddmd.dtemplate; import ddmd.errors; import ddmd.expression; import ddmd.func; import ddmd.globals; import ddmd.hdrgen; import ddmd.id; import ddmd.identifier; import ddmd.mtype; import ddmd.nogc; import ddmd.root.array; import ddmd.root.rootobject; import ddmd.root.speller; import ddmd.root.stringtable; import ddmd.tokens; import ddmd.visitor; enum LOGSEMANTIC = false; /************************ TraitsExp ************************************/ // callback for TypeFunction::attributesApply struct PushAttributes { Expressions* mods; extern (C++) static int fp(void* param, const(char)* str) { PushAttributes* p = cast(PushAttributes*)param; p.mods.push(new StringExp(Loc(), cast(char*)str)); return 0; } } extern (C++) __gshared StringTable traitsStringTable; static this() { static immutable string[] names = [ "isAbstractClass", "isArithmetic", "isAssociativeArray", "isFinalClass", "isPOD", "isNested", "isFloating", "isIntegral", "isScalar", "isStaticArray", "isUnsigned", "isVirtualFunction", "isVirtualMethod", "isAbstractFunction", "isFinalFunction", "isOverrideFunction", "isStaticFunction", "isRef", "isOut", "isLazy", "hasMember", "identifier", "getProtection", "parent", "getMember", "getOverloads", "getVirtualFunctions", "getVirtualMethods", "classInstanceSize", "allMembers", "derivedMembers", "isSame", "compiles", "parameters", "getAliasThis", "getAttributes", "getFunctionAttributes", "getUnitTests", "getVirtualIndex", "getPointerBitmap", ]; traitsStringTable._init(40); foreach (s; names) { auto sv = traitsStringTable.insert(s.ptr, s.length, cast(void*)s.ptr); assert(sv); } } /** * get an array of size_t values that indicate possible pointer words in memory * if interpreted as the type given as argument * the first array element is the size of the type for independent interpretation * of the array * following elements bits represent one word (4/8 bytes depending on the target * architecture). If set the corresponding memory might contain a pointer/reference. * * [T.sizeof, pointerbit0-31/63, pointerbit32/64-63/128, ...] */ extern (C++) Expression pointerBitmap(TraitsExp e) { if (!e.args || e.args.dim != 1) { error(e.loc, "a single type expected for trait pointerBitmap"); return new ErrorExp(); } Type t = getType((*e.args)[0]); if (!t) { error(e.loc, "%s is not a type", (*e.args)[0].toChars()); return new ErrorExp(); } d_uns64 sz = t.size(e.loc); if (t.ty == Tclass && !(cast(TypeClass)t).sym.isInterfaceDeclaration()) sz = (cast(TypeClass)t).sym.AggregateDeclaration.size(e.loc); d_uns64 sz_size_t = Type.tsize_t.size(e.loc); d_uns64 bitsPerWord = sz_size_t * 8; d_uns64 cntptr = (sz + sz_size_t - 1) / sz_size_t; d_uns64 cntdata = (cntptr + bitsPerWord - 1) / bitsPerWord; Array!(d_uns64) data; data.setDim(cast(size_t)cntdata); data.zero(); extern (C++) final class PointerBitmapVisitor : Visitor { alias visit = super.visit; public: extern (D) this(Array!(d_uns64)* _data, d_uns64 _sz_size_t) { this.data = _data; this.sz_size_t = _sz_size_t; } void setpointer(d_uns64 off) { d_uns64 ptroff = off / sz_size_t; (*data)[cast(size_t)(ptroff / (8 * sz_size_t))] |= 1L << (ptroff % (8 * sz_size_t)); } override void visit(Type t) { Type tb = t.toBasetype(); if (tb != t) tb.accept(this); } override void visit(TypeError t) { visit(cast(Type)t); } override void visit(TypeNext t) { assert(0); } override void visit(TypeBasic t) { if (t.ty == Tvoid) setpointer(offset); } override void visit(TypeVector t) { } override void visit(TypeArray t) { assert(0); } override void visit(TypeSArray t) { d_uns64 arrayoff = offset; d_uns64 nextsize = t.next.size(); d_uns64 dim = t.dim.toInteger(); for (d_uns64 i = 0; i < dim; i++) { offset = arrayoff + i * nextsize; t.next.accept(this); } offset = arrayoff; } override void visit(TypeDArray t) { setpointer(offset + sz_size_t); } // dynamic array is {length,ptr} override void visit(TypeAArray t) { setpointer(offset); } override void visit(TypePointer t) { if (t.nextOf().ty != Tfunction) // don't mark function pointers setpointer(offset); } override void visit(TypeReference t) { setpointer(offset); } override void visit(TypeClass t) { setpointer(offset); } override void visit(TypeFunction t) { } override void visit(TypeDelegate t) { setpointer(offset); } // delegate is {context, function} override void visit(TypeQualified t) { assert(0); } // assume resolved override void visit(TypeIdentifier t) { assert(0); } override void visit(TypeInstance t) { assert(0); } override void visit(TypeTypeof t) { assert(0); } override void visit(TypeReturn t) { assert(0); } override void visit(TypeEnum t) { visit(cast(Type)t); } override void visit(TypeTuple t) { visit(cast(Type)t); } override void visit(TypeSlice t) { assert(0); } override void visit(TypeNull t) { // always a null pointer } override void visit(TypeStruct t) { d_uns64 structoff = offset; foreach (v; t.sym.fields) { offset = structoff + v.offset; if (v.type.ty == Tclass) setpointer(offset); else v.type.accept(this); } offset = structoff; } // a "toplevel" class is treated as an instance, while TypeClass fields are treated as references void visitClass(TypeClass t) { d_uns64 classoff = offset; // skip vtable-ptr and monitor if (t.sym.baseClass) visitClass(cast(TypeClass)t.sym.baseClass.type); foreach (v; t.sym.fields) { offset = classoff + v.offset; v.type.accept(this); } offset = classoff; } Array!(d_uns64)* data; d_uns64 offset; d_uns64 sz_size_t; } scope PointerBitmapVisitor pbv = new PointerBitmapVisitor(&data, sz_size_t); if (t.ty == Tclass) pbv.visitClass(cast(TypeClass)t); else t.accept(pbv); auto exps = new Expressions(); exps.push(new IntegerExp(e.loc, sz, Type.tsize_t)); foreach (d_uns64 i; 0 .. cntdata) exps.push(new IntegerExp(e.loc, data[cast(size_t)i], Type.tsize_t)); auto ale = new ArrayLiteralExp(e.loc, exps); ale.type = Type.tsize_t.sarrayOf(cntdata + 1); return ale; } extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc) { static if (LOGSEMANTIC) { printf("TraitsExp::semantic() %s\n", e.toChars()); } if (e.ident != Id.compiles && e.ident != Id.isSame && e.ident != Id.identifier && e.ident != Id.getProtection) { if (!TemplateInstance.semanticTiargs(e.loc, sc, e.args, 1)) return new ErrorExp(); } size_t dim = e.args ? e.args.dim : 0; Expression isX(T)(bool function(T) fp) { int result = 0; if (!dim) goto Lfalse; foreach (o; *e.args) { static if (is(T == Type)) auto y = getType(o); static if (is(T : Dsymbol)) { auto s = getDsymbol(o); if (!s) goto Lfalse; } static if (is(T == Dsymbol)) alias y = s; static if (is(T == Declaration)) auto y = s.isDeclaration(); static if (is(T == FuncDeclaration)) auto y = s.isFuncDeclaration(); if (!y || !fp(y)) goto Lfalse; } result = 1; Lfalse: return new IntegerExp(e.loc, result, Type.tbool); } alias isTypeX = isX!Type; alias isDsymX = isX!Dsymbol; alias isDeclX = isX!Declaration; alias isFuncX = isX!FuncDeclaration; if (e.ident == Id.isArithmetic) { return isTypeX(t => t.isintegral() || t.isfloating()); } if (e.ident == Id.isFloating) { return isTypeX(t => t.isfloating()); } if (e.ident == Id.isIntegral) { return isTypeX(t => t.isintegral()); } if (e.ident == Id.isScalar) { return isTypeX(t => t.isscalar()); } if (e.ident == Id.isUnsigned) { return isTypeX(t => t.isunsigned()); } if (e.ident == Id.isAssociativeArray) { return isTypeX(t => t.toBasetype().ty == Taarray); } if (e.ident == Id.isStaticArray) { return isTypeX(t => t.toBasetype().ty == Tsarray); } if (e.ident == Id.isAbstractClass) { return isTypeX(t => t.toBasetype().ty == Tclass && (cast(TypeClass)t.toBasetype()).sym.isAbstract()); } if (e.ident == Id.isFinalClass) { return isTypeX(t => t.toBasetype().ty == Tclass && ((cast(TypeClass)t.toBasetype()).sym.storage_class & STCfinal) != 0); } if (e.ident == Id.isTemplate) { return isDsymX((s) { if (!s.toAlias().isOverloadable()) return false; return overloadApply(s, sm => sm.isTemplateDeclaration() !is null) != 0; }); } if (e.ident == Id.isPOD) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto t = isType(o); if (!t) { e.error("type expected as second argument of __traits %s instead of %s", e.ident.toChars(), o.toChars()); return new ErrorExp(); } Type tb = t.baseElemOf(); if (auto sd = tb.ty == Tstruct ? (cast(TypeStruct)tb).sym : null) { if (sd.isPOD()) goto Ltrue; else goto Lfalse; } goto Ltrue; } if (e.ident == Id.isNested) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); if (!s) { } else if (auto ad = s.isAggregateDeclaration()) { if (ad.isNested()) goto Ltrue; else goto Lfalse; } else if (auto fd = s.isFuncDeclaration()) { if (fd.isNested()) goto Ltrue; else goto Lfalse; } e.error("aggregate or function expected instead of '%s'", o.toChars()); return new ErrorExp(); } if (e.ident == Id.isAbstractFunction) { return isFuncX(f => f.isAbstract()); } if (e.ident == Id.isVirtualFunction) { return isFuncX(f => f.isVirtual()); } if (e.ident == Id.isVirtualMethod) { return isFuncX(f => f.isVirtualMethod()); } if (e.ident == Id.isFinalFunction) { return isFuncX(f => f.isFinalFunc()); } if (e.ident == Id.isOverrideFunction) { return isFuncX(f => f.isOverride()); } if (e.ident == Id.isStaticFunction) { return isFuncX(f => !f.needThis() && !f.isNested()); } if (e.ident == Id.isRef) { return isDeclX(d => d.isRef()); } if (e.ident == Id.isOut) { return isDeclX(d => d.isOut()); } if (e.ident == Id.isLazy) { return isDeclX(d => (d.storage_class & STClazy) != 0); } if (e.ident == Id.identifier) { // Get identifier for symbol as a string literal /* Specify 0 for bit 0 of the flags argument to semanticTiargs() so that * a symbol should not be folded to a constant. * Bit 1 means don't convert Parameter to Type if Parameter has an identifier */ if (!TemplateInstance.semanticTiargs(e.loc, sc, e.args, 2)) return new ErrorExp(); if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; Identifier id; if (auto po = isParameter(o)) { id = po.ident; assert(id); } else { Dsymbol s = getDsymbol(o); if (!s || !s.ident) { e.error("argument %s has no identifier", o.toChars()); return new ErrorExp(); } id = s.ident; } auto se = new StringExp(e.loc, cast(char*)id.toChars()); return se.semantic(sc); } if (e.ident == Id.getProtection) { if (dim != 1) goto Ldimerror; Scope* sc2 = sc.push(); sc2.flags = sc.flags | SCOPEnoaccesscheck; bool ok = TemplateInstance.semanticTiargs(e.loc, sc2, e.args, 1); sc2.pop(); if (!ok) return new ErrorExp(); auto o = (*e.args)[0]; auto s = getDsymbol(o); if (!s) { if (!isError(o)) e.error("argument %s has no protection", o.toChars()); return new ErrorExp(); } if (s._scope) s.semantic(s._scope); auto protName = protectionToChars(s.prot().kind); // TODO: How about package(names) assert(protName); auto se = new StringExp(e.loc, cast(char*)protName); return se.semantic(sc); } if (e.ident == Id.parent) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); if (s) { if (auto fd = s.isFuncDeclaration()) // Bugzilla 8943 s = fd.toAliasFunc(); if (!s.isImport()) // Bugzilla 8922 s = s.toParent(); } if (!s || s.isImport()) { e.error("argument %s has no parent", o.toChars()); return new ErrorExp(); } if (auto f = s.isFuncDeclaration()) { if (auto td = getFuncTemplateDecl(f)) { if (td.overroot) // if not start of overloaded list of TemplateDeclaration's td = td.overroot; // then get the start Expression ex = new TemplateExp(e.loc, td, f); ex = ex.semantic(sc); return ex; } if (auto fld = f.isFuncLiteralDeclaration()) { // Directly translate to VarExp instead of FuncExp Expression ex = new VarExp(e.loc, fld, true); return ex.semantic(sc); } } return DsymbolExp.resolve(e.loc, sc, s, false); } if (e.ident == Id.hasMember || e.ident == Id.getMember || e.ident == Id.getOverloads || e.ident == Id.getVirtualMethods || e.ident == Id.getVirtualFunctions) { if (dim != 2) goto Ldimerror; auto o = (*e.args)[0]; auto ex = isExpression((*e.args)[1]); if (!ex) { e.error("expression expected as second argument of __traits %s", e.ident.toChars()); return new ErrorExp(); } ex = ex.ctfeInterpret(); StringExp se = ex.toStringExp(); if (!se || se.len == 0) { e.error("string expected as second argument of __traits %s instead of %s", e.ident.toChars(), ex.toChars()); return new ErrorExp(); } se = se.toUTF8(sc); if (se.sz != 1) { e.error("string must be chars"); return new ErrorExp(); } auto id = Identifier.idPool(se.peekSlice()); /* Prefer dsymbol, because it might need some runtime contexts. */ Dsymbol sym = getDsymbol(o); if (sym) { ex = new DsymbolExp(e.loc, sym); ex = new DotIdExp(e.loc, ex, id); } else if (auto t = isType(o)) ex = typeDotIdExp(e.loc, t, id); else if (auto ex2 = isExpression(o)) ex = new DotIdExp(e.loc, ex2, id); else { e.error("invalid first argument"); return new ErrorExp(); } if (e.ident == Id.hasMember) { if (sym) { if (auto sm = sym.search(e.loc, id)) goto Ltrue; } /* Take any errors as meaning it wasn't found */ Scope* sc2 = sc.push(); ex = ex.trySemantic(sc2); sc2.pop(); if (!ex) goto Lfalse; else goto Ltrue; } else if (e.ident == Id.getMember) { ex = ex.semantic(sc); return ex; } else if (e.ident == Id.getVirtualFunctions || e.ident == Id.getVirtualMethods || e.ident == Id.getOverloads) { uint errors = global.errors; Expression eorig = ex; ex = ex.semantic(sc); if (errors < global.errors) e.error("%s cannot be resolved", eorig.toChars()); //ex->print(); /* Create tuple of functions of ex */ auto exps = new Expressions(); FuncDeclaration f; if (ex.op == TOKvar) { VarExp ve = cast(VarExp)ex; f = ve.var.isFuncDeclaration(); ex = null; } else if (ex.op == TOKdotvar) { DotVarExp dve = cast(DotVarExp)ex; f = dve.var.isFuncDeclaration(); if (dve.e1.op == TOKdottype || dve.e1.op == TOKthis) ex = null; else ex = dve.e1; } overloadApply(f, (Dsymbol s) { auto fd = s.isFuncDeclaration(); if (!fd) return 0; if (e.ident == Id.getVirtualFunctions && !fd.isVirtual()) return 0; if (e.ident == Id.getVirtualMethods && !fd.isVirtualMethod()) return 0; auto fa = new FuncAliasDeclaration(fd.ident, fd, false); fa.protection = fd.protection; auto e = ex ? new DotVarExp(Loc(), ex, fa, false) : new DsymbolExp(Loc(), fa, false); exps.push(e); return 0; }); auto tup = new TupleExp(e.loc, exps); return tup.semantic(sc); } else assert(0); } if (e.ident == Id.classInstanceSize) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); auto cd = s ? s.isClassDeclaration() : null; if (!cd) { e.error("first argument is not a class"); return new ErrorExp(); } if (cd.sizeok != SIZEOKdone) { cd.size(e.loc); } if (cd.sizeok != SIZEOKdone) { e.error("%s %s is forward referenced", cd.kind(), cd.toChars()); return new ErrorExp(); } return new IntegerExp(e.loc, cd.structsize, Type.tsize_t); } if (e.ident == Id.getAliasThis) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); auto ad = s ? s.isAggregateDeclaration() : null; if (!ad) { e.error("argument is not an aggregate type"); return new ErrorExp(); } auto exps = new Expressions(); if (ad.aliasthis) exps.push(new StringExp(e.loc, cast(char*)ad.aliasthis.ident.toChars())); Expression ex = new TupleExp(e.loc, exps); ex = ex.semantic(sc); return ex; } if (e.ident == Id.getAttributes) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); if (!s) { version (none) { Expression x = isExpression(o); Type t = isType(o); if (x) printf("e = %s %s\n", Token.toChars(x.op), x.toChars()); if (t) printf("t = %d %s\n", t.ty, t.toChars()); } e.error("first argument is not a symbol"); return new ErrorExp(); } if (auto imp = s.isImport()) { s = imp.mod; } //printf("getAttributes %s, attrs = %p, scope = %p\n", s->toChars(), s->userAttribDecl, s->scope); auto udad = s.userAttribDecl; auto exps = udad ? udad.getAttributes() : new Expressions(); auto tup = new TupleExp(e.loc, exps); return tup.semantic(sc); } if (e.ident == Id.getFunctionAttributes) { // extract all function attributes as a tuple (const/shared/inout/pure/nothrow/etc) except UDAs. if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); auto t = isType(o); TypeFunction tf = null; if (s) { if (auto fd = s.isFuncDeclaration()) t = fd.type; else if (auto vd = s.isVarDeclaration()) t = vd.type; } if (t) { if (t.ty == Tfunction) tf = cast(TypeFunction)t; else if (t.ty == Tdelegate) tf = cast(TypeFunction)t.nextOf(); else if (t.ty == Tpointer && t.nextOf().ty == Tfunction) tf = cast(TypeFunction)t.nextOf(); } if (!tf) { e.error("first argument is not a function"); return new ErrorExp(); } auto mods = new Expressions(); PushAttributes pa; pa.mods = mods; tf.modifiersApply(&pa, &PushAttributes.fp); tf.attributesApply(&pa, &PushAttributes.fp, TRUSTformatSystem); auto tup = new TupleExp(e.loc, mods); return tup.semantic(sc); } if (e.ident == Id.allMembers || e.ident == Id.derivedMembers) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); if (!s) { e.error("argument has no members"); return new ErrorExp(); } if (auto imp = s.isImport()) { // Bugzilla 9692 s = imp.mod; } auto sds = s.isScopeDsymbol(); if (!sds || sds.isTemplateDeclaration()) { e.error("%s %s has no members", s.kind(), s.toChars()); return new ErrorExp(); } auto idents = new Identifiers(); int pushIdentsDg(size_t n, Dsymbol sm) { if (!sm) return 1; //printf("\t[%i] %s %s\n", i, sm->kind(), sm->toChars()); if (sm.ident) { if (sm.ident.string[0] == '_' && sm.ident.string[1] == '_' && sm.ident != Id.ctor && sm.ident != Id.dtor && sm.ident != Id.__xdtor && sm.ident != Id.postblit && sm.ident != Id.__xpostblit) { return 0; } if (sm.ident == Id.empty) { return 0; } if (sm.isTypeInfoDeclaration()) // Bugzilla 15177 return 0; //printf("\t%s\n", sm->ident->toChars()); /* Skip if already present in idents[] */ foreach (id; *idents) { if (id == sm.ident) return 0; // Avoid using strcmp in the first place due to the performance impact in an O(N^2) loop. debug assert(strcmp(id.toChars(), sm.ident.toChars()) != 0); } idents.push(sm.ident); } else if (auto ed = sm.isEnumDeclaration()) { ScopeDsymbol._foreach(null, ed.members, &pushIdentsDg); } return 0; } ScopeDsymbol._foreach(sc, sds.members, &pushIdentsDg); auto cd = sds.isClassDeclaration(); if (cd && e.ident == Id.allMembers) { if (cd._scope) cd.semantic(null); // Bugzilla 13668: Try to resolve forward reference void pushBaseMembersDg(ClassDeclaration cd) { for (size_t i = 0; i < cd.baseclasses.dim; i++) { auto cb = (*cd.baseclasses)[i].sym; assert(cb); ScopeDsymbol._foreach(null, cb.members, &pushIdentsDg); if (cb.baseclasses.dim) pushBaseMembersDg(cb); } } pushBaseMembersDg(cd); } // Turn Identifiers into StringExps reusing the allocated array assert(Expressions.sizeof == Identifiers.sizeof); auto exps = cast(Expressions*)idents; foreach (i, id; *idents) { auto se = new StringExp(e.loc, cast(char*)id.toChars()); (*exps)[i] = se; } /* Making this a tuple is more flexible, as it can be statically unrolled. * To make an array literal, enclose __traits in [ ]: * [ __traits(allMembers, ...) ] */ Expression ex = new TupleExp(e.loc, exps); ex = ex.semantic(sc); return ex; } if (e.ident == Id.compiles) { /* Determine if all the objects - types, expressions, or symbols - * compile without error */ if (!dim) goto Lfalse; foreach (o; *e.args) { uint errors = global.startGagging(); Scope* sc2 = sc.push(); sc2.tinst = null; sc2.minst = null; sc2.flags = (sc.flags & ~(SCOPEctfe | SCOPEcondition)) | SCOPEcompile | SCOPEfullinst; bool err = false; auto t = isType(o); auto ex = t ? t.toExpression() : isExpression(o); if (!ex && t) { Dsymbol s; t.resolve(e.loc, sc2, &ex, &t, &s); if (t) { t.semantic(e.loc, sc2); if (t.ty == Terror) err = true; } else if (s && s.errors) err = true; } if (ex) { ex = ex.semantic(sc2); ex = resolvePropertiesOnly(sc2, ex); ex = ex.optimize(WANTvalue); if (sc2.func && sc2.func.type.ty == Tfunction) { auto tf = cast(TypeFunction)sc2.func.type; canThrow(ex, sc2.func, tf.isnothrow); } ex = checkGC(sc2, ex); if (ex.op == TOKerror) err = true; } sc2.pop(); if (global.endGagging(errors) || err) { goto Lfalse; } } goto Ltrue; } if (e.ident == Id.isSame) { /* Determine if two symbols are the same */ if (dim != 2) goto Ldimerror; if (!TemplateInstance.semanticTiargs(e.loc, sc, e.args, 0)) return new ErrorExp(); auto o1 = (*e.args)[0]; auto o2 = (*e.args)[1]; auto s1 = getDsymbol(o1); auto s2 = getDsymbol(o2); //printf("isSame: %s, %s\n", o1->toChars(), o2->toChars()); version (none) { printf("o1: %p\n", o1); printf("o2: %p\n", o2); if (!s1) { if (auto ea = isExpression(o1)) printf("%s\n", ea.toChars()); if (auto ta = isType(o1)) printf("%s\n", ta.toChars()); goto Lfalse; } else printf("%s %s\n", s1.kind(), s1.toChars()); } if (!s1 && !s2) { auto ea1 = isExpression(o1); auto ea2 = isExpression(o2); if (ea1 && ea2) { if (ea1.equals(ea2)) goto Ltrue; } } if (!s1 || !s2) goto Lfalse; s1 = s1.toAlias(); s2 = s2.toAlias(); if (auto fa1 = s1.isFuncAliasDeclaration()) s1 = fa1.toAliasFunc(); if (auto fa2 = s2.isFuncAliasDeclaration()) s2 = fa2.toAliasFunc(); if (s1 == s2) goto Ltrue; else goto Lfalse; } if (e.ident == Id.getUnitTests) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); if (!s) { e.error("argument %s to __traits(getUnitTests) must be a module or aggregate", o.toChars()); return new ErrorExp(); } if (auto imp = s.isImport()) // Bugzilla 10990 s = imp.mod; auto sds = s.isScopeDsymbol(); if (!sds) { e.error("argument %s to __traits(getUnitTests) must be a module or aggregate, not a %s", s.toChars(), s.kind()); return new ErrorExp(); } auto exps = new Expressions(); if (global.params.useUnitTests) { bool[void*] uniqueUnitTests; void collectUnitTests(Dsymbols* a) { if (!a) return; foreach (s; *a) { if (auto atd = s.isAttribDeclaration()) { collectUnitTests(atd.include(null, null)); continue; } if (auto ud = s.isUnitTestDeclaration()) { if (cast(void*)ud in uniqueUnitTests) continue; auto ad = new FuncAliasDeclaration(ud.ident, ud, false); ad.protection = ud.protection; auto e = new DsymbolExp(Loc(), ad, false); exps.push(e); uniqueUnitTests[cast(void*)ud] = true; } } } collectUnitTests(sds.members); } auto te = new TupleExp(e.loc, exps); return te.semantic(sc); } if (e.ident == Id.getVirtualIndex) { if (dim != 1) goto Ldimerror; auto o = (*e.args)[0]; auto s = getDsymbol(o); auto fd = s ? s.isFuncDeclaration() : null; if (!fd) { e.error("first argument to __traits(getVirtualIndex) must be a function"); return new ErrorExp(); } fd = fd.toAliasFunc(); // Neccessary to support multiple overloads. return new IntegerExp(e.loc, fd.vtblIndex, Type.tptrdiff_t); } if (e.ident == Id.getPointerBitmap) { return pointerBitmap(e); } extern (D) void* trait_search_fp(const(char)* seed, ref int cost) { //printf("trait_search_fp('%s')\n", seed); size_t len = strlen(seed); if (!len) return null; cost = 0; StringValue* sv = traitsStringTable.lookup(seed, len); return sv ? sv.ptrvalue : null; } if (auto sub = cast(const(char)*)speller(e.ident.toChars(), &trait_search_fp, idchars)) e.error("unrecognized trait '%s', did you mean '%s'?", e.ident.toChars(), sub); else e.error("unrecognized trait '%s'", e.ident.toChars()); return new ErrorExp(); Ldimerror: e.error("wrong number of arguments %d", cast(int)dim); return new ErrorExp(); Lfalse: return new IntegerExp(e.loc, 0, Type.tbool); Ltrue: return new IntegerExp(e.loc, 1, Type.tbool); }
D
/* PERMUTE_ARGS: REQUIRED_ARGS: -dip25 TEST_OUTPUT: --- fail_compilation/fail_scope.d(45): Error: escaping reference to local variable string fail_compilation/fail_scope.d(63): Error: escaping reference to local variable s fail_compilation/fail_scope.d(82): Error: escaping reference to local variable string fail_compilation/fail_scope.d(92): Error: escaping reference to local variable a fail_compilation/fail_scope.d(100): Error: escaping reference to local variable a fail_compilation/fail_scope.d(108): Error: escaping reference to outer local variable x fail_compilation/fail_scope.d(127): Error: escaping reference to local variable s fail_compilation/fail_scope.d(137): Error: escaping reference to local variable i --- //fail_compilation/fail_scope.d(30): Error: scope variable da may not be returned //fail_compilation/fail_scope.d(32): Error: scope variable o may not be returned //fail_compilation/fail_scope.d(33): Error: scope variable dg may not be returned //fail_compilation/fail_scope.d(35): Error: scope variable da may not be returned //fail_compilation/fail_scope.d(37): Error: scope variable o may not be returned //fail_compilation/fail_scope.d(38): Error: scope variable dg may not be returned //fail_compilation/fail_scope.d(40): Error: scope variable p may not be returned */ alias int delegate() dg_t; int[] checkEscapeScope1(scope int[] da) { return da; } int[3] checkEscapeScope2(scope int[3] sa) { return sa; } Object checkEscapeScope3(scope Object o) { return o; } dg_t checkEscapeScope4(scope dg_t dg) { return dg; } int[] checkEscapeScope1() { scope int[] da = []; return da; } int[3] checkEscapeScope2() { scope int[3] sa = [1,2,3]; return sa; } Object checkEscapeScope3() { scope Object o = new Object; return o; } // same with fail7294.d dg_t checkEscapeScope4() { scope dg_t dg = () => 1; return dg; } int* test(scope int* p) @safe { return p; } char[] foo140() { char[4] string = "abcd"; return string; } /************/ struct S { int x; ref int bar() return { return x; } } ref int test() { S s; return s.bar(); } /************/ ref int foo8(ref int x); ref int foo8(return ref int x); void testover() { int x; foo8(x); } /************/ char* fail141() { char[4] string = "abcd"; return string.ptr; } /************/ int[] test1313b() out{} body { int[2] a; return a; } int[] test1313a() //out{} body { int[2] a; return a; } /******************/ // https://issues.dlang.org/show_bug.cgi?id=15192 ref int fun15192(ref int x) @safe { ref int bar(){ return x; } return bar(); } ref int fun15192_2(return ref int x) @safe { ref int bar(){ return x; } return bar(); } /**************************/ // https://issues.dlang.org/show_bug.cgi?id=15193 ref int foo15193()@safe{ struct S{ int x; ref int bar() { return x; } } S s; return s.bar(); } /*****************************/ // https://issues.dlang.org/show_bug.cgi?id=16226 ref int test16226() @safe { int i; return foo16226(i); } ref foo16226(ref int bar) @safe { return bar; }
D
/Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/Objects-normal-tsan/x86_64/InterfaceController.o : /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/InterfaceController.swift /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/SwipeViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/Target\ Support\ Files/SwipeViewController/SwipeViewController-umbrella.h /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/unextended-module.modulemap /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/Objects-normal-tsan/x86_64/SwipeViewController.o : /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/InterfaceController.swift /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/SwipeViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/Target\ Support\ Files/SwipeViewController/SwipeViewController-umbrella.h /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/unextended-module.modulemap /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/Objects-normal-tsan/x86_64/SwipeViewController.swiftmodule : /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/InterfaceController.swift /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/SwipeViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/Target\ Support\ Files/SwipeViewController/SwipeViewController-umbrella.h /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/unextended-module.modulemap /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/Objects-normal-tsan/x86_64/SwipeViewController.swiftdoc : /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/InterfaceController.swift /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/SwipeViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/Target\ Support\ Files/SwipeViewController/SwipeViewController-umbrella.h /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/unextended-module.modulemap /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/Objects-normal-tsan/x86_64/SwipeViewController-Swift.h : /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/InterfaceController.swift /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/SwipeViewController/Pod/Classes/SwipeViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Users/apple-1/Documents/xCode/CoreDataSampleApp/Pods/Target\ Support\ Files/SwipeViewController/SwipeViewController-umbrella.h /Users/apple-1/Documents/xCode/CoreDataSampleApp/Build/Intermediates/Pods.build/Release-iphonesimulator/SwipeViewController.build/unextended-module.modulemap
D
/******************************************************************************* * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Port to the D programming language: * Frank Benoit <[email protected]> *******************************************************************************/ module dwt.custom.CTabItem; import dwt.dwthelper.utils; import dwt.DWT; import dwt.DWTException; import dwt.graphics.Color; import dwt.graphics.Font; import dwt.graphics.GC; import dwt.graphics.Image; import dwt.graphics.Point; import dwt.graphics.RGB; import dwt.graphics.Rectangle; import dwt.graphics.TextLayout; import dwt.widgets.Control; import dwt.widgets.Display; import dwt.widgets.Item; import dwt.widgets.Widget; import dwt.custom.CTabFolder; /** * Instances of this class represent a selectable user interface object * that represent a page in a notebook widget. * * <dl> * <dt><b>Styles:</b></dt> * <dd>DWT.CLOSE</dd> * <dt><b>Events:</b></dt> * <dd>(none)</dd> * </dl> * <p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> * * @see <a href="http://www.eclipse.org/swt/snippets/#ctabfolder">CTabFolder, CTabItem snippets</a> * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class CTabItem : Item { CTabFolder parent; int x,y,width,height = 0; Control control; // the tab page String toolTipText; String shortenedText; int shortenedTextWidth; // Appearance Font font; Image disabledImage; Rectangle closeRect; int closeImageState = CTabFolder.NONE; bool showClose = false; bool showing = false; // internal constants static final int TOP_MARGIN = 2; static final int BOTTOM_MARGIN = 2; static final int LEFT_MARGIN = 4; static final int RIGHT_MARGIN = 4; static final int INTERNAL_SPACING = 4; static final int FLAGS = DWT.DRAW_TRANSPARENT | DWT.DRAW_MNEMONIC; static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026" /** * Constructs a new instance of this class given its parent * (which must be a <code>CTabFolder</code>) and a style value * describing its behavior and appearance. The item is added * to the end of the items maintained by its parent. * <p> * The style value is either one of the style constants defined in * class <code>DWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>DWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a CTabFolder which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * </ul> * * @see DWT * @see Widget#getStyle() */ public this (CTabFolder parent, int style) { this(parent, style, parent.getItemCount()); } /** * Constructs a new instance of this class given its parent * (which must be a <code>CTabFolder</code>), a style value * describing its behavior and appearance, and the index * at which to place it in the items maintained by its parent. * <p> * The style value is either one of the style constants defined in * class <code>DWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>DWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a CTabFolder which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * @param index the zero-relative index to store the receiver in its parent * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li> * </ul> * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * </ul> * * @see DWT * @see Widget#getStyle() */ public this (CTabFolder parent, int style, int index) { closeRect = new Rectangle(0, 0, 0, 0); super (parent, style); showClose = (style & DWT.CLOSE) !is 0; parent.createItem (this, index); } /* * Return whether to use ellipses or just truncate labels */ bool useEllipses() { return parent.simple; } String shortenText(GC gc, String text, int width) { return useEllipses() ? shortenText(gc, text, width, ELLIPSIS) : shortenText(gc, text, width, ""); //$NON-NLS-1$ } String shortenText(GC gc, String text, int width, String ellipses) { if (gc.textExtent(text, FLAGS).x <= width) return text; int ellipseWidth = gc.textExtent(ellipses, FLAGS).x; int length = text.length; TextLayout layout = new TextLayout(getDisplay()); layout.setText(text); int end = layout.getPreviousOffset(length, DWT.MOVEMENT_CLUSTER); while (end > 0) { text = text[ 0 .. end ]; int l = gc.textExtent(text, FLAGS).x; if (l + ellipseWidth <= width) { break; } end = layout.getPreviousOffset(end, DWT.MOVEMENT_CLUSTER); } layout.dispose(); return end is 0 ? text.substring(0, 1) : text ~ ellipses; } public override void dispose() { if (isDisposed ()) return; //if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); parent.destroyItem(this); super.dispose(); parent = null; control = null; toolTipText = null; shortenedText = null; font = null; } void drawClose(GC gc) { if (closeRect.width is 0 || closeRect.height is 0) return; Display display = getDisplay(); // draw X 9x9 int indent = Math.max(1, (CTabFolder.BUTTON_SIZE-9)/2); int x = closeRect.x + indent; int y = closeRect.y + indent; y += parent.onBottom ? -1 : 1; Color closeBorder = display.getSystemColor(CTabFolder.BUTTON_BORDER); switch (closeImageState) { case CTabFolder.NORMAL: { int[] shape = [x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9, x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9, x,y+7, x+2,y+5, x+2,y+4, x,y+2]; gc.setBackground(display.getSystemColor(CTabFolder.BUTTON_FILL)); gc.fillPolygon(shape); gc.setForeground(closeBorder); gc.drawPolygon(shape); break; } case CTabFolder.HOT: { int[] shape = [x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9, x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9, x,y+7, x+2,y+5, x+2,y+4, x,y+2]; Color fill = new Color(display, CTabFolder.CLOSE_FILL); gc.setBackground(fill); gc.fillPolygon(shape); fill.dispose(); gc.setForeground(closeBorder); gc.drawPolygon(shape); break; } case CTabFolder.SELECTED: { int[] shape = [x+1,y+1, x+3,y+1, x+5,y+3, x+6,y+3, x+8,y+1, x+10,y+1, x+10,y+3, x+8,y+5, x+8,y+6, x+10,y+8, x+10,y+10, x+8,y+10, x+6,y+8, x+5,y+8, x+3,y+10, x+1,y+10, x+1,y+8, x+3,y+6, x+3,y+5, x+1,y+3]; Color fill = new Color(display, CTabFolder.CLOSE_FILL); gc.setBackground(fill); gc.fillPolygon(shape); fill.dispose(); gc.setForeground(closeBorder); gc.drawPolygon(shape); break; } case CTabFolder.NONE: { int[] shape = [x,y, x+10,y, x+10,y+10, x,y+10]; if (parent.gradientColors !is null && !parent.gradientVertical) { parent.drawBackground(gc, shape, false); } else { Color defaultBackground = parent.getBackground(); Image image = parent.bgImage; Color[] colors = parent.gradientColors; int[] percents = parent.gradientPercents; bool vertical = parent.gradientVertical; parent.drawBackground(gc, shape, x, y, 10, 10, defaultBackground, image, colors, percents, vertical); } break; } default: } } void drawSelected(GC gc ) { Point size = parent.getSize(); int rightEdge = Math.min (x + width, parent.getRightItemEdge()); // Draw selection border across all tabs int xx = parent.borderLeft; int yy = parent.onBottom ? size.y - parent.borderBottom - parent.tabHeight - parent.highlight_header : parent.borderTop + parent.tabHeight + 1; int ww = size.x - parent.borderLeft - parent.borderRight; int hh = parent.highlight_header - 1; int[] shape = [xx,yy, xx+ww,yy, xx+ww,yy+hh, xx,yy+hh]; if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) { parent.drawBackground(gc, shape, true); } else { gc.setBackground(parent.selectionBackground); gc.fillRectangle(xx, yy, ww, hh); } if (parent.single) { if (!showing) return; } else { // if selected tab scrolled out of view or partially out of view // just draw bottom line if (!showing) { int x1 = Math.max(0, parent.borderLeft - 1); int y1 = (parent.onBottom) ? y - 1 : y + height; int x2 = size.x - parent.borderRight; gc.setForeground(CTabFolder.borderColor); gc.drawLine(x1, y1, x2, y1); return; } // draw selected tab background and outline shape = null; if (this.parent.onBottom) { int[] left = parent.simple ? CTabFolder.SIMPLE_BOTTOM_LEFT_CORNER : CTabFolder.BOTTOM_LEFT_CORNER; int[] right = parent.simple ? CTabFolder.SIMPLE_BOTTOM_RIGHT_CORNER : parent.curve; if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { left = [x, y+height]; } shape = new int[left.length+right.length+8]; int index = 0; shape[index++] = x; // first point repeated here because below we reuse shape to draw outline shape[index++] = y - 1; shape[index++] = x; shape[index++] = y - 1; for (int i = 0; i < left.length/2; i++) { shape[index++] = x + left[2*i]; shape[index++] = y + height + left[2*i+1] - 1; } for (int i = 0; i < right.length/2; i++) { shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i]; shape[index++] = parent.simple ? y + height + right[2*i+1] - 1 : y + right[2*i+1] - 2; } shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; shape[index++] = y - 1; shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; shape[index++] = y - 1; } else { int[] left = parent.simple ? CTabFolder.SIMPLE_TOP_LEFT_CORNER : CTabFolder.TOP_LEFT_CORNER; int[] right = parent.simple ? CTabFolder.SIMPLE_TOP_RIGHT_CORNER : parent.curve; if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { left = [x, y]; } shape = new int[left.length+right.length+8]; int index = 0; shape[index++] = x; // first point repeated here because below we reuse shape to draw outline shape[index++] = y + height + 1; shape[index++] = x; shape[index++] = y + height + 1; for (int i = 0; i < left.length/2; i++) { shape[index++] = x + left[2*i]; shape[index++] = y + left[2*i+1]; } for (int i = 0; i < right.length/2; i++) { shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i]; shape[index++] = y + right[2*i+1]; } shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; shape[index++] = y + height + 1; shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; shape[index++] = y + height + 1; } Rectangle clipping = gc.getClipping(); Rectangle bounds = getBounds(); bounds.height += 1; if (parent.onBottom) bounds.y -= 1; bool tabInPaint = clipping.intersects(bounds); if (tabInPaint) { // fill in tab background if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) { parent.drawBackground(gc, shape, true); } else { Color defaultBackground = parent.selectionBackground; Image image = parent.selectionBgImage; Color[] colors = parent.selectionGradientColors; int[] percents = parent.selectionGradientPercents; bool vertical = parent.selectionGradientVertical; xx = x; yy = parent.onBottom ? y -1 : y + 1; ww = width; hh = height; if (!parent.single && !parent.simple) ww += parent.curveWidth - parent.curveIndent; parent.drawBackground(gc, shape, xx, yy, ww, hh, defaultBackground, image, colors, percents, vertical); } } //Highlight MUST be drawn before the outline so that outline can cover it in the right spots (start of swoop) //otherwise the curve looks jagged drawHighlight(gc, rightEdge); // draw outline shape[0] = Math.max(0, parent.borderLeft - 1); if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { shape[1] = parent.onBottom ? y + height - 1 : y; shape[5] = shape[3] = shape[1]; } shape[shape.length - 2] = size.x - parent.borderRight + 1; for (int i = 0; i < shape.length/2; i++) { if (shape[2*i + 1] is y + height + 1) shape[2*i + 1] -= 1; } RGB inside = parent.selectionBackground.getRGB(); if (parent.selectionBgImage !is null || (parent.selectionGradientColors !is null && parent.selectionGradientColors.length > 1)) { inside = null; } RGB outside = parent.getBackground().getRGB(); if (parent.bgImage !is null || (parent.gradientColors !is null && parent.gradientColors.length > 1)) { outside = null; } parent.antialias(shape, CTabFolder.borderColor.getRGB(), inside, outside, gc); gc.setForeground(CTabFolder.borderColor); gc.drawPolyline(shape); if (!tabInPaint) return; } // draw Image int xDraw = x + LEFT_MARGIN; if (parent.single && (parent.showClose || showClose)) xDraw += CTabFolder.BUTTON_SIZE; Image image = getImage(); if (image !is null) { Rectangle imageBounds = image.getBounds(); // only draw image if it won't overlap with close button int maxImageWidth = rightEdge - xDraw - RIGHT_MARGIN; if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING; if (imageBounds.width < maxImageWidth) { int imageX = xDraw; int imageY = y + (height - imageBounds.height) / 2; imageY += parent.onBottom ? -1 : 1; gc.drawImage(image, imageX, imageY); xDraw += imageBounds.width + INTERNAL_SPACING; } } // draw Text int textWidth = rightEdge - xDraw - RIGHT_MARGIN; if (!parent.single && closeRect.width > 0) textWidth -= closeRect.width + INTERNAL_SPACING; if (textWidth > 0) { Font gcFont = gc.getFont(); gc.setFont(font is null ? parent.getFont() : font); if (shortenedText is null || shortenedTextWidth !is textWidth) { shortenedText = shortenText(gc, getText(), textWidth); shortenedTextWidth = textWidth; } Point extent = gc.textExtent(shortenedText, FLAGS); int textY = y + (height - extent.y) / 2; textY += parent.onBottom ? -1 : 1; gc.setForeground(parent.selectionForeground); gc.drawText(shortenedText, xDraw, textY, FLAGS); gc.setFont(gcFont); // draw a Focus rectangle if (parent.isFocusControl()) { Display display = getDisplay(); if (parent.simple || parent.single) { gc.setBackground(display.getSystemColor(DWT.COLOR_BLACK)); gc.setForeground(display.getSystemColor(DWT.COLOR_WHITE)); gc.drawFocus(xDraw-1, textY-1, extent.x+2, extent.y+2); } else { gc.setForeground(display.getSystemColor(CTabFolder.BUTTON_BORDER)); gc.drawLine(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1); } } } if (parent.showClose || showClose) drawClose(gc); } /* * Draw a highlight effect along the left, top, and right edges of the tab. * Only for curved tabs, on top. * Do not draw if insufficient colors. */ void drawHighlight(GC gc, int rightEdge) { //only draw for curvy tabs and only draw for top tabs if(parent.simple || this.parent.onBottom) return; if(parent.selectionHighlightGradientBegin is null) return; Color[] gradients = parent.selectionHighlightGradientColorsCache; if(gradients is null) return; int gradientsSize = gradients.length; if(gradientsSize is 0) return; //shouldn't happen but just to be tidy gc.setForeground(gradients[0]); //draw top horizontal line gc.drawLine( CTabFolder.TOP_LEFT_CORNER_HILITE[0] + x + 1, //rely on fact that first pair is top/right of curve 1 + y, rightEdge - parent.curveIndent, 1 + y); int[] leftHighlightCurve = CTabFolder.TOP_LEFT_CORNER_HILITE; int d = parent.tabHeight - parent.topCurveHighlightEnd.length /2; int lastX = 0; int lastY = 0; int lastColorIndex = 0; //draw upper left curve highlight for (int i = 0; i < leftHighlightCurve.length /2; i++) { int rawX = leftHighlightCurve[i * 2]; int rawY = leftHighlightCurve[i * 2 + 1]; lastX = rawX + x; lastY = rawY + y; lastColorIndex = rawY - 1; gc.setForeground(gradients[lastColorIndex]); gc.drawPoint(lastX, lastY); } //draw left vertical line highlight for(int i = lastColorIndex; i < gradientsSize; i++) { gc.setForeground(gradients[i]); gc.drawPoint(lastX, 1 + lastY++); } int rightEdgeOffset = rightEdge - parent.curveIndent; //draw right swoop highlight up to diagonal portion for (int i = 0; i < parent.topCurveHighlightStart.length /2; i++) { int rawX = parent.topCurveHighlightStart[i * 2]; int rawY = parent.topCurveHighlightStart[i * 2 + 1]; lastX = rawX + rightEdgeOffset; lastY = rawY + y; lastColorIndex = rawY - 1; if(lastColorIndex >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[lastColorIndex]); gc.drawPoint(lastX, lastY); } //draw right diagonal line highlight for(int i = lastColorIndex; i < lastColorIndex + d; i++) { if(i >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[i]); gc.drawPoint(1 + lastX++, 1 + lastY++); } //draw right swoop highlight from diagonal portion to end for (int i = 0; i < parent.topCurveHighlightEnd.length /2; i++) { int rawX = parent.topCurveHighlightEnd[i * 2]; //d is already encoded in this value int rawY = parent.topCurveHighlightEnd[i * 2 + 1]; //d already encoded lastX = rawX + rightEdgeOffset; lastY = rawY + y; lastColorIndex = rawY - 1; if(lastColorIndex >= gradientsSize) break; //can happen if tabs are unusually short and cut off the curve gc.setForeground(gradients[lastColorIndex]); gc.drawPoint(lastX, lastY); } } /* * Draw the unselected border for the receiver on the right. * * @param gc */ void drawRightUnselectedBorder(GC gc) { int[] shape = null; int startX = x + width - 1; if (this.parent.onBottom) { int[] right = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.BOTTOM_RIGHT_CORNER; shape = new int[right.length + 2]; int index = 0; for (int i = 0; i < right.length / 2; i++) { shape[index++] = startX + right[2 * i]; shape[index++] = y + height + right[2 * i + 1] - 1; } shape[index++] = startX; shape[index++] = y - 1; } else { int[] right = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.TOP_RIGHT_CORNER; shape = new int[right.length + 2]; int index = 0; for (int i = 0; i < right.length / 2; i++) { shape[index++] = startX + right[2 * i]; shape[index++] = y + right[2 * i + 1]; } shape[index++] = startX; shape[index++] = y + height; } drawBorder(gc, shape); } /* * Draw the border of the tab * * @param gc * @param shape */ void drawBorder(GC gc, int[] shape) { gc.setForeground(CTabFolder.borderColor); gc.drawPolyline(shape); } /* * Draw the unselected border for the receiver on the left. * * @param gc */ void drawLeftUnselectedBorder(GC gc) { int[] shape = null; if (this.parent.onBottom) { int[] left = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.BOTTOM_LEFT_CORNER; shape = new int[left.length + 2]; int index = 0; shape[index++] = x; shape[index++] = y - 1; for (int i = 0; i < left.length / 2; i++) { shape[index++] = x + left[2 * i]; shape[index++] = y + height + left[2 * i + 1] - 1; } } else { int[] left = parent.simple ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER : CTabFolder.TOP_LEFT_CORNER; shape = new int[left.length + 2]; int index = 0; shape[index++] = x; shape[index++] = y + height; for (int i = 0; i < left.length / 2; i++) { shape[index++] = x + left[2 * i]; shape[index++] = y + left[2 * i + 1]; } } drawBorder(gc, shape); } void drawUnselected(GC gc) { // Do not draw partial items if (!showing) return; Rectangle clipping = gc.getClipping(); Rectangle bounds = getBounds(); if (!clipping.intersects(bounds)) return; // draw border int index = parent.indexOf(this); if (index > 0 && index < parent.selectedIndex) drawLeftUnselectedBorder(gc); // If it is the last one then draw a line if (index > parent.selectedIndex) drawRightUnselectedBorder(gc); // draw Image int xDraw = x + LEFT_MARGIN; Image image = getImage(); if (image !is null && parent.showUnselectedImage) { Rectangle imageBounds = image.getBounds(); // only draw image if it won't overlap with close button int maxImageWidth = x + width - xDraw - RIGHT_MARGIN; if (parent.showUnselectedClose && (parent.showClose || showClose)) { maxImageWidth -= closeRect.width + INTERNAL_SPACING; } if (imageBounds.width < maxImageWidth) { int imageX = xDraw; int imageHeight = imageBounds.height; int imageY = y + (height - imageHeight) / 2; imageY += parent.onBottom ? -1 : 1; int imageWidth = imageBounds.width * imageHeight / imageBounds.height; gc.drawImage(image, imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, imageX, imageY, imageWidth, imageHeight); xDraw += imageWidth + INTERNAL_SPACING; } } // draw Text int textWidth = x + width - xDraw - RIGHT_MARGIN; if (parent.showUnselectedClose && (parent.showClose || showClose)) { textWidth -= closeRect.width + INTERNAL_SPACING; } if (textWidth > 0) { Font gcFont = gc.getFont(); gc.setFont(font is null ? parent.getFont() : font); if (shortenedText is null || shortenedTextWidth !is textWidth) { shortenedText = shortenText(gc, getText(), textWidth); shortenedTextWidth = textWidth; } Point extent = gc.textExtent(shortenedText, FLAGS); int textY = y + (height - extent.y) / 2; textY += parent.onBottom ? -1 : 1; gc.setForeground(parent.getForeground()); gc.drawText(shortenedText, xDraw, textY, FLAGS); gc.setFont(gcFont); } // draw close if (parent.showUnselectedClose && (parent.showClose || showClose)) drawClose(gc); } /** * Returns a rectangle describing the receiver's size and location * relative to its parent. * * @return the receiver's bounding column rectangle * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public Rectangle getBounds () { //checkWidget(); int w = width; if (!parent.simple && !parent.single && parent.indexOf(this) is parent.selectedIndex) w += parent.curveWidth - parent.curveIndent; return new Rectangle(x, y, w, height); } /** * Gets the control that is displayed in the content area of the tab item. * * @return the control * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public Control getControl () { checkWidget(); return control; } /** * Get the image displayed in the tab if the tab is disabled. * * @return the disabled image or null * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @deprecated the disabled image is not used */ public Image getDisabledImage() { checkWidget(); return disabledImage; } /** * Returns the font that the receiver will use to paint textual information. * * @return the receiver's font * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 */ public Font getFont() { checkWidget(); if (font !is null) return font; return parent.getFont(); } /** * Returns the receiver's parent, which must be a <code>CTabFolder</code>. * * @return the receiver's parent * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public CTabFolder getParent () { //checkWidget(); return parent; } /** * Returns <code>true</code> to indicate that the receiver's close button should be shown. * Otherwise return <code>false</code>. The initial value is defined by the style (DWT.CLOSE) * that was used to create the receiver. * * @return <code>true</code> if the close button should be shown * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.4 */ public bool getShowClose() { checkWidget(); return showClose; } /** * Returns the receiver's tool tip text, or null if it has * not been set. * * @return the receiver's tool tip text * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public String getToolTipText () { checkWidget(); if (toolTipText is null && shortenedText !is null) { String text = getText(); if (shortenedText!=text) return text; } return toolTipText; } /** * Returns <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise. * * @return <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise. * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 */ public bool isShowing () { checkWidget(); return showing; } void onPaint(GC gc, bool isSelected) { if (width is 0 || height is 0) return; if (isSelected) { drawSelected(gc); } else { drawUnselected(gc); } } int preferredHeight(GC gc) { Image image = getImage(); int h = (image is null) ? 0 : image.getBounds().height; String text = getText(); if (font is null) { h = Math.max(h, gc.textExtent(text, FLAGS).y); } else { Font gcFont = gc.getFont(); gc.setFont(font); h = Math.max(h, gc.textExtent(text, FLAGS).y); gc.setFont(gcFont); } return h + TOP_MARGIN + BOTTOM_MARGIN; } int preferredWidth(GC gc, bool isSelected, bool minimum) { // NOTE: preferred width does not include the "dead space" caused // by the curve. if (isDisposed()) return 0; int w = 0; Image image = getImage(); if (image !is null && (isSelected || parent.showUnselectedImage)) { w += image.getBounds().width; } String text = null; if (minimum) { int minChars = parent.minChars; text = minChars is 0 ? null : getText(); if (text !is null && text.length > minChars) { if (useEllipses()) { int end = minChars < ELLIPSIS.length + 1 ? minChars : minChars - ELLIPSIS.length; text = text[ 0 .. end ]; if (minChars > ELLIPSIS.length + 1) text ~= ELLIPSIS; } else { int end = minChars; text = text[ 0 .. end ]; } } } else { text = getText(); } if (text !is null) { if (w > 0) w += INTERNAL_SPACING; if (font is null) { w += gc.textExtent(text, FLAGS).x; } else { Font gcFont = gc.getFont(); gc.setFont(font); w += gc.textExtent(text, FLAGS).x; gc.setFont(gcFont); } } if (parent.showClose || showClose) { if (isSelected || parent.showUnselectedClose) { if (w > 0) w += INTERNAL_SPACING; w += CTabFolder.BUTTON_SIZE; } } return w + LEFT_MARGIN + RIGHT_MARGIN; } /** * Sets the control that is used to fill the client area of * the tab folder when the user selects the tab item. * * @param control the new control (or null) * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li> * </ul> * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setControl (Control control) { checkWidget(); if (control !is null) { if (control.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); if (control.getParent() !is parent) DWT.error (DWT.ERROR_INVALID_PARENT); } if (this.control !is null && !this.control.isDisposed()) { this.control.setVisible(false); } this.control = control; if (this.control !is null) { int index = parent.indexOf (this); if (index is parent.getSelectionIndex ()) { this.control.setBounds(parent.getClientArea ()); this.control.setVisible(true); } else { this.control.setVisible(false); } } } /** * Sets the image that is displayed if the tab item is disabled. * Null will clear the image. * * @param image the image to be displayed when the item is disabled or null * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @deprecated This image is not used */ public void setDisabledImage (Image image) { checkWidget(); if (image !is null && image.isDisposed ()) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } this.disabledImage = image; } /** * Sets the font that the receiver will use to paint textual information * for this item to the font specified by the argument, or to the default font * for that kind of control if the argument is null. * * @param font the new font (or null) * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> * </ul> * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.0 */ public void setFont (Font font) { checkWidget(); if (font !is null && font.isDisposed ()) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } if (font is null && this.font is null) return; if (font !is null && font==this.font) return; this.font = font; if (!parent.updateTabHeight(false)) { parent.updateItems(); parent.redrawTabs(); } } public override void setImage (Image image) { checkWidget(); if (image !is null && image.isDisposed ()) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } Image oldImage = getImage(); if (image is null && oldImage is null) return; if (image !is null && image==oldImage) return; super.setImage(image); if (!parent.updateTabHeight(false)) { // If image is the same size as before, // redraw only the image if (oldImage !is null && image !is null) { Rectangle oldBounds = oldImage.getBounds(); Rectangle bounds = image.getBounds(); if (bounds.width is oldBounds.width && bounds.height is oldBounds.height) { if (showing) { bool selected = parent.indexOf(this) is parent.selectedIndex; if (selected || parent.showUnselectedImage) { int imageX = x + LEFT_MARGIN, maxImageWidth; if (selected) { if (parent.single && (parent.showClose || showClose)) imageX += CTabFolder.BUTTON_SIZE; int rightEdge = Math.min (x + width, parent.getRightItemEdge()); maxImageWidth = rightEdge - imageX - RIGHT_MARGIN; if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING; } else { maxImageWidth = x + width - imageX - RIGHT_MARGIN; if (parent.showUnselectedClose && (parent.showClose || showClose)) { maxImageWidth -= closeRect.width + INTERNAL_SPACING; } } if (bounds.width < maxImageWidth) { int imageY = y + (height - bounds.height) / 2 + (parent.onBottom ? -1 : 1); parent.redraw(imageX, imageY, bounds.width, bounds.height, false); } } } return; } } parent.updateItems(); parent.redrawTabs(); } } /** * Sets to <code>true</code> to indicate that the receiver's close button should be shown. * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has * no effect. * * @param close the new state of the close button * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 3.4 */ public void setShowClose(bool close) { checkWidget(); if (showClose is close) return; showClose = close; parent.updateItems(); parent.redrawTabs(); } public override void setText (String string) { checkWidget(); // DWT extension: allow null for zero length string //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); if (string.equals (getText())) return; super.setText(string); shortenedText = null; shortenedTextWidth = 0; if (!parent.updateTabHeight(false)) { parent.updateItems(); parent.redrawTabs(); } } /** * Sets the receiver's tool tip text to the argument, which * may be null indicating that no tool tip text should be shown. * * @param string the new tool tip text (or null) * * @exception DWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setToolTipText (String string) { checkWidget(); toolTipText = string; } }
D
; Copyright (C) 2008 The Android Open Source Project ; ; Licensed under the Apache License, Version 2.0 (the "License"); ; you may not use this file except in compliance with the License. ; You may obtain a copy of the License at ; ; http://www.apache.org/licenses/LICENSE-2.0 ; ; Unless required by applicable law or agreed to in writing, software ; distributed under the License is distributed on an "AS IS" BASIS, ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; See the License for the specific language governing permissions and ; limitations under the License. .source T_aget_9.java .class public dot.junit.opcodes.aget.d.T_aget_9 .super java/lang/Object .method public <init>()V .limit regs 1 invoke-direct {v0}, java/lang/Object/<init>()V return-void .end method .method public run([II)I .limit regs 9 aget v0, v7, v9 return v0 .end method
D
/** Copyright: Copyright (c) 2017-2019 Andrey Penechko. License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). Authors: Andrey Penechko. */ /// Resolve all symbol references (variable/type/function/enum name uses) /// using information collected on previous pass module fe.names_resolve; import std.stdio; import std.string : format; import all; void pass_names_resolve(ref CompilationContext context, CompilePassPerModule[] subPasses) { auto state = NameResolveState(&context); foreach (ref SourceFileInfo file; context.files.data) { AstIndex modIndex = file.mod.get_ast_index(&context); require_name_resolve(modIndex, state); assert(context.analisysStack.length == 0); } } struct NameResolveState { CompilationContext* context; } void require_name_resolve(ref AstIndex nodeIndex, CompilationContext* context) { auto state = NameResolveState(context); require_name_resolve(nodeIndex, state); } void require_name_resolve(ref AstNodes items, ref NameResolveState state) { foreach(ref AstIndex item; items) require_name_resolve(item, state); } void require_name_resolve(ref AstIndex nodeIndex, ref NameResolveState state) { AstNode* node = state.context.getAstNode(nodeIndex); switch(node.state) with(AstNodeState) { case name_register_self, name_register_nested, name_resolve, type_check: state.context.circular_dependency; assert(false); case parse_done: auto name_state = NameRegisterState(state.context); require_name_register_self(0, nodeIndex, name_state); state.context.throwOnErrors; goto case; case name_register_self_done: require_name_register(nodeIndex, state.context); state.context.throwOnErrors; break; case name_register_nested_done: break; // all requirement are done case name_resolve_done, type_check_done: return; // already name resolved default: state.context.internal_error(node.loc, "Node %s in %s state", node.astType, node.state); } final switch(node.astType) with(AstType) { case error: state.context.internal_error(node.loc, "Visiting error node"); break; case abstract_node: state.context.internal_error(node.loc, "Visiting abstract node"); break; case decl_alias: name_resolve_alias(cast(AliasDeclNode*)node, state); break; case decl_builtin: assert(false); case decl_module: name_resolve_module(cast(ModuleDeclNode*)node, state); break; case decl_import: assert(false); case decl_function: name_resolve_func(cast(FunctionDeclNode*)node, state); break; case decl_var: name_resolve_var(cast(VariableDeclNode*)node, state); break; case decl_struct: name_resolve_struct(cast(StructDeclNode*)node, state); break; case decl_enum: name_resolve_enum(cast(EnumDeclaration*)node, state); break; case decl_enum_member: name_resolve_enum_member(cast(EnumMemberDecl*)node, state); break; case decl_static_if: assert(false); case decl_template: assert(false); case decl_template_param: assert(false); case stmt_block: name_resolve_block(cast(BlockStmtNode*)node, state); break; case stmt_if: name_resolve_if(cast(IfStmtNode*)node, state); break; case stmt_while: name_resolve_while(cast(WhileStmtNode*)node, state); break; case stmt_do_while: name_resolve_do(cast(DoWhileStmtNode*)node, state); break; case stmt_for: name_resolve_for(cast(ForStmtNode*)node, state); break; case stmt_return: name_resolve_return(cast(ReturnStmtNode*)node, state); break; case stmt_break: assert(false); case stmt_continue: assert(false); case expr_name_use: name_resolve_name_use(nodeIndex, cast(NameUseExprNode*)node, state); break; case expr_member: name_resolve_member(cast(MemberExprNode*)node, state); break; case expr_bin_op: name_resolve_binary_op(cast(BinaryExprNode*)node, state); break; case expr_un_op: name_resolve_unary_op(cast(UnaryExprNode*)node, state); break; case expr_call: name_resolve_call(cast(CallExprNode*)node, state); break; case expr_index: name_resolve_index(cast(IndexExprNode*)node, state); break; case expr_slice: name_resolve_expr_slice(cast(SliceExprNode*)node, state); break; case expr_type_conv: name_resolve_type_conv(cast(TypeConvExprNode*)node, state); break; case literal_int: assert(false); case literal_string: assert(false); case literal_null: assert(false); case literal_bool: assert(false); case type_basic: assert(false); case type_func_sig: name_resolve_func_sig(cast(FunctionSignatureNode*)node, state); break; case type_ptr: name_resolve_ptr(cast(PtrTypeNode*)node, state); break; case type_static_array: name_resolve_static_array(cast(StaticArrayTypeNode*)node, state); break; case type_slice: name_resolve_slice(cast(SliceTypeNode*)node, state); break; } } /// Error means that lookup failed due to earlier failure or error, so no new error should be produced enum LookupResult : ubyte { success, failure, error } /// Look up symbol by Identifier. Searches the stack of scopes. // Returns errorNode if not found or error occured AstIndex lookupScopeIdRecursive(Scope* scop, const Identifier id, TokenIndex from, CompilationContext* context) { Scope* sc = scop; //writefln("lookup %s", context.idString(id)); // first phase while(sc) { AstIndex symIndex = sc.symbols.get(id, AstIndex.init); //writefln(" scope %s %s %s", context.getAstNodeIndex(sc), sc.debugName, symIndex); if (symIndex) { AstNode* symNode = context.getAstNode(symIndex); if (sc.kind == ScopeKind.local) { // we need to skip forward references in function scope uint fromStart = context.tokenLocationBuffer[from].start; uint toStart = context.tokenLocationBuffer[symNode.loc].start; //writefln(" local %s %s", fromStart, toStart); // backward reference if (fromStart > toStart) { return symIndex; } } else { // forward reference allowed in global and member scopes return symIndex; } } sc = sc.parentScope.get_scope(context); } // second phase return lookupImports(scop, id, from, context); } // Returns errorNode if not found or error occured AstIndex lookupImports(Scope* scop, const Identifier id, TokenIndex from, CompilationContext* context) { while (scop) { AstIndex symIndex; ModuleDeclNode* symMod; foreach (AstIndex impIndex; scop.imports) { ModuleDeclNode* imp = context.getAst!ModuleDeclNode(impIndex); // TODO: check that import is higher in ordered scopes AstIndex scopeSym = imp.memberScope.lookup_scope(id, context); if (!scopeSym) continue; if (scopeSym && symIndex && scopeSym != symIndex) { string mod1Id = context.idString(symMod.id); string sym1Id = context.idString(symIndex.get_node_id(context)); string mod2Id = context.idString(imp.id); string sym2Id = context.idString(scopeSym.get_node_id(context)); context.error(from, "`%s.%s` at %s conflicts with `%s.%s` at %s", mod1Id, sym1Id, FmtSrcLoc(context.getAstNode(symIndex).loc, context), mod2Id, sym2Id, FmtSrcLoc(context.getAstNode(scopeSym).loc, context)); return context.errorNode; } symIndex = scopeSym; symMod = imp; } if (symIndex) return symIndex; scop = scop.parentScope.get_scope(context); } return context.errorNode; }
D
/** * Compiler implementation of the * $(LINK2 http://www.dlang.org, D programming language). * * Copyright: Copyright (c) 1999-2017 by Digital Mars, All Rights Reserved * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(DMDSRC _staticcond.d) */ module ddmd.staticcond; import ddmd.arraytypes; import ddmd.dmodule; import ddmd.dscope; import ddmd.dsymbol; import ddmd.errors; import ddmd.expression; import ddmd.globals; import ddmd.identifier; import ddmd.mtype; import ddmd.tokens; import ddmd.utils; /******************************************** * Semantically analyze and then evaluate a static condition at compile time. * This is special because short circuit operators &&, || and ?: at the top * level are not semantically analyzed if the result of the expression is not * necessary. * Params: * exp = original expression, for error messages * Returns: * true if evaluates to true */ bool evalStaticCondition(Scope* sc, Expression exp, Expression e, ref bool errors) { if (e.op == TOKandand) { AndAndExp aae = cast(AndAndExp)e; bool result = evalStaticCondition(sc, exp, aae.e1, errors); if (errors || !result) return false; result = evalStaticCondition(sc, exp, aae.e2, errors); return !errors && result; } if (e.op == TOKoror) { OrOrExp ooe = cast(OrOrExp)e; bool result = evalStaticCondition(sc, exp, ooe.e1, errors); if (errors) return false; if (result) return true; result = evalStaticCondition(sc, exp, ooe.e2, errors); return !errors && result; } if (e.op == TOKquestion) { CondExp ce = cast(CondExp)e; bool result = evalStaticCondition(sc, exp, ce.econd, errors); if (errors) return false; Expression leg = result ? ce.e1 : ce.e2; result = evalStaticCondition(sc, exp, leg, errors); return !errors && result; } uint nerrors = global.errors; sc = sc.startCTFE(); sc.flags |= SCOPEcondition; e = e.semantic(sc); e = resolveProperties(sc, e); sc = sc.endCTFE(); e = e.optimize(WANTvalue); if (nerrors != global.errors || e.op == TOKerror || e.type.toBasetype() == Type.terror) { errors = true; return false; } if (!e.type.isBoolean()) { exp.error("expression `%s` of type `%s` does not have a boolean value", exp.toChars(), e.type.toChars()); errors = true; return false; } e = e.ctfeInterpret(); if (e.isBool(true)) return true; else if (e.isBool(false)) return false; e.error("expression `%s` is not constant", e.toChars()); errors = true; return false; }
D
/home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab5/os/target/riscv64imac-unknown-none-elf/debug/deps/volatile-7091e82015bd4da0.rmeta: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/volatile-0.2.6/src/lib.rs /home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab5/os/target/riscv64imac-unknown-none-elf/debug/deps/libvolatile-7091e82015bd4da0.rlib: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/volatile-0.2.6/src/lib.rs /home/hustccc/OS_Tutorial_Summer_of_Code/rCore_Labs/Lab5/os/target/riscv64imac-unknown-none-elf/debug/deps/volatile-7091e82015bd4da0.d: /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/volatile-0.2.6/src/lib.rs /home/hustccc/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/volatile-0.2.6/src/lib.rs:
D
/***********************************************************************\ * ole2ver.d * * * * Windows API header module * * * * Translated from MinGW API for MS-Windows 3.10 * * * * Placed into public domain * \***********************************************************************/ module os.win32.ole2ver; // These are apparently not documented on the MSDN site const rmm = 23; const rup = 639;
D
/* TEST_OUTPUT: --- fail_compilation/fail10346.d(13): Error: undefined identifier T fail_compilation/fail10346.d(16): Error: template fail10346.bar does not match any function template declaration. Candidates are: fail_compilation/fail10346.d(13): fail10346.bar(T x, T)(Foo!T) fail_compilation/fail10346.d(16): Error: template fail10346.bar(T x, T)(Foo!T) cannot deduce template function from argument types !(10)(Foo!int) fail_compilation/fail10346.d(16): Error: template instance bar!10 errors instantiating template --- */ struct Foo(T) {} void bar(T x, T)(Foo!T) {} void main() { Foo!int spam; bar!10(spam); }
D
import std.stdio; import std.range; import std.algorithm; import std.string; import std.conv; import std.file; import std.path; import std.parallelism; import std.algorithm.comparison : equal; import std.container.rbtree; import std.traits; import core.thread; import std.process; import std.datetime.stopwatch : benchmark; struct FaiRecord { string header, lineTerm; ulong seqLen, lineLen, offset; @property ulong lineOffset() { return lineLen + lineTerm.length; } string toString() { return format("%s\t%s\t%s\t%s\t%s", header, seqLen, offset, lineLen, lineOffset); } unittest { auto rec = FaiRecord("chr2", "\n", 10, 50, 4); assert(rec.toString() == "chr2\t10\t4\t50\t51"); rec.lineTerm = "\r\n"; assert(rec.toString() == "chr2\t10\t4\t50\t52"); } this(string str) { auto res = str.split("\t"); header ~= res[0]; seqLen = to!ulong(res[1]); offset = to!ulong(res[2]); lineLen = to!ulong(res[3]); lineTerm = (to!ulong(res[4])-lineLen) == 1 ? "\n" : "\r\n"; } unittest { auto s = "chr2\t10\t4\t50\t51"; assert(FaiRecord(s).toString() == s); } this(string header, string lineTerm, ulong seqLen, ulong lineLen, ulong offset) { this.header = header; this.seqLen = seqLen; this.offset = offset; this.lineLen = lineLen; this.lineTerm = lineTerm; } unittest { assert(FaiRecord("chr2", "\n", 10, 50, 4).toString() == "chr2\t10\t4\t50\t51"); } } auto buildFai() { File f = File("/home/ubuntu/Documents/Dexp/TEST/fastaExmp.fna", "r"); //f.seek(0); file may be gone, exception? string lineTerm = f.byLine(KeepTerminator.yes).take(1).front.endsWith("\r\n") ? "\r\n" : "\n"; ulong lineLen = f.byLine(KeepTerminator.yes).take(1).to!string.length - 4; //to!string adds brackets like ["%data%"] //f.byLine(KeepTerminator.yes).take(1).writeln(); //Maybe try block? string[] contents; try{ contents = readText("/home/ubuntu/Documents/Dexp/TEST/fastaExmp.fna").splitLines(KeepTerminator.no); } catch(FileException e){ return parseFastaSingleThread(); } FaiRecord[] records; auto readHeaders = redBlackTree!string; ulong step = f.size()/taskPool.size(); Task!(parseFasta, Parameters!parseFasta)*[] tasks;//(parseFasta, Parameters!parseFasta)*[] tasks; // //writeln("File Size - ", f.size(), "\ntaskPool Size - ", taskPool.size(), "\nlineLen - ", lineLen, "\nstep - ", step ); //writeln(taskPool.size()); for(int i = 0; i < taskPool.size(); i++){ tasks ~= task!parseFasta(&contents, &readHeaders, i*step/lineLen, lineTerm); tasks[i].executeInNewThread(); } foreach(t; tasks){ records ~= t.yieldForce(); } return records; } auto parseFasta(string[]* contents, RedBlackTree!(string)* readHeaders, ulong firstLineNumber, string lineTerm){ FaiRecord[] records; ulong offset; foreach(line; (*contents)[firstLineNumber..$]) { writeln('(',line,'|',(*contents).back,')'); offset += line.length + lineTerm.length; if ( line.startsWith(">") ) { string header = line.split(" ").front[1..$]; if(header in (*readHeaders)){ return records; } (*readHeaders).insert(header); records~=FaiRecord(); records[$-1].lineTerm = lineTerm; records[$-1].header ~= header; records[$-1].offset = offset; } else { if(records.length == 0) continue; //writeln("Records Length - ", records.length, "\n Line - ", line, "\n Thread ID - ", thisThreadID(),']'); records[$-1].toString(); if ( records[$-1].lineLen == 0 ) { records[$-1].lineLen = line.length; } records[$-1].seqLen += line.length; } } return records; } auto parseFastaSingleThread(){ File f = File("/home/ubuntu/Documents/Dexp/TEST/fastaExmp.fna", "r"); FaiRecord[] records; string lineTerm = f.byLine(KeepTerminator.yes).take(1).front.endsWith("\r\n") ? "\r\n" : "\n"; f.seek(0); ulong offset; foreach(line; f.byLine(KeepTerminator.no, lineTerm)) { offset+= line.length + lineTerm.length; if ( line.startsWith(">") ) { records~=FaiRecord(); records[$-1].lineTerm = lineTerm; records[$-1].header ~= line.split(" ").front[1..$]; records[$-1].offset = offset; } else { if ( records[$-1].lineLen == 0 ) { records[$-1].lineLen = line.length; } records[$-1].seqLen += line.length; } } return records; } int main(){ //auto records = parseFastaSingleThread("/home/ubuntu/Documents/Dexp/TEST/fasta");//buildFai("/home/ubuntu/Documents/Dexp/TEST/fasta"); //foreach(t; records) writeln(t.toString()); auto r = benchmark!(buildFai, parseFastaSingleThread)(1); writeln("Parallel - ",r[0],"\nSingle thread - ",r[1]); return 0; }
D
/* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ module flow.variable.service.history.InternalHistoryVariableManager; import hunt.time.LocalDateTime; import flow.variable.service.impl.persistence.entity.VariableInstanceEntity; alias Date = LocalDateTime; interface InternalHistoryVariableManager { /** * Record a variable has been created, if audit history is enabled. */ void recordVariableCreate(VariableInstanceEntity variable, Date createTime); /** * Record a variable has been updated, if audit history is enabled. */ void recordVariableUpdate(VariableInstanceEntity variable, Date updateTime); /** * Record a variable has been deleted, if audit history is enabled. */ void recordVariableRemoved(VariableInstanceEntity variable, Date removeTime); }
D
Long: delegation Arg: <LEVEL> Help: GSS-API delegation permission Protocols: GSS/kerberos Category: misc --- Set LEVEL to tell the server what it is allowed to delegate when it comes to user credentials. .RS .IP "none" Don't allow any delegation. .IP "policy" Delegates if and only if the OK-AS-DELEGATE flag is set in the Kerberos service ticket, which is a matter of realm policy. .IP "always" Unconditionally allow the server to delegate. .RE
D
instance Mod_2008_PSINOV_Ghorim_MT (Npc_Default) { //-------- primary data -------- name = "Ghorim"; Npctype = Npctype_Main; guild = GIL_OUT; level = 9; voice = 2; id = 2008; //-------- abilities -------- attribute[ATR_STRENGTH] = 15; attribute[ATR_DEXTERITY] = 15; attribute[ATR_MANA_MAX] = 0; attribute[ATR_MANA] = 0; attribute[ATR_HITPOINTS_MAX] = 148; attribute[ATR_HITPOINTS] = 148; //-------- visuals -------- // animations Mdl_SetVisual (self,"HUMANS.MDS"); Mdl_ApplyOverlayMds (self,"Humans_Mage.mds"); // body mesh ,bdytex,skin,head mesh ,headtex,teethtex,ruestung Mdl_SetVisualBody (self,"hum_body_Naked0", 1, 1 ,"Hum_Head_Psionic", 168, 1, NOV_ARMOR_L); Mdl_SetModelFatness(self,0); fight_tactic = FAI_HUMAN_STRONG; //-------- Talente -------- //-------- inventory -------- EquipItem (self, ItMw_ShortSword2); //-------------Daily Routine------------- daily_routine = Rtn_PreStart_2008; }; FUNC VOID Rtn_PreStart_2008 () { TA_Stomp_Herb (06,55,23,55,"PSI_HERB_PLACE_1"); TA_Sleep (23,55,06,55,"PSI_6_HUT_IN_BED3"); }; FUNC VOID Rtn_Sumpfmensch_2008 () { TA_Stomp_Herb (07,00,22,00,"PSI_HERB_PLACE_1"); TA_Sit_Campfire (22,00,07,00,"PSI_PLACE"); }; FUNC VOID Rtn_Sumpfmensch2_2008 () { TA_Stomp_Herb (07,00,22,00,"PSI_HERB_PLACE_1"); TA_Smalltalk_Sumpfmensch01 (07,00,22,00,"PSI_PATH_2_6"); }; FUNC VOID Rtn_Tot_2008 () { TA_Stand_WP (08,00,20,00,"TOT"); TA_Stand_WP (20,00,08,00,"TOT"); };
D
void f(int x){ Print(x+a); } int main(){ int a; a = 2; f(a); }
D
//######################################################################## //## //## Perception_Testmodell //## //######################################################################## instance Perception_Testmodell (Npc_Default) { //-------- primary data -------- name = "Perception_Testmodell"; guild = GIL_NONE; level = 1; voice = 11;//15; id = 99; //-------- abilities -------- attribute[ATR_STRENGTH] = 10; attribute[ATR_DEXTERITY] = 10; attribute[ATR_MANA_MAX] = 10; attribute[ATR_MANA] = 10; attribute[ATR_HITPOINTS_MAX] = 40; attribute[ATR_HITPOINTS] = 40; //-------- visuals -------- Mdl_SetVisual (self,"HUMANS.MDS"); Mdl_ApplyOverlayMds (self,"Humans_Mage.mds"); // body mesh, head mesh, hairmesh, face-tex, hair-tex, skin Mdl_SetVisualBody (self,"hum_body_Naked0",0, 1,"Hum_Head_Bald", 82, 1, DMB_ARMOR_M); //-------- Talente -------- //Npc_LearnFightTalent (self, TAL_1H_SWORD2); //Npc_LearnFightTalent (self, TAL_1H_AXE2); //-------- inventory -------- //CreateInvItem (self, ItMw1hSword01); //CreateInvItem (self, ItFo_Apple); //CreateInvItems (self, ItMiNugget, 4); //-------- ai ---------- start_aistate = ZS_PTM_Hangaround; fight_tactic = FAI_HUMAN_MAGE; }; func void ZS_PTM_Hangaround () { PrintDebugNpc (PD_ZS_FRAME, "ZS_PTM_Hangaround"); // * Wahrnehmungen aktiv * Npc_PercEnable (self, PERC_ASSESSPLAYER , B_PTM_AssessPlayer ); Npc_PercEnable (self, PERC_ASSESSENEMY , B_PTM_AssessEnemy ); Npc_PercEnable (self, PERC_ASSESSFIGHTER , B_PTM_AssessFighter ); Npc_PercEnable (self, PERC_ASSESSBODY , B_PTM_AssessBody ); Npc_PercEnable (self, PERC_ASSESSITEM , B_PTM_AssessItem ); Npc_SetPercTime (self, 1); // * Wahrnehmungen passiv * Npc_PercEnable (self, PERC_ASSESSMURDER , B_PTM_AssessMurder ); Npc_PercEnable (self, PERC_ASSESSDEFEAT , B_PTM_AssessDefeat ); Npc_PercEnable (self, PERC_ASSESSDAMAGE , B_PTM_AssessDamage ); Npc_PercEnable (self, PERC_ASSESSOTHERSDAMAGE , B_PTM_AssessOhtersDamage); Npc_PercEnable (self, PERC_ASSESSTHREAT , B_PTM_AssessThreat ); Npc_PercEnable (self, PERC_ASSESSREMOVEWEAPON , B_PTM_AssessRemoveWeapon); Npc_PercEnable (self, PERC_OBSERVEINTRUDER , B_PTM_ObserveIntruder ); Npc_PercEnable (self, PERC_ASSESSFIGHTSOUND , B_PTM_AssessFightSound ); Npc_PercEnable (self, PERC_ASSESSQUIETSOUND , B_PTM_AssessQuietSound ); Npc_PercEnable (self, PERC_ASSESSWARN , B_PTM_AssessWarn ); Npc_PercEnable (self, PERC_CATCHTHIEF , B_PTM_CatchThief ); Npc_PercEnable (self, PERC_ASSESSTHEFT , B_PTM_AssessTheft ); Npc_PercEnable (self, PERC_ASSESSCALL , B_PTM_AssessCall ); Npc_PercEnable (self, PERC_ASSESSTALK , B_PTM_AssessTalk ); Npc_PercEnable (self, PERC_ASSESSGIVENITEM , B_PTM_AssessGivenItem ); Npc_PercEnable (self, PERC_ASSESSFAKEGUILD , B_PTM_AssessFakeGuild ); Npc_PercEnable (self, PERC_MOVEMOB , B_PTM_MoveMob ); Npc_PercEnable (self, PERC_MOVENPC , B_PTM_MoveNpc ); Npc_PercEnable (self, PERC_DRAWWEAPON , B_PTM_DrawWeapon ); Npc_PercEnable (self, PERC_OBSERVESUSPECT , B_PTM_ObserveSuspect ); Npc_PercEnable (self, PERC_NPCCOMMAND , B_PTM_NpcCommand ); Npc_PercEnable (self, PERC_ASSESSMAGIC , B_PTM_AssessMagic ); Npc_PercEnable (self, PERC_ASSESSSTOPMAGIC , B_PTM_AssessStopMagic ); Npc_PercEnable (self, PERC_ASSESSCASTER , B_PTM_AssessCaster ); Npc_PercEnable (self, PERC_ASSESSSURPRISE , B_PTM_AssessSurprise ); Npc_PercEnable (self, PERC_ASSESSENTERROOM , B_PTM_AssessEnterRoom ); Npc_PercEnable (self, PERC_ASSESSUSEMOB , B_PTM_AssessUseMob ); }; func void ZS_PTM_Hangaround_Loop () { PrintDebugNpc (PD_ZS_LOOP, "ZS_PTM_Hangaround_Loop"); }; func void ZS_PTM_Hangaround_End () { PrintDebugNpc (PD_ZS_FRAME, "ZS_PTM_Hangaround_End"); }; func void B_PTM_AssessPlayer () { PrintDebugNpc(PD_ZS_DETAIL, "B_PTM_AssessPlayer" ); PrintGlobals(PD_ZS_DETAIL); }; func void B_PTM_AssessEnemy () { PrintDebugNpc(PD_ZS_DETAIL, "B_PTM_AssessEnemy" ); PrintGlobals(PD_ZS_DETAIL); }; func void B_PTM_AssessFighter () { PrintDebugNpc(PD_ZS_DETAIL, "B_PTM_AssessFighter" ); PrintGlobals(PD_ZS_DETAIL); }; func void B_PTM_AssessBody () { PrintDebugNpc(PD_ZS_DETAIL, "B_PTM_AssessBody" ); PrintGlobals(PD_ZS_DETAIL); }; func void B_PTM_AssessItem () { PrintDebugNpc(PD_ZS_DETAIL, "B_PTM_AssessItem" ); PrintGlobals(PD_ZS_DETAIL); }; func void B_PTM_AssessMurder () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessMurder" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessDefeat () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessDefeat" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessDamage () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessDamage" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessOhtersDamage () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessOhtersDamage" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessThreat () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessThreat" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessRemoveWeapon () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessRemoveWeapon" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_ObserveIntruder () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_ObserveIntruder" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessFightSound () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessFightSound" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessQuietSound () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessQuietSound" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessWarn () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessWarn" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_CatchThief () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_CatchThief" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessTheft () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessTheft" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessCall () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessCall" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessTalk () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessTalk" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessGivenItem () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessGivenItem" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessFakeGuild () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessFakeGuild" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_MoveMob () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_MoveMob" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_MoveNpc () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_MoveNpc" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_DrawWeapon () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_DrawWeapon" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_ObserveSuspect () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_ObserveSuspect" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_NpcCommand () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_NpcCommand" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessMagic () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessMagic" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessStopMagic () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessStopMagic" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessCaster () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessCaster" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessSurprise () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessSurprise" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessEnterRoom () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessEnterRoom" ); PrintGlobals(PD_ZS_FRAME); }; func void B_PTM_AssessUseMob () { PrintDebugNpc(PD_ZS_FRAME, "B_PTM_AssessUseMob" ); PrintGlobals(PD_ZS_FRAME); };
D
/******************************************************************************* copyright: Copyright (c) 2006 Dinrus. все rights reserved license: BSD стиль: see doc/license.txt for details version: Initial release: Feb 2006 author: Regan Heath, Oskar Linde This module реализует the Tiger algorithm by Ross Anderson и Eli Biham. *******************************************************************************/ module util.digest.Tiger; private import stdrus; private import util.digest.MerkleDamgard; public import util.digest.Digest; /******************************************************************************* *******************************************************************************/ final class Tiger : MerkleDamgard { private бдол[3] контекст; private бцел npass = 3; private const бцел padChar = 0x01; /*********************************************************************** ***********************************************************************/ private static const бдол[3] начальное = [ 0x0123456789ABCDEF, 0xFEDCBA9876543210, 0xF096A5B4C3B2E187 ]; /*********************************************************************** Construct an Tiger ***********************************************************************/ this(); /*********************************************************************** The размер of a tiger дайджест is 24 байты ***********************************************************************/ override бцел размерДайджеста(); /*********************************************************************** Initialize the cipher Remarks: Returns the cipher состояние в_ it's начальное значение ***********************************************************************/ override проц сбрось(); /*********************************************************************** Obtain the дайджест Возвращает: the дайджест Remarks: Returns a дайджест of the текущ cipher состояние, this may be the final дайджест, or a дайджест of the состояние between calls в_ обнови() ***********************************************************************/ override проц создайДайджест(ббайт[] буф); /*********************************************************************** Get the число of проходки being performed Возвращает: the число of проходки Remarks: The Tiger algorithm may perform an arbitrary число of проходки the minimum recommended число is 3 и this число should be quite безопасно however the "ultra-cautious" may wish в_ increase this число. ***********************************************************************/ бцел проходки(); /*********************************************************************** Набор the число of проходки в_ be performed Параметры: n = the число of проходки в_ perform Remarks: The Tiger algorithm may perform an arbitrary число of проходки the minimum recommended число is 3 и this число should be quite безопасно however the "ultra-cautious" may wish в_ increase this число. ***********************************************************************/ проц проходки(бцел n); /*********************************************************************** блок размер Возвращает: the блок размер Remarks: Specifies the размер (in байты) of the блок of данные в_ пароль в_ each вызов в_ трансформируй(). For Tiger the размерБлока is 64. ***********************************************************************/ protected override бцел размерБлока(); /*********************************************************************** Length паддинг размер Возвращает: the length паддинг размер Remarks: Specifies the размер (in байты) of the паддинг which uses the length of the данные which имеется been ciphered, this паддинг is carried out by the padLength метод. For Tiger the добавьРазмер is 8. ***********************************************************************/ protected бцел добавьРазмер(); /*********************************************************************** Pads the cipher данные Параметры: данные = a срез of the cipher буфер в_ заполни with паддинг Remarks: Fills the passed буфер срез with the appropriate паддинг for the final вызов в_ трансформируй(). This паддинг will заполни the cipher буфер up в_ размерБлока()-добавьРазмер(). ***********************************************************************/ protected override проц padMessage(ббайт[] at); /*********************************************************************** Performs the length паддинг Параметры: данные = the срез of the cipher буфер в_ заполни with паддинг length = the length of the данные which имеется been ciphered Remarks: Fills the passed буфер срез with добавьРазмер() байты of паддинг based on the length in байты of the ввод данные which имеется been ciphered. ***********************************************************************/ protected override проц padLength(ббайт[] at, бдол length); /*********************************************************************** Performs the cipher on a блок of данные Параметры: данные = the блок of данные в_ cipher Remarks: The actual cipher algorithm is carried out by this метод on the passed блок of данные. This метод is called for every размерБлока() байты of ввод данные и once ещё with the остаток данные псеп_в_конце в_ размерБлока(). ***********************************************************************/ protected override проц трансформируй(ббайт[] ввод); /*********************************************************************** ***********************************************************************/ private static ббайт получиБайт(бдол c, бцел b1, бцел b2 = 0); /*********************************************************************** ***********************************************************************/ private static проц округли(ref бдол a, ref бдол b, ref бдол c, бдол x, бдол mul); /*********************************************************************** ***********************************************************************/ private static проц пароль(ref бдол a, ref бдол b, ref бдол c, бдол[8] x, бдол mul); /*********************************************************************** ***********************************************************************/ private static проц keySchedule(бдол[8] x); /*********************************************************************** ***********************************************************************/ private static бдол[] t1() ; private static бдол[] t2() ; private static бдол[] t3(); private static бдол[] t4() ; } /******************************************************************************* *******************************************************************************/ private static бдол[1024] таблица = [ 0x02aab17cf7e90c5e /* 0 */, 0xac424b03e243a8ec /* 1 */, 0x72cd5be30dd5fcd3 /* 2 */, 0x6d019b93f6f97f3a /* 3 */, 0xcd9978ffd21f9193 /* 4 */, 0x7573a1c9708029e2 /* 5 */, 0xb164326b922a83c3 /* 6 */, 0x46883eee04915870 /* 7 */, 0xeaace3057103ece6 /* 8 */, 0xc54169b808a3535c /* 9 */, 0x4ce754918ddec47c /* 10 */, 0x0aa2f4dfdc0df40c /* 11 */, 0x10b76f18a74dbefa /* 12 */, 0xc6ccb6235ad1ab6a /* 13 */, 0x13726121572fe2ff /* 14 */, 0x1a488c6f199d921e /* 15 */, 0x4bc9f9f4da0007ca /* 16 */, 0x26f5e6f6e85241c7 /* 17 */, 0x859079dbea5947b6 /* 18 */, 0x4f1885c5c99e8c92 /* 19 */, 0xd78e761ea96f864b /* 20 */, 0x8e36428c52b5c17d /* 21 */, 0x69cf6827373063c1 /* 22 */, 0xb607c93d9bb4c56e /* 23 */, 0x7d820e760e76b5ea /* 24 */, 0x645c9cc6f07fdc42 /* 25 */, 0xbf38a078243342e0 /* 26 */, 0x5f6b343c9d2e7d04 /* 27 */, 0xf2c28aeb600b0ec6 /* 28 */, 0x6c0ed85f7254bcac /* 29 */, 0x71592281a4db4fe5 /* 30 */, 0x1967fa69ce0fed9f /* 31 */, 0xfd5293f8b96545db /* 32 */, 0xc879e9d7f2a7600b /* 33 */, 0x860248920193194e /* 34 */, 0xa4f9533b2d9cc0b3 /* 35 */, 0x9053836c15957613 /* 36 */, 0xdb6dcf8afc357bf1 /* 37 */, 0x18beea7a7a370f57 /* 38 */, 0x037117ca50b99066 /* 39 */, 0x6ab30a9774424a35 /* 40 */, 0xf4e92f02e325249b /* 41 */, 0x7739db07061ccae1 /* 42 */, 0xd8f3b49ceca42a05 /* 43 */, 0xbd56be3f51382f73 /* 44 */, 0x45faed5843b0bb28 /* 45 */, 0x1c813d5c11bf1f83 /* 46 */, 0x8af0e4b6d75fa169 /* 47 */, 0x33ee18a487ad9999 /* 48 */, 0x3c26e8eab1c94410 /* 49 */, 0xb510102bc0a822f9 /* 50 */, 0x141eef310ce6123b /* 51 */, 0xfc65b90059ddb154 /* 52 */, 0xe0158640c5e0e607 /* 53 */, 0x884e079826c3a3cf /* 54 */, 0x930d0d9523c535fd /* 55 */, 0x35638d754e9a2b00 /* 56 */, 0x4085fccf40469dd5 /* 57 */, 0xc4b17ad28be23a4c /* 58 */, 0xcab2f0fc6a3e6a2e /* 59 */, 0x2860971a6b943fcd /* 60 */, 0x3dde6ee212e30446 /* 61 */, 0x6222f32ae01765ae /* 62 */, 0x5d550bb5478308fe /* 63 */, 0xa9efa98da0eda22a /* 64 */, 0xc351a71686c40da7 /* 65 */, 0x1105586d9c867c84 /* 66 */, 0xdcffee85fda22853 /* 67 */, 0xccfbd0262c5eef76 /* 68 */, 0xbaf294cb8990d201 /* 69 */, 0xe69464f52afad975 /* 70 */, 0x94b013afdf133e14 /* 71 */, 0x06a7d1a32823c958 /* 72 */, 0x6f95fe5130f61119 /* 73 */, 0xd92ab34e462c06c0 /* 74 */, 0xed7bde33887c71d2 /* 75 */, 0x79746d6e6518393e /* 76 */, 0x5ba419385d713329 /* 77 */, 0x7c1ba6b948a97564 /* 78 */, 0x31987c197bfdac67 /* 79 */, 0xde6c23c44b053d02 /* 80 */, 0x581c49fed002d64d /* 81 */, 0xdd474d6338261571 /* 82 */, 0xaa4546c3e473d062 /* 83 */, 0x928fce349455f860 /* 84 */, 0x48161bbacaab94d9 /* 85 */, 0x63912430770e6f68 /* 86 */, 0x6ec8a5e602c6641c /* 87 */, 0x87282515337ddd2b /* 88 */, 0x2cda6b42034b701b /* 89 */, 0xb03d37c181cb096d /* 90 */, 0xe108438266c71c6f /* 91 */, 0x2b3180c7eb51b255 /* 92 */, 0xdf92b82f96c08bbc /* 93 */, 0x5c68c8c0a632f3ba /* 94 */, 0x5504cc861c3d0556 /* 95 */, 0xabbfa4e55fb26b8f /* 96 */, 0x41848b0ab3baceb4 /* 97 */, 0xb334a273aa445d32 /* 98 */, 0xbca696f0a85ad881 /* 99 */, 0x24f6ec65b528d56c /* 100 */, 0x0ce1512e90f4524a /* 101 */, 0x4e9dd79d5506d35a /* 102 */, 0x258905fac6ce9779 /* 103 */, 0x2019295b3e109b33 /* 104 */, 0xf8a9478b73a054cc /* 105 */, 0x2924f2f934417eb0 /* 106 */, 0x3993357d536d1bc4 /* 107 */, 0x38a81ac21db6ff8b /* 108 */, 0x47c4fbf17d6016bf /* 109 */, 0x1e0faadd7667e3f5 /* 110 */, 0x7abcff62938beb96 /* 111 */, 0xa78dad948fc179c9 /* 112 */, 0x8f1f98b72911e50d /* 113 */, 0x61e48eae27121a91 /* 114 */, 0x4d62f7ad31859808 /* 115 */, 0xeceba345ef5ceaeb /* 116 */, 0xf5ceb25ebc9684ce /* 117 */, 0xf633e20cb7f76221 /* 118 */, 0xa32cdf06ab8293e4 /* 119 */, 0x985a202ca5ee2ca4 /* 120 */, 0xcf0b8447cc8a8fb1 /* 121 */, 0x9f765244979859a3 /* 122 */, 0xa8d516b1a1240017 /* 123 */, 0x0bd7ba3ebb5dc726 /* 124 */, 0xe54bca55b86adb39 /* 125 */, 0x1d7a3afd6c478063 /* 126 */, 0x519ec608e7669edd /* 127 */, 0x0e5715a2d149aa23 /* 128 */, 0x177d4571848ff194 /* 129 */, 0xeeb55f3241014c22 /* 130 */, 0x0f5e5ca13a6e2ec2 /* 131 */, 0x8029927b75f5c361 /* 132 */, 0xad139fabc3d6e436 /* 133 */, 0x0d5df1a94ccf402f /* 134 */, 0x3e8bd948bea5dfc8 /* 135 */, 0xa5a0d357bd3ff77e /* 136 */, 0xa2d12e251f74f645 /* 137 */, 0x66fd9e525e81a082 /* 138 */, 0x2e0c90ce7f687a49 /* 139 */, 0xc2e8bcbeba973bc5 /* 140 */, 0x000001bce509745f /* 141 */, 0x423777bbe6dab3d6 /* 142 */, 0xd1661c7eaef06eb5 /* 143 */, 0xa1781f354daacfd8 /* 144 */, 0x2d11284a2b16affc /* 145 */, 0xf1fc4f67fa891d1f /* 146 */, 0x73ecc25dcb920ada /* 147 */, 0xae610c22c2a12651 /* 148 */, 0x96e0a810d356b78a /* 149 */, 0x5a9a381f2fe7870f /* 150 */, 0xd5ad62ede94e5530 /* 151 */, 0xd225e5e8368d1427 /* 152 */, 0x65977b70c7af4631 /* 153 */, 0x99f889b2de39d74f /* 154 */, 0x233f30bf54e1d143 /* 155 */, 0x9a9675d3d9a63c97 /* 156 */, 0x5470554ff334f9a8 /* 157 */, 0x166acb744a4f5688 /* 158 */, 0x70c74caab2e4aead /* 159 */, 0xf0d091646f294d12 /* 160 */, 0x57b82a89684031d1 /* 161 */, 0xefd95a5a61be0b6b /* 162 */, 0x2fbd12e969f2f29a /* 163 */, 0x9bd37013feff9fe8 /* 164 */, 0x3f9b0404d6085a06 /* 165 */, 0x4940c1f3166cfe15 /* 166 */, 0x09542c4dcdf3defb /* 167 */, 0xb4c5218385cd5ce3 /* 168 */, 0xc935b7dc4462a641 /* 169 */, 0x3417f8a68ed3b63f /* 170 */, 0xb80959295b215b40 /* 171 */, 0xf99cdaef3b8c8572 /* 172 */, 0x018c0614f8fcb95d /* 173 */, 0x1b14accd1a3acdf3 /* 174 */, 0x84d471f200bb732d /* 175 */, 0xc1a3110e95e8da16 /* 176 */, 0x430a7220bf1a82b8 /* 177 */, 0xb77e090d39df210e /* 178 */, 0x5ef4bd9f3cd05e9d /* 179 */, 0x9d4ff6da7e57a444 /* 180 */, 0xda1d60e183d4a5f8 /* 181 */, 0xb287c38417998e47 /* 182 */, 0xfe3edc121bb31886 /* 183 */, 0xc7fe3ccc980ccbef /* 184 */, 0xe46fb590189bfd03 /* 185 */, 0x3732fd469a4c57dc /* 186 */, 0x7ef700a07cf1ad65 /* 187 */, 0x59c64468a31d8859 /* 188 */, 0x762fb0b4d45b61f6 /* 189 */, 0x155baed099047718 /* 190 */, 0x68755e4c3d50baa6 /* 191 */, 0xe9214e7f22d8b4df /* 192 */, 0x2addbf532eac95f4 /* 193 */, 0x32ae3909b4bd0109 /* 194 */, 0x834df537b08e3450 /* 195 */, 0xfa209da84220728d /* 196 */, 0x9e691d9b9efe23f7 /* 197 */, 0x0446d288c4ae8d7f /* 198 */, 0x7b4cc524e169785b /* 199 */, 0x21d87f0135ca1385 /* 200 */, 0xcebb400f137b8aa5 /* 201 */, 0x272e2b66580796be /* 202 */, 0x3612264125c2b0de /* 203 */, 0x057702bdad1efbb2 /* 204 */, 0xd4babb8eacf84be9 /* 205 */, 0x91583139641bc67b /* 206 */, 0x8bdc2de08036e024 /* 207 */, 0x603c8156f49f68ed /* 208 */, 0xf7d236f7dbef5111 /* 209 */, 0x9727c4598ad21e80 /* 210 */, 0xa08a0896670a5fd7 /* 211 */, 0xcb4a8f4309eba9cb /* 212 */, 0x81af564b0f7036a1 /* 213 */, 0xc0b99aa778199abd /* 214 */, 0x959f1ec83fc8e952 /* 215 */, 0x8c505077794a81b9 /* 216 */, 0x3acaaf8f056338f0 /* 217 */, 0x07b43f50627a6778 /* 218 */, 0x4a44ab49f5eccc77 /* 219 */, 0x3bc3d6e4b679ee98 /* 220 */, 0x9cc0d4d1cf14108c /* 221 */, 0x4406c00b206bc8a0 /* 222 */, 0x82a18854c8d72d89 /* 223 */, 0x67e366b35c3c432c /* 224 */, 0xb923dd61102b37f2 /* 225 */, 0x56ab2779d884271d /* 226 */, 0xbe83e1b0ff1525af /* 227 */, 0xfb7c65d4217e49a9 /* 228 */, 0x6bdbe0e76d48e7d4 /* 229 */, 0x08df828745d9179e /* 230 */, 0x22ea6a9add53bd34 /* 231 */, 0xe36e141c5622200a /* 232 */, 0x7f805d1b8cb750ee /* 233 */, 0xafe5c7a59f58e837 /* 234 */, 0xe27f996a4fb1c23c /* 235 */, 0xd3867dfb0775f0d0 /* 236 */, 0xd0e673de6e88891a /* 237 */, 0x123aeb9eafb86c25 /* 238 */, 0x30f1d5d5c145b895 /* 239 */, 0xbb434a2dee7269e7 /* 240 */, 0x78cb67ecf931fa38 /* 241 */, 0xf33b0372323bbf9c /* 242 */, 0x52d66336fb279c74 /* 243 */, 0x505f33ac0afb4eaa /* 244 */, 0xe8a5cd99a2cce187 /* 245 */, 0x534974801e2d30bb /* 246 */, 0x8d2d5711d5876d90 /* 247 */, 0x1f1a412891bc038e /* 248 */, 0xd6e2e71d82e56648 /* 249 */, 0x74036c3a497732b7 /* 250 */, 0x89b67ed96361f5ab /* 251 */, 0xffed95d8f1ea02a2 /* 252 */, 0xe72b3bd61464d43d /* 253 */, 0xa6300f170bdc4820 /* 254 */, 0xebc18760ed78a77a /* 255 */, 0xe6a6be5a05a12138 /* 256 */, 0xb5a122a5b4f87c98 /* 257 */, 0x563c6089140b6990 /* 258 */, 0x4c46cb2e391f5dd5 /* 259 */, 0xd932addbc9b79434 /* 260 */, 0x08ea70e42015aff5 /* 261 */, 0xd765a6673e478cf1 /* 262 */, 0xc4fb757eab278d99 /* 263 */, 0xdf11c6862d6e0692 /* 264 */, 0xddeb84f10d7f3b16 /* 265 */, 0x6f2ef604a665ea04 /* 266 */, 0x4a8e0f0ff0e0dfb3 /* 267 */, 0xa5edeef83dbcba51 /* 268 */, 0xfc4f0a2a0ea4371e /* 269 */, 0xe83e1da85cb38429 /* 270 */, 0xdc8ff882ba1b1ce2 /* 271 */, 0xcd45505e8353e80d /* 272 */, 0x18d19a00d4db0717 /* 273 */, 0x34a0cfeda5f38101 /* 274 */, 0x0be77e518887caf2 /* 275 */, 0x1e341438b3c45136 /* 276 */, 0xe05797f49089ccf9 /* 277 */, 0xffd23f9df2591d14 /* 278 */, 0x543dda228595c5cd /* 279 */, 0x661f81fd99052a33 /* 280 */, 0x8736e641db0f7b76 /* 281 */, 0x15227725418e5307 /* 282 */, 0xe25f7f46162eb2fa /* 283 */, 0x48a8b2126c13d9fe /* 284 */, 0xafdc541792e76eea /* 285 */, 0x03d912bfc6d1898f /* 286 */, 0x31b1aafa1b83f51b /* 287 */, 0xf1ac2796e42ab7d9 /* 288 */, 0x40a3a7d7fcd2ebac /* 289 */, 0x1056136d0afbbcc5 /* 290 */, 0x7889e1dd9a6d0c85 /* 291 */, 0xd33525782a7974aa /* 292 */, 0xa7e25d09078ac09b /* 293 */, 0xbd4138b3eac6edd0 /* 294 */, 0x920abfbe71eb9e70 /* 295 */, 0xa2a5d0f54fc2625c /* 296 */, 0xc054e36b0b1290a3 /* 297 */, 0xf6dd59ff62fe932b /* 298 */, 0x3537354511a8ac7d /* 299 */, 0xca845e9172fadcd4 /* 300 */, 0x84f82b60329d20dc /* 301 */, 0x79c62ce1cd672f18 /* 302 */, 0x8b09a2add124642c /* 303 */, 0xd0c1e96a19d9e726 /* 304 */, 0x5a786a9b4ba9500c /* 305 */, 0x0e020336634c43f3 /* 306 */, 0xc17b474aeb66d822 /* 307 */, 0x6a731ae3ec9baac2 /* 308 */, 0x8226667ae0840258 /* 309 */, 0x67d4567691caeca5 /* 310 */, 0x1d94155c4875adb5 /* 311 */, 0x6d00fd985b813fdf /* 312 */, 0x51286efcb774cd06 /* 313 */, 0x5e8834471fa744af /* 314 */, 0xf72ca0aee761ae2e /* 315 */, 0xbe40e4cdaee8e09a /* 316 */, 0xe9970bbb5118f665 /* 317 */, 0x726e4beb33df1964 /* 318 */, 0x703b000729199762 /* 319 */, 0x4631d816f5ef30a7 /* 320 */, 0xb880b5b51504a6be /* 321 */, 0x641793c37ed84b6c /* 322 */, 0x7b21ed77f6e97d96 /* 323 */, 0x776306312ef96b73 /* 324 */, 0xae528948e86ff3f4 /* 325 */, 0x53dbd7f286a3f8f8 /* 326 */, 0x16cadce74cfc1063 /* 327 */, 0x005c19bdfa52c6dd /* 328 */, 0x68868f5d64d46ad3 /* 329 */, 0x3a9d512ccf1e186a /* 330 */, 0x367e62c2385660ae /* 331 */, 0xe359e7ea77dcb1d7 /* 332 */, 0x526c0773749abe6e /* 333 */, 0x735ae5f9d09f734b /* 334 */, 0x493fc7cc8a558ba8 /* 335 */, 0xb0b9c1533041ab45 /* 336 */, 0x321958ba470a59bd /* 337 */, 0x852db00b5f46c393 /* 338 */, 0x91209b2bd336b0e5 /* 339 */, 0x6e604f7d659ef19f /* 340 */, 0xb99a8ae2782ccb24 /* 341 */, 0xccf52ab6c814c4c7 /* 342 */, 0x4727d9afbe11727b /* 343 */, 0x7e950d0c0121b34d /* 344 */, 0x756f435670ad471f /* 345 */, 0xf5add442615a6849 /* 346 */, 0x4e87e09980b9957a /* 347 */, 0x2acfa1df50aee355 /* 348 */, 0xd898263afd2fd556 /* 349 */, 0xc8f4924dd80c8fd6 /* 350 */, 0xcf99ca3d754a173a /* 351 */, 0xfe477bacaf91bf3c /* 352 */, 0xed5371f6d690c12d /* 353 */, 0x831a5c285e687094 /* 354 */, 0xc5d3c90a3708a0a4 /* 355 */, 0x0f7f903717d06580 /* 356 */, 0x19f9bb13b8fdf27f /* 357 */, 0xb1bd6f1b4d502843 /* 358 */, 0x1c761ba38fff4012 /* 359 */, 0x0d1530c4e2e21f3b /* 360 */, 0x8943ce69a7372c8a /* 361 */, 0xe5184e11feb5ce66 /* 362 */, 0x618bdb80bd736621 /* 363 */, 0x7d29bad68b574d0b /* 364 */, 0x81bb613e25e6fe5b /* 365 */, 0x071c9c10bc07913f /* 366 */, 0xc7beeb7909ac2d97 /* 367 */, 0xc3e58d353bc5d757 /* 368 */, 0xeb017892f38f61e8 /* 369 */, 0xd4effb9c9b1cc21a /* 370 */, 0x99727d26f494f7ab /* 371 */, 0xa3e063a2956b3e03 /* 372 */, 0x9d4a8b9a4aa09c30 /* 373 */, 0x3f6ab7d500090fb4 /* 374 */, 0x9cc0f2a057268ac0 /* 375 */, 0x3dee9d2dedbf42d1 /* 376 */, 0x330f49c87960a972 /* 377 */, 0xc6b2720287421b41 /* 378 */, 0x0ac59ec07c00369c /* 379 */, 0xef4eac49cb353425 /* 380 */, 0xf450244eef0129d8 /* 381 */, 0x8acc46e5caf4deb6 /* 382 */, 0x2ffeab63989263f7 /* 383 */, 0x8f7cb9fe5d7a4578 /* 384 */, 0x5bd8f7644e634635 /* 385 */, 0x427a7315bf2dc900 /* 386 */, 0x17d0c4aa2125261c /* 387 */, 0x3992486c93518e50 /* 388 */, 0xb4cbfee0a2d7d4c3 /* 389 */, 0x7c75d6202c5ddd8d /* 390 */, 0xdbc295d8e35b6c61 /* 391 */, 0x60b369d302032b19 /* 392 */, 0xce42685fdce44132 /* 393 */, 0x06f3ddb9ddf65610 /* 394 */, 0x8ea4d21db5e148f0 /* 395 */, 0x20b0fce62fcd496f /* 396 */, 0x2c1b912358b0ee31 /* 397 */, 0xb28317b818f5a308 /* 398 */, 0xa89c1e189ca6d2cf /* 399 */, 0x0c6b18576aaadbc8 /* 400 */, 0xb65deaa91299fae3 /* 401 */, 0xfb2b794b7f1027e7 /* 402 */, 0x04e4317f443b5beb /* 403 */, 0x4b852d325939d0a6 /* 404 */, 0xd5ae6beefb207ffc /* 405 */, 0x309682b281c7d374 /* 406 */, 0xbae309a194c3b475 /* 407 */, 0x8cc3f97b13b49f05 /* 408 */, 0x98a9422ff8293967 /* 409 */, 0x244b16b01076ff7c /* 410 */, 0xf8bf571c663d67ee /* 411 */, 0x1f0d6758eee30da1 /* 412 */, 0xc9b611d97adeb9b7 /* 413 */, 0xb7afd5887b6c57a2 /* 414 */, 0x6290ae846b984fe1 /* 415 */, 0x94df4cdeacc1a5fd /* 416 */, 0x058a5bd1c5483aff /* 417 */, 0x63166cc142ba3c37 /* 418 */, 0x8db8526eb2f76f40 /* 419 */, 0xe10880036f0d6d4e /* 420 */, 0x9e0523c9971d311d /* 421 */, 0x45ec2824cc7cd691 /* 422 */, 0x575b8359e62382c9 /* 423 */, 0xfa9e400dc4889995 /* 424 */, 0xd1823ecb45721568 /* 425 */, 0xdafd983b8206082f /* 426 */, 0xaa7d29082386a8cb /* 427 */, 0x269fcd4403b87588 /* 428 */, 0x1b91f5f728bdd1e0 /* 429 */, 0xe4669f39040201f6 /* 430 */, 0x7a1d7c218cf04ade /* 431 */, 0x65623c29d79ce5ce /* 432 */, 0x2368449096c00bb1 /* 433 */, 0xab9bf1879da503ba /* 434 */, 0xbc23ecb1a458058e /* 435 */, 0x9a58df01bb401ecc /* 436 */, 0xa070e868a85f143d /* 437 */, 0x4ff188307df2239e /* 438 */, 0x14d565b41a641183 /* 439 */, 0xee13337452701602 /* 440 */, 0x950e3dcf3f285e09 /* 441 */, 0x59930254b9c80953 /* 442 */, 0x3bf299408930da6d /* 443 */, 0xa955943f53691387 /* 444 */, 0xa15edecaa9cb8784 /* 445 */, 0x29142127352be9a0 /* 446 */, 0x76f0371fff4e7afb /* 447 */, 0x0239f450274f2228 /* 448 */, 0xbb073af01d5e868b /* 449 */, 0xbfc80571c10e96c1 /* 450 */, 0xd267088568222e23 /* 451 */, 0x9671a3d48e80b5b0 /* 452 */, 0x55b5d38ae193bb81 /* 453 */, 0x693ae2d0a18b04b8 /* 454 */, 0x5c48b4ecadd5335f /* 455 */, 0xfd743b194916a1ca /* 456 */, 0x2577018134be98c4 /* 457 */, 0xe77987e83c54a4ad /* 458 */, 0x28e11014da33e1b9 /* 459 */, 0x270cc59e226aa213 /* 460 */, 0x71495f756d1a5f60 /* 461 */, 0x9be853fb60afef77 /* 462 */, 0xadc786a7f7443dbf /* 463 */, 0x0904456173b29a82 /* 464 */, 0x58bc7a66c232bd5e /* 465 */, 0xf306558c673ac8b2 /* 466 */, 0x41f639c6b6c9772a /* 467 */, 0x216defe99fda35da /* 468 */, 0x11640cc71c7be615 /* 469 */, 0x93c43694565c5527 /* 470 */, 0xea038e6246777839 /* 471 */, 0xf9abf3ce5a3e2469 /* 472 */, 0x741e768d0fd312d2 /* 473 */, 0x0144b883ced652c6 /* 474 */, 0xc20b5a5ba33f8552 /* 475 */, 0x1ae69633c3435a9d /* 476 */, 0x97a28ca4088cfdec /* 477 */, 0x8824a43c1e96f420 /* 478 */, 0x37612fa66eeea746 /* 479 */, 0x6b4cb165f9cf0e5a /* 480 */, 0x43aa1c06a0abfb4a /* 481 */, 0x7f4dc26ff162796b /* 482 */, 0x6cbacc8e54ed9b0f /* 483 */, 0xa6b7ffefd2bb253e /* 484 */, 0x2e25bc95b0a29d4f /* 485 */, 0x86d6a58bdef1388c /* 486 */, 0xded74ac576b6f054 /* 487 */, 0x8030bdbc2b45805d /* 488 */, 0x3c81af70e94d9289 /* 489 */, 0x3eff6dda9e3100db /* 490 */, 0xb38dc39fdfcc8847 /* 491 */, 0x123885528d17b87e /* 492 */, 0xf2da0ed240b1b642 /* 493 */, 0x44cefadcd54bf9a9 /* 494 */, 0x1312200e433c7ee6 /* 495 */, 0x9ffcc84f3a78c748 /* 496 */, 0xf0cd1f72248576bb /* 497 */, 0xec6974053638cfe4 /* 498 */, 0x2ba7b67c0cec4e4c /* 499 */, 0xac2f4df3e5ce32ed /* 500 */, 0xcb33d14326ea4c11 /* 501 */, 0xa4e9044cc77e58bc /* 502 */, 0x5f513293d934fcef /* 503 */, 0x5dc9645506e55444 /* 504 */, 0x50de418f317de40a /* 505 */, 0x388cb31a69dde259 /* 506 */, 0x2db4a83455820a86 /* 507 */, 0x9010a91e84711ae9 /* 508 */, 0x4df7f0b7b1498371 /* 509 */, 0xd62a2eabc0977179 /* 510 */, 0x22fac097aa8d5c0e /* 511 */, 0xf49fcc2ff1daf39b /* 512 */, 0x487fd5c66ff29281 /* 513 */, 0xe8a30667fcdca83f /* 514 */, 0x2c9b4be3d2fcce63 /* 515 */, 0xda3ff74b93fbbbc2 /* 516 */, 0x2fa165d2fe70ba66 /* 517 */, 0xa103e279970e93d4 /* 518 */, 0xbecdec77b0e45e71 /* 519 */, 0xcfb41e723985e497 /* 520 */, 0xb70aaa025ef75017 /* 521 */, 0xd42309f03840b8e0 /* 522 */, 0x8efc1ad035898579 /* 523 */, 0x96c6920be2b2abc5 /* 524 */, 0x66af4163375a9172 /* 525 */, 0x2174abdcca7127fb /* 526 */, 0xb33ccea64a72ff41 /* 527 */, 0xf04a4933083066a5 /* 528 */, 0x8d970acdd7289af5 /* 529 */, 0x8f96e8e031c8c25e /* 530 */, 0xf3fec02276875d47 /* 531 */, 0xec7bf310056190dd /* 532 */, 0xf5adb0aebb0f1491 /* 533 */, 0x9b50f8850fd58892 /* 534 */, 0x4975488358b74de8 /* 535 */, 0xa3354ff691531c61 /* 536 */, 0x0702bbe481d2c6ee /* 537 */, 0x89fb24057deded98 /* 538 */, 0xac3075138596e902 /* 539 */, 0x1d2d3580172772ed /* 540 */, 0xeb738fc28e6bc30d /* 541 */, 0x5854ef8f63044326 /* 542 */, 0x9e5c52325add3bbe /* 543 */, 0x90aa53cf325c4623 /* 544 */, 0xc1d24d51349dd067 /* 545 */, 0x2051cfeea69ea624 /* 546 */, 0x13220f0a862e7e4f /* 547 */, 0xce39399404e04864 /* 548 */, 0xd9c42ca47086fcb7 /* 549 */, 0x685ad2238a03e7cc /* 550 */, 0x066484b2ab2ff1db /* 551 */, 0xfe9d5d70efbf79ec /* 552 */, 0x5b13b9dd9c481854 /* 553 */, 0x15f0d475ed1509ad /* 554 */, 0x0bebcd060ec79851 /* 555 */, 0xd58c6791183ab7f8 /* 556 */, 0xd1187c5052f3eee4 /* 557 */, 0xc95d1192e54e82ff /* 558 */, 0x86eea14cb9ac6ca2 /* 559 */, 0x3485beb153677d5d /* 560 */, 0xdd191d781f8c492a /* 561 */, 0xf60866baa784ebf9 /* 562 */, 0x518f643ba2d08c74 /* 563 */, 0x8852e956e1087c22 /* 564 */, 0xa768cb8dc410ae8d /* 565 */, 0x38047726bfec8e1a /* 566 */, 0xa67738b4cd3b45aa /* 567 */, 0xad16691cec0dde19 /* 568 */, 0xc6d4319380462e07 /* 569 */, 0xc5a5876d0ba61938 /* 570 */, 0x16b9fa1fa58fd840 /* 571 */, 0x188ab1173ca74f18 /* 572 */, 0xabda2f98c99c021f /* 573 */, 0x3e0580ab134ae816 /* 574 */, 0x5f3b05b773645abb /* 575 */, 0x2501a2be5575f2f6 /* 576 */, 0x1b2f74004e7e8ba9 /* 577 */, 0x1cd7580371e8d953 /* 578 */, 0x7f6ed89562764e30 /* 579 */, 0xb15926ff596f003d /* 580 */, 0x9f65293da8c5d6b9 /* 581 */, 0x6ecef04dd690f84c /* 582 */, 0x4782275fff33af88 /* 583 */, 0xe41433083f820801 /* 584 */, 0xfd0dfe409a1af9b5 /* 585 */, 0x4325a3342cdb396b /* 586 */, 0x8ae77e62b301b252 /* 587 */, 0xc36f9e9f6655615a /* 588 */, 0x85455a2d92d32c09 /* 589 */, 0xf2c7dea949477485 /* 590 */, 0x63cfb4c133a39eba /* 591 */, 0x83b040cc6ebc5462 /* 592 */, 0x3b9454c8fdb326b0 /* 593 */, 0x56f56a9e87ffd78c /* 594 */, 0x2dc2940d99f42bc6 /* 595 */, 0x98f7df096b096e2d /* 596 */, 0x19a6e01e3ad852bf /* 597 */, 0x42a99ccbdbd4b40b /* 598 */, 0xa59998af45e9c559 /* 599 */, 0x366295e807d93186 /* 600 */, 0x6b48181bfaa1f773 /* 601 */, 0x1fec57e2157a0a1d /* 602 */, 0x4667446af6201ad5 /* 603 */, 0xe615ebcacfb0f075 /* 604 */, 0xb8f31f4f68290778 /* 605 */, 0x22713ed6ce22d11e /* 606 */, 0x3057c1a72ec3c93b /* 607 */, 0xcb46acc37c3f1f2f /* 608 */, 0xdbb893fd02aaf50e /* 609 */, 0x331fd92e600b9fcf /* 610 */, 0xa498f96148ea3ad6 /* 611 */, 0xa8d8426e8b6a83ea /* 612 */, 0xa089b274b7735cdc /* 613 */, 0x87f6b3731e524a11 /* 614 */, 0x118808e5cbc96749 /* 615 */, 0x9906e4c7b19bd394 /* 616 */, 0xafed7f7e9b24a20c /* 617 */, 0x6509eadeeb3644a7 /* 618 */, 0x6c1ef1d3e8ef0ede /* 619 */, 0xb9c97d43e9798fb4 /* 620 */, 0xa2f2d784740c28a3 /* 621 */, 0x7b8496476197566f /* 622 */, 0x7a5be3e6b65f069d /* 623 */, 0xf96330ed78be6f10 /* 624 */, 0xeee60de77a076a15 /* 625 */, 0x2b4bee4aa08b9bd0 /* 626 */, 0x6a56a63ec7b8894e /* 627 */, 0x02121359ba34fef4 /* 628 */, 0x4cbf99f8283703fc /* 629 */, 0x398071350caf30c8 /* 630 */, 0xd0a77a89f017687a /* 631 */, 0xf1c1a9eb9e423569 /* 632 */, 0x8c7976282dee8199 /* 633 */, 0x5d1737a5dd1f7abd /* 634 */, 0x4f53433c09a9fa80 /* 635 */, 0xfa8b0c53df7ca1d9 /* 636 */, 0x3fd9dcbc886ccb77 /* 637 */, 0xc040917ca91b4720 /* 638 */, 0x7dd00142f9d1dcdf /* 639 */, 0x8476fc1d4f387b58 /* 640 */, 0x23f8e7c5f3316503 /* 641 */, 0x032a2244e7e37339 /* 642 */, 0x5c87a5d750f5a74b /* 643 */, 0x082b4cc43698992e /* 644 */, 0xdf917becb858f63c /* 645 */, 0x3270b8fc5bf86dda /* 646 */, 0x10ae72bb29b5dd76 /* 647 */, 0x576ac94e7700362b /* 648 */, 0x1ad112dac61efb8f /* 649 */, 0x691bc30ec5faa427 /* 650 */, 0xff246311cc327143 /* 651 */, 0x3142368e30e53206 /* 652 */, 0x71380e31e02ca396 /* 653 */, 0x958d5c960aad76f1 /* 654 */, 0xf8d6f430c16da536 /* 655 */, 0xc8ffd13f1be7e1d2 /* 656 */, 0x7578ae66004ddbe1 /* 657 */, 0x05833f01067be646 /* 658 */, 0xbb34b5ad3bfe586d /* 659 */, 0x095f34c9a12b97f0 /* 660 */, 0x247ab64525d60ca8 /* 661 */, 0xdcdbc6f3017477d1 /* 662 */, 0x4a2e14d4decad24d /* 663 */, 0xbdb5e6d9be0a1eeb /* 664 */, 0x2a7e70f7794301ab /* 665 */, 0xdef42d8a270540fd /* 666 */, 0x01078ec0a34c22c1 /* 667 */, 0xe5de511af4c16387 /* 668 */, 0x7ebb3a52bd9a330a /* 669 */, 0x77697857aa7d6435 /* 670 */, 0x004e831603ae4c32 /* 671 */, 0xe7a21020ad78e312 /* 672 */, 0x9d41a70c6ab420f2 /* 673 */, 0x28e06c18ea1141e6 /* 674 */, 0xd2b28cbd984f6b28 /* 675 */, 0x26b75f6c446e9d83 /* 676 */, 0xba47568c4d418d7f /* 677 */, 0xd80badbfe6183d8e /* 678 */, 0x0e206d7f5f166044 /* 679 */, 0xe258a43911cbca3e /* 680 */, 0x723a1746b21dc0bc /* 681 */, 0xc7caa854f5d7cdd3 /* 682 */, 0x7cac32883d261d9c /* 683 */, 0x7690c26423ba942c /* 684 */, 0x17e55524478042b8 /* 685 */, 0xe0be477656a2389f /* 686 */, 0x4d289b5e67ab2da0 /* 687 */, 0x44862b9c8fbbfd31 /* 688 */, 0xb47cc8049d141365 /* 689 */, 0x822c1b362b91c793 /* 690 */, 0x4eb14655fb13dfd8 /* 691 */, 0x1ecbba0714e2a97b /* 692 */, 0x6143459d5cde5f14 /* 693 */, 0x53a8fbf1d5f0ac89 /* 694 */, 0x97ea04d81c5e5b00 /* 695 */, 0x622181a8d4fdb3f3 /* 696 */, 0xe9bcd341572a1208 /* 697 */, 0x1411258643cce58a /* 698 */, 0x9144c5fea4c6e0a4 /* 699 */, 0x0d33d06565cf620f /* 700 */, 0x54a48d489f219ca1 /* 701 */, 0xc43e5eac6d63c821 /* 702 */, 0xa9728b3a72770daf /* 703 */, 0xd7934e7b20df87ef /* 704 */, 0xe35503b61a3e86e5 /* 705 */, 0xcae321fbc819d504 /* 706 */, 0x129a50b3ac60bfa6 /* 707 */, 0xcd5e68ea7e9fb6c3 /* 708 */, 0xb01c90199483b1c7 /* 709 */, 0x3de93cd5c295376c /* 710 */, 0xaed52edf2ab9ad13 /* 711 */, 0x2e60f512c0a07884 /* 712 */, 0xbc3d86a3e36210c9 /* 713 */, 0x35269d9b163951ce /* 714 */, 0x0c7d6e2ad0cdb5fa /* 715 */, 0x59e86297d87f5733 /* 716 */, 0x298ef221898db0e7 /* 717 */, 0x55000029d1a5aa7e /* 718 */, 0x8bc08ae1b5061b45 /* 719 */, 0xc2c31c2b6c92703a /* 720 */, 0x94cc596baf25ef42 /* 721 */, 0x0a1d73db22540456 /* 722 */, 0x04b6a0f9d9c4179a /* 723 */, 0xeffdafa2ae3d3c60 /* 724 */, 0xf7c8075bb49496c4 /* 725 */, 0x9cc5c7141d1cd4e3 /* 726 */, 0x78bd1638218e5534 /* 727 */, 0xb2f11568f850246a /* 728 */, 0xedfabcfa9502bc29 /* 729 */, 0x796ce5f2da23051b /* 730 */, 0xaae128b0dc93537c /* 731 */, 0x3a493da0ee4b29ae /* 732 */, 0xb5df6b2c416895d7 /* 733 */, 0xfcabbd25122d7f37 /* 734 */, 0x70810b58105dc4b1 /* 735 */, 0xe10fdd37f7882a90 /* 736 */, 0x524dcab5518a3f5c /* 737 */, 0x3c9e85878451255b /* 738 */, 0x4029828119bd34e2 /* 739 */, 0x74a05b6f5d3ceccb /* 740 */, 0xb610021542e13eca /* 741 */, 0x0ff979d12f59e2ac /* 742 */, 0x6037da27e4f9cc50 /* 743 */, 0x5e92975a0df1847d /* 744 */, 0xd66de190d3e623fe /* 745 */, 0x5032d6b87b568048 /* 746 */, 0x9a36b7ce8235216e /* 747 */, 0x80272a7a24f64b4a /* 748 */, 0x93efed8b8c6916f7 /* 749 */, 0x37ddbff44cce1555 /* 750 */, 0x4b95db5d4b99bd25 /* 751 */, 0x92d3fda169812fc0 /* 752 */, 0xfb1a4a9a90660bb6 /* 753 */, 0x730c196946a4b9b2 /* 754 */, 0x81e289aa7f49da68 /* 755 */, 0x64669a0f83b1a05f /* 756 */, 0x27b3ff7d9644f48b /* 757 */, 0xcc6b615c8db675b3 /* 758 */, 0x674f20b9bcebbe95 /* 759 */, 0x6f31238275655982 /* 760 */, 0x5ae488713e45cf05 /* 761 */, 0xbf619f9954c21157 /* 762 */, 0xeabac46040a8eae9 /* 763 */, 0x454c6fe9f2c0c1cd /* 764 */, 0x419cf6496412691c /* 765 */, 0xd3dc3bef265b0f70 /* 766 */, 0x6d0e60f5c3578a9e /* 767 */, 0x5b0e608526323c55 /* 768 */, 0x1a46c1a9fa1b59f5 /* 769 */, 0xa9e245a17c4c8ffa /* 770 */, 0x65ca5159db2955d7 /* 771 */, 0x05db0a76ce35afc2 /* 772 */, 0x81eac77ea9113d45 /* 773 */, 0x528ef88ab6ac0a0d /* 774 */, 0xa09ea253597be3ff /* 775 */, 0x430ddfb3ac48cd56 /* 776 */, 0xc4b3a67af45ce46f /* 777 */, 0x4ececfd8fbe2d05e /* 778 */, 0x3ef56f10b39935f0 /* 779 */, 0x0b22d6829cd619c6 /* 780 */, 0x17fd460a74df2069 /* 781 */, 0x6cf8cc8e8510ed40 /* 782 */, 0xd6c824bf3a6ecaa7 /* 783 */, 0x61243d581a817049 /* 784 */, 0x048bacb6bbc163a2 /* 785 */, 0xd9a38ac27d44cc32 /* 786 */, 0x7fddff5baaf410ab /* 787 */, 0xad6d495aa804824b /* 788 */, 0xe1a6a74f2d8c9f94 /* 789 */, 0xd4f7851235dee8e3 /* 790 */, 0xfd4b7f886540d893 /* 791 */, 0x247c20042aa4bfda /* 792 */, 0x096ea1c517d1327c /* 793 */, 0xd56966b4361a6685 /* 794 */, 0x277da5c31221057d /* 795 */, 0x94d59893a43acff7 /* 796 */, 0x64f0c51ccdc02281 /* 797 */, 0x3d33bcc4ff6189db /* 798 */, 0xe005cb184ce66af1 /* 799 */, 0xff5ccd1d1db99bea /* 800 */, 0xb0b854a7fe42980f /* 801 */, 0x7bd46a6a718d4b9f /* 802 */, 0xd10fa8cc22a5fd8c /* 803 */, 0xd31484952be4bd31 /* 804 */, 0xc7fa975fcb243847 /* 805 */, 0x4886ed1e5846c407 /* 806 */, 0x28cddb791eb70b04 /* 807 */, 0xc2b00be2f573417f /* 808 */, 0x5c9590452180f877 /* 809 */, 0x7a6bddfff370eb00 /* 810 */, 0xce509e38d6d9d6a4 /* 811 */, 0xebeb0f00647fa702 /* 812 */, 0x1dcc06cf76606f06 /* 813 */, 0xe4d9f28ba286ff0a /* 814 */, 0xd85a305dc918c262 /* 815 */, 0x475b1d8732225f54 /* 816 */, 0x2d4fb51668ccb5fe /* 817 */, 0xa679b9d9d72bba20 /* 818 */, 0x53841c0d912d43a5 /* 819 */, 0x3b7eaa48bf12a4e8 /* 820 */, 0x781e0e47f22f1ddf /* 821 */, 0xeff20ce60ab50973 /* 822 */, 0x20d261d19dffb742 /* 823 */, 0x16a12b03062a2e39 /* 824 */, 0x1960eb2239650495 /* 825 */, 0x251c16fed50eb8b8 /* 826 */, 0x9ac0c330f826016e /* 827 */, 0xed152665953e7671 /* 828 */, 0x02d63194a6369570 /* 829 */, 0x5074f08394b1c987 /* 830 */, 0x70ba598c90b25ce1 /* 831 */, 0x794a15810b9742f6 /* 832 */, 0x0d5925e9fcaf8c6c /* 833 */, 0x3067716cd868744e /* 834 */, 0x910ab077e8d7731b /* 835 */, 0x6a61bbdb5ac42f61 /* 836 */, 0x93513efbf0851567 /* 837 */, 0xf494724b9e83e9d5 /* 838 */, 0xe887e1985c09648d /* 839 */, 0x34b1d3c675370cfd /* 840 */, 0xdc35e433bc0d255d /* 841 */, 0xd0aab84234131be0 /* 842 */, 0x08042a50b48b7eaf /* 843 */, 0x9997c4ee44a3ab35 /* 844 */, 0x829a7b49201799d0 /* 845 */, 0x263b8307b7c54441 /* 846 */, 0x752f95f4fd6a6ca6 /* 847 */, 0x927217402c08c6e5 /* 848 */, 0x2a8ab754a795d9ee /* 849 */, 0xa442f7552f72943d /* 850 */, 0x2c31334e19781208 /* 851 */, 0x4fa98d7ceaee6291 /* 852 */, 0x55c3862f665db309 /* 853 */, 0xbd0610175d53b1f3 /* 854 */, 0x46fe6cb840413f27 /* 855 */, 0x3fe03792df0cfa59 /* 856 */, 0xcfe700372eb85e8f /* 857 */, 0xa7be29e7adbce118 /* 858 */, 0xe544ee5cde8431dd /* 859 */, 0x8a781b1b41f1873e /* 860 */, 0xa5c94c78a0d2f0e7 /* 861 */, 0x39412e2877b60728 /* 862 */, 0xa1265ef3afc9a62c /* 863 */, 0xbcc2770c6a2506c5 /* 864 */, 0x3ab66dd5dce1ce12 /* 865 */, 0xe65499d04a675b37 /* 866 */, 0x7d8f523481bfd216 /* 867 */, 0x0f6f64fcec15f389 /* 868 */, 0x74efbe618b5b13c8 /* 869 */, 0xacdc82b714273e1d /* 870 */, 0xdd40bfe003199d17 /* 871 */, 0x37e99257e7e061f8 /* 872 */, 0xfa52626904775aaa /* 873 */, 0x8bbbf63a463d56f9 /* 874 */, 0xf0013f1543a26e64 /* 875 */, 0xa8307e9f879ec898 /* 876 */, 0xcc4c27a4150177cc /* 877 */, 0x1b432f2cca1d3348 /* 878 */, 0xde1d1f8f9f6fa013 /* 879 */, 0x606602a047a7ddd6 /* 880 */, 0xd237ab64cc1cb2c7 /* 881 */, 0x9b938e7225fcd1d3 /* 882 */, 0xec4e03708e0ff476 /* 883 */, 0xfeb2fbda3d03c12d /* 884 */, 0xae0bced2ee43889a /* 885 */, 0x22cb8923ebfb4f43 /* 886 */, 0x69360d013cf7396d /* 887 */, 0x855e3602d2d4e022 /* 888 */, 0x073805bad01f784c /* 889 */, 0x33e17a133852f546 /* 890 */, 0xdf4874058ac7b638 /* 891 */, 0xba92b29c678aa14a /* 892 */, 0x0ce89fc76cfaadcd /* 893 */, 0x5f9d4e0908339e34 /* 894 */, 0xf1afe9291f5923b9 /* 895 */, 0x6e3480f60f4a265f /* 896 */, 0xeebf3a2ab29b841c /* 897 */, 0xe21938a88f91b4ad /* 898 */, 0x57dfeff845c6d3c3 /* 899 */, 0x2f006b0bf62caaf2 /* 900 */, 0x62f479ef6f75ee78 /* 901 */, 0x11a55ad41c8916a9 /* 902 */, 0xf229d29084fed453 /* 903 */, 0x42f1c27b16b000e6 /* 904 */, 0x2b1f76749823c074 /* 905 */, 0x4b76eca3c2745360 /* 906 */, 0x8c98f463b91691bd /* 907 */, 0x14bcc93cf1ade66a /* 908 */, 0x8885213e6d458397 /* 909 */, 0x8e177df0274d4711 /* 910 */, 0xb49b73b5503f2951 /* 911 */, 0x10168168c3f96b6b /* 912 */, 0x0e3d963b63cab0ae /* 913 */, 0x8dfc4b5655a1db14 /* 914 */, 0xf789f1356e14de5c /* 915 */, 0x683e68af4e51dac1 /* 916 */, 0xc9a84f9d8d4b0fd9 /* 917 */, 0x3691e03f52a0f9d1 /* 918 */, 0x5ed86e46e1878e80 /* 919 */, 0x3c711a0e99d07150 /* 920 */, 0x5a0865b20c4e9310 /* 921 */, 0x56fbfc1fe4f0682e /* 922 */, 0xea8d5de3105edf9b /* 923 */, 0x71abfdb12379187a /* 924 */, 0x2eb99de1bee77b9c /* 925 */, 0x21ecc0ea33cf4523 /* 926 */, 0x59a4d7521805c7a1 /* 927 */, 0x3896f5eb56ae7c72 /* 928 */, 0xaa638f3db18f75dc /* 929 */, 0x9f39358dabe9808e /* 930 */, 0xb7defa91c00b72ac /* 931 */, 0x6b5541fd62492d92 /* 932 */, 0x6dc6dee8f92e4d5b /* 933 */, 0x353f57abc4beea7e /* 934 */, 0x735769d6da5690ce /* 935 */, 0x0a234aa642391484 /* 936 */, 0xf6f9508028f80d9d /* 937 */, 0xb8e319a27ab3f215 /* 938 */, 0x31ad9c1151341a4d /* 939 */, 0x773c22a57bef5805 /* 940 */, 0x45c7561a07968633 /* 941 */, 0xf913da9e249dbe36 /* 942 */, 0xda652d9b78a64c68 /* 943 */, 0x4c27a97f3bc334ef /* 944 */, 0x76621220e66b17f4 /* 945 */, 0x967743899acd7d0b /* 946 */, 0xf3ee5bcae0ed6782 /* 947 */, 0x409f753600c879fc /* 948 */, 0x06d09a39b5926db6 /* 949 */, 0x6f83aeb0317ac588 /* 950 */, 0x01e6ca4a86381f21 /* 951 */, 0x66ff3462d19f3025 /* 952 */, 0x72207c24ddfd3bfb /* 953 */, 0x4af6b6d3e2ece2eb /* 954 */, 0x9c994dbec7ea08de /* 955 */, 0x49ace597b09a8bc4 /* 956 */, 0xb38c4766cf0797ba /* 957 */, 0x131b9373c57c2a75 /* 958 */, 0xb1822cce61931e58 /* 959 */, 0x9d7555b909ba1c0c /* 960 */, 0x127fafdd937d11d2 /* 961 */, 0x29da3badc66d92e4 /* 962 */, 0xa2c1d57154c2ecbc /* 963 */, 0x58c5134d82f6fe24 /* 964 */, 0x1c3ae3515b62274f /* 965 */, 0xe907c82e01cb8126 /* 966 */, 0xf8ed091913e37fcb /* 967 */, 0x3249d8f9c80046c9 /* 968 */, 0x80cf9bede388fb63 /* 969 */, 0x1881539a116cf19e /* 970 */, 0x5103f3f76bd52457 /* 971 */, 0x15b7e6f5ae47f7a8 /* 972 */, 0xdbd7c6ded47e9ccf /* 973 */, 0x44e55c410228bb1a /* 974 */, 0xb647d4255edb4e99 /* 975 */, 0x5d11882bb8aafc30 /* 976 */, 0xf5098bbb29d3212a /* 977 */, 0x8fb5ea14e90296b3 /* 978 */, 0x677b942157dd025a /* 979 */, 0xfb58e7c0a390acb5 /* 980 */, 0x89d3674c83bd4a01 /* 981 */, 0x9e2da4df4bf3b93b /* 982 */, 0xfcc41e328cab4829 /* 983 */, 0x03f38c96ba582c52 /* 984 */, 0xcad1bdbd7fd85db2 /* 985 */, 0xbbb442c16082ae83 /* 986 */, 0xb95fe86ba5da9ab0 /* 987 */, 0xb22e04673771a93f /* 988 */, 0x845358c9493152d8 /* 989 */, 0xbe2a488697b4541e /* 990 */, 0x95a2dc2dd38e6966 /* 991 */, 0xc02c11ac923c852b /* 992 */, 0x2388b1990df2a87b /* 993 */, 0x7c8008fa1b4f37be /* 994 */, 0x1f70d0c84d54e503 /* 995 */, 0x5490adec7ece57d4 /* 996 */, 0x002b3c27d9063a3a /* 997 */, 0x7eaea3848030a2bf /* 998 */, 0xc602326ded2003c0 /* 999 */, 0x83a7287d69a94086 /* 1000 */, 0xc57a5fcb30f57a8a /* 1001 */, 0xb56844e479ebe779 /* 1002 */, 0xa373b40f05dcbce9 /* 1003 */, 0xd71a786e88570ee2 /* 1004 */, 0x879cbacdbde8f6a0 /* 1005 */, 0x976ad1bcc164a32f /* 1006 */, 0xab21e25e9666d78b /* 1007 */, 0x901063aae5e5c33c /* 1008 */, 0x9818b34448698d90 /* 1009 */, 0xe36487ae3e1e8abb /* 1010 */, 0xafbdf931893bdcb4 /* 1011 */, 0x6345a0dc5fbbd519 /* 1012 */, 0x8628fe269b9465ca /* 1013 */, 0x1e5d01603f9c51ec /* 1014 */, 0x4de44006a15049b7 /* 1015 */, 0xbf6c70e5f776cbb1 /* 1016 */, 0x411218f2ef552bed /* 1017 */, 0xcb0c0708705a36a3 /* 1018 */, 0xe74d14754f986044 /* 1019 */, 0xcd56d9430ea8280e /* 1020 */, 0xc12591d7535f5065 /* 1021 */, 0xc83223f1720aef96 /* 1022 */, 0xc3a0396f7363a51f /* 1023 */ ]; /******************************************************************************* *******************************************************************************/ debug(UnitTest) { unittest { static ткст[] strings = [ "", "abc", "Tiger", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789", "Tiger - A Быстрый Нов Хэш Function, by Ross Anderson и Eli Biham", "Tiger - A Быстрый Нов Хэш Function, by Ross Anderson и Eli Biham, proceedings of Быстрый Software Encryption 3, Camмост.", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", x"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000", ]; static ткст[] results = [ "3293ac630c13f0245f92bbb1766e16167a4e58492dde73f3", "2aab1484e8c158f2bfb8c5ff41b57a525129131c957b5f93", "dd00230799f5009fec6debc838bb6a27df2b9d6f110c7937", "f71c8583902afb879edfe610f82c0d4786a3a534504486b5", "48ceeb6308b87d46e95d656112cdf18d97915f9765658957", "8a866829040a410c729ad23f5ada711603b3cdd357e4c15e", "ce55a6afd591f5ebac547ff84f89227f9331dab0b611c889", "0f7bf9a19b9c58f2b7610df7e84f0ac3a71c631e7b53f78e", "5ab6ff5b263acfab2013c3068c03a82979ea6db287a3ecdd", ]; Tiger h = new Tiger(); foreach(цел i, ткст s; strings) { h.обнови(cast(ббайт[]) s); ткст d = h.гексДайджест(); assert(d == results[i],":("~s~")("~d~")!=("~results[i]~")"); } } }
D
/home/nathan/Google Drive/computing/rust/minigrep/target/debug/deps/minigrep-3b12b7d9141365b1.rmeta: src/lib.rs /home/nathan/Google Drive/computing/rust/minigrep/target/debug/deps/minigrep-3b12b7d9141365b1.d: src/lib.rs src/lib.rs:
D
/******************************************************************************* Test Case Base Class. Common functionality used by all tests. Copyright: Copyright (c) 2017 Sociomantic Labs GmbH. All rights reserved. License: Boost Software License Version 1.0. See LICENSE.txt for details. *******************************************************************************/ module integrationtest.common.TestCase; import integrationtest.common.shellHelper; import std.stdio : File; // Hack to make rdmd report dependencies properly static import lib.shell.helper; /// TestCase from which other tests can derive class TestCase { import integrationtest.common.GHTestServer : RestAPI; import std.process; enum GitRepo = "tester/sandbox"; enum GitPath = "github.com:" ~ GitRepo; /// Temporary dir protected string tmp; /// Binary dir protected string bin; /// Data dir protected string data; /// Git repo dir protected string git; /// Shared data dir protected string common_data; /// Set to true if the test failed protected bool failed; /// Set to true if the timeout killed neptune protected bool killed; /// Pid of the neptune process protected Pid neptune_pid; /// Fake Github Class protected RestAPI fake_github; /// Port to use for github server protected ushort gh_port; /*************************************************************************** C'tor Params: gh_port = port to use for github test_file = path to the main.d file of the test ***************************************************************************/ public this ( ushort gh_port, string test_file = __FILE_FULL_PATH__ ) { import vibe.core.args; import vibe.web.rest; import vibe.http.router; import std.format; import std.random; this.tmp = format("%s/%x", readRequiredOption!string("tmp", "Temporary directory"), uniform!ulong()); "/usr/bin".cmd("mkdir " ~ this.tmp); this.gh_port = gh_port; assert(this.gh_port != 0); this.bin = readRequiredOption!string("bin", "Binary directory"); this.data = test_file[0 .. $-"main.d".length] ~ "data"; this.common_data = __FILE_FULL_PATH__[0 .. $-"TestCase.d".length] ~ "data"; this.git = this.tmp ~ "/" ~ GitPath; auto router = new URLRouter; router.registerRestInterface(this.fake_github = new RestAPI); auto settings = new HTTPServerSettings; settings.port = this.gh_port; listenHTTP(settings, router); this.prepareGitRepo(); } /// Starts the test task public void startTest ( ) { import vibe.core.core; auto task = runTask(&this.internalRun); runEventLoop(); task.join(); assert(!this.killed, "Neptune process timed out!"); assert(!this.failed, "Test failed!"); } /// Runs the test and stops the eventloop on exit private void internalRun ( ) { import vibe.core.core; scope(exit) exitEventLoop(); scope(failure) this.failed = true; this.run(); } /// child-class implemented test run function abstract protected void run ( ); /// Sets up the git repository protected void prepareGitRepo ( ) { this.tmp.cmd("rm -rf " ~ GitPath); this.tmp.cmd("mkdir -p " ~ GitPath); git.cmd("git init"); git.cmd("git config neptune.upstream " ~ GitRepo); git.cmd("git config neptune.upstreamremote origin"); git.cmd("git config neptune.oauthtoken 0000"); git.cmd("git config user.name Tes Ter"); git.cmd("git config user.email [email protected]"); git.cmd("git config neptune.mail-recipient [email protected]"); git.cmd("git remote add origin " ~ this.git); } /*************************************************************************** Adds release notes to the test git repo Params: branch = branch to add release notes to ***************************************************************************/ protected void prepareRelNotes ( string branch ) { import std.format; git.cmd(["git", "checkout", "-B", branch]); git.cmd(["cp", "-r", this.common_data ~ "/relnotes", "./"]); git.cmd("git add relnotes"); git.cmd(["git", "commit", "-m", "Add rel notes"]); } /*************************************************************************** Starts the neptune-release process. Uses a set of default parameters and overwrites $HOME to be the same as the git directory Any desired additional parameters can simply be passed as strings to this function. If the instance is running for more than 10 seconds, it will be force-killed and this.killed will be set to true. Params: args... = further parameters forwarded to neptune-release Returns: PipeProcess object associated with the neptune instance ***************************************************************************/ protected auto startNeptuneRelease ( Args... ) ( Args args ) { import vibe.core.core; import std.format; import core.time; auto neptune = pipeProcess([format("%s/neptune-release", this.bin), args, "--assume-yes=true", "--no-send-mail", "--verbose", format("--base-url=http://127.0.0.1:%s", this.gh_port)], Redirect.all, ["HOME" : this.git], Config.none, this.git); this.neptune_pid = neptune.pid; setTimer(10.seconds, &this.neptuneTimeout); return neptune; } /// Timer callback to kill neptune-process protected void neptuneTimeout ( ) { kill(this.neptune_pid); this.failed = true; } /// Validates the release notes in the TAG and github protected void checkRelNotes ( string ver, string path = "" ) { import std.format; import std.string : strip; import std.algorithm : startsWith, find; import std.range : empty, front; if (path == "") path = format("%s/relnotes.md", this.common_data); // Check for correct release notes file const(char)[] correct_relnotes; { auto file = File(path, "r"); auto fsize = file.size(); assert(fsize < 1024 * 16, "relnotes file unexpectedly large!"); correct_relnotes = strip(file.rawRead(new char[fsize])); auto gh_rel = this.fake_github.releases.find!(a=>a.name == ver); assert(!gh_rel.empty, "Release "~ ver ~" not found on gh fake server!"); auto test_relnotes = strip(gh_rel.front.content); assert(correct_relnotes == test_relnotes); } // Check for correct tag text { import lib.shell.helper : linesFrom; auto tagmsg = linesFrom(this.git.cmd(["git", "cat-file", ver, "-p"]), 6); assert(tagmsg.startsWith(correct_relnotes)); } } /*************************************************************************** Validates the release mail Params: stdout = stdout from neptune-process file = file that contains correct email ***************************************************************************/ protected void checkReleaseMail ( string stdout, string file = "mail.txt" ) { import lib.shell.helper : linesFrom; import std.algorithm : findSplitAfter, findSplitBefore; import std.file : readText; import std.range : empty; import std.string : strip; import std.format; auto begin = stdout.findSplitAfter("This is the announcement email:\n///////\n"); auto skip_first = begin[1].findSplitAfter("\n"); auto content = skip_first[1].findSplitBefore("///////\n"); assert(!begin[1].empty); assert(!skip_first[1].empty); assert(!content[1].empty); auto test_mail = content[0]; auto correct_mail = readText(data ~ "/" ~ file).linesFrom(2); if (test_mail != correct_mail) { import std.stdio; writeln("Generated Email is incorrect"); writeln("--------------------- bad --------------------------"); write(test_mail); writeln("--------------------- good -------------------------"); write(correct_mail); writeln("--------------------- end --------------------------"); assert(false); } } /// Checks the termination status & code of neptune-process protected void checkTerminationStatus ( ) { auto w = this.neptune_pid.tryWait(); // Check for correct termination status assert(w.terminated); assert(w.status == 0); } } /******************************************************************************* Asynchronously reads a file stream stream Params: stream = file stream to read Returns: text of the file stream *******************************************************************************/ public string getAsyncStream ( File stream ) { import vibe.stream.stdio; import vibe.stream.operations; auto stdstream = new StdFileStream(true, false); stdstream.setup(stream); return stdstream.readAllUTF8(); } /******************************************************************************* Checks if the given branch exists Params: wd = working directory to use branch = branch to check for Returns: true if branch exists, else false *******************************************************************************/ public bool branchExists ( string wd, string branch ) { import std.format; int status; wd.cmd(format("git rev-parse --verify %s", branch), status); // 0 means local branch with <branch-name> exists. return status == 0; }
D
/* Copyright (c) 2011-2013 Timur Gafarov Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ module dlib.geometry.plane; private { import std.math; import dlib.math.vector; import dlib.math.utils; } struct Plane { /* * Return a Plane with all values at zero */ static Plane opCall() { return Plane(0.0f, 0.0f, 0.0f, 0.0f); } /* * Return a Plane with the Vec3f component of n and distance of d */ static Plane opCall(Vector3f n, float d) { return Plane(n.x, n.y, n.z, d); } /* * Return a Plane with a Vec3f component of x, y, z and distance of d */ static Plane opCall(float x, float y, float z, float d) { Plane p; p.x = x; p.y = y; p.z = z; p.d = d; return p; } void fromPoints(Vector3f p0, Vector3f p1, Vector3f p2) { Vector3f v0 = p0 - p1; Vector3f v1 = p2 - p1; Vector3f n = cross(v1, v0); n.normalize(); x = n.x; y = n.y; z = n.z; d = -(p0.x * x + p0.y * y + p0.z * z); } void fromPointAndNormal(Vector3f p, Vector3f n) { n.normalize(); x = n.x; y = n.y; z = n.z; d = -(p.x * x + p.y * y + p.z * z); } float dot(Vector3f p) { return x * p.x + y * p.y + z * p.z; } void normalize() { float len = sqrt(x * x + y * y + z * z); x /= len; y /= len; z /= len; d /= len; } Plane normalized() { Plane res; float len = sqrt(x * x + y * y + z * z); return Plane(x / len, y / len, z / len, d / len); } /* * Get the distance from the center of the plane to the given point. * This is useful for determining which side of the plane the point is on. */ float distance(Vector3f p) { return x * p.x + y * p.y + z * p.z + d; } Vector3f reflect(Vector3f vec) { float d = distance(vec); return vec + Vector3f(-x, -y, -z) * 2 * d; } Vector3f project(Vector3f p) { float h = distance(p); return Vector3f(p.x - x * h, p.y - y * h, p.z - z * h); } bool isOnPlane(Vector3f p, float threshold = 0.001f) { float d = distance(p); if (d < threshold && d > -threshold) return true; return false; } /* * Calculate the intersection between this plane and a line * If the plane and the line are parallel, false is returned */ bool intersectsLine(Vector3f p0, Vector3f p1, ref float t) { Vector3f dir = p1 - p0; float div = dot(dir); if (div == 0.0) return false; t = -distance(p0) / div; return true; } bool intersectsLine(Vector3f p0, Vector3f p1, ref Vector3f ip) { Vector3f dir = p1 - p0; float div = dot(dir); if (div == 0.0) { ip = (p0 + p1) * 0.5f; return false; } float u = -distance(p0) / div; ip = p0 + (p1 - p0) * u; return true; } bool intersectsLineSegment(Vector3f p0, Vector3f p1, ref Vector3f ip) { Vector3f ray = p1 - p0; // calculate plane float d = dot(position); float dr = dot(ray); if (abs(dr) < EPSILON) return false; // avoid divide by zero // Compute the t value for the directed line ray intersecting the plane float t = (d - dot(p0)) / dr; // scale the ray by t Vector3f newRay = ray * t; // calc contact point ip = p0 + newRay; if (t >= 0.0 && t <= 1.0) return true; // line intersects plane return false; // line does not } float opIndex(size_t i) { return arrayof[i]; } float opIndexAssign(float value, size_t i) { return (arrayof[i] = value); } union { float[4] arrayof;// = [0, 0, 0, 0]; Vector4f vectorof; struct { float a, b, c, d; } Vector3f normal; } alias vectorof this; @property Vector3f position() { return -(normal * d); } }
D
module org.serviio.upnp.protocol.http.transport.ResourceTransportProtocolHandler; import java.lang; import java.io.FileNotFoundException; import java.util.Map; import org.apache.http.ProtocolVersion; import org.serviio.delivery.Client; import org.serviio.delivery.HttpResponseCodeException; import org.serviio.delivery.RangeHeaders; import org.serviio.delivery.ResourceDeliveryProcessor; import org.serviio.delivery.ResourceDeliveryProcessor:HttpMethod; import org.serviio.delivery.ResourceInfo; import org.serviio.upnp.protocol.http.transport.TransferMode; import org.serviio.upnp.protocol.http.transport.RequestedResourceDescriptor; public abstract interface ResourceTransportProtocolHandler { public abstract void handleResponse(Map!(String, String) paramMap, Map!(String, String) paramMap1, HttpMethod paramHttpMethod, ProtocolVersion paramProtocolVersion, ResourceInfo paramResourceInfo, Integer paramInteger, TransferMode paramTransferMode, Client paramClient, Long paramLong, RangeHeaders paramRangeHeaders); public abstract RangeHeaders handleByteRange(RangeHeaders paramRangeHeaders, ProtocolVersion paramProtocolVersion, ResourceInfo paramResourceInfo, Long paramLong); public abstract RangeHeaders handleTimeRange(RangeHeaders paramRangeHeaders, ProtocolVersion paramProtocolVersion, ResourceInfo paramResourceInfo); public abstract RequestedResourceDescriptor getRequestedResourceDescription(String paramString, Client paramClient); } /* Location: C:\Users\Main\Downloads\serviio.jar * Qualified Name: org.serviio.upnp.protocol.http.transport.ResourceTransportProtocolHandler * JD-Core Version: 0.7.0.1 */
D
/** * Thread Local Storage для DigitalMars D. * Модуль дает простой обмотчик для системно-специфичных средств (thread local storage) * локального сохранения в потоке. * * Authors: Mikola Lysenko, ([email protected]) * License: Public Domain (100% free) * Date: 9-11-2006 * Version: 0.3 * * History: * v0.3 - Fixed some clean up bugs and added fallback code for other platforms. * * v0.2 - Merged with stackthreads. * * v0.1 - Initial release. * * Bugs: * On non-windows & non-posix systems, the implementation uses a synchronized * block which may negatively impact performance. * * Локальное хранилище потока на Windows имеет неверную сборку мусора. Это же * на Posix и в других средах не имеет проблем. * * Пример: * <code><pre> * //Создать счетчик, исходно установленный на 5 * auto tls_counter = new ThreadLocal!(int)(5); * * //Создать поток * Thread t = new Thread( * { * //Просто уменьшать счётчик до достижения 0. * while(tls_counter.val > 0) * { * writefln("Countdown ... %d", tls_counter.val); * tls_counter.val = tls_counter.val - 1; * } * writefln("Blast off!"); * return 0; * }); * * // * // Смешать со счетчиком * // * assert(tls_counter.val == 5); * tls_counter.val = 20; * // * // Вызвать данную нить * // * t.start(); * t.wait(); * // * // В ходе работы будет выведено: * // * // Countdown ... 5 * // Countdown ... 4 * // Countdown ... 3 * // Countdown ... 2 * // Countdown ... 1 * // Blast off! * // * // По выполнение нитью работы счётчик остается нетронутым * // * assert(tls_counter.val == 20); * </pre></code> */ module auxd.st.tls; private import std.io, std.string, std.thread; /** * Исключение ThreadLocalException генерируется в случае, * если во время выполнения (в рантайм) не удается * правильно обработать локальное поточное действие. */ class ThreadLocalException : Exception { this(char[] msg) { super(msg); } } version(linux) version = TLS_UsePthreads; version(darwin) version = TLS_UsePthreads; version(Win32) version = TLS_UseWinAPI; version(TLS_UsePthreads) { private import std.gc; private extern(C) { typedef uint pthread_key_t; int pthread_key_delete(pthread_key_t); int pthread_key_create(pthread_key_t*, void function(void*)); int pthread_setspecific(pthread_key_t, void*); void *pthread_getspecific(pthread_key_t); const int EAGAIN = 11; const int ENOMEM = 12; const int EINVAL = 22; } /** * Thread Local Storage (Локальное Хранилище Потока) - это механизм * для ассоциации переменных с определенными потоками. * This can be used to ensure the principle of confinement, and is * useful for many sorts of algorithms. */ public class ThreadLocal(T) { /** * Allocates the thread local storage. * * Параметры: * def = An optional default value for the thread local storage. * * Выводит исключение: * A ThreadLocalException if the system could not allocate the storage. */ public this(T def = T.init) { this.def = def; switch(pthread_key_create(&tls_key, &clean_up)) { case 0: break; //Success case EAGAIN: throw new ThreadLocalException ("Out of keys for thread local storage"); case ENOMEM: throw new ThreadLocalException ("Out of memory for thread local storage"); default: throw new ThreadLocalException ("Undefined error while creating thread local storage"); } debug (ThreadLocal) writefln("TLS: Created %s", toString); } /** * Deallocates the thread local storage. */ public ~this() { debug (ThreadLocal) writefln("TLS: Deleting %s", toString); pthread_key_delete(tls_key); } /** * Возвращает: The current value of the thread local storage. */ public T val() { debug (ThreadLocal) writefln("TLS: Accessing %s", toString); TWrapper * w = cast(TWrapper*)pthread_getspecific(tls_key); if(w is null) { debug(ThreadLocal) writefln("TLS: Not found"); return def; } debug(ThreadLocal) writefln("TLS: Found %s", w); return w.val; } /** * Sets the thread local storage. Can be used with property syntax. * * Параметры: * nv = The new value of the thread local storage. * * Возвращает: * nv upon success * * Выводит исключение: * ThreadLocalException if the system could not set the ThreadLocalStorage. */ public T val(T nv) { debug (ThreadLocal) writefln("TLS: Setting %s", toString); void * w_old = pthread_getspecific(tls_key); if(w_old !is null) { (cast(TWrapper*)w_old).val = nv; } else { switch(pthread_setspecific(tls_key, TWrapper(nv))) { case 0: break; case ENOMEM: throw new ThreadLocalException ("Insufficient memory to set new thread local storage"); case EINVAL: throw new ThreadLocalException ("Invalid thread local storage"); default: throw new ThreadLocalException ("Undefined error when setting thread local storage"); } } debug(ThreadLocal) writefln("TLS: Set %s", toString); return nv; } /** * Converts the thread local storage into a stringified representation. * Can be useful for debugging. * * Возвращает: * A string representing the thread local storage. */ public char[] toString() { return format("ThreadLocal[%8x]", tls_key); } // Clean up thread local resources private extern(C) static void clean_up(void * obj) { if(obj is null) return; std.gc.removeRoot(obj); delete obj; } // The wrapper manages the thread local attributes` private struct TWrapper { T val; static void * opCall(T nv) { TWrapper * res = new TWrapper; std.gc.addRoot(cast(void*)res); res.val = nv; return cast(void*)res; } } private pthread_key_t tls_key; private T def; } } else version(TLS_UseWinAPI) { private import std.gc; private extern(Windows) { uint TlsAlloc(); bool TlsFree(uint); bool TlsSetValue(uint, void*); void* TlsGetValue(uint); } public class ThreadLocal(T) { public this(T def = T.init) { this.def = def; this.tls_key = TlsAlloc(); } public ~this() { TlsFree(tls_key); } public T val() { void * v = TlsGetValue(tls_key); if(v is null) return def; return (cast(TWrapper*)v).val; } public T val(T nv) { TWrapper * w_old = cast(TWrapper*)TlsGetValue(tls_key); if(w_old is null) { TlsSetValue(tls_key, TWrapper(nv)); } else { w_old.val = nv; } return nv; } private uint tls_key; private T def; private struct TWrapper { T val; static void * opCall(T nv) { TWrapper * res = new TWrapper; std.gc.addRoot(cast(void*)res); res.val = nv; return cast(void*)res; } } } } else { //Use a terrible hack insteaauxd... //Performance will be bad, but at least we can fake the result. public class ThreadLocal(T) { public this(T def = T.init) { this.def = def; } public T val() { synchronized(this) { Thread t = Threaauxd.getThis; if(t in tls_map) return tls_map[t]; return def; } } public T val(T nv) { synchronized(this) { return tls_map[Threaauxd.getThis] = nv; } } private T def; private T[Thread] tls_map; } } unittest { //Attempt to test out the tls auto tls = new ThreadLocal!(int); //Make sure default values work assert(tls.val == 0); //Init tls to something tls.val = 333; //Create some threads to mess with the tls Thread a = new Thread( { tls.val = 10; Threaauxd.yield; assert(tls.val == 10); tls.val = 1010; Threaauxd.yield; assert(tls.val == 1010); return 0; }); Thread b = new Thread( { tls.val = 20; Threaauxd.yield; assert(tls.val == 20); tls.val = 2020; Threaauxd.yield; assert(tls.val == 2020); return 0; }); a.start; b.start; //Wait until they have have finished a.wait; b.wait; //Make sure the value was preserved assert(tls.val == 333); //Try out structs struct TestStruct { int x = 10; real r = 20.0; byte b = 3; } auto tls2 = new ThreadLocal!(TestStruct); assert(tls2.val.x == 10); assert(tls2.val.r == 20.0); assert(tls2.val.b == 3); Thread x = new Thread( { assert(tls2.val.x == 10); TestStruct nv; nv.x = 20; tls2.val = nv; assert(tls2.val.x == 20); return 0; }); x.start(); x.wait(); assert(tls2.val.x == 10); //Try out objects static class TestClass { int x = 10; } auto tls3 = new ThreadLocal!(TestClass)(new TestClass); assert(tls3.val.x == 10); Thread y = new Thread( { tls3.val.x ++; tls3.val = new TestClass; tls3.val.x = 2020; assert(tls3.val.x == 2020); return 0; }); y.start; y.wait; assert(tls3.val.x == 11); }
D
/** * License: * $(BOOKTABLE , * $(TR $(TD cairoD wrapper/bindings) * $(TD $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0))) * $(TR $(TD $(LINK2 http://cgit.freedesktop.org/cairo/tree/COPYING, _cairo)) * $(TD $(LINK2 http://cgit.freedesktop.org/cairo/tree/COPYING-LGPL-2.1, LGPL 2.1) / * $(LINK2 http://cgit.freedesktop.org/cairo/plain/COPYING-MPL-1.1, MPL 1.1))) * ) * Authors: * $(BOOKTABLE , * $(TR $(TD Johannes Pfau) $(TD cairoD)) * $(TR $(TD $(LINK2 http://cairographics.org, _cairo team)) $(TD _cairo)) * ) */ /* * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) */ module cairo.xcb; import std.string; import std.conv; import cairo.cairo; import cairo.c.cairo; version(CAIRO_HAS_XCB_SURFACE) { import cairo.c.xcb; /// public class XCBSurface : Surface { public: /** * Create a $(D XCBSurface) from a existing $(D cairo_surface_t*). * XCBSurface is a garbage collected class. It will call $(D cairo_surface_destroy) * when it gets collected by the GC or when $(D dispose()) is called. * * Warning: * $(D ptr)'s reference count is not increased by this function! * Adjust reference count before calling it if necessary * * $(RED Only use this if you know what your doing! * This function should not be needed for standard cairoD usage.) */ this(cairo_surface_t* ptr) { super(ptr); } /// this(xcb_connection_t* connection, xcb_drawable_t drawable, xcb_visualtype_t* visual, int width, int height) { super(cairo_xcb_surface_create(connection, drawable, visual, width, height)); } /// this(xcb_connection_t* connection, xcb_screen_t* screen, xcb_pixmap_t bitmap, int width, int height) { super(cairo_xcb_surface_create_for_bitmap(connection, screen, bitmap, width, height)); } /// this(xcb_connection_t* connection, xcb_screen_t* screen, xcb_drawable_t drawable, xcb_render_pictforminfo_t* format, int width, int height) { super(cairo_xcb_surface_create_with_xrender_format(connection, screen, drawable, format, width, height)); } /// void setSize(int width, int height) { cairo_xcb_surface_set_size(this.nativePointer, width, height); checkError(); } /* debug interface */ /* not exported, use c api*/ } }
D
/Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Intermediates.noindex/StreamsApp.build/Debug-iphonesimulator/StreamsApp.build/Objects-normal/x86_64/UserHeaderView.o : /Users/mac/Documents/StreamsApp/StreamsApp/AppDelegate.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/PostTableViewCell/PostTableViewCell.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/StreamViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/NewPostViewController/NewPostViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/UserHeaderView/UserHeaderView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/DateToolsSwift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFACL.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFGeneric.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTextField.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTaskCompletionSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRole.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchase.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUserAuthenticationDelegate.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView_Private.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSubclassing.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTask.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchaseTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCollectionViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationToken.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPolygon.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSession.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRelation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFInstallation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenRegistration.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseClientConfiguration.h /Users/mac/Documents/StreamsApp/StreamsApp-Bridging-Header.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFDecoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFEncoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFNetworkActivityIndicatorManager.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProductTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryCollectionViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFExecutor.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnalytics.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Subclass.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseUIConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProduct.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-Swift.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadResult.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFGeoPoint.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFImageView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/StoreKit.framework/Headers/StoreKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Intermediates.noindex/StreamsApp.build/Debug-iphonesimulator/StreamsApp.build/Objects-normal/x86_64/UserHeaderView~partial.swiftmodule : /Users/mac/Documents/StreamsApp/StreamsApp/AppDelegate.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/PostTableViewCell/PostTableViewCell.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/StreamViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/NewPostViewController/NewPostViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/UserHeaderView/UserHeaderView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/DateToolsSwift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFACL.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFGeneric.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTextField.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTaskCompletionSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRole.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchase.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUserAuthenticationDelegate.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView_Private.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSubclassing.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTask.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchaseTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCollectionViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationToken.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPolygon.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSession.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRelation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFInstallation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenRegistration.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseClientConfiguration.h /Users/mac/Documents/StreamsApp/StreamsApp-Bridging-Header.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFDecoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFEncoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFNetworkActivityIndicatorManager.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProductTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryCollectionViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFExecutor.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnalytics.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Subclass.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseUIConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProduct.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-Swift.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadResult.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFGeoPoint.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFImageView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/StoreKit.framework/Headers/StoreKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Intermediates.noindex/StreamsApp.build/Debug-iphonesimulator/StreamsApp.build/Objects-normal/x86_64/UserHeaderView~partial.swiftdoc : /Users/mac/Documents/StreamsApp/StreamsApp/AppDelegate.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/PostTableViewCell/PostTableViewCell.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/StreamViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/NewPostViewController/NewPostViewController.swift /Users/mac/Documents/StreamsApp/StreamsApp/StreamViewController/UserHeaderView/UserHeaderView.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/DateToolsSwift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreLocation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFACL.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Headers/MBProgressHUD-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-umbrella.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFGeneric.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Deprecated.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTextField.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTaskCompletionSource.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRole.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchase.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/Parse.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUserAuthenticationDelegate.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView_Private.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSubclassing.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFTask.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPurchaseTableViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCollectionViewCell.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationToken.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPolygon.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSession.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFRelation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFInstallation.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFCancellationTokenRegistration.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseClientConfiguration.h /Users/mac/Documents/StreamsApp/StreamsApp-Bridging-Header.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFDecoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFEncoder.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFNetworkActivityIndicatorManager.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProductTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryTableViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQueryCollectionViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpViewController.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/BFExecutor.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnalytics.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFAnonymousUtils.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Subclass.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Headers/Bolts.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/ParseUIConstants.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFCloud+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFile+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFConfig+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFPush+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFUser+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery+Synchronous.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFObject.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFProduct.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Headers/DateToolsSwift-Swift.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFFileUploadResult.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFGeoPoint.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFImageView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFLogInView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFSignUpView.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Headers/PFQuery.h /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/MBProgressHUD/MBProgressHUD.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Parse/Parse.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/Bolts/Bolts.framework/Modules/module.modulemap /Users/mac/Documents/StreamsApp/DerivedData/StreamsApp/Build/Products/Debug-iphonesimulator/DateToolsSwift/DateToolsSwift.framework/Modules/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreLocation.framework/Headers/CoreLocation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/StoreKit.framework/Headers/StoreKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
United States telephone engineer who assisted Alexander Graham Bell in his experiments (1854-1934) United States psychologist considered the founder of behavioristic psychology (1878-1958) United States geneticist who (with Crick in 1953) helped discover the helical structure of DNA (born in 1928)
D
module std.random; version(WebAssembly) { import arsd.webassembly; int uniform(int low, int high) { int max = high - low; return low + eval!int(q{ return Math.floor(Math.random() * $0); }, max); } }
D
/******************************************************************************* * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Port to the D programming language: * Frank Benoit <[email protected]> *******************************************************************************/ module org.eclipse.swt.widgets.Display; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Device; import org.eclipse.swt.graphics.DeviceData; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GCData; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.PaletteData; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Resource; import org.eclipse.swt.internal.ImageList; import org.eclipse.swt.internal.Library; import org.eclipse.swt.internal.win32.OS; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Tray; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.EventTable; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Synchronizer; import org.eclipse.swt.widgets.Monitor; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.TrayItem; import java.lang.all; import java.lang.Thread; /** * Instances of this class are responsible for managing the * connection between SWT and the underlying operating * system. Their most important function is to implement * the SWT event loop in terms of the platform event model. * They also provide various methods for accessing information * about the operating system, and have overall control over * the operating system resources which SWT allocates. * <p> * Applications which are built with SWT will <em>almost always</em> * require only a single display. In particular, some platforms * which SWT supports will not allow more than one <em>active</em> * display. In other words, some platforms do not support * creating a new display if one already exists that has not been * sent the <code>dispose()</code> message. * <p> * In SWT, the thread which creates a <code>Display</code> * instance is distinguished as the <em>user-interface thread</em> * for that display. * </p> * The user-interface thread for a particular display has the * following special attributes: * <ul> * <li> * The event loop for that display must be run from the thread. * </li> * <li> * Some SWT API methods (notably, most of the public methods in * <code>Widget</code> and its subclasses), may only be called * from the thread. (To support multi-threaded user-interface * applications, class <code>Display</code> provides inter-thread * communication methods which allow threads other than the * user-interface thread to request that it perform operations * on their behalf.) * </li> * <li> * The thread is not allowed to construct other * <code>Display</code>s until that display has been disposed. * (Note that, this is in addition to the restriction mentioned * above concerning platform support for multiple displays. Thus, * the only way to have multiple simultaneously active displays, * even on platforms which support it, is to have multiple threads.) * </li> * </ul> * Enforcing these attributes allows SWT to be implemented directly * on the underlying operating system's event model. This has * numerous benefits including smaller footprint, better use of * resources, safer memory management, clearer program logic, * better performance, and fewer overall operating system threads * required. The down side however, is that care must be taken * (only) when constructing multi-threaded applications to use the * inter-thread communication mechanisms which this class provides * when required. * </p><p> * All SWT API methods which may only be called from the user-interface * thread are distinguished in their documentation by indicating that * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>" * SWT exception. * </p> * <dl> * <dt><b>Styles:</b></dt> * <dd>(none)</dd> * <dt><b>Events:</b></dt> * <dd>Close, Dispose, Settings</dd> * </dl> * <p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> * @see #syncExec * @see #asyncExec * @see #wake * @see #readAndDispatch * @see #sleep * @see Device#dispose * @see <a href="http://www.eclipse.org/swt/snippets/#display">Display snippets</a> * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class Display : Device { /** * the handle to the OS message queue * (Warning: This field is platform dependent) * <p> * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT * public API. It is marked public only so that it can be shared * within the packages provided by SWT. It is not available on all * platforms and should never be accessed from application code. * </p> */ public MSG* msg; /* Windows and Events */ Event [] eventQueue; //Callback windowCallback; //int windowProc_; int threadId; StringT windowClass_, windowShadowClass; mixin(gshared!(`static int WindowClassCount;`)); static const String WindowName = "SWT_Window"; //$NON-NLS-1$ static const String WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$ EventTable eventTable, filterTable; /* Widget Table */ int freeSlot; int [] indexTable; Control lastControl, lastGetControl; HANDLE lastHwnd; HWND lastGetHwnd; Control [] controlTable; static const int GROW_SIZE = 1024; mixin(gshared!(`private static /+const+/ int SWT_OBJECT_INDEX;`)); mixin(gshared!(`static const bool USE_PROPERTY = !OS.IsWinCE;`)); mixin(gshared!(`private static bool static_this_completed = false;`)); private static void static_this() { if( static_this_completed ){ return; } synchronized { if( static_this_completed ){ return; } static if (USE_PROPERTY) { SWT_OBJECT_INDEX = OS.GlobalAddAtom (StrToTCHARz("SWT_OBJECT_INDEX")); //$NON-NLS-1$ } else { SWT_OBJECT_INDEX = 0; } static_this_StartupInfo (); static_this_DeviceFinder (); static_this_completed = true; } } /* Startup info */ mixin(gshared!(`static STARTUPINFO* lpStartupInfo;`)); private static void static_this_StartupInfo (){ static if (!OS.IsWinCE) { lpStartupInfo = new STARTUPINFO (); lpStartupInfo.cb = STARTUPINFO.sizeof; OS.GetStartupInfo (lpStartupInfo); } } /* XP Themes */ HTHEME hButtonTheme_, hEditTheme_, hExplorerBarTheme_, hScrollBarTheme_, hTabTheme_; static const wchar [] BUTTON = "BUTTON\0"w; static const wchar [] EDIT = "EDIT\0"w; static const wchar [] EXPLORER = "EXPLORER\0"w; static const wchar [] EXPLORERBAR = "EXPLORERBAR\0"w; static const wchar [] SCROLLBAR = "SCROLLBAR\0"w; static const wchar [] LISTVIEW = "LISTVIEW\0"w; static const wchar [] TAB = "TAB\0"w; static const wchar [] TREEVIEW = "TREEVIEW\0"w; /* Focus */ int focusEvent; Control focusControl; /* Menus */ Menu [] bars, popups; MenuItem [] items; /* * The start value for WM_COMMAND id's. * Windows reserves the values 0..100. * * The SmartPhone SWT resource file reserves * the values 101..107. */ static const int ID_START = 108; /* Filter Hook */ //Callback msgFilterCallback; //int msgFilterProc_, HHOOK filterHook; bool runDragDrop = true, dragCancelled = false; MSG* hookMsg; /* Idle Hook */ //Callback foregroundIdleCallback; //int foregroundIdleProc_; HHOOK idleHook; /* Message Hook and Embedding */ bool ignoreNextKey; //Callback getMsgCallback, embeddedCallback; int getMsgProc_; HHOOK msgHook; HWND embeddedHwnd; int embeddedProc_; static const String AWT_WINDOW_CLASS = "SunAwtWindow"; static const short [] ACCENTS = [ cast(short) '~', '`', '\'', '^', '"']; /* Sync/Async Widget Communication */ Synchronizer synchronizer; bool runMessages = true, runMessagesInIdle = false, runMessagesInMessageProc = true; static const String RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ static const String RUN_MESSAGES_IN_MESSAGE_PROC_KEY = "org.eclipse.swt.internal.win32.runMessagesInMessageProc"; //$NON-NLS-1$ Thread thread; /* Display Shutdown */ Runnable [] disposeList; /* System Tray */ Tray tray; int nextTrayId; /* Timers */ int /*long*/ [] timerIds; Runnable [] timerList; int /*long*/ nextTimerId = SETTINGS_ID + 1; static const int SETTINGS_ID = 100; static const int SETTINGS_DELAY = 2000; /* Keyboard and Mouse */ RECT* clickRect; int clickCount, lastTime, lastButton; HWND lastClickHwnd; int scrollRemainder; int lastKey, lastAscii, lastMouse; bool lastVirtual, lastNull, lastDead; ubyte [256] keyboard; bool accelKeyHit, mnemonicKeyHit; bool lockActiveWindow, captureChanged, xMouse; /* Tool Tips */ int nextToolTipId; /* MDI */ bool ignoreRestoreFocus; Control lastHittestControl; int lastHittest; /* Message Only Window */ HWND hwndMessage; /* System Resources */ LOGFONT* lfSystemFont; Font systemFont; Image errorImage, infoImage, questionImage, warningIcon; Cursor [] cursors; Resource [] resources; static const int RESOURCE_SIZE = 1 + 4 + SWT.CURSOR_HAND + 1; /* ImageList Cache */ ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList; /* Custom Colors for ChooseColor */ COLORREF* lpCustColors; /* Sort Indicators */ Image upArrow, downArrow; /* Table */ char [] tableBuffer; NMHDR* hdr; NMLVDISPINFO* plvfi; HWND hwndParent; int columnCount; bool [] columnVisible; /* Resize and move recursion */ int resizeCount; static const int RESIZE_LIMIT = 4; /* Display Data */ Object data; String [] keys; Object [] values; /* Key Mappings */ mixin(gshared!(`static const int [] [] KeyTable = [ /* Keyboard and Mouse Masks */ [OS.VK_MENU, SWT.ALT], [OS.VK_SHIFT, SWT.SHIFT], [OS.VK_CONTROL, SWT.CONTROL], // [OS.VK_????, SWT.COMMAND], /* NOT CURRENTLY USED */ // [OS.VK_LBUTTON, SWT.BUTTON1], // [OS.VK_MBUTTON, SWT.BUTTON3], // [OS.VK_RBUTTON, SWT.BUTTON2], /* Non-Numeric Keypad Keys */ [OS.VK_UP, SWT.ARROW_UP], [OS.VK_DOWN, SWT.ARROW_DOWN], [OS.VK_LEFT, SWT.ARROW_LEFT], [OS.VK_RIGHT, SWT.ARROW_RIGHT], [OS.VK_PRIOR, SWT.PAGE_UP], [OS.VK_NEXT, SWT.PAGE_DOWN], [OS.VK_HOME, SWT.HOME], [OS.VK_END, SWT.END], [OS.VK_INSERT, SWT.INSERT], /* Virtual and Ascii Keys */ [OS.VK_BACK, SWT.BS], [OS.VK_RETURN, SWT.CR], [OS.VK_DELETE, SWT.DEL], [OS.VK_ESCAPE, SWT.ESC], [OS.VK_RETURN, SWT.LF], [OS.VK_TAB, SWT.TAB], /* Functions Keys */ [OS.VK_F1, SWT.F1], [OS.VK_F2, SWT.F2], [OS.VK_F3, SWT.F3], [OS.VK_F4, SWT.F4], [OS.VK_F5, SWT.F5], [OS.VK_F6, SWT.F6], [OS.VK_F7, SWT.F7], [OS.VK_F8, SWT.F8], [OS.VK_F9, SWT.F9], [OS.VK_F10, SWT.F10], [OS.VK_F11, SWT.F11], [OS.VK_F12, SWT.F12], [OS.VK_F13, SWT.F13], [OS.VK_F14, SWT.F14], [OS.VK_F15, SWT.F15], /* Numeric Keypad Keys */ [OS.VK_MULTIPLY, SWT.KEYPAD_MULTIPLY], [OS.VK_ADD, SWT.KEYPAD_ADD], [OS.VK_RETURN, SWT.KEYPAD_CR], [OS.VK_SUBTRACT, SWT.KEYPAD_SUBTRACT], [OS.VK_DECIMAL, SWT.KEYPAD_DECIMAL], [OS.VK_DIVIDE, SWT.KEYPAD_DIVIDE], [OS.VK_NUMPAD0, SWT.KEYPAD_0], [OS.VK_NUMPAD1, SWT.KEYPAD_1], [OS.VK_NUMPAD2, SWT.KEYPAD_2], [OS.VK_NUMPAD3, SWT.KEYPAD_3], [OS.VK_NUMPAD4, SWT.KEYPAD_4], [OS.VK_NUMPAD5, SWT.KEYPAD_5], [OS.VK_NUMPAD6, SWT.KEYPAD_6], [OS.VK_NUMPAD7, SWT.KEYPAD_7], [OS.VK_NUMPAD8, SWT.KEYPAD_8], [OS.VK_NUMPAD9, SWT.KEYPAD_9], // [OS.VK_????, SWT.KEYPAD_EQUAL], /* Other keys */ [OS.VK_CAPITAL, SWT.CAPS_LOCK], [OS.VK_NUMLOCK, SWT.NUM_LOCK], [OS.VK_SCROLL, SWT.SCROLL_LOCK], [OS.VK_PAUSE, SWT.PAUSE], [OS.VK_CANCEL, SWT.BREAK], [OS.VK_SNAPSHOT, SWT.PRINT_SCREEN], // [OS.VK_????, SWT.HELP], ];`)); /* Multiple Displays */ mixin(gshared!(`static Display Default;`)); mixin(gshared!(`static Display [] Displays;`)); /* Multiple Monitors */ org.eclipse.swt.widgets.Monitor.Monitor[] monitors = null; int monitorCount = 0; /* Modality */ Shell [] modalShells; Dialog modalDialog; static bool TrimEnabled = false; /* Private SWT Window Messages */ mixin(gshared!(`static const int SWT_GETACCELCOUNT = OS.WM_APP;`)); mixin(gshared!(`static const int SWT_GETACCEL = OS.WM_APP + 1;`)); mixin(gshared!(`static const int SWT_KEYMSG = OS.WM_APP + 2;`)); mixin(gshared!(`static const int SWT_DESTROY = OS.WM_APP + 3;`)); mixin(gshared!(`static const int SWT_TRAYICONMSG = OS.WM_APP + 4;`)); mixin(gshared!(`static const int SWT_NULL = OS.WM_APP + 5;`)); mixin(gshared!(`static const int SWT_RUNASYNC = OS.WM_APP + 6;`)); mixin(gshared!(`static int SWT_TASKBARCREATED;`)); mixin(gshared!(`static int SWT_RESTORECARET;`)); mixin(gshared!(`static int DI_GETDRAGIMAGE;`)); /* Workaround for Adobe Reader 7.0 */ int hitCount; /* Package Name */ static const String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$ /* * This code is intentionally commented. In order * to support CLDC, .class cannot be used because * it does not compile on some Java compilers when * they are targeted for CLDC. */ // static { // String name = Display.class.getName (); // int index = name.lastIndexOf ('.'); // PACKAGE_PREFIX = name.substring (0, index + 1); // } /* * TEMPORARY CODE. Install the runnable that * gets the current display. This code will * be removed in the future. */ private static void static_this_DeviceFinder () { DeviceFinder = new class() Runnable { public void run () { Device device = getCurrent (); if (device is null) { device = getDefault (); } setDevice (device); } }; } /* * TEMPORARY CODE. */ static void setDevice (Device device) { static_this(); CurrentDevice = device; } /** * Constructs a new instance of this class. * <p> * Note: The resulting display is marked as the <em>current</em> * display. If this is the first display which has been * constructed since the application started, it is also * marked as the <em>default</em> display. * </p> * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see #getCurrent * @see #getDefault * @see Widget#checkSubclass * @see Shell */ public this () { this (null); } /** * Constructs a new instance of this class using the parameter. * * @param data the device data */ public this (DeviceData data) { static_this(); msg = new MSG(); hookMsg = new MSG(); super (data); synchronizer = new Synchronizer (this); cursors = new Cursor [SWT.CURSOR_HAND + 1]; } Control _getFocusControl () { return findControl (OS.GetFocus ()); } void addBar (Menu menu) { if (bars is null) bars = new Menu [4]; int length_ = cast(int) bars.length; for (int i=0; i<length_; i++) { if (bars [i] is menu) return; } int index = 0; while (index < length_) { if (bars [index] is null) break; index++; } if (index is length_) { Menu [] newBars = new Menu [length_ + 4]; System.arraycopy (bars, 0, newBars, 0, length_); bars = newBars; } bars [index] = menu; } void addControl (HANDLE handle, Control control) { if (handle is null) return; if (freeSlot is -1) { int length_ = (freeSlot = cast(int) indexTable.length) + GROW_SIZE; int [] newIndexTable = new int [length_]; Control [] newControlTable = new Control [length_]; System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot); System.arraycopy (controlTable, 0, newControlTable, 0, freeSlot); for (int i=freeSlot; i<length_-1; i++) newIndexTable [i] = i + 1; newIndexTable [length_ - 1] = -1; indexTable = newIndexTable; controlTable = newControlTable; } static if (USE_PROPERTY) { OS.SetProp (handle, cast(wchar*)SWT_OBJECT_INDEX, cast(void*) freeSlot + 1); } else { OS.SetWindowLongPtr (handle, OS.GWLP_USERDATA, freeSlot + 1); } int oldSlot = freeSlot; freeSlot = indexTable [oldSlot]; indexTable [oldSlot] = -2; controlTable [oldSlot] = control; } /** * Adds the listener to the collection of listeners who will * be notified when an event of the given type occurs anywhere * in a widget. The event type is one of the event constants * defined in class <code>SWT</code>. When the event does occur, * the listener is notified by sending it the <code>handleEvent()</code> * message. * <p> * Setting the type of an event to <code>SWT.None</code> from * within the <code>handleEvent()</code> method can be used to * change the event type and stop subsequent Java listeners * from running. Because event filters run before other listeners, * event filters can both block other listeners and set arbitrary * fields within an event. For this reason, event filters are both * powerful and dangerous. They should generally be avoided for * performance, debugging and code maintenance reasons. * </p> * * @param eventType the type of event to listen for * @param listener the listener which should be notified when the event occurs * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Listener * @see SWT * @see #removeFilter * @see #removeListener * * @since 3.0 */ public void addFilter (int eventType, Listener listener) { checkDevice (); if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); if (filterTable is null) filterTable = new EventTable (); filterTable.hook (eventType, listener); } /** * Adds the listener to the collection of listeners who will * be notified when an event of the given type occurs. The event * type is one of the event constants defined in class <code>SWT</code>. * When the event does occur in the display, the listener is notified by * sending it the <code>handleEvent()</code> message. * * @param eventType the type of event to listen for * @param listener the listener which should be notified when the event occurs * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Listener * @see SWT * @see #removeListener * * @since 2.0 */ public void addListener (int eventType, Listener listener) { checkDevice (); if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable is null) eventTable = new EventTable (); eventTable.hook (eventType, listener); } void addMenuItem (MenuItem item) { if (items is null) items = new MenuItem [64]; for (int i=0; i<items.length; i++) { if (items [i] is null) { item.id = i + ID_START; items [i] = item; return; } } item.id = cast(int) items.length + ID_START; MenuItem [] newItems = new MenuItem [items.length + 64]; newItems [items.length] = item; System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } void addPopup (Menu menu) { if (popups is null) popups = new Menu [4]; int length_ = cast(int) popups.length; for (int i=0; i<length_; i++) { if (popups [i] is menu) return; } int index = 0; while (index < length_) { if (popups [index] is null) break; index++; } if (index is length_) { Menu [] newPopups = new Menu [length_ + 4]; System.arraycopy (popups, 0, newPopups, 0, length_); popups = newPopups; } popups [index] = menu; } int asciiKey (int key) { static if (OS.IsWinCE) return 0; /* Get the current keyboard. */ for (int i=0; i<keyboard.length; i++) keyboard [i] = 0; if (!OS.GetKeyboardState (keyboard.ptr)) return 0; /* Translate the key to ASCII or UNICODE using the virtual keyboard */ static if (OS.IsUnicode) { wchar result; if (OS.ToUnicode (key, key, keyboard.ptr, &result, 1, 0) is 1) return result; } else { short [] result = new short [1]; if (OS.ToAscii (key, key, keyboard, result, 0) is 1) return result [0]; } return 0; } /** * Causes the <code>run()</code> method of the runnable to * be invoked by the user-interface thread at the next * reasonable opportunity. The caller of this method continues * to run in parallel, and is not notified when the * runnable has completed. Specifying <code>null</code> as the * runnable simply wakes the user-interface thread when run. * <p> * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. * </p> * * @param runnable code to run on the user-interface thread or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #syncExec */ public void asyncExec (Runnable runnable) { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); synchronizer.asyncExec (runnable); } } /** * Causes the system hardware to emit a short sound * (if it supports this capability). * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void beep () { checkDevice (); OS.MessageBeep (OS.MB_OK); } /** * Checks that this class can be subclassed. * <p> * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>. * </p> * * @exception SWTException <ul> * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> * </ul> * * @see Widget#checkSubclass */ protected void checkSubclass () { //if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS); } override protected void checkDevice () { if (thread is null) error (SWT.ERROR_WIDGET_DISPOSED); if (thread !is Thread.currentThread ()) { /* * Bug in IBM JVM 1.6. For some reason, under * conditions that are yet to be full understood, * Thread.currentThread() is either returning null * or a different instance from the one that was * saved when the Display was created. This is * possibly a JIT problem because modifying this * method to print logging information when the * error happens seems to fix the problem. The * fix is to use operating system calls to verify * that the current thread is not the Display thread. * * NOTE: Despite the fact that Thread.currentThread() * is used in other places, the failure has not been * observed in all places where it is called. */ if (threadId !is OS.GetCurrentThreadId ()) { error (SWT.ERROR_THREAD_INVALID_ACCESS); } } if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); } static void checkDisplay (Thread thread, bool multiple) { synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (Displays [i] !is null) { if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); //$NON-NLS-1$ if (Displays [i].thread is thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); } } } } void clearModal (Shell shell) { if (modalShells is null) return; int index = 0, length_ = cast(int) modalShells.length; while (index < length_) { if (modalShells [index] is shell) break; if (modalShells [index] is null) return; index++; } if (index is length_) return; System.arraycopy (modalShells, index + 1, modalShells, index, --length_ - index); modalShells [length_] = null; if (index is 0 && modalShells [0] is null) modalShells = null; Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) shells [i].updateModal (); } int controlKey (int key) { int upper = cast(int)OS.CharUpper (cast(wchar*) key); if (64 <= upper && upper <= 95) return upper & 0xBF; return key; } /** * Requests that the connection between SWT and the underlying * operating system be closed. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Device#dispose * * @since 2.0 */ public void close () { checkDevice (); Event event = new Event (); sendEvent (SWT.Close, event); if (event.doit) dispose (); } /** * Creates the device in the operating system. If the device * does not have a handle, this method may do nothing depending * on the device. * <p> * This method is called before <code>init</code>. * </p> * * @param data the DeviceData which describes the receiver * * @see #init */ override protected void create (DeviceData data) { checkSubclass (); checkDisplay (thread = Thread.currentThread (), true); createDisplay (data); register (this); if (Default is null) Default = this; } void createDisplay (DeviceData data) { } static HBITMAP create32bitDIB (Image image) { static_this(); int transparentPixel = -1, alpha = -1; HBITMAP hMask; HBITMAP hBitmap; byte[] alphaData = null; switch (image.type) { case SWT.ICON: ICONINFO info; OS.GetIconInfo (image.handle, &info); hBitmap = info.hbmColor; hMask = info.hbmMask; break; case SWT.BITMAP: ImageData data = image.getImageData (); hBitmap = image.handle; alpha = data.alpha; alphaData = data.alphaData; transparentPixel = data.transparentPixel; break; default: } BITMAP bm; OS.GetObject (hBitmap, BITMAP.sizeof, &bm); int imgWidth = bm.bmWidth; int imgHeight = bm.bmHeight; auto hDC = OS.GetDC (null); auto srcHdc = OS.CreateCompatibleDC (hDC); auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap); auto memHdc = OS.CreateCompatibleDC (hDC); BITMAPINFOHEADER bmiHeader; bmiHeader.biSize = BITMAPINFOHEADER.sizeof; bmiHeader.biWidth = imgWidth; bmiHeader.biHeight = -imgHeight; bmiHeader.biPlanes = 1; bmiHeader.biBitCount = cast(short)32; bmiHeader.biCompression = OS.BI_RGB; byte [] bmi = new byte [BITMAPINFOHEADER.sizeof]; bmi[ 0 .. BITMAPINFOHEADER.sizeof ] = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof ]; void* pBits; auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0); if (memDib is null) SWT.error (SWT.ERROR_NO_HANDLES); auto oldMemBitmap = OS.SelectObject (memHdc, memDib); BITMAP dibBM; OS.GetObject (memDib, BITMAP.sizeof, &dibBM); int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY); byte red = 0, green = 0, blue = 0; if (transparentPixel !is -1) { if (bm.bmBitsPixel <= 8) { byte [4] color; OS.GetDIBColorTable (srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr); blue = color [0]; green = color [1]; red = color [2]; } else { switch (bm.bmBitsPixel) { case 16: blue = cast(byte)((transparentPixel & 0x1F) << 3); green = cast(byte)((transparentPixel & 0x3E0) >> 2); red = cast(byte)((transparentPixel & 0x7C00) >> 7); break; case 24: blue = cast(byte)((transparentPixel & 0xFF0000) >> 16); green = cast(byte)((transparentPixel & 0xFF00) >> 8); red = cast(byte)(transparentPixel & 0xFF); break; case 32: blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24); green = cast(byte)((transparentPixel & 0xFF0000) >> 16); red = cast(byte)((transparentPixel & 0xFF00) >> 8); break; default: } } } byte [] srcData = (cast(byte*)pBits)[ 0 .. sizeInBytes].dup; if (hMask !is null) { OS.SelectObject(srcHdc, hMask); for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (OS.GetPixel(srcHdc, x, y) !is 0) { srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData[dp + 3] = cast(byte)0; } else { srcData[dp + 3] = cast(byte)0xFF; } dp += 4; } } } else if (alpha !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { srcData [dp + 3] = cast(byte)alpha; if (srcData [dp + 3] is 0) srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = 0; dp += 4; } } } else if (alphaData !is null) { for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { srcData [dp + 3] = alphaData [ap++]; if (srcData [dp + 3] is 0) srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = 0; dp += 4; } } } else if (transparentPixel !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) { srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData [dp + 3] = cast(byte)0; } else { srcData [dp + 3] = cast(byte)0xFF; } dp += 4; } } } else { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { srcData [dp + 3] = cast(byte)0xFF; dp += 4; } } } (cast(byte*)pBits)[ 0 .. sizeInBytes] = srcData[]; OS.SelectObject (srcHdc, oldSrcBitmap); OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteObject (srcHdc); OS.DeleteObject (memHdc); OS.ReleaseDC (null, hDC); if (hBitmap !is image.handle && hBitmap !is null) OS.DeleteObject (hBitmap); if (hMask !is null) OS.DeleteObject (hMask); return memDib; } static HBITMAP create32bitDIB (HBITMAP hBitmap, int alpha, byte [] alphaData, int transparentPixel) { static_this(); BITMAP bm; OS.GetObject (hBitmap, BITMAP.sizeof, &bm); int imgWidth = bm.bmWidth; int imgHeight = bm.bmHeight; auto hDC = OS.GetDC (null); auto srcHdc = OS.CreateCompatibleDC (hDC); auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap); auto memHdc = OS.CreateCompatibleDC (hDC); BITMAPINFOHEADER bmiHeader; bmiHeader.biSize = BITMAPINFOHEADER.sizeof; bmiHeader.biWidth = imgWidth; bmiHeader.biHeight = -imgHeight; bmiHeader.biPlanes = 1; bmiHeader.biBitCount = cast(short)32; bmiHeader.biCompression = OS.BI_RGB; byte [] bmi = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof]; void* pBits; auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0); if (memDib is null) SWT.error (SWT.ERROR_NO_HANDLES); auto oldMemBitmap = OS.SelectObject (memHdc, memDib); BITMAP dibBM; OS.GetObject (memDib, BITMAP.sizeof, &dibBM); int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY); byte red = 0, green = 0, blue = 0; if (transparentPixel !is -1) { if (bm.bmBitsPixel <= 8) { byte [4] color; OS.GetDIBColorTable (srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr); blue = color [0]; green = color [1]; red = color [2]; } else { switch (bm.bmBitsPixel) { case 16: blue = cast(byte)((transparentPixel & 0x1F) << 3); green = cast(byte)((transparentPixel & 0x3E0) >> 2); red = cast(byte)((transparentPixel & 0x7C00) >> 7); break; case 24: blue = cast(byte)((transparentPixel & 0xFF0000) >> 16); green = cast(byte)((transparentPixel & 0xFF00) >> 8); red = cast(byte)(transparentPixel & 0xFF); break; case 32: blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24); green = cast(byte)((transparentPixel & 0xFF0000) >> 16); red = cast(byte)((transparentPixel & 0xFF00) >> 8); break; default: } } } OS.SelectObject (srcHdc, oldSrcBitmap); OS.SelectObject (memHdc, oldMemBitmap); OS.DeleteObject (srcHdc); OS.DeleteObject (memHdc); OS.ReleaseDC (null, hDC); byte [] srcData = (cast(byte*)pBits)[ 0 .. sizeInBytes ].dup; if (alpha !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { srcData [dp + 3] = cast(byte)alpha; dp += 4; } } } else if (alphaData !is null) { for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { srcData [dp + 3] = alphaData [ap++]; dp += 4; } } } else if (transparentPixel !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) { srcData [dp + 3] = cast(byte)0; } else { srcData [dp + 3] = cast(byte)0xFF; } dp += 4; } } } (cast(byte*)pBits)[ 0 .. sizeInBytes ] = srcData[]; return memDib; } static Image createIcon (Image image) { static_this(); Device device = image.getDevice (); ImageData data = image.getImageData (); if (data.alpha is -1 && data.alphaData is null) { ImageData mask = data.getTransparencyMask (); return new Image (device, data, mask); } int width = data.width, height = data.height; HBITMAP hMask, hBitmap; auto hDC = device.internal_new_GC (null); auto dstHdc = OS.CreateCompatibleDC (hDC); HBITMAP oldDstBitmap; if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { hBitmap = Display.create32bitDIB (image.handle, data.alpha, data.alphaData, data.transparentPixel); hMask = OS.CreateBitmap (width, height, 1, 1, null); oldDstBitmap = OS.SelectObject (dstHdc, hMask); OS.PatBlt (dstHdc, 0, 0, width, height, OS.BLACKNESS); } else { hMask = Display.createMaskFromAlpha (data, width, height); /* Icons need black pixels where the mask is transparent */ hBitmap = OS.CreateCompatibleBitmap (hDC, width, height); oldDstBitmap = OS.SelectObject (dstHdc, hBitmap); auto srcHdc = OS.CreateCompatibleDC (hDC); auto oldSrcBitmap = OS.SelectObject (srcHdc, image.handle); OS.PatBlt (dstHdc, 0, 0, width, height, OS.BLACKNESS); OS.BitBlt (dstHdc, 0, 0, width, height, srcHdc, 0, 0, OS.SRCINVERT); OS.SelectObject (srcHdc, hMask); OS.BitBlt (dstHdc, 0, 0, width, height, srcHdc, 0, 0, OS.SRCAND); OS.SelectObject (srcHdc, image.handle); OS.BitBlt (dstHdc, 0, 0, width, height, srcHdc, 0, 0, OS.SRCINVERT); OS.SelectObject (srcHdc, oldSrcBitmap); OS.DeleteDC (srcHdc); } OS.SelectObject (dstHdc, oldDstBitmap); OS.DeleteDC (dstHdc); device.internal_dispose_GC (hDC, null); ICONINFO info; info.fIcon = true; info.hbmColor = hBitmap; info.hbmMask = hMask; auto hIcon = OS.CreateIconIndirect (&info); if (hIcon is null) SWT.error(SWT.ERROR_NO_HANDLES); OS.DeleteObject (hBitmap); OS.DeleteObject (hMask); return Image.win32_new (device, SWT.ICON, hIcon); } static HBITMAP createMaskFromAlpha (ImageData data, int destWidth, int destHeight) { static_this(); int srcWidth = data.width; int srcHeight = data.height; ImageData mask = ImageData.internal_new (srcWidth, srcHeight, 1, new PaletteData([new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)]), 2, null, 1, null, null, -1, -1, -1, 0, 0, 0, 0); int ap = 0; for (int y = 0; y < mask.height; y++) { for (int x = 0; x < mask.width; x++) { mask.setPixel (x, y, (data.alphaData [ap++] & 0xff) <= 127 ? 1 : 0); } } auto hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data.ptr); if (srcWidth !is destWidth || srcHeight !is destHeight) { auto hdc = OS.GetDC (null); auto hdc1 = OS.CreateCompatibleDC (hdc); OS.SelectObject (hdc1, hMask); auto hdc2 = OS.CreateCompatibleDC (hdc); auto hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null); OS.SelectObject (hdc2, hMask2); static if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR); OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); OS.DeleteDC (hdc1); OS.DeleteDC (hdc2); OS.ReleaseDC (null, hdc); OS.DeleteObject(hMask); hMask = hMask2; } return hMask; } static void deregister (Display display) { synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (display is Displays [i]) Displays [i] = null; } } } /** * Destroys the device in the operating system and releases * the device's handle. If the device does not have a handle, * this method may do nothing depending on the device. * <p> * This method is called after <code>release</code>. * </p> * @see Device#dispose * @see #release */ override protected void destroy () { if (this is Default) Default = null; deregister (this); destroyDisplay (); } void destroyDisplay () { } /** * Causes the <code>run()</code> method of the runnable to * be invoked by the user-interface thread just before the * receiver is disposed. Specifying a <code>null</code> runnable * is ignored. * * @param runnable code to run at dispose time. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void disposeExec (Runnable runnable) { checkDevice (); if (disposeList is null) disposeList = new Runnable [4]; for (int i=0; i<disposeList.length; i++) { if (disposeList [i] is null) { disposeList [i] = runnable; return; } } Runnable [] newDisposeList = new Runnable [disposeList.length + 4]; SimpleType!(Runnable).arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length); newDisposeList [disposeList.length] = runnable; disposeList = newDisposeList; } void drawMenuBars () { if (bars is null) return; for (int i=0; i<bars.length; i++) { Menu menu = bars [i]; if (menu !is null && !menu.isDisposed ()) menu.update (); } bars = null; } private static extern(Windows) int embeddedFunc (HWND hwnd, int msg, int wParam, int lParam) { switch (msg) { case SWT_KEYMSG: { MSG* keyMsg = cast(MSG*)lParam; OS.TranslateMessage (keyMsg); OS.DispatchMessage (keyMsg); auto hHeap = OS.GetProcessHeap (); OS.HeapFree (hHeap, 0, cast(void*)lParam); break; } case SWT_DESTROY: { OS.DestroyWindow (hwnd); //if (embeddedCallback !is null) embeddedCallback.dispose (); //if (getMsgCallback !is null) getMsgCallback.dispose (); //embeddedCallback = getMsgCallback = null; //embeddedProc_ = getMsgProc_ = 0; break; } default: } return OS.DefWindowProc (hwnd, msg, wParam, lParam); } /** * Does whatever display specific cleanup is required, and then * uses the code in <code>SWTError.error</code> to handle the error. * * @param code the descriptive error code * * @see SWT#error(int) */ void error (int code) { SWT.error (code); } bool filterEvent (Event event) { if (filterTable !is null) filterTable.sendEvent (event); return false; } bool filters (int eventType) { if (filterTable is null) return false; return filterTable.hooks (eventType); } bool filterMessage (MSG* msg) { int message = msg.message; if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) { Control control = findControl (msg.hwnd); if (control !is null) { if (translateAccelerator (msg, control) || translateMnemonic (msg, control) || translateTraversal (msg, control)) { lastAscii = lastKey = 0; lastVirtual = lastNull = lastDead = false; return true; } } } return false; } Control findControl (HANDLE handle) { if (handle is null) return null; HWND hwndOwner = null; do { Control control = getControl (handle); if (control !is null) return control; hwndOwner = OS.GetWindow (handle, OS.GW_OWNER); handle = OS.GetParent (handle); } while (handle !is null && handle !is hwndOwner); return null; } /** * Given the operating system handle for a widget, returns * the instance of the <code>Widget</code> subclass which * represents it in the currently running application, if * such exists, or null if no matching widget can be found. * <p> * <b>IMPORTANT:</b> This method should not be called from * application code. The arguments are platform-specific. * </p> * * @param handle the handle for the widget * @return the SWT widget that the handle represents * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Widget findWidget (HANDLE handle) { checkDevice (); return getControl (handle); } /** * Given the operating system handle for a widget, * and widget-specific id, returns the instance of * the <code>Widget</code> subclass which represents * the handle/id pair in the currently running application, * if such exists, or null if no matching widget can be found. * <p> * <b>IMPORTANT:</b> This method should not be called from * application code. The arguments are platform-specific. * </p> * * @param handle the handle for the widget * @param id the id for the subwidget (usually an item) * @return the SWT widget that the handle/id pair represents * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.1 */ public Widget findWidget (HANDLE handle, int id) { checkDevice (); //TODO - should ids be long Control control = getControl (handle); return control !is null ? control.findItem (cast(HANDLE) id) : null; } /** * Given a widget and a widget-specific id, returns the * instance of the <code>Widget</code> subclass which represents * the widget/id pair in the currently running application, * if such exists, or null if no matching widget can be found. * * @param widget the widget * @param id the id for the subwidget (usually an item) * @return the SWT subwidget (usually an item) that the widget/id pair represents * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.3 */ public Widget findWidget (Widget widget, int /*long*/ id) { checkDevice (); //TODO - should ids be long if (cast(Control)widget) { return findWidget ((cast(Control) widget).handle, id); } return null; } private static extern(Windows) int foregroundIdleProcFunc (int code, uint wParam, int lParam) { auto d = Display.getCurrent(); return d.foregroundIdleProc( code, wParam, lParam ); } int foregroundIdleProc (int code, int wParam, int lParam) { if (code >= 0) { if (runMessages && getMessageCount () !is 0) { if (runMessagesInIdle) { if (runMessagesInMessageProc) { OS.PostMessage (hwndMessage, SWT_RUNASYNC, 0, 0); } else { runAsyncMessages (false); } } wakeThread (); } } return OS.CallNextHookEx (idleHook, code, wParam, lParam); } /** * Returns the display which the given thread is the * user-interface thread for, or null if the given thread * is not a user-interface thread for any display. Specifying * <code>null</code> as the thread will return <code>null</code> * for the display. * * @param thread the user-interface thread * @return the display for the given thread */ public static Display findDisplay (Thread thread) { static_this(); synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { Display display = Displays [i]; if (display !is null && display.thread is thread) { return display; } } return null; } } /** * Returns the currently active <code>Shell</code>, or null * if no shell belonging to the currently running application * is active. * * @return the active shell or null * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Shell getActiveShell () { checkDevice (); Control control = findControl (OS.GetActiveWindow ()); return control !is null ? control.getShell () : null; } /** * Returns a rectangle describing the receiver's size and location. Note that * on multi-monitor systems the origin can be negative. * * @return the bounding rectangle * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ override public Rectangle getBounds () { checkDevice (); if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) { int width = OS.GetSystemMetrics (OS.SM_CXSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYSCREEN); return new Rectangle (0, 0, width, height); } int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN); int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN); int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN); return new Rectangle (x, y, width, height); } /** * Returns the display which the currently running thread is * the user-interface thread for, or null if the currently * running thread is not a user-interface thread for any display. * * @return the current display */ public static Display getCurrent () { static_this(); return findDisplay (Thread.currentThread ()); } int getClickCount (int type, int button, HWND hwnd, int lParam) { switch (type) { case SWT.MouseDown: int doubleClick = OS.GetDoubleClickTime (); if (clickRect is null) clickRect = new RECT (); int deltaTime = Math.abs (lastTime - getLastEventTime ()); POINT pt; OS.POINTSTOPOINT (pt, lParam); if (lastClickHwnd is hwnd && lastButton is button && (deltaTime <= doubleClick) && OS.PtInRect (clickRect, pt)) { clickCount++; } else { clickCount = 1; } //FALL THROUGH case SWT.MouseDoubleClick: lastButton = button; lastClickHwnd = hwnd; lastTime = getLastEventTime (); int xInset = OS.GetSystemMetrics (OS.SM_CXDOUBLECLK) / 2; int yInset = OS.GetSystemMetrics (OS.SM_CYDOUBLECLK) / 2; int x = OS.GET_X_LPARAM (lParam), y = OS.GET_Y_LPARAM (lParam); OS.SetRect (clickRect, x - xInset, y - yInset, x + xInset, y + yInset); //FALL THROUGH case SWT.MouseUp: return clickCount; default: } return 0; } /** * Returns a rectangle which describes the area of the * receiver which is capable of displaying data. * * @return the client area * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #getBounds */ override public Rectangle getClientArea () { checkDevice (); if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) { RECT rect; OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); int width = rect.right - rect.left; int height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); } int x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN); int y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN); int width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN); return new Rectangle (x, y, width, height); } Control getControl (HANDLE handle) { if (handle is null) return null; if (lastControl !is null && lastHwnd is handle) { return lastControl; } if (lastGetControl !is null && lastGetHwnd is handle) { return lastGetControl; } int index; static if (USE_PROPERTY) { index = cast(int) OS.GetProp (handle, cast(wchar*)SWT_OBJECT_INDEX) - 1; } else { index = OS.GetWindowLongPtr (handle, OS.GWLP_USERDATA) - 1; } if (0 <= index && index < controlTable.length) { Control control = controlTable [index]; /* * Because GWL_USERDATA can be used by native widgets that * do not belong to SWT, it is possible that GWL_USERDATA * could return an index that is in the range of the table, * but was not put there by SWT. Therefore, it is necessary * to check the handle of the control that is in the table * against the handle that provided the GWL_USERDATA. */ if (control !is null && control.checkHandle (handle)) { lastGetHwnd = handle; lastGetControl = control; return control; } } return null; } /** * Returns the control which the on-screen pointer is currently * over top of, or null if it is not currently over one of the * controls built by the currently running application. * * @return the control under the cursor * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Control getCursorControl () { checkDevice (); POINT pt; if (!OS.GetCursorPos (&pt)) return null; return findControl (OS.WindowFromPoint (pt)); } /** * Returns the location of the on-screen pointer relative * to the top left corner of the screen. * * @return the cursor location * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Point getCursorLocation () { checkDevice (); POINT pt; OS.GetCursorPos (&pt); return new Point (pt.x, pt.y); } /** * Returns an array containing the recommended cursor sizes. * * @return the array of cursor sizes * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.0 */ public Point [] getCursorSizes () { checkDevice (); return [ new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))]; } /** * Returns the default display. One is created (making the * thread that invokes this method its user-interface thread) * if it did not already exist. * * @return the default display */ public static Display getDefault () { static_this(); synchronized (Device.classinfo) { if (Default is null) Default = new Display (); return Default; } } //PORTING_TODO /+static bool isValidClass (Class clazz) { String name = clazz.getName (); int index = name.lastIndexOf ('.'); return name.substring (0, index + 1).equals (PACKAGE_PREFIX); }+/ /** * Returns the application defined property of the receiver * with the specified name, or null if it has not been set. * <p> * Applications may have associated arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the display is disposed * of, it is the application's responsibility to provide a * <code>disposeExec()</code> handler which does so. * </p> * * @param key the name of the property * @return the value of the property or null if it has not been set * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #setData(String, Object) * @see #disposeExec(Runnable) */ public Object getData (String key) { checkDevice (); // SWT extension: allow null string //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { return new Boolean(runMessagesInIdle); } if (key.equals (RUN_MESSAGES_IN_MESSAGE_PROC_KEY)) { return new Boolean (runMessagesInMessageProc); } if (keys.length is 0) return null; for (int i=0; i<keys.length; i++) { if (keys [i] ==/*eq*/key) return values [i]; } return null; } /** * Returns the application defined, display specific data * associated with the receiver, or null if it has not been * set. The <em>display specific data</em> is a single, * unnamed field that is stored with every display. * <p> * Applications may put arbitrary objects in this field. If * the object stored in the display specific data needs to * be notified when the display is disposed of, it is the * application's responsibility to provide a * <code>disposeExec()</code> handler which does so. * </p> * * @return the display specific data * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #setData(Object) * @see #disposeExec(Runnable) */ public Object getData () { checkDevice (); return data; } /** * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>. * The button dismissal alignment is the ordering that should be used when positioning the * default dismissal button for a dialog. For example, in a dialog that contains an OK and * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>, * the button ordering should be CANCEL/OK. * * @return the button dismissal order * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1 */ public int getDismissalAlignment () { checkDevice (); return SWT.LEFT; } /** * Returns the longest duration, in milliseconds, between * two mouse button clicks that will be considered a * <em>double click</em> by the underlying operating system. * * @return the double click time * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public int getDoubleClickTime () { checkDevice (); return OS.GetDoubleClickTime (); } /** * Returns the control which currently has keyboard focus, * or null if keyboard events are not currently going to * any of the controls built by the currently running * application. * * @return the control under the cursor * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Control getFocusControl () { checkDevice (); if (focusControl !is null && !focusControl.isDisposed ()) { return focusControl; } return _getFocusControl (); } String getFontName (LOGFONT* logFont) { wchar* chars; static if (OS.IsUnicode) { chars = logFont.lfFaceName.ptr; } else { chars = new char[OS.LF_FACESIZE]; byte[] bytes = logFont.lfFaceName; OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes, bytes.length, chars, chars.length); } return TCHARzToStr( chars ); } /** * Returns true when the high contrast mode is enabled. * Otherwise, false is returned. * <p> * Note: This operation is a hint and is not supported on * platforms that do not have this concept. * </p> * * @return the high contrast mode * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.0 */ public bool getHighContrast () { checkDevice (); static if (OS.IsWinCE) { return false; } else { HIGHCONTRAST pvParam; pvParam.cbSize = HIGHCONTRAST.sizeof; OS.SystemParametersInfo (OS.SPI_GETHIGHCONTRAST, 0, &pvParam, 0); return (pvParam.dwFlags & OS.HCF_HIGHCONTRASTON) !is 0; } } /** * Returns the maximum allowed depth of icons on this display, in bits per pixel. * On some platforms, this may be different than the actual depth of the display. * * @return the maximum icon depth * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Device#getDepth */ public int getIconDepth () { checkDevice (); if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { if (getDepth () >= 24) return 32; } /* Use the character encoding for the default locale */ LPCTSTR buffer1 = StrToTCHARz( "Control Panel\\Desktop\\WindowMetrics" ); //$NON-NLS-1$ void* phkResult; int result = OS.RegOpenKeyEx ( cast(void*)OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, &phkResult); if (result !is 0) return 4; int depth = 4; uint lpcbData; /* Use the character encoding for the default locale */ LPCTSTR buffer2 = StrToTCHARz( "Shell Icon BPP" ); //$NON-NLS-1$ result = OS.RegQueryValueEx (phkResult , buffer2, null, null, null, &lpcbData); if (result is 0) { ubyte[] lpData = new ubyte[ lpcbData / TCHAR.sizeof ]; lpData[] = 0; result = OS.RegQueryValueEx (phkResult , buffer2, null, null, lpData.ptr, &lpcbData); if (result is 0) { try { depth = Integer.parseInt ( cast(String) lpData ); } catch (NumberFormatException e) {} } } OS.RegCloseKey (phkResult ); return depth; } /** * Returns an array containing the recommended icon sizes. * * @return the array of icon sizes * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Decorations#setImages(Image[]) * * @since 3.0 */ public Point [] getIconSizes () { checkDevice (); return [ new Point (OS.GetSystemMetrics (OS.SM_CXSMICON), OS.GetSystemMetrics (OS.SM_CYSMICON)), new Point (OS.GetSystemMetrics (OS.SM_CXICON), OS.GetSystemMetrics (OS.SM_CYICON)) ]; } ImageList getImageList (int style, int width, int height) { if (imageList is null) imageList = new ImageList [4]; int i = 0; int length_ = cast(int) imageList.length; while (i < length_) { ImageList list = imageList [i]; if (list is null) break; Point size = list.getImageSize(); if (size.x is width && size.y is height) { if (list.getStyle () is style) { list.addRef(); return list; } } i++; } if (i is length_) { ImageList [] newList = new ImageList [length_ + 4]; System.arraycopy (imageList, 0, newList, 0, length_); imageList = newList; } ImageList list = new ImageList (style); imageList [i] = list; list.addRef(); return list; } ImageList getImageListToolBar (int style, int width, int height) { if (toolImageList is null) toolImageList = new ImageList [4]; int i = 0; int length_ = cast(int) toolImageList.length; while (i < length_) { ImageList list = toolImageList [i]; if (list is null) break; Point size = list.getImageSize(); if (size.x is width && size.y is height) { if (list.getStyle () is style) { list.addRef(); return list; } } i++; } if (i is length_) { ImageList [] newList = new ImageList [length_ + 4]; System.arraycopy (toolImageList, 0, newList, 0, length_); toolImageList = newList; } ImageList list = new ImageList (style); toolImageList [i] = list; list.addRef(); return list; } ImageList getImageListToolBarDisabled (int style, int width, int height) { if (toolDisabledImageList is null) toolDisabledImageList = new ImageList [4]; int i = 0; int length_ = cast(int) toolDisabledImageList.length; while (i < length_) { ImageList list = toolDisabledImageList [i]; if (list is null) break; Point size = list.getImageSize(); if (size.x is width && size.y is height) { if (list.getStyle () is style) { list.addRef(); return list; } } i++; } if (i is length_) { ImageList [] newList = new ImageList [length_ + 4]; System.arraycopy (toolDisabledImageList, 0, newList, 0, length_); toolDisabledImageList = newList; } ImageList list = new ImageList (style); toolDisabledImageList [i] = list; list.addRef(); return list; } ImageList getImageListToolBarHot (int style, int width, int height) { if (toolHotImageList is null) toolHotImageList = new ImageList [4]; int i = 0; int length_ = cast(int) toolHotImageList.length; while (i < length_) { ImageList list = toolHotImageList [i]; if (list is null) break; Point size = list.getImageSize(); if (size.x is width && size.y is height) { if (list.getStyle () is style) { list.addRef(); return list; } } i++; } if (i is length_) { ImageList [] newList = new ImageList [length_ + 4]; System.arraycopy (toolHotImageList, 0, newList, 0, length_); toolHotImageList = newList; } ImageList list = new ImageList (style); toolHotImageList [i] = list; list.addRef(); return list; } int getLastEventTime () { return OS.IsWinCE ? OS.GetTickCount () : OS.GetMessageTime (); } MenuItem getMenuItem (int id) { if (items is null) return null; id = id - ID_START; if (0 <= id && id < items.length) return items [id]; return null; } int getMessageCount () { return synchronizer.getMessageCount (); } Shell getModalShell () { if (modalShells is null) return null; int index = cast(int) modalShells.length; while (--index >= 0) { Shell shell = modalShells [index]; if (shell !is null) return shell; } return null; } Dialog getModalDialog () { return modalDialog; } /** * Returns an array of monitors attached to the device. * * @return the array of monitors * * @since 3.0 */ public org.eclipse.swt.widgets.Monitor.Monitor [] getMonitors () { checkDevice (); if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { return [getPrimaryMonitor ()]; } monitors = new org.eclipse.swt.widgets.Monitor.Monitor [4]; OS.EnumDisplayMonitors (null, null, &monitorEnumFunc, cast(int)cast(void*)this ); org.eclipse.swt.widgets.Monitor.Monitor [] result = new org.eclipse.swt.widgets.Monitor.Monitor [monitorCount]; System.arraycopy (monitors, 0, result, 0, monitorCount); monitors = null; monitorCount = 0; return result; } static extern(Windows) int getMsgFunc (int code, uint wParam, int lParam) { return Display.getCurrent().getMsgProc( code, wParam, lParam ); } int getMsgProc (int code, int wParam, int lParam) { if (embeddedHwnd is null) { auto hInstance = OS.GetModuleHandle (null); embeddedHwnd = OS.CreateWindowEx (0, windowClass_.ptr, null, OS.WS_OVERLAPPED, 0, 0, 0, 0, null, null, hInstance, null); //embeddedCallback = new Callback (this, "embeddedProc", 4); //$NON-NLS-1$ //embeddedProc_ = embeddedCallback.getAddress (); //if (embeddedProc_ is 0) error (SWT.ERROR_NO_MORE_CALLBACKS); OS.SetWindowLongPtr (embeddedHwnd, OS.GWLP_WNDPROC, cast(LONG_PTR) &embeddedFunc); } if (code >= 0 && (wParam & OS.PM_REMOVE) !is 0) { MSG* msg = cast(MSG*)lParam; switch (msg.message) { case OS.WM_KEYDOWN: case OS.WM_KEYUP: case OS.WM_SYSKEYDOWN: case OS.WM_SYSKEYUP: { Control control = findControl (msg.hwnd); if (control !is null) { auto hHeap = OS.GetProcessHeap (); MSG* keyMsg = cast(MSG*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof); *keyMsg = *msg; OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, cast(int)keyMsg); switch (msg.wParam) { case OS.VK_SHIFT: case OS.VK_MENU: case OS.VK_CONTROL: case OS.VK_CAPITAL: case OS.VK_NUMLOCK: case OS.VK_SCROLL: break; default: msg.message = OS.WM_NULL; //OS.MoveMemory (lParam, msg, MSG.sizeof); } } default: } } } return OS.CallNextHookEx (msgHook, code, wParam, lParam); } /** * Returns the primary monitor for that device. * * @return the primary monitor * * @since 3.0 */ public org.eclipse.swt.widgets.Monitor.Monitor getPrimaryMonitor () { checkDevice (); if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { org.eclipse.swt.widgets.Monitor.Monitor monitor = new org.eclipse.swt.widgets.Monitor.Monitor(); int width = OS.GetSystemMetrics (OS.SM_CXSCREEN); int height = OS.GetSystemMetrics (OS.SM_CYSCREEN); monitor.width = width; monitor.height = height; RECT rect; OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); monitor.clientX = rect.left; monitor.clientY = rect.top; monitor.clientWidth = rect.right - rect.left; monitor.clientHeight = rect.bottom - rect.top; return monitor; } monitors = new org.eclipse.swt.widgets.Monitor.Monitor [4]; OS.EnumDisplayMonitors (null, null, &monitorEnumFunc, cast(int)cast(void*)this); org.eclipse.swt.widgets.Monitor.Monitor result = null; MONITORINFO lpmi; lpmi.cbSize = MONITORINFO.sizeof; for (int i = 0; i < monitorCount; i++) { org.eclipse.swt.widgets.Monitor.Monitor monitor = monitors [i]; OS.GetMonitorInfo (monitors [i].handle, &lpmi); if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) !is 0) { result = monitor; break; } } monitors = null; monitorCount = 0; return result; } /** * Returns a (possibly empty) array containing all shells which have * not been disposed and have the receiver as their display. * * @return the receiver's shells * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Shell [] getShells () { checkDevice (); int index = 0; Shell [] result = new Shell [16]; for (int i = 0; i < controlTable.length; i++) { Control control = controlTable [i]; if (control !is null && (cast(Shell)control)) { int j = 0; while (j < index) { if (result [j] is control) break; j++; } if (j is index) { if (index is result.length) { Shell [] newResult = new Shell [index + 16]; System.arraycopy (result, 0, newResult, 0, index); result = newResult; } result [index++] = cast(Shell) control; } } } if (index is result.length) return result; Shell [] newResult = new Shell [index]; System.arraycopy (result, 0, newResult, 0, index); return newResult; } Image getSortImage (int direction) { switch (direction) { case SWT.UP: { if (upArrow !is null) return upArrow; Color c1 = getSystemColor (SWT.COLOR_WIDGET_NORMAL_SHADOW); Color c2 = getSystemColor (SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); Color c3 = getSystemColor (SWT.COLOR_WIDGET_BACKGROUND); PaletteData palette = new PaletteData([c1.getRGB (), c2.getRGB (), c3.getRGB ()]); ImageData imageData = new ImageData (8, 8, 4, palette); imageData.transparentPixel = 2; upArrow = new Image (this, imageData); GC gc = new GC (upArrow); gc.setBackground (c3); gc.fillRectangle (0, 0, 8, 8); gc.setForeground (c1); int [] line1 = [0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1]; gc.drawPolyline (line1); gc.setForeground (c2); int [] line2 = [0,7, 7,7, 7,6, 6,6, 6,4, 5,4, 5,2, 4,2, 4,1]; gc.drawPolyline (line2); gc.dispose (); return upArrow; } case SWT.DOWN: { if (downArrow !is null) return downArrow; Color c1 = getSystemColor (SWT.COLOR_WIDGET_NORMAL_SHADOW); Color c2 = getSystemColor (SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); Color c3 = getSystemColor (SWT.COLOR_WIDGET_BACKGROUND); PaletteData palette = new PaletteData ([c1.getRGB (), c2.getRGB (), c3.getRGB ()]); ImageData imageData = new ImageData (8, 8, 4, palette); imageData.transparentPixel = 2; downArrow = new Image (this, imageData); GC gc = new GC (downArrow); gc.setBackground (c3); gc.fillRectangle (0, 0, 8, 8); gc.setForeground (c1); int [] line1 = [7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6]; gc.drawPolyline (line1); gc.setForeground (c2); int [] line2 = [4,6, 4,5, 5,5, 5,3, 6,3, 6,1, 7,1]; gc.drawPolyline (line2); gc.dispose (); return downArrow; } default: } return null; } /** * Gets the synchronizer used by the display. * * @return the receiver's synchronizer * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.4 */ public Synchronizer getSynchronizer () { checkDevice (); return synchronizer; } /** * Returns the thread that has invoked <code>syncExec</code> * or null if no such runnable is currently being invoked by * the user-interface thread. * <p> * Note: If a runnable invoked by asyncExec is currently * running, this method will return null. * </p> * * @return the receiver's sync-interface thread * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Thread getSyncThread () { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); return synchronizer.syncThread; } } /** * Returns the matching standard color for the given * constant, which should be one of the color constants * specified in class <code>SWT</code>. Any value other * than one of the SWT color constants which is passed * in will result in the color black. This color should * not be free'd because it was allocated by the system, * not the application. * * @param id the color constant * @return the matching color * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT */ override public Color getSystemColor (int id) { checkDevice (); int pixel = 0x00000000; switch (id) { case SWT.COLOR_WIDGET_DARK_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DDKSHADOW); break; case SWT.COLOR_WIDGET_NORMAL_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DSHADOW); break; case SWT.COLOR_WIDGET_LIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DLIGHT); break; case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DHIGHLIGHT); break; case SWT.COLOR_WIDGET_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_3DFACE); break; case SWT.COLOR_WIDGET_BORDER: pixel = OS.GetSysColor (OS.COLOR_WINDOWFRAME); break; case SWT.COLOR_WIDGET_FOREGROUND: case SWT.COLOR_LIST_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOWTEXT); break; case SWT.COLOR_LIST_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOW); break; case SWT.COLOR_LIST_SELECTION: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHT); break; case SWT.COLOR_LIST_SELECTION_TEXT: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);break; case SWT.COLOR_INFO_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOTEXT); break; case SWT.COLOR_INFO_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOBK); break; case SWT.COLOR_TITLE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_CAPTIONTEXT); break; case SWT.COLOR_TITLE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION); break; case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTACTIVECAPTION); if (pixel is 0) pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION); break; case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTIONTEXT); break; case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION); break; case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTINACTIVECAPTION); if (pixel is 0) pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION); break; default: return super.getSystemColor (id); } return Color.win32_new (this, pixel); } /** * Returns the matching standard platform cursor for the given * constant, which should be one of the cursor constants * specified in class <code>SWT</code>. This cursor should * not be free'd because it was allocated by the system, * not the application. A value of <code>null</code> will * be returned if the supplied constant is not an SWT cursor * constant. * * @param id the SWT cursor constant * @return the corresponding cursor or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT#CURSOR_ARROW * @see SWT#CURSOR_WAIT * @see SWT#CURSOR_CROSS * @see SWT#CURSOR_APPSTARTING * @see SWT#CURSOR_HELP * @see SWT#CURSOR_SIZEALL * @see SWT#CURSOR_SIZENESW * @see SWT#CURSOR_SIZENS * @see SWT#CURSOR_SIZENWSE * @see SWT#CURSOR_SIZEWE * @see SWT#CURSOR_SIZEN * @see SWT#CURSOR_SIZES * @see SWT#CURSOR_SIZEE * @see SWT#CURSOR_SIZEW * @see SWT#CURSOR_SIZENE * @see SWT#CURSOR_SIZESE * @see SWT#CURSOR_SIZESW * @see SWT#CURSOR_SIZENW * @see SWT#CURSOR_UPARROW * @see SWT#CURSOR_IBEAM * @see SWT#CURSOR_NO * @see SWT#CURSOR_HAND * * @since 3.0 */ public Cursor getSystemCursor (int id) { checkDevice (); if (!(0 <= id && id < cursors.length)) return null; if (cursors [id] is null) { cursors [id] = new Cursor (this, id); } return cursors [id]; } /** * Returns a reasonable font for applications to use. * On some platforms, this will match the "default font" * or "system font" if such can be found. This font * should not be free'd because it was allocated by the * system, not the application. * <p> * Typically, applications which want the default look * should simply not set the font on the widgets they * create. Widgets are always created with the correct * default font for the class of user-interface component * they represent. * </p> * * @return a font * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ override public Font getSystemFont () { checkDevice (); if (systemFont !is null) return systemFont; HFONT hFont; static if (!OS.IsWinCE) { NONCLIENTMETRICS info; info.cbSize = NONCLIENTMETRICS.sizeof; if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) { LOGFONT logFont = info.lfMessageFont; hFont = OS.CreateFontIndirect (&logFont); lfSystemFont = hFont !is null ? &logFont : null; } } if (hFont is null) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT); if (hFont is null) hFont = OS.GetStockObject (OS.SYSTEM_FONT); return systemFont = Font.win32_new (this, hFont); } /** * Returns the matching standard platform image for the given * constant, which should be one of the icon constants * specified in class <code>SWT</code>. This image should * not be free'd because it was allocated by the system, * not the application. A value of <code>null</code> will * be returned either if the supplied constant is not an * SWT icon constant or if the platform does not define an * image that corresponds to the constant. * * @param id the SWT icon constant * @return the corresponding image or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see SWT#ICON_ERROR * @see SWT#ICON_INFORMATION * @see SWT#ICON_QUESTION * @see SWT#ICON_WARNING * @see SWT#ICON_WORKING * * @since 3.0 */ public Image getSystemImage (int id) { checkDevice (); switch (id) { case SWT.ICON_ERROR: { if (errorImage !is null) return errorImage; auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return errorImage = Image.win32_new (this, SWT.ICON, hIcon); } case SWT.ICON_WORKING: case SWT.ICON_INFORMATION: { if (infoImage !is null) return infoImage; auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return infoImage = Image.win32_new (this, SWT.ICON, hIcon); } case SWT.ICON_QUESTION: { if (questionImage !is null) return questionImage; auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return questionImage = Image.win32_new (this, SWT.ICON, hIcon); } case SWT.ICON_WARNING: { if (warningIcon !is null) return warningIcon; auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED); return warningIcon = Image.win32_new (this, SWT.ICON, hIcon); } default: } return null; } /** * Returns the single instance of the system tray or null * when there is no system tray available for the platform. * * @return the system tray or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.0 */ public Tray getSystemTray () { checkDevice (); if (tray !is null) return tray; static if (!OS.IsWinCE) tray = new Tray (this, SWT.NONE); return tray; } /** * Returns the user-interface thread for the receiver. * * @return the receiver's user-interface thread * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Thread getThread () { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); return thread; } } HTHEME hButtonTheme () { if (hButtonTheme_ !is null) return hButtonTheme_; return hButtonTheme_ = OS.OpenThemeData (hwndMessage, BUTTON.ptr); } HTHEME hEditTheme () { if (hEditTheme_ !is null) return hEditTheme_; return hEditTheme_ = OS.OpenThemeData (hwndMessage, EDIT.ptr); } HTHEME hExplorerBarTheme () { if (hExplorerBarTheme_ !is null) return hExplorerBarTheme_; return hExplorerBarTheme_ = OS.OpenThemeData (hwndMessage, EXPLORERBAR.ptr); } HTHEME hScrollBarTheme () { if (hScrollBarTheme_ !is null) return hScrollBarTheme_; return hScrollBarTheme_ = OS.OpenThemeData (hwndMessage, SCROLLBAR.ptr); } HTHEME hTabTheme () { if (hTabTheme_ !is null) return hTabTheme_; return hTabTheme_ = OS.OpenThemeData (hwndMessage, TAB.ptr); } /** * Invokes platform specific functionality to allocate a new GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Display</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param data the platform specific GC data * @return the platform specific GC handle * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * @exception SWTError <ul> * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> * </ul> */ override public HDC internal_new_GC (GCData data) { if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); auto hDC = OS.GetDC (null); if (hDC is null) SWT.error (SWT.ERROR_NO_HANDLES); if (data !is null) { int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if ((data.style & mask) !is 0) { data.layout = (data.style & SWT.RIGHT_TO_LEFT) !is 0 ? OS.LAYOUT_RTL : 0; } else { data.style |= SWT.LEFT_TO_RIGHT; } data.device = this; data.font = getSystemFont (); } return hDC; } /** * Initializes any internal resources needed by the * device. * <p> * This method is called after <code>create</code>. * </p> * * @see #create */ override protected void init_ () { super.init_ (); /* Create the callbacks */ //windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$ //windowProc_ = windowCallback.getAddress (); //if (windowProc_ is 0) error (SWT.ERROR_NO_MORE_CALLBACKS); /* Remember the current thread id */ threadId = OS.GetCurrentThreadId (); /* Use the character encoding for the default locale */ windowClass_ = StrToTCHARs ( 0, WindowName ~ String_valueOf(WindowClassCount), true ); windowShadowClass = StrToTCHARs ( 0, WindowShadowName ~ String_valueOf(WindowClassCount), true ); WindowClassCount++; /* Register the SWT window class */ auto hHeap = OS.GetProcessHeap (); auto hInstance = OS.GetModuleHandle (null); WNDCLASS lpWndClass; lpWndClass.hInstance = hInstance; lpWndClass.lpfnWndProc = &windowProcFunc; lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS; lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW); //DWT_TODO: Check if this can be disabled for SWT /+ /* * Set the default icon for the window class to IDI_APPLICATION. * This is not necessary for native Windows applications but * versions of Java starting at JDK 1.6 set the icon in the * executable instead of leaving the default. */ if (!OS.IsWinCE && Library.JAVA_VERSION >= Library.JAVA_VERSION (1, 6, 0)) { TCHAR[] lpszFile = NewTCHARs (0, OS.MAX_PATH); while (OS.GetModuleFileName (0, lpszFile.ptr, lpszFile.length) is lpszFile.length) { lpszFile = NewTCHARs (0, lpszFile.length + OS.MAX_PATH); } if (OS.ExtractIconEx (lpszFile.ptr, -1, null, null, 1) !is 0) { String fileName = TCHARzToStr( lpszFile.ptr ); if (fileName.endsWith ("java.exe") || fileName.endsWith ("javaw.exe")) { //$NON-NLS-1$ //$NON-NLS-2$ lpWndClass.hIcon = OS.LoadIcon (0, OS.IDI_APPLICATION); } } } +/ int byteCount = cast(int) (windowClass_.length * TCHAR.sizeof); auto buf = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); lpWndClass.lpszClassName = buf; OS.MoveMemory (buf, windowClass_.ptr, byteCount); OS.RegisterClass (&lpWndClass); OS.HeapFree (hHeap, 0, buf); /* Register the SWT drop shadow window class */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { lpWndClass.style |= OS.CS_DROPSHADOW; } byteCount = cast(int) (windowShadowClass.length * TCHAR.sizeof); buf = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); lpWndClass.lpszClassName = buf; OS.MoveMemory (buf, windowShadowClass.ptr, byteCount); OS.RegisterClass (&lpWndClass); OS.HeapFree (hHeap, 0, buf); /* Create the message only HWND */ hwndMessage = OS.CreateWindowEx (0, windowClass_.ptr, null, OS.WS_OVERLAPPED, 0, 0, 0, 0, null, null, hInstance, null); //messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$ //messageProc_ = messageCallback.getAddress (); //if (messageProc_ is 0) error (SWT.ERROR_NO_MORE_CALLBACKS); OS.SetWindowLongPtr (hwndMessage, OS.GWLP_WNDPROC, cast(LONG_PTR) &messageProcFunc); /* Create the filter hook */ static if (!OS.IsWinCE) { //msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$ //msgFilterProc_ = msgFilterCallback.getAddress (); //if (msgFilterProc_ is 0) error (SWT.ERROR_NO_MORE_CALLBACKS); filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, &msgFilterProcFunc, null, threadId); } /* Create the idle hook */ static if (!OS.IsWinCE) { //foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$ //foregroundIdleProc_ = foregroundIdleCallback.getAddress (); //if (foregroundIdleProc_ is 0) error (SWT.ERROR_NO_MORE_CALLBACKS); idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, &foregroundIdleProcFunc, null, threadId); } /* Register custom messages message */ SWT_TASKBARCREATED = OS.RegisterWindowMessage (StrToTCHARz ( "TaskbarCreated" )); SWT_RESTORECARET = OS.RegisterWindowMessage (StrToTCHARz ( "SWT_RESTORECARET")); DI_GETDRAGIMAGE = OS.RegisterWindowMessage (StrToTCHARz ( "ShellGetDragImage")); //$NON-NLS-1$ /* Initialize OLE */ static if (!OS.IsWinCE) OS.OleInitialize (null); /* Initialize buffered painting */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)){ OS.BufferedPaintInit (); } /* Initialize the Widget Table */ indexTable = new int [GROW_SIZE]; controlTable = new Control [GROW_SIZE]; for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1; indexTable [GROW_SIZE - 1] = -1; } /** * Invokes platform specific functionality to dispose a GC handle. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public * API for <code>Display</code>. It is marked public only so that it * can be shared within the packages provided by SWT. It is not * available on all platforms, and should never be called from * application code. * </p> * * @param hDC the platform specific GC handle * @param data the platform specific GC data */ override public void internal_dispose_GC (HDC hDC, GCData data) { OS.ReleaseDC (null, hDC); } bool isXMouseActive () { /* * NOTE: X-Mouse is active when bit 1 of the UserPreferencesMask is set. */ bool xMouseActive = false; LPCTSTR key = StrToTCHARz( "Control Panel\\Desktop" ); //$NON-NLS-1$ void* phKey; int result = OS.RegOpenKeyEx (cast(void*)OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, &phKey); if (result is 0) { LPCTSTR lpValueName = StrToTCHARz ( "UserPreferencesMask" ); //$NON-NLS-1$ uint[4] lpcbData; uint lpData; result = OS.RegQueryValueEx (phKey, lpValueName, null, null, cast(ubyte*)&lpData, lpcbData.ptr); if (result is 0) xMouseActive = (lpData & 0x01) !is 0; OS.RegCloseKey (phKey); } return xMouseActive; } bool isValidThread () { return thread is Thread.currentThread (); } /** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> * * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param point to be mapped * @return point with mapped coordinates * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the point is null</li> * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1.2 */ public Point map (Control from, Control to, Point point) { checkDevice (); if (point is null) error (SWT.ERROR_NULL_ARGUMENT); return map (from, to, point.x, point.y); } /** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> * * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param x coordinates to be mapped * @param y coordinates to be mapped * @return point with mapped coordinates * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1.2 */ public Point map (Control from, Control to, int x, int y) { checkDevice (); if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (from is to) return new Point (x, y); auto hwndFrom = from !is null ? from.handle : null; auto hwndTo = to !is null ? to.handle : null; POINT point; point.x = x; point.y = y; OS.MapWindowPoints (hwndFrom, hwndTo, &point, 1); return new Point (point.x, point.y); } /** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> * * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param rectangle to be mapped * @return rectangle with mapped coordinates * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1.2 */ public Rectangle map (Control from, Control to, Rectangle rectangle) { checkDevice (); if (rectangle is null) error (SWT.ERROR_NULL_ARGUMENT); return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); } /** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to * the display. * <p> * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. * </p> * * @param from the source <code>Control</code> or <code>null</code> * @param to the destination <code>Control</code> or <code>null</code> * @param x coordinates to be mapped * @param y coordinates to be mapped * @param width coordinates to be mapped * @param height coordinates to be mapped * @return rectangle with mapped coordinates * * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1.2 */ public Rectangle map (Control from, Control to, int x, int y, int width, int height) { checkDevice (); if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (from is to) return new Rectangle (x, y, width, height); auto hwndFrom = from !is null ? from.handle : null; auto hwndTo = to !is null ? to.handle : null; RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; OS.MapWindowPoints (hwndFrom, hwndTo, cast(POINT*)&rect, 2); return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } /* * Returns a single character, converted from the default * multi-byte character set (MBCS) used by the operating * system widgets to a wide character set (WCS) used by Java. * * @param ch the MBCS character * @return the WCS character */ static wchar mbcsToWcs (int ch) { return mbcsToWcs (ch, 0); } /* * Returns a single character, converted from the specified * multi-byte character set (MBCS) used by the operating * system widgets to a wide character set (WCS) used by Java. * * @param ch the MBCS character * @param codePage the code page used to convert the character * @return the WCS character */ static wchar mbcsToWcs (int ch, int codePage) { if (OS.IsUnicode) return cast(wchar) ch; int key = ch & 0xFFFF; if (key <= 0x7F) return cast(wchar) ch; CHAR[] buffer; if (key <= 0xFF) { buffer = new CHAR [1]; buffer [0] = cast(CHAR) key; } else { buffer = new CHAR [2]; buffer [0] = cast(CHAR) ((key >> 8) & 0xFF); buffer [1] = cast(CHAR) (key & 0xFF); } wchar [] unicode = new wchar [1]; int cp = codePage !is 0 ? codePage : OS.CP_ACP; int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer.ptr, cast(int) buffer.length, unicode.ptr, 1); if (count is 0) return 0; return unicode [0]; } private static extern(Windows) int messageProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) { Display d = Display.getCurrent(); return d.messageProc( hwnd, msg, wParam, lParam ); } int messageProc (HWND hwnd, uint msg, uint wParam, int lParam) { switch (msg) { case SWT_RUNASYNC: { if (runMessagesInIdle) runAsyncMessages (false); break; } case SWT_KEYMSG: { bool consumed = false; MSG* keyMsg = cast(MSG*) lParam; Control control = findControl (keyMsg.hwnd); if (control !is null) { /* * Feature in Windows. When the user types an accent key such * as ^ in order to get an accented character on a German keyboard, * calling TranslateMessage(), ToUnicode() or ToAscii() consumes * the key. This means that a subsequent call to TranslateMessage() * will see a regular key rather than the accented key. The fix * is to use MapVirtualKey() and VkKeyScan () to detect an accent * and avoid calls to TranslateMessage(). */ bool accentKey = false; switch (keyMsg.message) { case OS.WM_KEYDOWN: case OS.WM_SYSKEYDOWN: { static if (!OS.IsWinCE) { switch (keyMsg.wParam) { case OS.VK_SHIFT: case OS.VK_MENU: case OS.VK_CONTROL: case OS.VK_CAPITAL: case OS.VK_NUMLOCK: case OS.VK_SCROLL: break; default: { /* * Bug in Windows. The high bit in the result of MapVirtualKey() on * Windows NT is bit 32 while the high bit on Windows 95 is bit 16. * They should both be bit 32. The fix is to test the right bit. */ int mapKey = OS.MapVirtualKey (keyMsg.wParam, 2); if (mapKey !is 0) { accentKey = (mapKey & (OS.IsWinNT ? 0x80000000 : 0x8000)) !is 0; if (!accentKey) { for (int i=0; i<ACCENTS.length; i++) { int value = OS.VkKeyScan (ACCENTS [i]); if (value !is -1 && (value & 0xFF) is keyMsg.wParam) { int state = value >> 8; if ((OS.GetKeyState (OS.VK_SHIFT) < 0) is ((state & 0x1) !is 0) && (OS.GetKeyState (OS.VK_CONTROL) < 0) is ((state & 0x2) !is 0) && (OS.GetKeyState (OS.VK_MENU) < 0) is ((state & 0x4) !is 0)) { if ((state & 0x7) !is 0) accentKey = true; break; } } } } } break; } } } break; } default: } if (!accentKey && !ignoreNextKey) { keyMsg.hwnd = control.handle; int flags = OS.PM_REMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE; do { if (!(consumed |= filterMessage (keyMsg))) { OS.TranslateMessage (keyMsg); consumed |= OS.DispatchMessage (keyMsg) is 1; } } while (OS.PeekMessage (keyMsg, keyMsg.hwnd, OS.WM_KEYFIRST, OS.WM_KEYLAST, flags)); } switch (keyMsg.message) { case OS.WM_KEYDOWN: case OS.WM_SYSKEYDOWN: { switch (keyMsg.wParam) { case OS.VK_SHIFT: case OS.VK_MENU: case OS.VK_CONTROL: case OS.VK_CAPITAL: case OS.VK_NUMLOCK: case OS.VK_SCROLL: break; default: { ignoreNextKey = accentKey; break; } } } default: } } switch (keyMsg.wParam) { case OS.VK_SHIFT: case OS.VK_MENU: case OS.VK_CONTROL: case OS.VK_CAPITAL: case OS.VK_NUMLOCK: case OS.VK_SCROLL: consumed = true; default: } if (consumed) { auto hHeap = OS.GetProcessHeap (); OS.HeapFree (hHeap, 0, cast(void*)lParam); } else { OS.PostMessage (embeddedHwnd, SWT_KEYMSG, wParam, lParam); } return 0; } case SWT_TRAYICONMSG: { if (tray !is null) { TrayItem [] items = tray.items; for (int i=0; i<items.length; i++) { TrayItem item = items [i]; if (item !is null && item.id is wParam) { return item.messageProc (hwnd, msg, wParam, lParam); } } } return 0; } case OS.WM_ACTIVATEAPP: { /* * Feature in Windows. When multiple shells are * disabled and one of the shells has an enabled * dialog child and the user selects a disabled * shell that does not have the enabled dialog * child using the Task bar, Windows brings the * disabled shell to the front. As soon as the * user clicks on the disabled shell, the enabled * dialog child comes to the front. This behavior * is unspecified and seems strange. Normally, a * disabled shell is frozen on the screen and the * user cannot change the z-order by clicking with * the mouse. The fix is to look for WM_ACTIVATEAPP * and force the enabled dialog child to the front. * This is typically what the user is expecting. * * NOTE: If the modal shell is disabled for any * reason, it should not be brought to the front. */ if (wParam !is 0) { if (!isXMouseActive ()) { auto hwndActive = OS.GetActiveWindow (); if (hwndActive !is null && OS.IsWindowEnabled (hwndActive)) break; Shell modal = modalDialog !is null ? modalDialog.parent : getModalShell (); if (modal !is null && !modal.isDisposed ()) { auto hwndModal = modal.handle; if (OS.IsWindowEnabled (hwndModal)) { modal.bringToTop (); if (modal.isDisposed ()) break; } auto hwndPopup = OS.GetLastActivePopup (hwndModal); if (hwndPopup !is null && hwndPopup !is modal.handle) { if (getControl (hwndPopup) is null) { if (OS.IsWindowEnabled (hwndPopup)) { OS.SetActiveWindow (hwndPopup); } } } } } } break; } case OS.WM_ENDSESSION: { if (wParam !is 0) { dispose (); /* * When the session is ending, no SWT program can continue * to run. In order to avoid running code after the display * has been disposed, exit from Java. */ /* This code is intentionally commented */ // System.exit (0); } break; } case OS.WM_QUERYENDSESSION: { Event event = new Event (); sendEvent (SWT.Close, event); if (!event.doit) return 0; break; } case OS.WM_DWMCOLORIZATIONCOLORCHANGED: { OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null); break; } case OS.WM_SETTINGCHANGE: { if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null); break; } switch (wParam) { case 0: case 1: case OS.SPI_SETHIGHCONTRAST: OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null); default: } break; } case OS.WM_THEMECHANGED: { if (OS.COMCTL32_MAJOR >= 6) { if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_); if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_); if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_); if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_); if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_); hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null; } break; } case OS.WM_TIMER: { if (wParam is SETTINGS_ID) { OS.KillTimer (hwndMessage, SETTINGS_ID); runSettings (); } else { runTimer (wParam); } break; } default: { if (msg is SWT_TASKBARCREATED) { if (tray !is null) { TrayItem [] items = tray.items; for (int i=0; i<items.length; i++) { TrayItem item = items [i]; if (item !is null) item.recreate (); } } } } } return OS.DefWindowProc (hwnd, msg, wParam, lParam); } private static extern(Windows) int monitorEnumFunc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor, int dwData) { auto d = cast(Display)cast(void*)dwData; return d.monitorEnumProc( hmonitor, hdc, lprcMonitor ); } int monitorEnumProc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor) { if (monitorCount >= monitors.length) { org.eclipse.swt.widgets.Monitor.Monitor[] newMonitors = new org.eclipse.swt.widgets.Monitor.Monitor [monitors.length + 4]; System.arraycopy (monitors, 0, newMonitors, 0, monitors.length); monitors = newMonitors; } MONITORINFO lpmi; lpmi.cbSize = MONITORINFO.sizeof; OS.GetMonitorInfo (hmonitor, &lpmi); org.eclipse.swt.widgets.Monitor.Monitor monitor = new org.eclipse.swt.widgets.Monitor.Monitor (); monitor.handle = hmonitor; monitor.x = lpmi.rcMonitor.left; monitor.y = lpmi.rcMonitor.top; monitor.width = lpmi.rcMonitor.right - lpmi.rcMonitor.left; monitor.height = lpmi.rcMonitor.bottom - lpmi.rcMonitor.top; monitor.clientX = lpmi.rcWork.left; monitor.clientY = lpmi.rcWork.top; monitor.clientWidth = lpmi.rcWork.right - lpmi.rcWork.left; monitor.clientHeight = lpmi.rcWork.bottom - lpmi.rcWork.top; monitors [monitorCount++] = monitor; return 1; } private static extern(Windows) int msgFilterProcFunc (int code, uint wParam, int lParam) { Display pThis = Display.getCurrent(); return pThis.msgFilterProc( code, wParam, lParam ); } int msgFilterProc (int code, int wParam, int lParam) { switch (code) { case OS.MSGF_COMMCTRL_BEGINDRAG: { if (!runDragDrop && !dragCancelled) { *hookMsg = *cast(MSG*)lParam; if (hookMsg.message is OS.WM_MOUSEMOVE) { dragCancelled = true; OS.SendMessage (hookMsg.hwnd, OS.WM_CANCELMODE, 0, 0); } } break; } /* * Feature in Windows. For some reason, when the user clicks * a table or tree, the Windows hook WH_MSGFILTER is sent when * an input event from a dialog box, message box, menu, or scroll * bar did not occur, causing async messages to run at the wrong * time. The fix is to check the message filter code. */ case OS.MSGF_DIALOGBOX: case OS.MSGF_MAINLOOP: case OS.MSGF_MENU: case OS.MSGF_MOVE: case OS.MSGF_MESSAGEBOX: case OS.MSGF_NEXTWINDOW: case OS.MSGF_SCROLLBAR: case OS.MSGF_SIZE: { if (runMessages) { *hookMsg = *cast(MSG*)lParam; if (hookMsg.message is OS.WM_NULL) { MSG msg; int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE; if (!OS.PeekMessage (&msg, null, 0, 0, flags)) { if (runAsyncMessages (false)) wakeThread (); } } } break; } default: } return OS.CallNextHookEx (filterHook, code, wParam, lParam); } int numpadKey (int key) { switch (key) { case OS.VK_NUMPAD0: return '0'; case OS.VK_NUMPAD1: return '1'; case OS.VK_NUMPAD2: return '2'; case OS.VK_NUMPAD3: return '3'; case OS.VK_NUMPAD4: return '4'; case OS.VK_NUMPAD5: return '5'; case OS.VK_NUMPAD6: return '6'; case OS.VK_NUMPAD7: return '7'; case OS.VK_NUMPAD8: return '8'; case OS.VK_NUMPAD9: return '9'; case OS.VK_MULTIPLY: return '*'; case OS.VK_ADD: return '+'; case OS.VK_SEPARATOR: return '\0'; case OS.VK_SUBTRACT: return '-'; case OS.VK_DECIMAL: return '.'; case OS.VK_DIVIDE: return '/'; default: } return 0; } /** * Generate a low level system event. * * <code>post</code> is used to generate low level keyboard * and mouse events. The intent is to enable automated UI * testing by simulating the input from the user. Most * SWT applications should never need to call this method. * <p> * Note that this operation can fail when the operating system * fails to generate the event for any reason. For example, * this can happen when there is no such key or mouse button * or when the system event queue is full. * </p> * <p> * <b>Event Types:</b> * <p>KeyDown, KeyUp * <p>The following fields in the <code>Event</code> apply: * <ul> * <li>(in) type KeyDown or KeyUp</li> * <p> Either one of: * <li>(in) character a character that corresponds to a keyboard key</li> * <li>(in) keyCode the key code of the key that was typed, * as defined by the key code constants in class <code>SWT</code></li> * </ul> * <p>MouseDown, MouseUp</p> * <p>The following fields in the <code>Event</code> apply: * <ul> * <li>(in) type MouseDown or MouseUp * <li>(in) button the button that is pressed or released * </ul> * <p>MouseMove</p> * <p>The following fields in the <code>Event</code> apply: * <ul> * <li>(in) type MouseMove * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates * </ul> * </dl> * * @param event the event to be generated * * @return true if the event was generated or false otherwise * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the event is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 3.0 * */ public bool post (Event event) { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); if (event is null) error (SWT.ERROR_NULL_ARGUMENT); int type = event.type; switch (type){ case SWT.KeyDown: case SWT.KeyUp: { KEYBDINPUT inputs; inputs.wVk = cast(short) untranslateKey (event.keyCode); if (inputs.wVk is 0) { char key = cast(char) event.character; switch (key) { case SWT.BS: inputs.wVk = cast(short) OS.VK_BACK; break; case SWT.CR: inputs.wVk = cast(short) OS.VK_RETURN; break; case SWT.DEL: inputs.wVk = cast(short) OS.VK_DELETE; break; case SWT.ESC: inputs.wVk = cast(short) OS.VK_ESCAPE; break; case SWT.TAB: inputs.wVk = cast(short) OS.VK_TAB; break; /* * Since there is no LF key on the keyboard, do not attempt * to map LF to CR or attempt to post an LF key. */ // case SWT.LF: inputs.wVk = cast(short) OS.VK_RETURN; break; case SWT.LF: return false; default: { static if (OS.IsWinCE) { inputs.wVk = cast(int)OS.CharUpper (cast(wchar*) key); } else { inputs.wVk = OS.VkKeyScan (cast(short) wcsToMbcs (key, 0)); if (inputs.wVk is -1) return false; inputs.wVk &= 0xFF; } } } } inputs.dwFlags = type is SWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0; auto hHeap = OS.GetProcessHeap (); auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); pInputs.type = OS.INPUT_KEYBOARD; //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit pInputs.ki = inputs; //OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof); bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0; OS.HeapFree (hHeap, 0, pInputs); return result; } case SWT.MouseDown: case SWT.MouseMove: case SWT.MouseUp: case SWT.MouseWheel: { MOUSEINPUT inputs; if (type is SWT.MouseMove){ inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE; int x= 0, y = 0, width = 0, height = 0; if (OS.WIN32_VERSION >= OS.VERSION (5, 0)) { inputs.dwFlags |= OS.MOUSEEVENTF_VIRTUALDESK; x = OS.GetSystemMetrics (OS.SM_XVIRTUALSCREEN); y = OS.GetSystemMetrics (OS.SM_YVIRTUALSCREEN); width = OS.GetSystemMetrics (OS.SM_CXVIRTUALSCREEN); height = OS.GetSystemMetrics (OS.SM_CYVIRTUALSCREEN); } else { width = OS.GetSystemMetrics (OS.SM_CXSCREEN); height = OS.GetSystemMetrics (OS.SM_CYSCREEN); } inputs.dx = ((event.x - x) * 65535 + width - 2) / (width - 1); inputs.dy = ((event.y - y) * 65535 + height - 2) / (height - 1); } else { if (type is SWT.MouseWheel) { if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false; inputs.dwFlags = OS.MOUSEEVENTF_WHEEL; switch (event.detail) { case SWT.SCROLL_PAGE: inputs.mouseData = event.count * OS.WHEEL_DELTA; break; case SWT.SCROLL_LINE: int value; OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0); inputs.mouseData = event.count * OS.WHEEL_DELTA / value; break; default: return false; } } else { switch (event.button) { case 1: inputs.dwFlags = type is SWT.MouseDown ? OS.MOUSEEVENTF_LEFTDOWN : OS.MOUSEEVENTF_LEFTUP; break; case 2: inputs.dwFlags = type is SWT.MouseDown ? OS.MOUSEEVENTF_MIDDLEDOWN : OS.MOUSEEVENTF_MIDDLEUP; break; case 3: inputs.dwFlags = type is SWT.MouseDown ? OS.MOUSEEVENTF_RIGHTDOWN : OS.MOUSEEVENTF_RIGHTUP; break; case 4: { if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false; inputs.dwFlags = type is SWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP; inputs.mouseData = OS.XBUTTON1; break; } case 5: { if (OS.WIN32_VERSION < OS.VERSION (5, 0)) return false; inputs.dwFlags = type is SWT.MouseDown ? OS.MOUSEEVENTF_XDOWN : OS.MOUSEEVENTF_XUP; inputs.mouseData = OS.XBUTTON2; break; } default: return false; } } } auto hHeap = OS.GetProcessHeap (); auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof); pInputs.type = OS.INPUT_MOUSE; //TODO - DWORD type of INPUT structure aligned to 8 bytes on 64 bit pInputs.mi = inputs; bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0; OS.HeapFree (hHeap, 0, pInputs); return result; } default: } return false; } } void postEvent (Event event) { /* * Place the event at the end of the event queue. * This code is always called in the Display's * thread so it must be re-enterant but does not * need to be synchronized. */ if (eventQueue is null) eventQueue = new Event [4]; int index = 0; int length_ = cast(int) eventQueue.length; while (index < length_) { if (eventQueue [index] is null) break; index++; } if (index is length_) { Event [] newQueue = new Event [length_ + 4]; System.arraycopy (eventQueue, 0, newQueue, 0, length_); eventQueue = newQueue; } eventQueue [index] = event; } /** * Reads an event from the operating system's event queue, * dispatches it appropriately, and returns <code>true</code> * if there is potentially more work to do, or <code>false</code> * if the caller can sleep until another event is placed on * the event queue. * <p> * In addition to checking the system event queue, this method also * checks if any inter-thread messages (created by <code>syncExec()</code> * or <code>asyncExec()</code>) are waiting to be processed, and if * so handles them before returning. * </p> * * @return <code>false</code> if the caller can sleep upon return from this method * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li> * </ul> * * @see #sleep * @see #wake */ public bool readAndDispatch () { checkDevice (); lpStartupInfo = null; drawMenuBars (); runPopups (); if (OS.PeekMessage (msg, null, 0, 0, OS.PM_REMOVE)) { if (!filterMessage (msg)) { OS.TranslateMessage (msg); OS.DispatchMessage (msg); } runDeferredEvents (); return true; } return runMessages && runAsyncMessages (false); } static void register (Display display) { static_this(); synchronized (Device.classinfo) { for (int i=0; i<Displays.length; i++) { if (Displays [i] is null) { Displays [i] = display; return; } } Display [] newDisplays = new Display [Displays.length + 4]; System.arraycopy (Displays, 0, newDisplays, 0, Displays.length); newDisplays [Displays.length] = display; Displays = newDisplays; } } /** * Releases any internal resources back to the operating * system and clears all fields except the device handle. * <p> * Disposes all shells which are currently open on the display. * After this method has been invoked, all related related shells * will answer <code>true</code> when sent the message * <code>isDisposed()</code>. * </p><p> * When a device is destroyed, resources that were acquired * on behalf of the programmer need to be returned to the * operating system. For example, if the device allocated a * font to be used as the system font, this font would be * freed in <code>release</code>. Also,to assist the garbage * collector and minimize the amount of memory that is not * reclaimed when the programmer keeps a reference to a * disposed device, all fields except the handle are zero'd. * The handle is needed by <code>destroy</code>. * </p> * This method is called before <code>destroy</code>. * * @see Device#dispose * @see #destroy */ override protected void release () { sendEvent (SWT.Dispose, new Event ()); Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; if (!shell.isDisposed ()) shell.dispose (); } if (tray !is null) tray.dispose (); tray = null; while (readAndDispatch ()) {} if (disposeList !is null) { for (int i=0; i<disposeList.length; i++) { if (disposeList [i] !is null) disposeList [i].run (); } } disposeList = null; synchronizer.releaseSynchronizer (); synchronizer = null; releaseDisplay (); super.release (); } void releaseDisplay () { if (embeddedHwnd !is null) { OS.PostMessage (embeddedHwnd, SWT_DESTROY, 0, 0); } /* Release XP Themes */ if (OS.COMCTL32_MAJOR >= 6) { if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_); if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_); if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_); if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_); if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_); hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null; } /* Unhook the message hook */ static if (!OS.IsWinCE) { if (msgHook !is null) OS.UnhookWindowsHookEx (msgHook); msgHook = null; } /* Unhook the filter hook */ static if (!OS.IsWinCE) { if (filterHook !is null) OS.UnhookWindowsHookEx (filterHook); filterHook = null; //msgFilterCallback.dispose (); //msgFilterCallback = null; //msgFilterProc_ = 0; } /* Unhook the idle hook */ static if (!OS.IsWinCE) { if (idleHook !is null) OS.UnhookWindowsHookEx (idleHook); idleHook = null; //foregroundIdleCallback.dispose (); //foregroundIdleCallback = null; //foregroundIdleProc_ = 0; } /* Destroy the message only HWND */ if (hwndMessage !is null) OS.DestroyWindow (hwndMessage); hwndMessage = null; //messageCallback.dispose (); //messageCallback = null; //messageProc_ = 0; /* Unregister the SWT window class */ auto hHeap = OS.GetProcessHeap (); auto hInstance = OS.GetModuleHandle (null); OS.UnregisterClass (windowClass_.ptr, hInstance); /* Unregister the SWT drop shadow window class */ OS.UnregisterClass (windowShadowClass.ptr, hInstance); windowClass_ = windowShadowClass = null; //windowCallback.dispose (); //windowCallback = null; //windowProc_ = 0; /* Release the System fonts */ if (systemFont !is null) systemFont.dispose (); systemFont = null; lfSystemFont = null; /* Release the System Images */ if (errorImage !is null) errorImage.dispose (); if (infoImage !is null) infoImage.dispose (); if (questionImage !is null) questionImage.dispose (); if (warningIcon !is null) warningIcon.dispose (); errorImage = infoImage = questionImage = warningIcon = null; /* Release Sort Indicators */ if (upArrow !is null) upArrow.dispose (); if (downArrow !is null) downArrow.dispose (); upArrow = downArrow = null; /* Release the System Cursors */ for (int i = 0; i < cursors.length; i++) { if (cursors [i] !is null) cursors [i].dispose (); } cursors = null; /* Release Acquired Resources */ if (resources !is null) { for (int i=0; i<resources.length; i++) { if (resources [i] !is null) resources [i].dispose (); } resources = null; } /* Release Custom Colors for ChooseColor */ if (lpCustColors !is null) OS.HeapFree (hHeap, 0, lpCustColors); lpCustColors = null; /* Uninitialize OLE */ static if (!OS.IsWinCE) OS.OleUninitialize (); /* Uninitialize buffered painting */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { OS.BufferedPaintUnInit (); } /* Release references */ thread = null; msg = null; hookMsg = null; //keyboard = null; modalDialog = null; modalShells = null; data = null; keys = null; values = null; bars = popups = null; indexTable = null; timerIds = null; controlTable = null; lastControl = lastGetControl = lastHittestControl = null; imageList = toolImageList = toolHotImageList = toolDisabledImageList = null; timerList = null; tableBuffer = null; columnVisible = null; eventTable = filterTable = null; items = null; clickRect = null; hdr = null; plvfi = null; /* Release handles */ threadId = 0; } void releaseImageList (ImageList list) { int i = 0; int length_ = cast(int) imageList.length; while (i < length_) { if (imageList [i] is list) { if (list.removeRef () > 0) return; list.dispose (); System.arraycopy (imageList, i + 1, imageList, i, --length_ - i); imageList [length_] = null; for (int j=0; j<length_; j++) { if (imageList [j] !is null) return; } imageList = null; return; } i++; } } void releaseToolImageList (ImageList list) { int i = 0; int length_ = cast(int) toolImageList.length; while (i < length_) { if (toolImageList [i] is list) { if (list.removeRef () > 0) return; list.dispose (); System.arraycopy (toolImageList, i + 1, toolImageList, i, --length_ - i); toolImageList [length_] = null; for (int j=0; j<length_; j++) { if (toolImageList [j] !is null) return; } toolImageList = null; return; } i++; } } void releaseToolHotImageList (ImageList list) { int i = 0; int length_ = cast(int) toolHotImageList.length; while (i < length_) { if (toolHotImageList [i] is list) { if (list.removeRef () > 0) return; list.dispose (); System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length_ - i); toolHotImageList [length_] = null; for (int j=0; j<length_; j++) { if (toolHotImageList [j] !is null) return; } toolHotImageList = null; return; } i++; } } void releaseToolDisabledImageList (ImageList list) { int i = 0; int length_ = cast(int) toolDisabledImageList.length; while (i < length_) { if (toolDisabledImageList [i] is list) { if (list.removeRef () > 0) return; list.dispose (); System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length_ - i); toolDisabledImageList [length_] = null; for (int j=0; j<length_; j++) { if (toolDisabledImageList [j] !is null) return; } toolDisabledImageList = null; return; } i++; } } /** * Removes the listener from the collection of listeners who will * be notified when an event of the given type occurs anywhere in * a widget. The event type is one of the event constants defined * in class <code>SWT</code>. * * @param eventType the type of event to listen for * @param listener the listener which should no longer be notified when the event occurs * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @see Listener * @see SWT * @see #addFilter * @see #addListener * * @since 3.0 */ public void removeFilter (int eventType, Listener listener) { checkDevice (); if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); if (filterTable is null) return; filterTable.unhook (eventType, listener); if (filterTable.size () is 0) filterTable = null; } /** * Removes the listener from the collection of listeners who will * be notified when an event of the given type occurs. The event type * is one of the event constants defined in class <code>SWT</code>. * * @param eventType the type of event to listen for * @param listener the listener which should no longer be notified * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Listener * @see SWT * @see #addListener * * @since 2.0 */ public void removeListener (int eventType, Listener listener) { checkDevice (); if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable is null) return; eventTable.unhook (eventType, listener); } void removeBar (Menu menu) { if (bars is null) return; for (int i=0; i<bars.length; i++) { if (bars [i] is menu) { bars [i] = null; return; } } } Control removeControl (HANDLE handle) { if (handle is null) return null; lastControl = lastGetControl = null; Control control = null; int index; static if (USE_PROPERTY) { index = cast(int)OS.RemoveProp (handle, cast(wchar*)SWT_OBJECT_INDEX) - 1; } else { index = OS.GetWindowLongPtr (handle, OS.GWLP_USERDATA) - 1; OS.SetWindowLongPtr (handle, OS.GWLP_USERDATA, 0); } if (0 <= index && index < controlTable.length) { control = controlTable [index]; controlTable [index] = null; indexTable [index] = freeSlot; freeSlot = index; } return control; } void removeMenuItem (MenuItem item) { if (items is null) return; items [item.id - ID_START] = null; } void removePopup (Menu menu) { if (popups is null) return; for (int i=0; i<popups.length; i++) { if (popups [i] is menu) { popups [i] = null; return; } } } bool runAsyncMessages (bool all) { return synchronizer.runAsyncMessages (all); } bool runDeferredEvents () { /* * Run deferred events. This code is always * called in the Display's thread so it must * be re-enterant but need not be synchronized. */ while (eventQueue !is null) { /* Take an event off the queue */ Event event = eventQueue [0]; if (event is null) break; int length_ = cast(int) eventQueue.length; System.arraycopy (eventQueue, 1, eventQueue, 0, --length_); eventQueue [length_] = null; /* Run the event */ Widget widget = event.widget; if (widget !is null && !widget.isDisposed ()) { Widget item = event.item; if (item is null || !item.isDisposed ()) { widget.sendEvent (event); } } /* * At this point, the event queue could * be null due to a recursive invocation * when running the event. */ } /* Clear the queue */ eventQueue = null; return true; } bool runPopups () { if (popups is null) return false; bool result = false; while (popups !is null) { Menu menu = popups [0]; if (menu is null) break; int length_ = cast(int) popups.length; System.arraycopy (popups, 1, popups, 0, --length_); popups [length_] = null; runDeferredEvents (); if (!menu.isDisposed ()) menu._setVisible (true); result = true; } popups = null; return result; } void runSettings () { Font oldFont = getSystemFont (); saveResources (); updateImages (); sendEvent (SWT.Settings, null); Font newFont = getSystemFont (); bool sameFont = cast(bool)( oldFont ==/*eq*/ newFont ); Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; if (!shell.isDisposed ()) { if (!sameFont) { shell.updateFont (oldFont, newFont); } /* This code is intentionally commented */ //shell.redraw (true); shell.layout (true, true); } } } bool runTimer (int /*long*/ id) { if (timerList !is null && timerIds !is null) { int index = 0; while (index <timerIds.length) { if (timerIds [index] is id) { OS.KillTimer (hwndMessage, timerIds [index]); timerIds [index] = 0; Runnable runnable = timerList [index]; timerList [index] = null; if (runnable !is null) runnable.run (); return true; } index++; } } return false; } void saveResources () { int resourceCount = 0; if (resources is null) { resources = new Resource [RESOURCE_SIZE]; } else { resourceCount = cast(int) resources.length; Resource [] newResources = new Resource [resourceCount + RESOURCE_SIZE]; System.arraycopy (resources, 0, newResources, 0, resourceCount); resources = newResources; } if (systemFont !is null) { static if (!OS.IsWinCE) { NONCLIENTMETRICS info; info.cbSize = NONCLIENTMETRICS.sizeof; if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) { LOGFONT* logFont = &info.lfMessageFont; if (lfSystemFont is null || logFont.lfCharSet !is lfSystemFont.lfCharSet || logFont.lfHeight !is lfSystemFont.lfHeight || logFont.lfWidth !is lfSystemFont.lfWidth || logFont.lfEscapement !is lfSystemFont.lfEscapement || logFont.lfOrientation !is lfSystemFont.lfOrientation || logFont.lfWeight !is lfSystemFont.lfWeight || logFont.lfItalic !is lfSystemFont.lfItalic || logFont.lfUnderline !is lfSystemFont.lfUnderline || logFont.lfStrikeOut !is lfSystemFont.lfStrikeOut || logFont.lfCharSet !is lfSystemFont.lfCharSet || logFont.lfOutPrecision !is lfSystemFont.lfOutPrecision || logFont.lfClipPrecision !is lfSystemFont.lfClipPrecision || logFont.lfQuality !is lfSystemFont.lfQuality || logFont.lfPitchAndFamily !is lfSystemFont.lfPitchAndFamily || getFontName (logFont) !=/*eq*/ getFontName (lfSystemFont)) { resources [resourceCount++] = systemFont; lfSystemFont = logFont; systemFont = null; } } } } if (errorImage !is null) resources [resourceCount++] = errorImage; if (infoImage !is null) resources [resourceCount++] = infoImage; if (questionImage !is null) resources [resourceCount++] = questionImage; if (warningIcon !is null) resources [resourceCount++] = warningIcon; errorImage = infoImage = questionImage = warningIcon = null; for (int i=0; i<cursors.length; i++) { if (cursors [i] !is null) resources [resourceCount++] = cursors [i]; cursors [i] = null; } if (resourceCount < RESOURCE_SIZE) { Resource [] newResources = new Resource [resourceCount]; System.arraycopy (resources, 0, newResources, 0, resourceCount); resources = newResources; } } void sendEvent (int eventType, Event event) { if (eventTable is null && filterTable is null) { return; } if (event is null) event = new Event (); event.display = this; event.type = eventType; if (event.time is 0) event.time = getLastEventTime (); if (!filterEvent (event)) { if (eventTable !is null) eventTable.sendEvent (event); } } /** * Sets the location of the on-screen pointer relative to the top left corner * of the screen. <b>Note: It is typically considered bad practice for a * program to move the on-screen pointer location.</b> * * @param x the new x coordinate for the cursor * @param y the new y coordinate for the cursor * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.1 */ public void setCursorLocation (int x, int y) { checkDevice (); OS.SetCursorPos (x, y); } /** * Sets the location of the on-screen pointer relative to the top left corner * of the screen. <b>Note: It is typically considered bad practice for a * program to move the on-screen pointer location.</b> * * @param point new position * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_NULL_ARGUMENT - if the point is null * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @since 2.0 */ public void setCursorLocation (Point point) { checkDevice (); if (point is null) error (SWT.ERROR_NULL_ARGUMENT); setCursorLocation (point.x, point.y); } /** * Sets the application defined property of the receiver * with the specified name to the given argument. * <p> * Applications may have associated arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the display is disposed * of, it is the application's responsibility provide a * <code>disposeExec()</code> handler which does so. * </p> * * @param key the name of the property * @param value the new value for the property * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #getData(String) * @see #disposeExec(Runnable) */ public void setData (String key, Object value) { checkDevice (); // SWT extension: allow null string //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { auto data = cast(Boolean) value; runMessagesInIdle = data !is null && data.value; return; } if (key.equals (RUN_MESSAGES_IN_MESSAGE_PROC_KEY)) { Boolean data = cast(Boolean) value; runMessagesInMessageProc = data !is null && data.booleanValue (); return; } /* Remove the key/value pair */ if (value is null) { if (keys is null) return; int index = 0; while (index < keys.length && keys [index]!=/*eq*/key) index++; if (index is keys.length) return; if (keys.length is 1) { keys = null; values = null; } else { String [] newKeys = new String [keys.length - 1]; Object [] newValues = new Object [values.length - 1]; System.arraycopy (keys, 0, newKeys, 0, index); System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index); System.arraycopy (values, 0, newValues, 0, index); System.arraycopy (values, index + 1, newValues, index, newValues.length - index); keys = newKeys; values = newValues; } return; } /* Add the key/value pair */ if (keys is null) { keys.length = 1; values.length = 1; keys[0] = key; values[0] = value; return; } for (int i=0; i<keys.length; i++) { if (keys [i] ==/*eq*/key ) { values [i] = value; return; } } String [] newKeys = new String [keys.length + 1]; Object [] newValues = new Object [values.length + 1]; System.arraycopy (keys, 0, newKeys, 0, keys.length); System.arraycopy (values, 0, newValues, 0, values.length); newKeys [keys.length] = key; newValues [values.length] = value; keys = newKeys; values = newValues; } /** * Sets the application defined, display specific data * associated with the receiver, to the argument. * The <em>display specific data</em> is a single, * unnamed field that is stored with every display. * <p> * Applications may put arbitrary objects in this field. If * the object stored in the display specific data needs to * be notified when the display is disposed of, it is the * application's responsibility provide a * <code>disposeExec()</code> handler which does so. * </p> * * @param data the new display specific data * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #getData() * @see #disposeExec(Runnable) */ public void setData (Object data) { checkDevice (); this.data = data; } /** * On platforms which support it, sets the application name * to be the argument. On Motif, for example, this can be used * to set the name used for resource lookup. Specifying * <code>null</code> for the name clears it. * * @param name the new app name or <code>null</code> */ public static void setAppName (String name) { /* Do nothing */ } void setModalDialog (Dialog modalDailog) { this.modalDialog = modalDailog; Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) shells [i].updateModal (); } void setModalShell (Shell shell) { if (modalShells is null) modalShells = new Shell [4]; int index = 0, length_ = cast(int) modalShells.length; while (index < length_) { if (modalShells [index] is shell) return; if (modalShells [index] is null) break; index++; } if (index is length_) { Shell [] newModalShells = new Shell [length_ + 4]; System.arraycopy (modalShells, 0, newModalShells, 0, length_); modalShells = newModalShells; } modalShells [index] = shell; Shell [] shells = getShells (); for (int i=0; i<shells.length; i++) shells [i].updateModal (); } /** * Sets the synchronizer used by the display to be * the argument, which can not be null. * * @param synchronizer the new synchronizer for the display (must not be null) * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li> * </ul> */ public void setSynchronizer (Synchronizer synchronizer) { checkDevice (); if (synchronizer is null) error (SWT.ERROR_NULL_ARGUMENT); if (synchronizer is this.synchronizer) return; Synchronizer oldSynchronizer; synchronized (Device.classinfo) { oldSynchronizer = this.synchronizer; this.synchronizer = synchronizer; } if (oldSynchronizer !is null) { oldSynchronizer.runAsyncMessages(true); } } int shiftedKey (int key) { static if (OS.IsWinCE) return 0; /* Clear the virtual keyboard and press the shift key */ for (int i=0; i<keyboard.length; i++) keyboard [i] = 0; keyboard [OS.VK_SHIFT] |= 0x80; /* Translate the key to ASCII or UNICODE using the virtual keyboard */ static if (OS.IsUnicode) { wchar result; if (OS.ToUnicode (key, key, keyboard.ptr, &result, 1, 0) is 1) return result; } else { wchar result; if (OS.ToAscii (key, key, keyboard.ptr, &result, 0) is 1) return result; } return 0; } /** * Causes the user-interface thread to <em>sleep</em> (that is, * to be put in a state where it does not consume CPU cycles) * until an event is received or it is otherwise awakened. * * @return <code>true</code> if an event requiring dispatching was placed on the queue. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #wake */ public bool sleep () { checkDevice (); if (runMessages && getMessageCount () !is 0) return true; static if (OS.IsWinCE) { OS.MsgWaitForMultipleObjectsEx (0, null, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE); return true; } return cast(bool) OS.WaitMessage (); } /** * Causes the <code>run()</code> method of the runnable to * be invoked by the user-interface thread at the next * reasonable opportunity. The thread which calls this method * is suspended until the runnable completes. Specifying <code>null</code> * as the runnable simply wakes the user-interface thread. * <p> * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. * </p> * * @param runnable code to run on the user-interface thread or <code>null</code> * * @exception SWTException <ul> * <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #asyncExec */ public void syncExec (Runnable runnable) { Synchronizer synchronizer; synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); synchronizer = this.synchronizer; } synchronizer.syncExec (runnable); } /** * Causes the <code>run()</code> method of the runnable to * be invoked by the user-interface thread after the specified * number of milliseconds have elapsed. If milliseconds is less * than zero, the runnable is not executed. * <p> * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. * </p> * * @param milliseconds the delay before running the runnable * @param runnable code to run on the user-interface thread * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #asyncExec */ public void timerExec (int milliseconds, Runnable runnable) { checkDevice (); if (runnable is null) error (SWT.ERROR_NULL_ARGUMENT); assert( runnable ); if (timerList is null) timerList = new Runnable [4]; if (timerIds is null) timerIds = new int /*long*/ [4]; int index = 0; while (index < timerList.length) { if (timerList [index] is runnable) break; index++; } int /*long*/ timerId = 0; if (index !is timerList.length) { timerId = timerIds [index]; if (milliseconds < 0) { OS.KillTimer (hwndMessage, timerId); timerList [index] = null; timerIds [index] = 0; return; } } else { if (milliseconds < 0) return; index = 0; while (index < timerList.length) { if (timerList [index] is null) break; index++; } timerId = nextTimerId++; if (index is timerList.length) { Runnable [] newTimerList = new Runnable [timerList.length + 4]; SimpleType!(Runnable).arraycopy (timerList, 0, newTimerList, 0, timerList.length); timerList = newTimerList; int /*long*/ [] newTimerIds = new int /*long*/ [timerIds.length + 4]; System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length); timerIds = newTimerIds; } } int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, null); if (newTimerID !is 0) { timerList [index] = runnable; timerIds [index] = newTimerID; } } bool translateAccelerator (MSG* msg, Control control) { accelKeyHit = true; bool result = control.translateAccelerator (msg); accelKeyHit = false; return result; } static int translateKey (int key) { for (int i=0; i<KeyTable.length; i++) { if (KeyTable [i] [0] is key) return KeyTable [i] [1]; } return 0; } bool translateMnemonic (MSG* msg, Control control) { switch (msg.message) { case OS.WM_CHAR: case OS.WM_SYSCHAR: return control.translateMnemonic (msg); default: } return false; } bool translateTraversal (MSG* msg, Control control) { switch (msg.message) { case OS.WM_KEYDOWN: switch (msg.wParam) { case OS.VK_RETURN: case OS.VK_ESCAPE: case OS.VK_TAB: case OS.VK_UP: case OS.VK_DOWN: case OS.VK_LEFT: case OS.VK_RIGHT: case OS.VK_PRIOR: case OS.VK_NEXT: return control.translateTraversal (msg); default: } break; case OS.WM_SYSKEYDOWN: switch (msg.wParam) { case OS.VK_MENU: return control.translateTraversal (msg); default: } break; default: } return false; } static int untranslateKey (int key) { for (int i=0; i<KeyTable.length; i++) { if (KeyTable [i] [1] is key) return KeyTable [i] [0]; } return 0; } /** * Forces all outstanding paint requests for the display * to be processed before this method returns. * * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see Control#update() */ public void update() { checkDevice (); /* * Feature in Windows. When an application does not remove * events from the event queue for some time, Windows assumes * the application is not responding and no longer sends paint * events to the application. The fix is to detect that the * application is not responding and call PeekMessage() with * PM_REMOVE to tell Windows that the application is ready * to dispatch events. Note that the message does not have * to be found or dispatched in order to wake Windows up. * * NOTE: This allows other cross thread messages to be delivered, * most notably WM_ACTIVATE. */ if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { if (OS.IsHungAppWindow (hwndMessage)) { MSG msg; int flags = OS.PM_REMOVE | OS.PM_NOYIELD; OS.PeekMessage (&msg, hwndMessage, SWT_NULL, SWT_NULL, flags); } } Shell[] shells = getShells (); for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; if (!shell.isDisposed ()) shell.update (true); } } void updateImages () { if (upArrow !is null) upArrow.dispose (); if (downArrow !is null) downArrow.dispose (); upArrow = downArrow = null; for (int i=0; i<controlTable.length; i++) { Control control = controlTable [i]; if (control !is null) control.updateImages (); } } /** * If the receiver's user-interface thread was <code>sleep</code>ing, * causes it to be awakened and start running again. Note that this * method may be called from any thread. * * @exception SWTException <ul> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> * </ul> * * @see #sleep */ public void wake () { synchronized (Device.classinfo) { if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); if (thread is Thread.currentThread ()) return; wakeThread (); } } void wakeThread () { static if (OS.IsWinCE) { OS.PostMessage (hwndMessage, OS.WM_NULL, 0, 0); } else { OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0); } } /* * Returns a single character, converted from the wide * character set (WCS) used by Java to the specified * multi-byte character set used by the operating system * widgets. * * @param ch the WCS character * @param codePage the code page used to convert the character * @return the MBCS character */ static int wcsToMbcs (wchar ch, int codePage) { if (OS.IsUnicode) return ch; if (ch <= 0x7F) return ch; wchar[1] wc; wc[0] = ch; auto r = StrToMBCSs( String_valueOf(wc), codePage ); return r[0]; } /* * Returns a single character, converted from the wide * character set (WCS) used by Java to the default * multi-byte character set used by the operating system * widgets. * * @param ch the WCS character * @return the MBCS character */ static int wcsToMbcs (char ch) { return wcsToMbcs (ch, 0); } private static extern(Windows) int windowProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) { auto d = Display.getCurrent(); return d.windowProc( hwnd, msg, wParam, lParam ); } int windowProc(){ return cast(int)&windowProcFunc; } int windowProc (HWND hwnd, uint msg, uint wParam, int lParam) { /* * Feature in Windows. On Vista only, it is faster to * compute and answer the data for the visible columns * of a table when scrolling, rather than just return * the data for each column when asked. */ if (columnVisible !is null) { if (msg is OS.WM_NOTIFY && hwndParent is hwnd) { OS.MoveMemory (hdr, lParam, NMHDR.sizeof); switch (hdr.code) { case OS.LVN_GETDISPINFOA: case OS.LVN_GETDISPINFOW: { OS.MoveMemory (plvfi, lParam, OS.NMLVDISPINFO_sizeof); if (0 <= plvfi.item.iSubItem && plvfi.item.iSubItem < columnCount) { if (!columnVisible [plvfi.item.iSubItem]) return 0; } break; } default: } } } /* * Bug in Adobe Reader 7.0. For some reason, when Adobe * Reader 7.0 is deactivated from within Internet Explorer, * it sends thousands of consecutive WM_NCHITTEST messages * to the control that is under the cursor. It seems that * if the control takes some time to respond to the message, * Adobe stops sending them. The fix is to detect this case * and sleep. * * NOTE: Under normal circumstances, Windows will never send * consecutive WM_NCHITTEST messages to the same control without * another message (normally WM_SETCURSOR) in between. */ if (msg is OS.WM_NCHITTEST) { if (hitCount++ >= 1024) { try {Thread.sleep (1);} catch (Exception t) {} } } else { hitCount = 0; } if (lastControl !is null && lastHwnd is hwnd) { return lastControl.windowProc (hwnd, msg, wParam, lParam); } int index; static if (USE_PROPERTY) { index = cast(int)OS.GetProp (hwnd, cast(wchar*)SWT_OBJECT_INDEX) - 1; } else { index = OS.GetWindowLongPtr (hwnd, OS.GWLP_USERDATA) - 1; } if (0 <= index && index < controlTable.length) { Control control = controlTable [index]; if (control !is null) { lastHwnd = hwnd; lastControl = control; return control.windowProc (hwnd, msg, wParam, lParam); } } return OS.DefWindowProc (hwnd, msg, wParam, lParam); } static String withCrLf (String string) { /* If the string is empty, return the string. */ int length_ = cast(int) string.length; if (length_ is 0) return string; /* * Check for an LF or CR/LF and assume the rest of * the string is formated that way. This will not * work if the string contains mixed delimiters. */ int i = string.indexOf ('\n', 0); if (i is -1) return string; if (i > 0 && string.charAt (i - 1) is '\r') { return string; } /* * The string is formatted with LF. Compute the * number of lines and the size of the buffer * needed to hold the result */ i++; int count = 1; while (i < length_) { if ((i = string.indexOf ('\n', i)) is -1) break; count++; i++; } count += length_; /* Create a new string with the CR/LF line terminator. */ i = 0; StringBuffer result = new StringBuffer (count); while (i < length_) { int j = string.indexOf ('\n', i); if (j is -1) j = length_; result.append (string.substring (i, j)); if ((i = j) < length_) { result.append ("\r\n"); //$NON-NLS-1$ i++; } } return result.toString (); } String windowClass(){ return TCHARsToStr( windowClass_ ); } }
D
/* Copyright (c) 2019 Timur Gafarov Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ module dagon.render.shaders.sunlight; import std.stdio; import std.math; import dlib.core.memory; import dlib.core.ownership; import dlib.math.vector; import dlib.math.matrix; import dlib.math.transformation; import dlib.math.interpolation; import dlib.image.color; import dlib.text.unmanagedstring; import dagon.core.bindings; import dagon.graphics.shader; import dagon.graphics.state; import dagon.graphics.csm; class SunLightShader: Shader { String vs, fs; Matrix4x4f defaultShadowMatrix; GLuint defaultShadowTexture; this(Owner owner) { vs = Shader.load("data/__internal/shaders/SunLight/SunLight.vert.glsl"); fs = Shader.load("data/__internal/shaders/SunLight/SunLight.frag.glsl"); auto myProgram = New!ShaderProgram(vs, fs, this); super(myProgram, owner); defaultShadowMatrix = Matrix4x4f.identity; glGenTextures(1, &defaultShadowTexture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D_ARRAY, defaultShadowTexture); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT24, 1, 1, 3, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glBindTexture(GL_TEXTURE_2D_ARRAY, 0); } ~this() { if (glIsFramebuffer(defaultShadowTexture)) glDeleteFramebuffers(1, &defaultShadowTexture); vs.free(); fs.free(); } override void bindParameters(GraphicsState* state) { setParameter("viewMatrix", state.viewMatrix); setParameter("invViewMatrix", state.invViewMatrix); setParameter("projectionMatrix", state.projectionMatrix); setParameter("invProjectionMatrix", state.invProjectionMatrix); setParameter("resolution", state.resolution); setParameter("zNear", state.zNear); setParameter("zFar", state.zFar); // Environment if (state.environment) { setParameter("fogColor", state.environment.fogColor); setParameter("fogStart", state.environment.fogStart); setParameter("fogEnd", state.environment.fogEnd); } else { setParameter("fogColor", Color4f(0.5f, 0.5f, 0.5f, 1.0f)); setParameter("fogStart", 0.0f); setParameter("fogEnd", 1000.0f); } // Light Vector4f lightDirHg; Color4f lightColor; float lightEnergy = 1.0f; int lightScattering = 0; float lightScatteringG = 0.0f; float lightScatteringDensity = 0.0f; int lightScatteringSamples = 1; float lightScatteringMaxRandomStepOffset = 0.0f; bool lightScatteringShadow = false; if (state.light) { auto light = state.light; lightDirHg = Vector4f(light.directionAbsolute); lightDirHg.w = 0.0; lightColor = light.color; lightEnergy = light.energy; lightScattering = light.scatteringEnabled; lightScatteringG = 1.0f - light.scattering; lightScatteringDensity = light.mediumDensity; lightScatteringSamples = light.scatteringSamples; lightScatteringMaxRandomStepOffset = light.scatteringMaxRandomStepOffset; lightScatteringShadow = light.scatteringUseShadow; } else { lightDirHg = Vector4f(0.0f, 0.0f, 1.0f, 0.0f); lightColor = Color4f(1.0f, 1.0f, 1.0f, 1.0f); } Vector3f lightDir = (lightDirHg * state.viewMatrix).xyz; setParameter("lightDirection", lightDir); setParameter("lightColor", lightColor); setParameter("lightEnergy", lightEnergy); setParameter("lightScattering", lightScattering); setParameter("lightScatteringG", lightScatteringG); setParameter("lightScatteringDensity", lightScatteringDensity); setParameter("lightScatteringSamples", lightScatteringSamples); setParameter("lightScatteringMaxRandomStepOffset", lightScatteringMaxRandomStepOffset); setParameter("lightScatteringShadow", lightScatteringShadow); setParameter("time", state.localTime); // Texture 0 - color buffer glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, state.colorTexture); setParameter("colorBuffer", 0); // Texture 1 - depth buffer glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, state.depthTexture); setParameter("depthBuffer", 1); // Texture 2 - normal buffer glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, state.normalTexture); setParameter("normalBuffer", 2); // Texture 3 - pbr buffer glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, state.pbrTexture); setParameter("pbrBuffer", 3); // Texture 4 - shadow map if (state.light) { if (state.light.shadowEnabled) { CascadedShadowMap csm = cast(CascadedShadowMap)state.light.shadowMap; glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D_ARRAY, csm.depthTexture); setParameter("shadowTextureArray", 4); setParameter("shadowResolution", cast(float)csm.resolution); setParameter("shadowMatrix1", csm.area1.shadowMatrix); setParameter("shadowMatrix2", csm.area2.shadowMatrix); setParameter("shadowMatrix3", csm.area3.shadowMatrix); setParameterSubroutine("shadowMap", ShaderType.Fragment, "shadowMapCascaded"); } else { glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D_ARRAY, defaultShadowTexture); setParameter("shadowTextureArray", 4); setParameter("shadowMatrix1", defaultShadowMatrix); setParameter("shadowMatrix2", defaultShadowMatrix); setParameter("shadowMatrix3", defaultShadowMatrix); setParameterSubroutine("shadowMap", ShaderType.Fragment, "shadowMapNone"); } } // Texture 5 - occlusion buffer if (glIsTexture(state.occlusionTexture)) { glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, state.occlusionTexture); setParameter("occlusionBuffer", 5); setParameter("haveOcclusionBuffer", true); } else { setParameter("haveOcclusionBuffer", false); } glActiveTexture(GL_TEXTURE0); super.bindParameters(state); } override void unbindParameters(GraphicsState* state) { super.unbindParameters(state); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D_ARRAY, 0); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); } }
D
module UnrealScript.TribesGame.TrFamilyInfo_Light_Architect_BE; import ScriptClasses; import UnrealScript.Helpers; import UnrealScript.TribesGame.TrFamilyInfo_Light_Architect; extern(C++) interface TrFamilyInfo_Light_Architect_BE : TrFamilyInfo_Light_Architect { public extern(D): private static __gshared ScriptClass mStaticClass; @property final static ScriptClass StaticClass() { mixin(MGSCC("Class TribesGame.TrFamilyInfo_Light_Architect_BE")); } private static __gshared TrFamilyInfo_Light_Architect_BE mDefaultProperties; @property final static TrFamilyInfo_Light_Architect_BE DefaultProperties() { mixin(MGDPC("TrFamilyInfo_Light_Architect_BE", "TrFamilyInfo_Light_Architect_BE TribesGame.Default__TrFamilyInfo_Light_Architect_BE")); } }
D
module org.serviio.delivery.resource.transcode.TranscodingConfiguration; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.serviio.library.metadata.MediaFileType; import org.serviio.delivery.resource.transcode.TranscodingDefinition; public class TranscodingConfiguration { private bool keepStreamOpen = true; private Map!(MediaFileType, List!(TranscodingDefinition)) config = new HashMap!(MediaFileType, List!(TranscodingDefinition))(); public List!(TranscodingDefinition) getDefinitions(MediaFileType fileType) { List!(TranscodingDefinition) result = cast(List!(TranscodingDefinition))this.config.get(fileType); if (result !is null) { return Collections.unmodifiableList(cast(List!(TranscodingDefinition))this.config.get(fileType)); } return Collections.emptyList!(TranscodingDefinition)(); } public List!(TranscodingDefinition) getDefinitions() { List!(TranscodingDefinition) result = new ArrayList!(TranscodingDefinition)(); foreach (List!(TranscodingDefinition) configs ; this.config.values()) { result.addAll(configs); } return Collections.unmodifiableList(result); } public void addDefinition(MediaFileType fileType, TranscodingDefinition definition) { if (!this.config.containsKey(fileType)) { this.config.put(fileType, new ArrayList!(TranscodingDefinition)()); } List!(TranscodingDefinition) defs = cast(List!(TranscodingDefinition))this.config.get(fileType); defs.add(definition); } public bool isKeepStreamOpen() { return this.keepStreamOpen; } public void setKeepStreamOpen(bool keepStreamOpen) { this.keepStreamOpen = keepStreamOpen; } } /* Location: C:\Users\Main\Downloads\serviio.jar * Qualified Name: org.serviio.delivery.resource.transcode.TranscodingConfiguration * JD-Core Version: 0.7.0.1 */
D
/* * DSFML - The Simple and Fast Multimedia Library for D * * Copyright (c) 2013 - 2018 Jeremy DeHaan ([email protected]) * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not claim * that you wrote the original software. If you use this software in a product, * an acknowledgment in the product documentation would be appreciated but is * not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution * * * DSFML is based on SFML (Copyright Laurent Gomila) */ /** * A sound buffer holds the data of a sound, which is an array of audio samples. * A sample is a 16 bits signed integer that defines the amplitude of the sound * at a given time. The sound is then restituted by playing these samples at a * high rate (for example, 44100 samples per second is the standard rate used * for playing CDs). In short, audio samples are like texture pixels, and a * SoundBuffer is similar to a Texture. * * A sound buffer can be loaded from a file (see `loadFromFile()` for the * complete list of supported formats), from memory, from a custom stream * (see $(INPUTSTREAM_LINK)) or directly from an array of samples. It can also * be saved back to a file. * * Sound buffers alone are not very useful: they hold the audio data but cannot * be played. To do so, you need to use the $(SOUND_LINK) class, which provides * functions to play/pause/stop the sound as well as changing the way it is * outputted (volume, pitch, 3D position, ...). * * This separation allows more flexibility and better performances: indeed a * $(U SoundBuffer) is a heavy resource, and any operation on it is slow (often * too slow for real-time applications). On the other side, a $(SOUND_LINK) is a * lightweight object, which can use the audio data of a sound buffer and change * the way it is played without actually modifying that data. Note that it is * also possible to bind several $(SOUND_LINK) instances to the same * $(U SoundBuffer). * * It is important to note that the Sound instance doesn't copy the buffer that * it uses, it only keeps a reference to it. Thus, a $(U SoundBuffer) must not * be destructed while it is used by a Sound (i.e. never write a function that * uses a local $(U SoundBuffer) instance for loading a sound). * *Example: * --- * // Declare a new sound buffer * auto buffer = SoundBuffer(); * * // Load it from a file * if (!buffer.loadFromFile("sound.wav")) * { * // error... * } * * // Create a sound source and bind it to the buffer * auto sound1 = new Sound(); * sound1.setBuffer(buffer); * * // Play the sound * sound1.play(); * * // Create another sound source bound to the same buffer * auto sound2 = new Sound(); * sound2.setBuffer(buffer); * * // Play it with a higher pitch -- the first sound remains unchanged * sound2.pitch = 2; * sound2.play(); * --- * * See_Also: * $(SOUND_LINK), $(SOUNDBUFFERRECORDER_LINK) */ module dsfml.audio.soundbuffer; public import dsfml.system.time; import dsfml.audio.inputsoundfile; import dsfml.audio.sound; import dsfml.system.inputstream; import std.stdio; import std.string; import std.algorithm; import std.array; import dsfml.system.err; /** * Storage for audio samples defining a sound. */ class SoundBuffer { package sfSoundBuffer* sfPtr; /// Default constructor. this() { sfPtr = sfSoundBuffer_construct(); } /// Destructor. ~this() { import dsfml.system.config; mixin(destructorOutput); sfSoundBuffer_destroy(sfPtr); } /** * Get the array of audio samples stored in the buffer. * * The format of the returned samples is 16 bits signed integer (short). * * Returns: Read-only array of sound samples. */ const(short[]) getSamples() const { auto sampleCount = sfSoundBuffer_getSampleCount(sfPtr); if(sampleCount > 0) return sfSoundBuffer_getSamples(sfPtr)[0 .. sampleCount]; return null; } /** * Get the sample rate of the sound. * * The sample rate is the number of samples played per second. The higher, * the better the quality (for example, 44100 samples/s is CD quality). * * Returns: Sample rate (number of samples per second). */ uint getSampleRate() const { return sfSoundBuffer_getSampleRate(sfPtr); } /** * Get the number of channels used by the sound. * * If the sound is mono then the number of channels will be 1, 2 for stereo, * etc. * * Returns: Number of channels. */ uint getChannelCount() const { return sfSoundBuffer_getChannelCount(sfPtr); } /** * Get the total duration of the sound. * * Returns: Sound duration. */ Time getDuration() const { return microseconds(sfSoundBuffer_getDuration(sfPtr)); } /** * Load the sound buffer from a file. * * The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The * supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. * * Params: * filename = Path of the sound file to load * * Returns: true if loading succeeded, false if it failed. */ bool loadFromFile(const(char)[] filename) { return sfSoundBuffer_loadFromFile(sfPtr, filename.ptr, filename.length); } /** * Load the sound buffer from a file in memory. * * The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The * supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. * * Params: * data = The array of data * * Returns: true if loading succeeded, false if it failed. */ bool loadFromMemory(const(void)[] data) { return sfSoundBuffer_loadFromMemory(sfPtr, data.ptr, data.length); } /* * Load the sound buffer from a custom stream. * * The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. The * supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. * * Params: * stream = Source stream to read from * * Returns: true if loading succeeded, false if it failed. */ bool loadFromStream(InputStream stream) { return sfSoundBuffer_loadFromStream(sfPtr, new SoundBufferStream(stream)); } /** * Load the sound buffer from an array of audio samples. * * The assumed format of the audio samples is 16 bits signed integer * (short). * * Params: * samples = Array of samples in memory * channelCount = Number of channels (1 = mono, 2 = stereo, ...) * sampleRate = Sample rate (number of samples to play per second) * * Returns: true if loading succeeded, false if it failed. */ bool loadFromSamples(const(short[]) samples, uint channelCount, uint sampleRate) { return sfSoundBuffer_loadFromSamples(sfPtr, samples.ptr, samples.length, channelCount, sampleRate); } /** * Save the sound buffer to an audio file. * * The supported audio formats are: WAV, OGG/Vorbis, FLAC. * * Params: * filename = Path of the sound file to write * * Returns: true if saving succeeded, false if it failed. */ bool saveToFile(const(char)[] filename) const { return sfSoundBuffer_saveToFile(sfPtr, filename.ptr, filename.length); } } unittest { version(DSFML_Unittest_Audio) { import std.stdio; writeln("Unit test for sound buffer"); auto soundbuffer = new SoundBuffer(); if(!soundbuffer.loadFromFile("res/TestSound.ogg")) { //error return; } writeln("Sample Rate: ", soundbuffer.getSampleRate()); writeln("Channel Count: ", soundbuffer.getChannelCount()); writeln("Duration: ", soundbuffer.getDuration().asSeconds()); writeln("Sample Count: ", soundbuffer.getSamples().length); //use sound buffer here writeln(); } } private extern(C++) interface sfmlInputStream { long read(void* data, long size); long seek(long position); long tell(); long getSize(); } private class SoundBufferStream:sfmlInputStream { private InputStream myStream; this(InputStream stream) { myStream = stream; } extern(C++)long read(void* data, long size) { return myStream.read(data[0..cast(size_t)size]); } extern(C++)long seek(long position) { return myStream.seek(position); } extern(C++)long tell() { return myStream.tell(); } extern(C++)long getSize() { return myStream.getSize(); } } package struct sfSoundBuffer; private extern(C): sfSoundBuffer* sfSoundBuffer_construct(); bool sfSoundBuffer_loadFromFile(sfSoundBuffer* soundBuffer, const char* filename, size_t length); bool sfSoundBuffer_loadFromMemory(sfSoundBuffer* soundBuffer, const void* data, size_t sizeInBytes); bool sfSoundBuffer_loadFromStream(sfSoundBuffer* soundBuffer, sfmlInputStream stream); bool sfSoundBuffer_loadFromSamples(sfSoundBuffer* soundBuffer, const short* samples, size_t sampleCount, uint channelCount, uint sampleRate); sfSoundBuffer* sfSoundBuffer_copy(const sfSoundBuffer* soundBuffer); void sfSoundBuffer_destroy(sfSoundBuffer* soundBuffer); bool sfSoundBuffer_saveToFile(const sfSoundBuffer* soundBuffer, const char* filename, size_t length); const(short)* sfSoundBuffer_getSamples(const sfSoundBuffer* soundBuffer); size_t sfSoundBuffer_getSampleCount(const sfSoundBuffer* soundBuffer); uint sfSoundBuffer_getSampleRate(const sfSoundBuffer* soundBuffer); uint sfSoundBuffer_getChannelCount(const sfSoundBuffer* soundBuffer); long sfSoundBuffer_getDuration(const sfSoundBuffer* soundBuffer);
D
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QEGLFSFUNCTIONS_H #define QEGLFSFUNCTIONS_H public import qt.QtCore.QByteArray; public import qt.QtGui.QGuiApplication; QT_BEGIN_NAMESPACE class QEglFSFunctions { public: typedef void (*LoadKeymapType)(ref const(QString) filename); static QByteArray loadKeymapTypeIdentifier() { return QByteArrayLiteral("EglFSLoadKeymap"); } static void loadKeymap(ref const(QString) filename) { LoadKeymapType func = reinterpret_cast<LoadKeymapType>(QGuiApplication::platformFunction(loadKeymapTypeIdentifier())); if (func) func(filename); } }; QT_END_NAMESPACE #endif // QEGLFSFUNCTIONS_H
D
instance PAL_257_Ritter (Npc_Default) { // ------ NSC ------ name = NAME_RITTER; guild = GIL_PAL; id = 257; voice = 9; flags = NPC_FLAG_IMMORTAL; //NPC_FLAG_IMMORTAL oder 0 npctype = NPCTYPE_OCAMBIENT; // ------ Attribute ------ B_SetAttributesToChapter (self, 4); //setzt Attribute und LEVEL entsprechend dem angegebenen Kapitel (1-6) // ------ Kampf-Taktik ------ fight_tactic = FAI_HUMAN_MASTER; // MASTER / STRONG / COWARD // ------ Equippte Waffen ------ //Munition wird automatisch generiert, darf aber angegeben werden EquipItem (self, ItMw_1h_Pal_Sword); EquipItem (self, ItRw_Mil_Crossbow); // ------ Inventory ------ B_CreateAmbientInv (self); // ------ visuals ------ //Muss NACH Attributen kommen, weil in B_SetNpcVisual die Breite abh. v. STR skaliert wird B_SetNpcVisual (self, MALE, "Hum_Head_Bald", Face_N_NormalBart_Swiney, BodyTex_N, ITAR_PAL_M); Mdl_SetModelFatness (self, 1); Mdl_ApplyOverlayMds (self, "Humans_Militia.mds"); // Tired / Militia / Mage / Arrogance / Relaxed // ------ NSC-relevante Talente vergeben ------ B_GiveNpcTalents (self); // ------ Kampf-Talente ------ //Der enthaltene B_AddFightSkill setzt Talent-Ani abhängig von TrefferChance% - alle Kampftalente werden gleichhoch gesetzt B_SetFightSkills (self, 70); //Grenzen für Talent-Level liegen bei 30 und 60 // ------ TA anmelden ------ daily_routine = Rtn_Start_257; }; FUNC VOID Rtn_Start_257 () { TA_Practice_Sword (08,00,19,00,"OC_TRAIN_03"); TA_Sit_Campfire (19,00,08,00,"OC_CAMPFIRE_OUT_03"); }; FUNC VOID Rtn_Marcos_257 () { TA_Stand_Guarding (08,00,19,00,"OW_STAND_GUARDS"); TA_Stand_Guarding (19,00,08,00,"OW_STAND_GUARDS"); };
D
/******************************************************************//** * \file src/sfx/engine.d * \brief OpenAL sound engine * * <i>Copyright (c) 2012</i> Danny Arends<br> * Last modified Feb, 2012<br> * First written Dec, 2011<br> * Written in the D Programming Language (http://www.digitalmars.com/d) **********************************************************************/ module sfx.engine; import core.stdinc, core.terminal; import openal.al, openal.alc, openal.alut; import openal.alstructs, openal.alutstructs; import core.events.engine, sfx.formats.wav; mixin(GenOutput!("SFX", "Green")); /*! \brief EventHandler for all SFX related events * * The SFXEngine class is the main EventHandler for all SFX related events */ class SFXEngine : EventHandler{ public: this(){ try{ alutInit(cast(int*)0, cast(char**)""); if(alGetError() == AL_NO_ERROR){ wSFX("Sound initialized"); listDevices(); checkEAX(); }else{ ERR("ALUT initialization failed"); } }catch(Throwable t){ ERR("ALUT found, but it fails to load"); } } void load(){ sounds.length = 0; foreach(string e; dirEntries("data/sounds", SpanMode.breadth)){ e = e[e.indexOf("data/")..$]; if(isFile(e) && e.indexOf(".wav") > 0){ sounds ~= e; } } wSFX("Buffered %d sounds",sounds.length); } void listDevices(){ wSFX("Devices available: "); if(alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT".dup.ptr) == AL_TRUE){ wSFX("%s",to!string(cast(char*)alcGetString(null, ALC_DEVICE_SPECIFIER))); }else{ WARN("Device enumeration (ALC_ENUMERATION_EXT) not supported"); } } bool checkEAX(){ if(alIsExtensionPresent("EAX2.0".dup.ptr) == AL_TRUE){ hasEAX = true; wSFX("EAX 2.0 is supported"); }else{ WARN("EAX 2.0 not supported"); } return hasEAX; } wavInfo getSound(string name, bool verbose = false){ foreach(string e; sounds){ if(e.indexOf(name) > 0){ return loadSound(this, e, verbose); } } assert(0); } ALfloat* getSourcePos(){ return SourcePos.ptr; } ALfloat* getSourceVel(){ return SourceVel.ptr; } override void handle(Event e){ } private: string[] sounds; bool hasEAX = false; ALfloat SourcePos[3] = [0.0, 0.0, 0.0]; ALfloat SourceVel[3] = [0.0, 0.0, 0.0]; ALfloat ListenerPos[3] = [0.0, 0.0, 0.0]; ALfloat ListenerVel[3] = [0.0, 0.0, 0.0]; ALfloat ListenerOri[6] = [0.0, 0.0, -1.0, 0.0, 1.0, 0.0]; }
D
// Written in the D programming language. /** * Contains the elementary mathematical functions (powers, roots, * and trigonometric functions), and low-level floating-point operations. * Mathematical special functions are available in $(D std.mathspecial). * $(SCRIPT inhibitQuickIndex = 1;) $(DIVC quickindex, $(BOOKTABLE , $(TR $(TH Category) $(TH Members) ) $(TR $(TDNW Constants) $(TD $(MYREF E) $(MYREF PI) $(MYREF PI_2) $(MYREF PI_4) $(MYREF M_1_PI) $(MYREF M_2_PI) $(MYREF M_2_SQRTPI) $(MYREF LN10) $(MYREF LN2) $(MYREF LOG2) $(MYREF LOG2E) $(MYREF LOG2T) $(MYREF LOG10E) $(MYREF SQRT2) $(MYREF SQRT1_2) )) $(TR $(TDNW Classics) $(TD $(MYREF abs) $(MYREF fabs) $(MYREF sqrt) $(MYREF cbrt) $(MYREF hypot) $(MYREF poly) $(MYREF nextPow2) $(MYREF truncPow2) )) $(TR $(TDNW Trigonometry) $(TD $(MYREF sin) $(MYREF cos) $(MYREF tan) $(MYREF asin) $(MYREF acos) $(MYREF atan) $(MYREF atan2) $(MYREF sinh) $(MYREF cosh) $(MYREF tanh) $(MYREF asinh) $(MYREF acosh) $(MYREF atanh) $(MYREF expi) )) $(TR $(TDNW Rounding) $(TD $(MYREF ceil) $(MYREF floor) $(MYREF round) $(MYREF lround) $(MYREF trunc) $(MYREF rint) $(MYREF lrint) $(MYREF nearbyint) $(MYREF rndtol) $(MYREF quantize) )) $(TR $(TDNW Exponentiation & Logarithms) $(TD $(MYREF pow) $(MYREF exp) $(MYREF exp2) $(MYREF expm1) $(MYREF ldexp) $(MYREF frexp) $(MYREF log) $(MYREF log2) $(MYREF log10) $(MYREF logb) $(MYREF ilogb) $(MYREF log1p) $(MYREF scalbn) )) $(TR $(TDNW Modulus) $(TD $(MYREF fmod) $(MYREF modf) $(MYREF remainder) )) $(TR $(TDNW Floating-point operations) $(TD $(MYREF approxEqual) $(MYREF feqrel) $(MYREF fdim) $(MYREF fmax) $(MYREF fmin) $(MYREF fma) $(MYREF nextDown) $(MYREF nextUp) $(MYREF nextafter) $(MYREF NaN) $(MYREF getNaNPayload) $(MYREF cmp) )) $(TR $(TDNW Introspection) $(TD $(MYREF isFinite) $(MYREF isIdentical) $(MYREF isInfinity) $(MYREF isNaN) $(MYREF isNormal) $(MYREF isSubnormal) $(MYREF signbit) $(MYREF sgn) $(MYREF copysign) $(MYREF isPowerOf2) )) $(TR $(TDNW Complex Numbers) $(TD $(MYREF abs) $(MYREF conj) $(MYREF sin) $(MYREF cos) $(MYREF expi) )) $(TR $(TDNW Hardware Control) $(TD $(MYREF IeeeFlags) $(MYREF FloatingPointControl) )) ) ) * The functionality closely follows the IEEE754-2008 standard for * floating-point arithmetic, including the use of camelCase names rather * than C99-style lower case names. All of these functions behave correctly * when presented with an infinity or NaN. * * The following IEEE 'real' formats are currently supported: * $(UL * $(LI 64 bit Big-endian 'double' (eg PowerPC)) * $(LI 128 bit Big-endian 'quadruple' (eg SPARC)) * $(LI 64 bit Little-endian 'double' (eg x86-SSE2)) * $(LI 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)) * $(LI 128 bit Little-endian 'quadruple' (not implemented on any known processor!)) * $(LI Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support) * ) * Unlike C, there is no global 'errno' variable. Consequently, almost all of * these functions are pure nothrow. * * Status: * The semantics and names of feqrel and approxEqual will be revised. * * Macros: * TABLE_SV = <table border="1" cellpadding="4" cellspacing="0"> * <caption>Special Values</caption> * $0</table> * SVH = $(TR $(TH $1) $(TH $2)) * SV = $(TR $(TD $1) $(TD $2)) * TH3 = $(TR $(TH $1) $(TH $2) $(TH $3)) * TD3 = $(TR $(TD $1) $(TD $2) $(TD $3)) * TABLE_DOMRG = <table border="1" cellpadding="4" cellspacing="0"> * $(SVH Domain X, Range Y) $(SV $1, $2) * </table> * DOMAIN=$1 * RANGE=$1 * NAN = $(RED NAN) * SUP = <span style="vertical-align:super;font-size:smaller">$0</span> * GAMMA = &#915; * THETA = &theta; * INTEGRAL = &#8747; * INTEGRATE = $(BIG &#8747;<sub>$(SMALL $1)</sub><sup>$2</sup>) * POWER = $1<sup>$2</sup> * SUB = $1<sub>$2</sub> * BIGSUM = $(BIG &Sigma; <sup>$2</sup><sub>$(SMALL $1)</sub>) * CHOOSE = $(BIG &#40;) <sup>$(SMALL $1)</sup><sub>$(SMALL $2)</sub> $(BIG &#41;) * PLUSMN = &plusmn; * INFIN = &infin; * PLUSMNINF = &plusmn;&infin; * PI = &pi; * LT = &lt; * GT = &gt; * SQRT = &radic; * HALF = &frac12; * * Copyright: Copyright Digital Mars 2000 - 2011. * D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, * log2, floor, ceil and lrint functions are based on the CEPHES math library, * which is Copyright (C) 2001 Stephen L. Moshier $(LT)[email protected]$(GT) * and are incorporated herein by permission of the author. The author * reserves the right to distribute this material elsewhere under different * copying permissions. These modifications are distributed here under * the following terms: * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: $(HTTP digitalmars.com, Walter Bright), Don Clugston, * Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger * Source: $(PHOBOSSRC std/_math.d) */ module std.math; version (Win64) { version (D_InlineAsm_X86_64) version = Win64_DMD_InlineAsm; } static import core.math; static import core.stdc.math; import std.traits; // CommonType, isFloatingPoint, isIntegral, isSigned, isUnsigned, Largest, Unqual version(LDC) { import ldc.intrinsics; } version(DigitalMars) { version = INLINE_YL2X; // x87 has opcodes for these } version (X86) version = X86_Any; version (X86_64) version = X86_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; version(D_InlineAsm_X86) { version = InlineAsm_X86_Any; } else version(D_InlineAsm_X86_64) { version = InlineAsm_X86_Any; } version (X86_64) version = StaticallyHaveSSE; version (X86) version (OSX) version = StaticallyHaveSSE; version (StaticallyHaveSSE) { private enum bool haveSSE = true; } else { static import core.cpuid; private alias haveSSE = core.cpuid.sse; } version(unittest) { import core.stdc.stdio; // : sprintf; static if (real.sizeof > double.sizeof) enum uint useDigits = 16; else enum uint useDigits = 15; /****************************************** * Compare floating point numbers to n decimal digits of precision. * Returns: * 1 match * 0 nomatch */ private bool equalsDigit(real x, real y, uint ndigits) { if (signbit(x) != signbit(y)) return 0; if (isInfinity(x) && isInfinity(y)) return 1; if (isInfinity(x) || isInfinity(y)) return 0; if (isNaN(x) && isNaN(y)) return 1; if (isNaN(x) || isNaN(y)) return 0; char[30] bufx; char[30] bufy; assert(ndigits < bufx.length); int ix; int iy; version(CRuntime_Microsoft) alias real_t = double; else alias real_t = real; ix = sprintf(bufx.ptr, "%.*Lg", ndigits, cast(real_t) x); iy = sprintf(bufy.ptr, "%.*Lg", ndigits, cast(real_t) y); assert(ix < bufx.length && ix > 0); assert(ix < bufy.length && ix > 0); return bufx[0 .. ix] == bufy[0 .. iy]; } } package: // The following IEEE 'real' formats are currently supported. version(LittleEndian) { static assert(real.mant_dig == 53 || real.mant_dig == 64 || real.mant_dig == 113, "Only 64-bit, 80-bit, and 128-bit reals"~ " are supported for LittleEndian CPUs"); } else { static assert(real.mant_dig == 53 || real.mant_dig == 106 || real.mant_dig == 113, "Only 64-bit and 128-bit reals are supported for BigEndian CPUs."~ " double-double reals have partial support"); } // Underlying format exposed through floatTraits enum RealFormat { ieeeHalf, ieeeSingle, ieeeDouble, ieeeExtended, // x87 80-bit real ieeeExtended53, // x87 real rounded to precision of double. ibmExtended, // IBM 128-bit extended ieeeQuadruple, } // Constants used for extracting the components of the representation. // They supplement the built-in floating point properties. template floatTraits(T) { // EXPMASK is a ushort mask to select the exponent portion (without sign) // EXPSHIFT is the number of bits the exponent is left-shifted by in its ushort // EXPBIAS is the exponent bias - 1 (exp == EXPBIAS yields ×2^-1). // EXPPOS_SHORT is the index of the exponent when represented as a ushort array. // SIGNPOS_BYTE is the index of the sign when represented as a ubyte array. // RECIP_EPSILON is the value such that (smallest_subnormal) * RECIP_EPSILON == T.min_normal enum T RECIP_EPSILON = (1/T.epsilon); static if (T.mant_dig == 24) { // Single precision float enum ushort EXPMASK = 0x7F80; enum ushort EXPSHIFT = 7; enum ushort EXPBIAS = 0x3F00; enum uint EXPMASK_INT = 0x7F80_0000; enum uint MANTISSAMASK_INT = 0x007F_FFFF; enum realFormat = RealFormat.ieeeSingle; version(LittleEndian) { enum EXPPOS_SHORT = 1; enum SIGNPOS_BYTE = 3; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 53) { static if (T.sizeof == 8) { // Double precision float, or real == double enum ushort EXPMASK = 0x7FF0; enum ushort EXPSHIFT = 4; enum ushort EXPBIAS = 0x3FE0; enum uint EXPMASK_INT = 0x7FF0_0000; enum uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only enum realFormat = RealFormat.ieeeDouble; version(LittleEndian) { enum EXPPOS_SHORT = 3; enum SIGNPOS_BYTE = 7; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.sizeof == 12) { // Intel extended real80 rounded to double enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended53; version(LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static assert(false, "No traits support for " ~ T.stringof); } else static if (T.mant_dig == 64) { // Intel extended real80 enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended; version(LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 113) { // Quadruple precision float enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeQuadruple; version(LittleEndian) { enum EXPPOS_SHORT = 7; enum SIGNPOS_BYTE = 15; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 106) { // IBM Extended doubledouble enum ushort EXPMASK = 0x7FF0; enum ushort EXPSHIFT = 4; enum realFormat = RealFormat.ibmExtended; // the exponent byte is not unique version(LittleEndian) { enum EXPPOS_SHORT = 7; // [3] is also an exp short enum SIGNPOS_BYTE = 15; } else { enum EXPPOS_SHORT = 0; // [4] is also an exp short enum SIGNPOS_BYTE = 0; } } else static assert(false, "No traits support for " ~ T.stringof); } // These apply to all floating-point types version(LittleEndian) { enum MANTISSA_LSB = 0; enum MANTISSA_MSB = 1; } else { enum MANTISSA_LSB = 1; enum MANTISSA_MSB = 0; } // Common code for math implementations. // Helper for floor/ceil T floorImpl(T)(const T x) @trusted pure nothrow @nogc { alias F = floatTraits!(T); // Take care not to trigger library calls from the compiler, // while ensuring that we don't get defeated by some optimizers. union floatBits { T rv; ushort[T.sizeof/2] vu; } floatBits y = void; y.rv = x; // Find the exponent (power of 2) static if (F.realFormat == RealFormat.ieeeSingle) { int exp = ((y.vu[F.EXPPOS_SHORT] >> 7) & 0xff) - 0x7f; version (LittleEndian) int pos = 0; else int pos = 3; } else static if (F.realFormat == RealFormat.ieeeDouble) { int exp = ((y.vu[F.EXPPOS_SHORT] >> 4) & 0x7ff) - 0x3ff; version (LittleEndian) int pos = 0; else int pos = 3; } else static if (F.realFormat == RealFormat.ieeeExtended) { int exp = (y.vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) int pos = 0; else int pos = 4; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { int exp = (y.vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) int pos = 0; else int pos = 7; } else static assert(false, "Not implemented for this architecture"); if (exp < 0) { if (x < 0.0) return -1.0; else return 0.0; } exp = (T.mant_dig - 1) - exp; // Zero 16 bits at a time. while (exp >= 16) { version (LittleEndian) y.vu[pos++] = 0; else y.vu[pos--] = 0; exp -= 16; } // Clear the remaining bits. if (exp > 0) y.vu[pos] &= 0xffff ^ ((1 << exp) - 1); if ((x < 0.0) && (x != y.rv)) y.rv -= 1.0; return y.rv; } public: // Values obtained from Wolfram Alpha. 116 bits ought to be enough for anybody. // Wolfram Alpha LLC. 2011. Wolfram|Alpha. http://www.wolframalpha.com/input/?i=e+in+base+16 (access July 6, 2011). enum real E = 0x1.5bf0a8b1457695355fb8ac404e7a8p+1L; /** e = 2.718281... */ enum real LOG2T = 0x1.a934f0979a3715fc9257edfe9b5fbp+1L; /** $(SUB log, 2)10 = 3.321928... */ enum real LOG2E = 0x1.71547652b82fe1777d0ffda0d23a8p+0L; /** $(SUB log, 2)e = 1.442695... */ enum real LOG2 = 0x1.34413509f79fef311f12b35816f92p-2L; /** $(SUB log, 10)2 = 0.301029... */ enum real LOG10E = 0x1.bcb7b1526e50e32a6ab7555f5a67cp-2L; /** $(SUB log, 10)e = 0.434294... */ enum real LN2 = 0x1.62e42fefa39ef35793c7673007e5fp-1L; /** ln 2 = 0.693147... */ enum real LN10 = 0x1.26bb1bbb5551582dd4adac5705a61p+1L; /** ln 10 = 2.302585... */ enum real PI = 0x1.921fb54442d18469898cc51701b84p+1L; /** $(_PI) = 3.141592... */ enum real PI_2 = PI/2; /** $(PI) / 2 = 1.570796... */ enum real PI_4 = PI/4; /** $(PI) / 4 = 0.785398... */ enum real M_1_PI = 0x1.45f306dc9c882a53f84eafa3ea69cp-2L; /** 1 / $(PI) = 0.318309... */ enum real M_2_PI = 2*M_1_PI; /** 2 / $(PI) = 0.636619... */ enum real M_2_SQRTPI = 0x1.20dd750429b6d11ae3a914fed7fd8p+0L; /** 2 / $(SQRT)$(PI) = 1.128379... */ enum real SQRT2 = 0x1.6a09e667f3bcc908b2fb1366ea958p+0L; /** $(SQRT)2 = 1.414213... */ enum real SQRT1_2 = SQRT2/2; /** $(SQRT)$(HALF) = 0.707106... */ // Note: Make sure the magic numbers in compiler backend for x87 match these. /*********************************** * Calculates the absolute value of a number * * Params: * Num = (template parameter) type of number * x = real number value * z = complex number value * y = imaginary number value * * Returns: * The absolute value of the number. If floating-point or integral, * the return type will be the same as the input; if complex or * imaginary, the returned value will be the corresponding floating * point type. * * For complex numbers, abs(z) = sqrt( $(POWER z.re, 2) + $(POWER z.im, 2) ) * = hypot(z.re, z.im). */ Num abs(Num)(Num x) @safe pure nothrow if (is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) && !(is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*)))) { static if (isFloatingPoint!(Num)) return fabs(x); else return x >= 0 ? x : -x; } /// ditto auto abs(Num)(Num z) @safe pure nothrow @nogc if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* : const(creal*))) { return hypot(z.re, z.im); } /// ditto auto abs(Num)(Num y) @safe pure nothrow @nogc if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))) { return fabs(y.im); } /// ditto @safe pure nothrow @nogc unittest { assert(isIdentical(abs(-0.0L), 0.0L)); assert(isNaN(abs(real.nan))); assert(abs(-real.infinity) == real.infinity); assert(abs(-3.2Li) == 3.2L); assert(abs(71.6Li) == 71.6L); assert(abs(-56) == 56); assert(abs(2321312L) == 2321312L); assert(abs(-1L+1i) == sqrt(2.0L)); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { T f = 3; assert(abs(f) == f); assert(abs(-f) == f); } foreach (T; AliasSeq!(cfloat, cdouble, creal)) { T f = -12+3i; assert(abs(f) == hypot(f.re, f.im)); assert(abs(-f) == hypot(f.re, f.im)); } } /*********************************** * Complex conjugate * * conj(x + iy) = x - iy * * Note that z * conj(z) = $(POWER z.re, 2) - $(POWER z.im, 2) * is always a real number */ auto conj(Num)(Num z) @safe pure nothrow @nogc if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* : const(creal*))) { //FIXME //Issue 14206 static if (is(Num* : const(cdouble*))) return cast(cdouble) conj(cast(creal) z); else return z.re - z.im*1fi; } /** ditto */ auto conj(Num)(Num y) @safe pure nothrow @nogc if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))) { return -y; } /// @safe pure nothrow @nogc unittest { creal c = 7 + 3Li; assert(conj(c) == 7-3Li); ireal z = -3.2Li; assert(conj(z) == -z); } //Issue 14206 @safe pure nothrow @nogc unittest { cdouble c = 7 + 3i; assert(conj(c) == 7-3i); idouble z = -3.2i; assert(conj(z) == -z); } //Issue 14206 @safe pure nothrow @nogc unittest { cfloat c = 7f + 3fi; assert(conj(c) == 7f-3fi); ifloat z = -3.2fi; assert(conj(z) == -z); } /*********************************** * Returns cosine of x. x is in radians. * * $(TABLE_SV * $(TR $(TH x) $(TH cos(x)) $(TH invalid?)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) $(TD yes) ) * ) * Bugs: * Results are undefined if |x| >= $(POWER 2,64). */ real cos(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.cos(x); } //FIXME ///ditto double cos(double x) @safe pure nothrow @nogc { return cos(cast(real) x); } //FIXME ///ditto float cos(float x) @safe pure nothrow @nogc { return cos(cast(real) x); } @safe unittest { real function(real) pcos = &cos; assert(pcos != null); } /*********************************** * Returns $(HTTP en.wikipedia.org/wiki/Sine, sine) of x. x is in $(HTTP en.wikipedia.org/wiki/Radian, radians). * * $(TABLE_SV * $(TH3 x , sin(x) , invalid?) * $(TD3 $(NAN) , $(NAN) , yes ) * $(TD3 $(PLUSMN)0.0, $(PLUSMN)0.0, no ) * $(TD3 $(PLUSMNINF), $(NAN) , yes ) * ) * * Params: * x = angle in radians (not degrees) * Returns: * sine of x * See_Also: * $(MYREF cos), $(MYREF tan), $(MYREF asin) * Bugs: * Results are undefined if |x| >= $(POWER 2,64). */ real sin(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.sin(x); } //FIXME ///ditto double sin(double x) @safe pure nothrow @nogc { return sin(cast(real) x); } //FIXME ///ditto float sin(float x) @safe pure nothrow @nogc { return sin(cast(real) x); } /// @safe unittest { import std.math : sin, PI; import std.stdio : writefln; void someFunc() { real x = 30.0; auto result = sin(x * (PI / 180)); // convert degrees to radians writefln("The sine of %s degrees is %s", x, result); } } @safe unittest { real function(real) psin = &sin; assert(psin != null); } /*********************************** * Returns sine for complex and imaginary arguments. * * sin(z) = sin(z.re)*cosh(z.im) + cos(z.re)*sinh(z.im)i * * If both sin($(THETA)) and cos($(THETA)) are required, * it is most efficient to use expi($(THETA)). */ creal sin(creal z) @safe pure nothrow @nogc { const creal cs = expi(z.re); const creal csh = coshisinh(z.im); return cs.im * csh.re + cs.re * csh.im * 1i; } /** ditto */ ireal sin(ireal y) @safe pure nothrow @nogc { return cosh(y.im)*1i; } /// @safe pure nothrow @nogc unittest { assert(sin(0.0+0.0i) == 0.0); assert(sin(2.0+0.0i) == sin(2.0L) ); } /*********************************** * cosine, complex and imaginary * * cos(z) = cos(z.re)*cosh(z.im) - sin(z.re)*sinh(z.im)i */ creal cos(creal z) @safe pure nothrow @nogc { const creal cs = expi(z.re); const creal csh = coshisinh(z.im); return cs.re * csh.re - cs.im * csh.im * 1i; } /** ditto */ real cos(ireal y) @safe pure nothrow @nogc { return cosh(y.im); } /// @safe pure nothrow @nogc unittest { assert(cos(0.0+0.0i)==1.0); assert(cos(1.3L+0.0i)==cos(1.3L)); assert(cos(5.2Li)== cosh(5.2L)); } /**************************************************************************** * Returns tangent of x. x is in radians. * * $(TABLE_SV * $(TR $(TH x) $(TH tan(x)) $(TH invalid?)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD $(NAN)) $(TD yes)) * ) */ real tan(real x) @trusted pure nothrow @nogc { version(D_InlineAsm_X86) { asm pure nothrow @nogc { fld x[EBP] ; // load theta fxam ; // test for oddball values fstsw AX ; sahf ; jc trigerr ; // x is NAN, infinity, or empty // 387's can handle subnormals SC18: fptan ; fstsw AX ; sahf ; jnp Clear1 ; // C2 = 1 (x is out of range) // Do argument reduction to bring x into range fldpi ; fxch ; SC17: fprem1 ; fstsw AX ; sahf ; jp SC17 ; fstp ST(1) ; // remove pi from stack jmp SC18 ; trigerr: jnp Lret ; // if theta is NAN, return theta fstp ST(0) ; // dump theta } return real.nan; Clear1: asm pure nothrow @nogc{ fstp ST(0) ; // dump X, which is always 1 } Lret: {} } else version(D_InlineAsm_X86_64) { version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX] ; // load theta } } else { asm pure nothrow @nogc { fld x[RBP] ; // load theta } } asm pure nothrow @nogc { fxam ; // test for oddball values fstsw AX ; test AH,1 ; jnz trigerr ; // x is NAN, infinity, or empty // 387's can handle subnormals SC18: fptan ; fstsw AX ; test AH,4 ; jz Clear1 ; // C2 = 1 (x is out of range) // Do argument reduction to bring x into range fldpi ; fxch ; SC17: fprem1 ; fstsw AX ; test AH,4 ; jnz SC17 ; fstp ST(1) ; // remove pi from stack jmp SC18 ; trigerr: test AH,4 ; jz Lret ; // if theta is NAN, return theta fstp ST(0) ; // dump theta } return real.nan; Clear1: asm pure nothrow @nogc{ fstp ST(0) ; // dump X, which is always 1 } Lret: {} } else { // Coefficients for tan(x) and PI/4 split into three parts. static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { static immutable real[6] P = [ 2.883414728874239697964612246732416606301E10L, -2.307030822693734879744223131873392503321E9L, 5.160188250214037865511600561074819366815E7L, -4.249691853501233575668486667664718192660E5L, 1.272297782199996882828849455156962260810E3L, -9.889929415807650724957118893791829849557E-1L ]; static immutable real[7] Q = [ 8.650244186622719093893836740197250197602E10L -4.152206921457208101480801635640958361612E10L, 2.758476078803232151774723646710890525496E9L, -5.733709132766856723608447733926138506824E7L, 4.529422062441341616231663543669583527923E5L, -1.317243702830553658702531997959756728291E3L, 1.0 ]; enum real DP1 = 7.853981633974483067550664827649598009884357452392578125E-1L; enum real DP2 = 2.8605943630549158983813312792950660807511260829685741796657E-18L; enum real DP3 = 2.1679525325309452561992610065108379921905808E-35L; } else { static immutable real[3] P = [ -1.7956525197648487798769E7L, 1.1535166483858741613983E6L, -1.3093693918138377764608E4L, ]; static immutable real[5] Q = [ -5.3869575592945462988123E7L, 2.5008380182335791583922E7L, -1.3208923444021096744731E6L, 1.3681296347069295467845E4L, 1.0000000000000000000000E0L, ]; enum real P1 = 7.853981554508209228515625E-1L; enum real P2 = 7.946627356147928367136046290398E-9L; enum real P3 = 3.061616997868382943065164830688E-17L; } // Special cases. if (x == 0.0 || isNaN(x)) return x; if (isInfinity(x)) return real.nan; // Make argument positive but save the sign. bool sign = false; if (signbit(x)) { sign = true; x = -x; } // Compute x mod PI/4. real y = floor(x / PI_4); // Strip high bits of integer part. real z = ldexp(y, -4); // Compute y - 16 * (y / 16). z = y - ldexp(floor(z), 4); // Integer and fraction part modulo one octant. int j = cast(int)(z); // Map zeros and singularities to origin. if (j & 1) { j += 1; y += 1.0; } z = ((x - y * P1) - y * P2) - y * P3; const real zz = z * z; if (zz > 1.0e-20L) y = z + z * (zz * poly(zz, P) / poly(zz, Q)); else y = z; if (j & 2) y = -1.0 / y; return (sign) ? -y : y; } } @safe nothrow @nogc unittest { static real[2][] vals = // angle,tan [ [ 0, 0], [ .5, .5463024898], [ 1, 1.557407725], [ 1.5, 14.10141995], [ 2, -2.185039863], [ 2.5,-.7470222972], [ 3, -.1425465431], [ 3.5, .3745856402], [ 4, 1.157821282], [ 4.5, 4.637332055], [ 5, -3.380515006], [ 5.5,-.9955840522], [ 6, -.2910061914], [ 6.5, .2202772003], [ 10, .6483608275], // special angles [ PI_4, 1], //[ PI_2, real.infinity], // PI_2 is not _exactly_ pi/2. [ 3*PI_4, -1], [ PI, 0], [ 5*PI_4, 1], //[ 3*PI_2, -real.infinity], [ 7*PI_4, -1], [ 2*PI, 0], ]; int i; for (i = 0; i < vals.length; i++) { real x = vals[i][0]; real r = vals[i][1]; real t = tan(x); //printf("tan(%Lg) = %Lg, should be %Lg\n", x, t, r); if (!isIdentical(r, t)) assert(fabs(r-t) <= .0000001); x = -x; r = -r; t = tan(x); //printf("tan(%Lg) = %Lg, should be %Lg\n", x, t, r); if (!isIdentical(r, t) && !(r != r && t != t)) assert(fabs(r-t) <= .0000001); } // overflow assert(isNaN(tan(real.infinity))); assert(isNaN(tan(-real.infinity))); // NaN propagation assert(isIdentical( tan(NaN(0x0123L)), NaN(0x0123L) )); } @system unittest { assert(equalsDigit(tan(PI / 3), std.math.sqrt(3.0), useDigits)); } /*************** * Calculates the arc cosine of x, * returning a value ranging from 0 to $(PI). * * $(TABLE_SV * $(TR $(TH x) $(TH acos(x)) $(TH invalid?)) * $(TR $(TD $(GT)1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes)) * ) */ real acos(real x) @safe pure nothrow @nogc { return atan2(sqrt(1-x*x), x); } /// ditto double acos(double x) @safe pure nothrow @nogc { return acos(cast(real) x); } /// ditto float acos(float x) @safe pure nothrow @nogc { return acos(cast(real) x); } @system unittest { assert(equalsDigit(acos(0.5), std.math.PI / 3, useDigits)); } /*************** * Calculates the arc sine of x, * returning a value ranging from -$(PI)/2 to $(PI)/2. * * $(TABLE_SV * $(TR $(TH x) $(TH asin(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(GT)1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD yes)) * ) */ real asin(real x) @safe pure nothrow @nogc { return atan2(x, sqrt(1-x*x)); } /// ditto double asin(double x) @safe pure nothrow @nogc { return asin(cast(real) x); } /// ditto float asin(float x) @safe pure nothrow @nogc { return asin(cast(real) x); } @system unittest { assert(equalsDigit(asin(0.5), PI / 6, useDigits)); } /*************** * Calculates the arc tangent of x, * returning a value ranging from -$(PI)/2 to $(PI)/2. * * $(TABLE_SV * $(TR $(TH x) $(TH atan(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) $(TD yes)) * ) */ real atan(real x) @safe pure nothrow @nogc { version(InlineAsm_X86_Any) { return atan2(x, 1.0L); } else { // Coefficients for atan(x) static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { static immutable real[9] P = [ -6.880597774405940432145577545328795037141E2L, -2.514829758941713674909996882101723647996E3L, -3.696264445691821235400930243493001671932E3L, -2.792272753241044941703278827346430350236E3L, -1.148164399808514330375280133523543970854E3L, -2.497759878476618348858065206895055957104E2L, -2.548067867495502632615671450650071218995E1L, -8.768423468036849091777415076702113400070E-1L, -6.635810778635296712545011270011752799963E-4L ]; static immutable real[9] Q = [ 2.064179332321782129643673263598686441900E3L, 8.782996876218210302516194604424986107121E3L, 1.547394317752562611786521896296215170819E4L, 1.458510242529987155225086911411015961174E4L, 7.928572347062145288093560392463784743935E3L, 2.494680540950601626662048893678584497900E3L, 4.308348370818927353321556740027020068897E2L, 3.566239794444800849656497338030115886153E1L, 1.0 ]; } else { static immutable real[5] P = [ -5.0894116899623603312185E1L, -9.9988763777265819915721E1L, -6.3976888655834347413154E1L, -1.4683508633175792446076E1L, -8.6863818178092187535440E-1L, ]; static immutable real[6] Q = [ 1.5268235069887081006606E2L, 3.9157570175111990631099E2L, 3.6144079386152023162701E2L, 1.4399096122250781605352E2L, 2.2981886733594175366172E1L, 1.0000000000000000000000E0L, ]; } // tan(PI/8) enum real TAN_PI_8 = 0.414213562373095048801688724209698078569672L; // tan(3 * PI/8) enum real TAN3_PI_8 = 2.414213562373095048801688724209698078569672L; // Special cases. if (x == 0.0) return x; if (isInfinity(x)) return copysign(PI_2, x); // Make argument positive but save the sign. bool sign = false; if (signbit(x)) { sign = true; x = -x; } // Range reduction. real y; if (x > TAN3_PI_8) { y = PI_2; x = -(1.0 / x); } else if (x > TAN_PI_8) { y = PI_4; x = (x - 1.0)/(x + 1.0); } else y = 0.0; // Rational form in x^^2. const real z = x * x; y = y + (poly(z, P) / poly(z, Q)) * z * x + x; return (sign) ? -y : y; } } /// ditto double atan(double x) @safe pure nothrow @nogc { return atan(cast(real) x); } /// ditto float atan(float x) @safe pure nothrow @nogc { return atan(cast(real) x); } @system unittest { assert(equalsDigit(atan(std.math.sqrt(3.0)), PI / 3, useDigits)); } /*************** * Calculates the arc tangent of y / x, * returning a value ranging from -$(PI) to $(PI). * * $(TABLE_SV * $(TR $(TH y) $(TH x) $(TH atan(y, x))) * $(TR $(TD $(NAN)) $(TD anything) $(TD $(NAN)) ) * $(TR $(TD anything) $(TD $(NAN)) $(TD $(NAN)) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(GT)0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)0.0) $(TD +0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(LT)0.0) $(TD $(PLUSMN)$(PI))) * $(TR $(TD $(PLUSMN)0.0) $(TD -0.0) $(TD $(PLUSMN)$(PI))) * $(TR $(TD $(GT)0.0) $(TD $(PLUSMN)0.0) $(TD $(PI)/2) ) * $(TR $(TD $(LT)0.0) $(TD $(PLUSMN)0.0) $(TD -$(PI)/2) ) * $(TR $(TD $(GT)0.0) $(TD $(INFIN)) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD anything) $(TD $(PLUSMN)$(PI)/2)) * $(TR $(TD $(GT)0.0) $(TD -$(INFIN)) $(TD $(PLUSMN)$(PI)) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(INFIN)) $(TD $(PLUSMN)$(PI)/4)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD -$(INFIN)) $(TD $(PLUSMN)3$(PI)/4)) * ) */ real atan2(real y, real x) @trusted pure nothrow @nogc { version(InlineAsm_X86_Any) { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [RDX]; // y fld real ptr [RCX]; // x fpatan; ret; } } else { asm pure nothrow @nogc { fld y; fld x; fpatan; } } } else { // Special cases. if (isNaN(x) || isNaN(y)) return real.nan; if (y == 0.0) { if (x >= 0 && !signbit(x)) return copysign(0, y); else return copysign(PI, y); } if (x == 0.0) return copysign(PI_2, y); if (isInfinity(x)) { if (signbit(x)) { if (isInfinity(y)) return copysign(3*PI_4, y); else return copysign(PI, y); } else { if (isInfinity(y)) return copysign(PI_4, y); else return copysign(0.0, y); } } if (isInfinity(y)) return copysign(PI_2, y); // Call atan and determine the quadrant. real z = atan(y / x); if (signbit(x)) { if (signbit(y)) z = z - PI; else z = z + PI; } if (z == 0.0) return copysign(z, y); return z; } } /// ditto double atan2(double y, double x) @safe pure nothrow @nogc { return atan2(cast(real) y, cast(real) x); } /// ditto float atan2(float y, float x) @safe pure nothrow @nogc { return atan2(cast(real) y, cast(real) x); } @system unittest { assert(equalsDigit(atan2(1.0L, std.math.sqrt(3.0L)), PI / 6, useDigits)); } /*********************************** * Calculates the hyperbolic cosine of x. * * $(TABLE_SV * $(TR $(TH x) $(TH cosh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)0.0) $(TD no) ) * ) */ real cosh(real x) @safe pure nothrow @nogc { // cosh = (exp(x)+exp(-x))/2. // The naive implementation works correctly. const real y = exp(x); return (y + 1.0/y) * 0.5; } /// ditto double cosh(double x) @safe pure nothrow @nogc { return cosh(cast(real) x); } /// ditto float cosh(float x) @safe pure nothrow @nogc { return cosh(cast(real) x); } @system unittest { assert(equalsDigit(cosh(1.0), (E + 1.0 / E) / 2, useDigits)); } /*********************************** * Calculates the hyperbolic sine of x. * * $(TABLE_SV * $(TR $(TH x) $(TH sinh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)$(INFIN)) $(TD no)) * ) */ real sinh(real x) @safe pure nothrow @nogc { // sinh(x) = (exp(x)-exp(-x))/2; // Very large arguments could cause an overflow, but // the maximum value of x for which exp(x) + exp(-x)) != exp(x) // is x = 0.5 * (real.mant_dig) * LN2. // = 22.1807 for real80. if (fabs(x) > real.mant_dig * LN2) { return copysign(0.5 * exp(fabs(x)), x); } const real y = expm1(x); return 0.5 * y / (y+1) * (y+2); } /// ditto double sinh(double x) @safe pure nothrow @nogc { return sinh(cast(real) x); } /// ditto float sinh(float x) @safe pure nothrow @nogc { return sinh(cast(real) x); } @system unittest { assert(equalsDigit(sinh(1.0), (E - 1.0 / E) / 2, useDigits)); } /*********************************** * Calculates the hyperbolic tangent of x. * * $(TABLE_SV * $(TR $(TH x) $(TH tanh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)1.0) $(TD no)) * ) */ real tanh(real x) @safe pure nothrow @nogc { // tanh(x) = (exp(x) - exp(-x))/(exp(x)+exp(-x)) if (fabs(x) > real.mant_dig * LN2) { return copysign(1, x); } const real y = expm1(2*x); return y / (y + 2); } /// ditto double tanh(double x) @safe pure nothrow @nogc { return tanh(cast(real) x); } /// ditto float tanh(float x) @safe pure nothrow @nogc { return tanh(cast(real) x); } @system unittest { assert(equalsDigit(tanh(1.0), sinh(1.0) / cosh(1.0), 15)); } package: /* Returns cosh(x) + I * sinh(x) * Only one call to exp() is performed. */ creal coshisinh(real x) @safe pure nothrow @nogc { // See comments for cosh, sinh. if (fabs(x) > real.mant_dig * LN2) { const real y = exp(fabs(x)); return y * 0.5 + 0.5i * copysign(y, x); } else { const real y = expm1(x); return (y + 1.0 + 1.0/(y + 1.0)) * 0.5 + 0.5i * y / (y+1) * (y+2); } } @safe pure nothrow @nogc unittest { creal c = coshisinh(3.0L); assert(c.re == cosh(3.0L)); assert(c.im == sinh(3.0L)); } public: /*********************************** * Calculates the inverse hyperbolic cosine of x. * * Mathematically, acosh(x) = log(x + sqrt( x*x - 1)) * * $(TABLE_DOMRG * $(DOMAIN 1..$(INFIN)), * $(RANGE 0..$(INFIN)) * ) * * $(TABLE_SV * $(SVH x, acosh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(LT)1, $(NAN) ) * $(SV 1, 0 ) * $(SV +$(INFIN),+$(INFIN)) * ) */ real acosh(real x) @safe pure nothrow @nogc { if (x > 1/real.epsilon) return LN2 + log(x); else return log(x + sqrt(x*x - 1)); } /// ditto double acosh(double x) @safe pure nothrow @nogc { return acosh(cast(real) x); } /// ditto float acosh(float x) @safe pure nothrow @nogc { return acosh(cast(real) x); } @system unittest { assert(isNaN(acosh(0.9))); assert(isNaN(acosh(real.nan))); assert(acosh(1.0)==0.0); assert(acosh(real.infinity) == real.infinity); assert(isNaN(acosh(0.5))); assert(equalsDigit(acosh(cosh(3.0)), 3, useDigits)); } /*********************************** * Calculates the inverse hyperbolic sine of x. * * Mathematically, * --------------- * asinh(x) = log( x + sqrt( x*x + 1 )) // if x >= +0 * asinh(x) = -log(-x + sqrt( x*x + 1 )) // if x <= -0 * ------------- * * $(TABLE_SV * $(SVH x, asinh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(PLUSMN)0, $(PLUSMN)0 ) * $(SV $(PLUSMN)$(INFIN),$(PLUSMN)$(INFIN)) * ) */ real asinh(real x) @safe pure nothrow @nogc { return (fabs(x) > 1 / real.epsilon) // beyond this point, x*x + 1 == x*x ? copysign(LN2 + log(fabs(x)), x) // sqrt(x*x + 1) == 1 + x * x / ( 1 + sqrt(x*x + 1) ) : copysign(log1p(fabs(x) + x*x / (1 + sqrt(x*x + 1)) ), x); } /// ditto double asinh(double x) @safe pure nothrow @nogc { return asinh(cast(real) x); } /// ditto float asinh(float x) @safe pure nothrow @nogc { return asinh(cast(real) x); } @system unittest { assert(isIdentical(asinh(0.0), 0.0)); assert(isIdentical(asinh(-0.0), -0.0)); assert(asinh(real.infinity) == real.infinity); assert(asinh(-real.infinity) == -real.infinity); assert(isNaN(asinh(real.nan))); assert(equalsDigit(asinh(sinh(3.0)), 3, useDigits)); } /*********************************** * Calculates the inverse hyperbolic tangent of x, * returning a value from ranging from -1 to 1. * * Mathematically, atanh(x) = log( (1+x)/(1-x) ) / 2 * * $(TABLE_DOMRG * $(DOMAIN -$(INFIN)..$(INFIN)), * $(RANGE -1 .. 1) * ) * $(BR) * $(TABLE_SV * $(SVH x, acosh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(PLUSMN)0, $(PLUSMN)0) * $(SV -$(INFIN), -0) * ) */ real atanh(real x) @safe pure nothrow @nogc { // log( (1+x)/(1-x) ) == log ( 1 + (2*x)/(1-x) ) return 0.5 * log1p( 2 * x / (1 - x) ); } /// ditto double atanh(double x) @safe pure nothrow @nogc { return atanh(cast(real) x); } /// ditto float atanh(float x) @safe pure nothrow @nogc { return atanh(cast(real) x); } @system unittest { assert(isIdentical(atanh(0.0), 0.0)); assert(isIdentical(atanh(-0.0),-0.0)); assert(isNaN(atanh(real.nan))); assert(isNaN(atanh(-real.infinity))); assert(atanh(0.0) == 0); assert(equalsDigit(atanh(tanh(0.5L)), 0.5, useDigits)); } /***************************************** * Returns x rounded to a long value using the current rounding mode. * If the integer value of x is * greater than long.max, the result is * indeterminate. */ long rndtol(real x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.rndtol(x); } //FIXME ///ditto long rndtol(double x) @safe pure nothrow @nogc { return rndtol(cast(real) x); } //FIXME ///ditto long rndtol(float x) @safe pure nothrow @nogc { return rndtol(cast(real) x); } @safe unittest { long function(real) prndtol = &rndtol; assert(prndtol != null); } /***************************************** * Returns x rounded to a long value using the FE_TONEAREST rounding mode. * If the integer value of x is * greater than long.max, the result is * indeterminate. */ extern (C) real rndtonl(real x); /*************************************** * Compute square root of x. * * $(TABLE_SV * $(TR $(TH x) $(TH sqrt(x)) $(TH invalid?)) * $(TR $(TD -0.0) $(TD -0.0) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no)) * ) */ float sqrt(float x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } /// ditto double sqrt(double x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } /// ditto real sqrt(real x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } @safe pure nothrow @nogc unittest { //ctfe enum ZX80 = sqrt(7.0f); enum ZX81 = sqrt(7.0); enum ZX82 = sqrt(7.0L); assert(isNaN(sqrt(-1.0f))); assert(isNaN(sqrt(-1.0))); assert(isNaN(sqrt(-1.0L))); } @safe unittest { float function(float) psqrtf = &sqrt; assert(psqrtf != null); double function(double) psqrtd = &sqrt; assert(psqrtd != null); real function(real) psqrtr = &sqrt; assert(psqrtr != null); } creal sqrt(creal z) @nogc @safe pure nothrow { creal c; real x,y,w,r; if (z == 0) { c = 0 + 0i; } else { const real z_re = z.re; const real z_im = z.im; x = fabs(z_re); y = fabs(z_im); if (x >= y) { r = y / x; w = sqrt(x) * sqrt(0.5 * (1 + sqrt(1 + r * r))); } else { r = x / y; w = sqrt(y) * sqrt(0.5 * (r + sqrt(1 + r * r))); } if (z_re >= 0) { c = w + (z_im / (w + w)) * 1.0i; } else { if (z_im < 0) w = -w; c = z_im / (w + w) + w * 1.0i; } } return c; } /** * Calculates e$(SUPERSCRIPT x). * * $(TABLE_SV * $(TR $(TH x) $(TH e$(SUPERSCRIPT x)) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD +0.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real exp(real x) @trusted pure nothrow @nogc { version(D_InlineAsm_X86) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). return exp2(LOG2E*x); } else version(D_InlineAsm_X86_64) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). return exp2(LOG2E*x); } else { alias F = floatTraits!real; static if (F.realFormat == RealFormat.ieeeDouble) { // Coefficients for exp(x) static immutable real[3] P = [ 9.99999999999999999910E-1L, 3.02994407707441961300E-2L, 1.26177193074810590878E-4L, ]; static immutable real[4] Q = [ 2.00000000000000000009E0L, 2.27265548208155028766E-1L, 2.52448340349684104192E-3L, 3.00198505138664455042E-6L, ]; // C1 + C2 = LN2. enum real C1 = 6.93145751953125E-1; enum real C2 = 1.42860682030941723212E-6; // Overflow and Underflow limits. enum real OF = 7.09782712893383996732E2; // ln((1-2^-53) * 2^1024) enum real UF = -7.451332191019412076235E2; // ln(2^-1075) } else static if (F.realFormat == RealFormat.ieeeExtended) { // Coefficients for exp(x) static immutable real[3] P = [ 9.9999999999999999991025E-1L, 3.0299440770744196129956E-2L, 1.2617719307481059087798E-4L, ]; static immutable real[4] Q = [ 2.0000000000000000000897E0L, 2.2726554820815502876593E-1L, 2.5244834034968410419224E-3L, 3.0019850513866445504159E-6L, ]; // C1 + C2 = LN2. enum real C1 = 6.9314575195312500000000E-1L; enum real C2 = 1.4286068203094172321215E-6L; // Overflow and Underflow limits. enum real OF = 1.1356523406294143949492E4L; // ln((1-2^-64) * 2^16384) enum real UF = -1.13994985314888605586758E4L; // ln(2^-16446) } else static if (F.realFormat == RealFormat.ieeeQuadruple) { // Coefficients for exp(x) - 1 static immutable real[5] P = [ 9.999999999999999999999999999999999998502E-1L, 3.508710990737834361215404761139478627390E-2L, 2.708775201978218837374512615596512792224E-4L, 6.141506007208645008909088812338454698548E-7L, 3.279723985560247033712687707263393506266E-10L ]; static immutable real[6] Q = [ 2.000000000000000000000000000000000000150E0, 2.368408864814233538909747618894558968880E-1L, 3.611828913847589925056132680618007270344E-3L, 1.504792651814944826817779302637284053660E-5L, 1.771372078166251484503904874657985291164E-8L, 2.980756652081995192255342779918052538681E-12L ]; // C1 + C2 = LN2. enum real C1 = 6.93145751953125E-1L; enum real C2 = 1.428606820309417232121458176568075500134E-6L; // Overflow and Underflow limits. enum real OF = 1.135583025911358400418251384584930671458833e4L; enum real UF = -1.143276959615573793352782661133116431383730e4L; } else static assert(0, "Not implemented for this architecture"); // Special cases. Raises an overflow or underflow flag accordingly, // except in the case for CTFE, where there are no hardware controls. if (isNaN(x)) return x; if (x > OF) { if (__ctfe) return real.infinity; else return real.max * copysign(real.max, real.infinity); } if (x < UF) { if (__ctfe) return 0.0; else return real.min_normal * copysign(real.min_normal, 0.0); } // Express: e^^x = e^^g * 2^^n // = e^^g * e^^(n * LOG2E) // = e^^(g + n * LOG2E) int n = cast(int) floor(LOG2E * x + 0.5); x -= n * C1; x -= n * C2; // Rational approximation for exponential of the fractional part: // e^^x = 1 + 2x P(x^^2) / (Q(x^^2) - P(x^^2)) const real xx = x * x; const real px = x * poly(xx, P); x = px / (poly(xx, Q) - px); x = 1.0 + ldexp(x, 1); // Scale by power of 2. x = ldexp(x, n); return x; } } /// ditto double exp(double x) @safe pure nothrow @nogc { return exp(cast(real) x); } /// ditto float exp(float x) @safe pure nothrow @nogc { return exp(cast(real) x); } @system unittest { assert(equalsDigit(exp(3.0L), E * E * E, useDigits)); } /** * Calculates the value of the natural logarithm base (e) * raised to the power of x, minus 1. * * For very small x, expm1(x) is more accurate * than exp(x)-1. * * $(TABLE_SV * $(TR $(TH x) $(TH e$(SUPERSCRIPT x)-1) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD -1.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real expm1(real x) @trusted pure nothrow @nogc { version(D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 asm pure nothrow @nogc { /* expm1() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * expm1(x) = 2^^(rndint(y))* 2^^(y-rndint(y)) - 1 where y = LN2*x. * = 2rndy * 2ym1 + 2rndy - 1, where 2rndy = 2^^(rndint(y)) * and 2ym1 = (2^^(y-rndint(y))-1). * If 2rndy < 0.5*real.epsilon, result is -1. * Implementation is otherwise the same as for exp2() */ naked; fld real ptr [ESP+4] ; // x mov AX, [ESP+4+8]; // AX = exponent and sign sub ESP, 12+8; // Create scratch space on the stack // [ESP,ESP+2] = scratchint // [ESP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [ESP+8], 0; mov dword ptr [ESP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fldl2e; fmulp ST(1), ST; // y = x*log2(e) fist dword ptr [ESP]; // scratchint = rndint(y) fisub dword ptr [ESP]; // y - rndint(y) // and now set scratchreal exponent mov EAX, [ESP]; add EAX, 0x3fff; jle short L_largenegative; cmp EAX,0x8000; jge short L_largepositive; mov [ESP+8+8],AX; f2xm1; // 2ym1 = 2^^(y-rndint(y)) -1 fld real ptr [ESP+8] ; // 2rndy = 2^^rndint(y) fmul ST(1), ST; // ST=2rndy, ST(1)=2rndy*2ym1 fld1; fsubp ST(1), ST; // ST = 2rndy-1, ST(1) = 2rndy * 2ym1 - 1 faddp ST(1), ST; // ST = 2rndy * 2ym1 + 2rndy - 1 add ESP,12+8; ret PARAMSIZE; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; L_largepositive: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [ESP+8+8], 0x7FFE; fstp ST(0); fld real ptr [ESP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add ESP,12+8; ret PARAMSIZE; L_largenegative: fstp ST(0); fld1; fchs; // return -1. Underflow flag is not set. add ESP,12+8; ret PARAMSIZE; } } else version(D_InlineAsm_X86_64) { asm pure nothrow @nogc { naked; } version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX]; // x mov AX,[RCX+8]; // AX = exponent and sign } } else { asm pure nothrow @nogc { fld real ptr [RSP+8]; // x mov AX,[RSP+8+8]; // AX = exponent and sign } } asm pure nothrow @nogc { /* expm1() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * expm1(x) = 2^(rndint(y))* 2^(y-rndint(y)) - 1 where y = LN2*x. * = 2rndy * 2ym1 + 2rndy - 1, where 2rndy = 2^(rndint(y)) * and 2ym1 = (2^(y-rndint(y))-1). * If 2rndy < 0.5*real.epsilon, result is -1. * Implementation is otherwise the same as for exp2() */ sub RSP, 24; // Create scratch space on the stack // [RSP,RSP+2] = scratchint // [RSP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [RSP+8], 0; mov dword ptr [RSP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fldl2e; fmul ; // y = x*log2(e) fist dword ptr [RSP]; // scratchint = rndint(y) fisub dword ptr [RSP]; // y - rndint(y) // and now set scratchreal exponent mov EAX, [RSP]; add EAX, 0x3fff; jle short L_largenegative; cmp EAX,0x8000; jge short L_largepositive; mov [RSP+8+8],AX; f2xm1; // 2^(y-rndint(y)) -1 fld real ptr [RSP+8] ; // 2^rndint(y) fmul ST(1), ST; fld1; fsubp ST(1), ST; fadd; add RSP,24; ret; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; L_largepositive: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [RSP+8+8], 0x7FFE; fstp ST(0); fld real ptr [RSP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add RSP,24; ret; L_largenegative: fstp ST(0); fld1; fchs; // return -1. Underflow flag is not set. add RSP,24; ret; } } else { // Coefficients for exp(x) - 1 and overflow/underflow limits. static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { static immutable real[8] P = [ 2.943520915569954073888921213330863757240E8L, -5.722847283900608941516165725053359168840E7L, 8.944630806357575461578107295909719817253E6L, -7.212432713558031519943281748462837065308E5L, 4.578962475841642634225390068461943438441E4L, -1.716772506388927649032068540558788106762E3L, 4.401308817383362136048032038528753151144E1L, -4.888737542888633647784737721812546636240E-1L ]; static immutable real[9] Q = [ 1.766112549341972444333352727998584753865E9L, -7.848989743695296475743081255027098295771E8L, 1.615869009634292424463780387327037251069E8L, -2.019684072836541751428967854947019415698E7L, 1.682912729190313538934190635536631941751E6L, -9.615511549171441430850103489315371768998E4L, 3.697714952261803935521187272204485251835E3L, -8.802340681794263968892934703309274564037E1L, 1.0 ]; enum real OF = 1.1356523406294143949491931077970764891253E4L; enum real UF = -1.143276959615573793352782661133116431383730e4L; } else { static immutable real[5] P = [ -1.586135578666346600772998894928250240826E4L, 2.642771505685952966904660652518429479531E3L, -3.423199068835684263987132888286791620673E2L, 1.800826371455042224581246202420972737840E1L, -5.238523121205561042771939008061958820811E-1L, ]; static immutable real[6] Q = [ -9.516813471998079611319047060563358064497E4L, 3.964866271411091674556850458227710004570E4L, -7.207678383830091850230366618190187434796E3L, 7.206038318724600171970199625081491823079E2L, -4.002027679107076077238836622982900945173E1L, 1.0 ]; enum real OF = 1.1356523406294143949492E4L; enum real UF = -4.5054566736396445112120088E1L; } // C1 + C2 = LN2. enum real C1 = 6.9314575195312500000000E-1L; enum real C2 = 1.428606820309417232121458176568075500134E-6L; // Special cases. Raises an overflow flag, except in the case // for CTFE, where there are no hardware controls. if (x > OF) { if (__ctfe) return real.infinity; else return real.max * copysign(real.max, real.infinity); } if (x == 0.0) return x; if (x < UF) return -1.0; // Express x = LN2 (n + remainder), remainder not exceeding 1/2. int n = cast(int) floor(0.5 + x / LN2); x -= n * C1; x -= n * C2; // Rational approximation: // exp(x) - 1 = x + 0.5 x^^2 + x^^3 P(x) / Q(x) real px = x * poly(x, P); real qx = poly(x, Q); const real xx = x * x; qx = x + (0.5 * xx + xx * px / qx); // We have qx = exp(remainder LN2) - 1, so: // exp(x) - 1 = 2^^n (qx + 1) - 1 = 2^^n qx + 2^^n - 1. px = ldexp(1.0, n); x = px * qx + (px - 1.0); return x; } } /** * Calculates 2$(SUPERSCRIPT x). * * $(TABLE_SV * $(TR $(TH x) $(TH exp2(x)) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD +0.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real exp2(real x) @nogc @trusted pure nothrow { version(D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 asm pure nothrow @nogc { /* exp2() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * exp2(x) = 2^^(rndint(x))* 2^^(y-rndint(x)) * The trick for high performance is to avoid the fscale(28cycles on core2), * frndint(19 cycles), leaving f2xm1(19 cycles) as the only slow instruction. * * We can do frndint by using fist. BUT we can't use it for huge numbers, * because it will set the Invalid Operation flag if overflow or NaN occurs. * Fortunately, whenever this happens the result would be zero or infinity. * * We can perform fscale by directly poking into the exponent. BUT this doesn't * work for the (very rare) cases where the result is subnormal. So we fall back * to the slow method in that case. */ naked; fld real ptr [ESP+4] ; // x mov AX, [ESP+4+8]; // AX = exponent and sign sub ESP, 12+8; // Create scratch space on the stack // [ESP,ESP+2] = scratchint // [ESP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [ESP+8], 0; mov dword ptr [ESP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fist dword ptr [ESP]; // scratchint = rndint(x) fisub dword ptr [ESP]; // x - rndint(x) // and now set scratchreal exponent mov EAX, [ESP]; add EAX, 0x3fff; jle short L_subnormal; cmp EAX,0x8000; jge short L_overflow; mov [ESP+8+8],AX; L_normal: f2xm1; fld1; faddp ST(1), ST; // 2^^(x-rndint(x)) fld real ptr [ESP+8] ; // 2^^rndint(x) add ESP,12+8; fmulp ST(1), ST; ret PARAMSIZE; L_subnormal: // Result will be subnormal. // In this rare case, the simple poking method doesn't work. // The speed doesn't matter, so use the slow fscale method. fild dword ptr [ESP]; // scratchint fld1; fscale; fstp real ptr [ESP+8]; // scratchreal = 2^^scratchint fstp ST(0); // drop scratchint jmp L_normal; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min_normal // squaring it will return 0, setting underflow flag mov word ptr [ESP+8+8], 1; test AX, 0x0200; jnz L_waslargenegative; L_overflow: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [ESP+8+8], 0x7FFE; L_waslargenegative: fstp ST(0); fld real ptr [ESP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add ESP,12+8; ret PARAMSIZE; } } else version(D_InlineAsm_X86_64) { asm pure nothrow @nogc { naked; } version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX]; // x mov AX,[RCX+8]; // AX = exponent and sign } } else { asm pure nothrow @nogc { fld real ptr [RSP+8]; // x mov AX,[RSP+8+8]; // AX = exponent and sign } } asm pure nothrow @nogc { /* exp2() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * exp2(x) = 2^(rndint(x))* 2^(y-rndint(x)) * The trick for high performance is to avoid the fscale(28cycles on core2), * frndint(19 cycles), leaving f2xm1(19 cycles) as the only slow instruction. * * We can do frndint by using fist. BUT we can't use it for huge numbers, * because it will set the Invalid Operation flag is overflow or NaN occurs. * Fortunately, whenever this happens the result would be zero or infinity. * * We can perform fscale by directly poking into the exponent. BUT this doesn't * work for the (very rare) cases where the result is subnormal. So we fall back * to the slow method in that case. */ sub RSP, 24; // Create scratch space on the stack // [RSP,RSP+2] = scratchint // [RSP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [RSP+8], 0; mov dword ptr [RSP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fist dword ptr [RSP]; // scratchint = rndint(x) fisub dword ptr [RSP]; // x - rndint(x) // and now set scratchreal exponent mov EAX, [RSP]; add EAX, 0x3fff; jle short L_subnormal; cmp EAX,0x8000; jge short L_overflow; mov [RSP+8+8],AX; L_normal: f2xm1; fld1; fadd; // 2^(x-rndint(x)) fld real ptr [RSP+8] ; // 2^rndint(x) add RSP,24; fmulp ST(1), ST; ret; L_subnormal: // Result will be subnormal. // In this rare case, the simple poking method doesn't work. // The speed doesn't matter, so use the slow fscale method. fild dword ptr [RSP]; // scratchint fld1; fscale; fstp real ptr [RSP+8]; // scratchreal = 2^scratchint fstp ST(0); // drop scratchint jmp L_normal; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min // squaring it will return 0, setting underflow flag mov word ptr [RSP+8+8], 1; test AX, 0x0200; jnz L_waslargenegative; L_overflow: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [RSP+8+8], 0x7FFE; L_waslargenegative: fstp ST(0); fld real ptr [RSP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add RSP,24; ret; } } else { // Coefficients for exp2(x) static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { static immutable real[5] P = [ 9.079594442980146270952372234833529694788E12L, 1.530625323728429161131811299626419117557E11L, 5.677513871931844661829755443994214173883E8L, 6.185032670011643762127954396427045467506E5L, 1.587171580015525194694938306936721666031E2L ]; static immutable real[6] Q = [ 2.619817175234089411411070339065679229869E13L, 1.490560994263653042761789432690793026977E12L, 1.092141473886177435056423606755843616331E10L, 2.186249607051644894762167991800811827835E7L, 1.236602014442099053716561665053645270207E4L, 1.0 ]; } else { static immutable real[3] P = [ 2.0803843631901852422887E6L, 3.0286971917562792508623E4L, 6.0614853552242266094567E1L, ]; static immutable real[4] Q = [ 6.0027204078348487957118E6L, 3.2772515434906797273099E5L, 1.7492876999891839021063E3L, 1.0000000000000000000000E0L, ]; } // Overflow and Underflow limits. enum real OF = 16_384.0L; enum real UF = -16_382.0L; // Special cases. Raises an overflow or underflow flag accordingly, // except in the case for CTFE, where there are no hardware controls. if (isNaN(x)) return x; if (x > OF) { if (__ctfe) return real.infinity; else return real.max * copysign(real.max, real.infinity); } if (x < UF) { if (__ctfe) return 0.0; else return real.min_normal * copysign(real.min_normal, 0.0); } // Separate into integer and fractional parts. int n = cast(int) floor(x + 0.5); x -= n; // Rational approximation: // exp2(x) = 1.0 + 2x P(x^^2) / (Q(x^^2) - P(x^^2)) const real xx = x * x; const real px = x * poly(xx, P); x = px / (poly(xx, Q) - px); x = 1.0 + ldexp(x, 1); // Scale by power of 2. x = ldexp(x, n); return x; } } /// @safe unittest { assert(feqrel(exp2(0.5L), SQRT2) >= real.mant_dig -1); assert(exp2(8.0L) == 256.0); assert(exp2(-9.0L)== 1.0L/512.0); } @safe unittest { version(CRuntime_Microsoft) {} else // aexp2/exp2f/exp2l not implemented { assert( core.stdc.math.exp2f(0.0f) == 1 ); assert( core.stdc.math.exp2 (0.0) == 1 ); assert( core.stdc.math.exp2l(0.0L) == 1 ); } } @system unittest { FloatingPointControl ctrl; if (FloatingPointControl.hasExceptionTraps) ctrl.disableExceptions(FloatingPointControl.allExceptions); ctrl.rounding = FloatingPointControl.roundToNearest; static if (real.mant_dig == 113) { static immutable real[2][] exptestpoints = [ // x exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069bc972dfefab6df34p+0L ], [ 3.0L, E*E*E ], [ 0x1.6p+13L, 0x1.6e509d45728655cdb4840542acb5p+16250L ], // near overflow [ 0x1.7p+13L, real.infinity ], // close overflow [ 0x1p+80L, real.infinity ], // far overflow [ real.infinity, real.infinity ], [-0x1.18p+13L, 0x1.5e4bf54b4807034ea97fef0059a6p-12927L ], // near underflow [-0x1.625p+13L, 0x1.a6bd68a39d11fec3a250cd97f524p-16358L ], // ditto [-0x1.62dafp+13L, 0x0.cb629e9813b80ed4d639e875be6cp-16382L ], // near underflow - subnormal [-0x1.6549p+13L, 0x0.0000000000000000000000000001p-16382L ], // ditto [-0x1.655p+13L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static if (real.mant_dig == 64) // 80-bit reals { static immutable real[2][] exptestpoints = [ // x exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069bc97p+0L ], [ 3.0L, E*E*E ], [ 0x1.1p+13L, 0x1.29aeffefc8ec645p+12557L ], // near overflow [ 0x1.7p+13L, real.infinity ], // close overflow [ 0x1p+80L, real.infinity ], // far overflow [ real.infinity, real.infinity ], [-0x1.18p+13L, 0x1.5e4bf54b4806db9p-12927L ], // near underflow [-0x1.625p+13L, 0x1.a6bd68a39d11f35cp-16358L ], // ditto [-0x1.62dafp+13L, 0x1.96c53d30277021dp-16383L ], // near underflow - subnormal [-0x1.643p+13L, 0x1p-16444L ], // ditto [-0x1.645p+13L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static if (real.mant_dig == 53) // 64-bit reals { static immutable real[2][] exptestpoints = [ // x, exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069cp+0L ], [ 3.0L, E*E*E ], [ 0x1.6p+9L, 0x1.93bf4ec282efbp+1015L ], // near overflow [ 0x1.7p+9L, real.infinity ], // close overflow [ 0x1p+80L, real.infinity ], // far overflow [ real.infinity, real.infinity ], [-0x1.6p+9L, 0x1.44a3824e5285fp-1016L ], // near underflow [-0x1.64p+9L, 0x0.06f84920bb2d4p-1022L ], // near underflow - subnormal [-0x1.743p+9L, 0x0.0000000000001p-1022L ], // ditto [-0x1.8p+9L, 0 ], // close underflow [-0x1p30L, 0 ], // far underflow ]; } else static assert(0, "No exp() tests for real type!"); const minEqualMantissaBits = real.mant_dig - 2; real x; IeeeFlags f; foreach (ref pair; exptestpoints) { resetIeeeFlags(); x = exp(pair[0]); f = ieeeFlags; assert(feqrel(x, pair[1]) >= minEqualMantissaBits); version (IeeeFlagsSupport) { // Check the overflow bit if (x == real.infinity) { // don't care about the overflow bit if input was inf // (e.g., the LLVM intrinsic doesn't set it on Linux x86_64) assert(pair[0] == real.infinity || f.overflow); } else assert(!f.overflow); // Check the underflow bit assert(f.underflow == (fabs(x) < real.min_normal)); // Invalid and div by zero shouldn't be affected. assert(!f.invalid); assert(!f.divByZero); } } // Ideally, exp(0) would not set the inexact flag. // Unfortunately, fldl2e sets it! // So it's not realistic to avoid setting it. assert(exp(0.0L) == 1.0); // NaN propagation. Doesn't set flags, bcos was already NaN. resetIeeeFlags(); x = exp(real.nan); f = ieeeFlags; assert(isIdentical(abs(x), real.nan)); assert(f.flags == 0); resetIeeeFlags(); x = exp(-real.nan); f = ieeeFlags; assert(isIdentical(abs(x), real.nan)); assert(f.flags == 0); x = exp(NaN(0x123)); assert(isIdentical(x, NaN(0x123))); // High resolution test (verified against GNU MPFR/Mathematica). assert(exp(0.5L) == 0x1.A612_98E1_E069_BC97_2DFE_FAB6_DF34p+0L); } /** * Calculate cos(y) + i sin(y). * * On many CPUs (such as x86), this is a very efficient operation; * almost twice as fast as calculating sin(y) and cos(y) separately, * and is the preferred method when both are required. */ creal expi(real y) @trusted pure nothrow @nogc { version(InlineAsm_X86_Any) { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [ECX]; fsincos; fxch ST(1), ST(0); ret; } } else { asm pure nothrow @nogc { fld y; fsincos; fxch ST(1), ST(0); } } } else { return cos(y) + sin(y)*1i; } } /// @safe pure nothrow @nogc unittest { assert(expi(1.3e5L) == cos(1.3e5L) + sin(1.3e5L) * 1i); assert(expi(0.0L) == 1L + 0.0Li); } /********************************************************************* * Separate floating point value into significand and exponent. * * Returns: * Calculate and return $(I x) and $(I exp) such that * value =$(I x)*2$(SUPERSCRIPT exp) and * .5 $(LT)= |$(I x)| $(LT) 1.0 * * $(I x) has same sign as value. * * $(TABLE_SV * $(TR $(TH value) $(TH returns) $(TH exp)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD 0)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD int.max)) * $(TR $(TD -$(INFIN)) $(TD -$(INFIN)) $(TD int.min)) * $(TR $(TD $(PLUSMN)$(NAN)) $(TD $(PLUSMN)$(NAN)) $(TD int.min)) * ) */ T frexp(T)(const T value, out int exp) @trusted pure nothrow @nogc if (isFloatingPoint!T) { Unqual!T vf = value; ushort* vu = cast(ushort*)&vf; static if (is(Unqual!T == float)) int* vi = cast(int*)&vf; else long* vl = cast(long*)&vf; int ex; alias F = floatTraits!T; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; static if (F.realFormat == RealFormat.ieeeExtended) { if (ex) { // If exponent is non-zero if (ex == F.EXPMASK) // infinity or NaN { if (*vl & 0x7FFF_FFFF_FFFF_FFFF) // NaN { *vl |= 0xC000_0000_0000_0000; // convert NaNS to NaNQ exp = int.min; } else if (vu[F.EXPPOS_SHORT] & 0x8000) // negative infinity exp = int.min; else // positive infinity exp = int.max; } else { exp = ex - F.EXPBIAS; vu[F.EXPPOS_SHORT] = (0x8000 & vu[F.EXPPOS_SHORT]) | 0x3FFE; } } else if (!*vl) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ex - F.EXPBIAS - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = ((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3FFE; } return vf; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) { // infinity or NaN if (vl[MANTISSA_LSB] | (vl[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) // NaN { // convert NaNS to NaNQ vl[MANTISSA_MSB] |= 0x0000_8000_0000_0000; exp = int.min; } else if (vu[F.EXPPOS_SHORT] & 0x8000) // negative infinity exp = int.min; else // positive infinity exp = int.max; } else { exp = ex - F.EXPBIAS; vu[F.EXPPOS_SHORT] = F.EXPBIAS | (0x8000 & vu[F.EXPPOS_SHORT]); } } else if ((vl[MANTISSA_LSB] | (vl[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) == 0) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ex - F.EXPBIAS - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = F.EXPBIAS | (0x8000 & vu[F.EXPPOS_SHORT]); } return vf; } else static if (F.realFormat == RealFormat.ieeeDouble) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if (*vl == 0x7FF0_0000_0000_0000) // positive infinity { exp = int.max; } else if (*vl == 0xFFF0_0000_0000_0000) // negative infinity exp = int.min; else { // NaN *vl |= 0x0008_0000_0000_0000; // convert NaNS to NaNQ exp = int.min; } } else { exp = (ex - F.EXPBIAS) >> 4; vu[F.EXPPOS_SHORT] = cast(ushort)((0x800F & vu[F.EXPPOS_SHORT]) | 0x3FE0); } } else if (!(*vl & 0x7FFF_FFFF_FFFF_FFFF)) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ((ex - F.EXPBIAS) >> 4) - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = cast(ushort)(((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3FE0); } return vf; } else static if (F.realFormat == RealFormat.ieeeSingle) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if (*vi == 0x7F80_0000) // positive infinity { exp = int.max; } else if (*vi == 0xFF80_0000) // negative infinity exp = int.min; else { // NaN *vi |= 0x0040_0000; // convert NaNS to NaNQ exp = int.min; } } else { exp = (ex - F.EXPBIAS) >> 7; vu[F.EXPPOS_SHORT] = cast(ushort)((0x807F & vu[F.EXPPOS_SHORT]) | 0x3F00); } } else if (!(*vi & 0x7FFF_FFFF)) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ((ex - F.EXPBIAS) >> 7) - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = cast(ushort)(((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3F00); } return vf; } else // static if (F.realFormat == RealFormat.ibmExtended) { assert(0, "frexp not implemented"); } } /// @system unittest { int exp; real mantissa = frexp(123.456L, exp); // check if values are equal to 19 decimal digits of precision assert(equalsDigit(mantissa * pow(2.0L, cast(real) exp), 123.456L, 19)); assert(frexp(-real.nan, exp) && exp == int.min); assert(frexp(real.nan, exp) && exp == int.min); assert(frexp(-real.infinity, exp) == -real.infinity && exp == int.min); assert(frexp(real.infinity, exp) == real.infinity && exp == int.max); assert(frexp(-0.0, exp) == -0.0 && exp == 0); assert(frexp(0.0, exp) == 0.0 && exp == 0); } @safe unittest { import std.meta : AliasSeq; import std.typecons : tuple, Tuple; foreach (T; AliasSeq!(real, double, float)) { Tuple!(T, T, int)[] vals = // x,frexp,exp [ tuple(T(0.0), T( 0.0 ), 0), tuple(T(-0.0), T( -0.0), 0), tuple(T(1.0), T( .5 ), 1), tuple(T(-1.0), T( -.5 ), 1), tuple(T(2.0), T( .5 ), 2), tuple(T(float.min_normal/2.0f), T(.5), -126), tuple(T.infinity, T.infinity, int.max), tuple(-T.infinity, -T.infinity, int.min), tuple(T.nan, T.nan, int.min), tuple(-T.nan, -T.nan, int.min), // Phobos issue #16026: tuple(3 * (T.min_normal * T.epsilon), T( .75), (T.min_exp - T.mant_dig) + 2) ]; foreach (elem; vals) { T x = elem[0]; T e = elem[1]; int exp = elem[2]; int eptr; T v = frexp(x, eptr); assert(isIdentical(e, v)); assert(exp == eptr); } static if (floatTraits!(T).realFormat == RealFormat.ieeeExtended) { static T[3][] extendedvals = [ // x,frexp,exp [0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal [0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063], [T.min_normal, .5, -16381], [T.min_normal/2.0L, .5, -16382] // subnormal ]; foreach (elem; extendedvals) { T x = elem[0]; T e = elem[1]; int exp = cast(int) elem[2]; int eptr; T v = frexp(x, eptr); assert(isIdentical(e, v)); assert(exp == eptr); } } } } @safe unittest { import std.meta : AliasSeq; void foo() { foreach (T; AliasSeq!(real, double, float)) { int exp; const T a = 1; immutable T b = 2; auto c = frexp(a, exp); auto d = frexp(b, exp); } } } /****************************************** * Extracts the exponent of x as a signed integral value. * * If x is not a special value, the result is the same as * $(D cast(int) logb(x)). * * $(TABLE_SV * $(TR $(TH x) $(TH ilogb(x)) $(TH Range error?)) * $(TR $(TD 0) $(TD FP_ILOGB0) $(TD yes)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD int.max) $(TD no)) * $(TR $(TD $(NAN)) $(TD FP_ILOGBNAN) $(TD no)) * ) */ int ilogb(T)(const T x) @trusted pure nothrow @nogc if (isFloatingPoint!T) { import core.bitop : bsr; alias F = floatTraits!T; union floatBits { T rv; ushort[T.sizeof/2] vu; uint[T.sizeof/4] vui; static if (T.sizeof >= 8) ulong[T.sizeof/8] vul; } floatBits y = void; y.rv = x; int ex = y.vu[F.EXPPOS_SHORT] & F.EXPMASK; static if (F.realFormat == RealFormat.ieeeExtended) { if (ex) { // If exponent is non-zero if (ex == F.EXPMASK) // infinity or NaN { if (y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF) // NaN return FP_ILOGBNAN; else // +-infinity return int.max; } else { return ex - F.EXPBIAS - 1; } } else if (!y.vul[0]) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(y.vul[0]); } } else static if (F.realFormat == RealFormat.ieeeQuadruple) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) { // infinity or NaN if (y.vul[MANTISSA_LSB] | ( y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) // NaN return FP_ILOGBNAN; else // +- infinity return int.max; } else { return ex - F.EXPBIAS - 1; } } else if ((y.vul[MANTISSA_LSB] | (y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) == 0) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal const ulong msb = y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF; const ulong lsb = y.vul[MANTISSA_LSB]; if (msb) return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(msb) + 64; else return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(lsb); } } else static if (F.realFormat == RealFormat.ieeeDouble) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if ((y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FF0_0000_0000_0000) // +- infinity return int.max; else // NaN return FP_ILOGBNAN; } else { return ((ex - F.EXPBIAS) >> 4) - 1; } } else if (!(y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF)) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal enum MANTISSAMASK_64 = ((cast(ulong) F.MANTISSAMASK_INT) << 32) | 0xFFFF_FFFF; return ((ex - F.EXPBIAS) >> 4) - T.mant_dig + 1 + bsr(y.vul[0] & MANTISSAMASK_64); } } else static if (F.realFormat == RealFormat.ieeeSingle) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if ((y.vui[0] & 0x7FFF_FFFF) == 0x7F80_0000) // +- infinity return int.max; else // NaN return FP_ILOGBNAN; } else { return ((ex - F.EXPBIAS) >> 7) - 1; } } else if (!(y.vui[0] & 0x7FFF_FFFF)) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal const uint mantissa = y.vui[0] & F.MANTISSAMASK_INT; return ((ex - F.EXPBIAS) >> 7) - T.mant_dig + 1 + bsr(mantissa); } } else // static if (F.realFormat == RealFormat.ibmExtended) { core.stdc.math.ilogbl(x); } } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc if (isIntegral!T && isUnsigned!T) { import core.bitop : bsr; if (x == 0) return FP_ILOGB0; else { static assert(T.sizeof <= ulong.sizeof, "integer size too large for the current ilogb implementation"); return bsr(x); } } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc if (isIntegral!T && isSigned!T) { import std.traits : Unsigned; // Note: abs(x) can not be used because the return type is not Unsigned and // the return value would be wrong for x == int.min Unsigned!T absx = x >= 0 ? x : -x; return ilogb(absx); } alias FP_ILOGB0 = core.stdc.math.FP_ILOGB0; alias FP_ILOGBNAN = core.stdc.math.FP_ILOGBNAN; @system nothrow @nogc unittest { import std.meta : AliasSeq; import std.typecons : Tuple; foreach (F; AliasSeq!(float, double, real)) { alias T = Tuple!(F, int); T[13] vals = // x, ilogb(x) [ T( F.nan , FP_ILOGBNAN ), T( -F.nan , FP_ILOGBNAN ), T( F.infinity, int.max ), T( -F.infinity, int.max ), T( 0.0 , FP_ILOGB0 ), T( -0.0 , FP_ILOGB0 ), T( 2.0 , 1 ), T( 2.0001 , 1 ), T( 1.9999 , 0 ), T( 0.5 , -1 ), T( 123.123 , 6 ), T( -123.123 , 6 ), T( 0.123 , -4 ), ]; foreach (elem; vals) { assert(ilogb(elem[0]) == elem[1]); } } // min_normal and subnormals assert(ilogb(-float.min_normal) == -126); assert(ilogb(nextUp(-float.min_normal)) == -127); assert(ilogb(nextUp(-float(0.0))) == -149); assert(ilogb(-double.min_normal) == -1022); assert(ilogb(nextUp(-double.min_normal)) == -1023); assert(ilogb(nextUp(-double(0.0))) == -1074); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { assert(ilogb(-real.min_normal) == -16382); assert(ilogb(nextUp(-real.min_normal)) == -16383); assert(ilogb(nextUp(-real(0.0))) == -16445); } else static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { assert(ilogb(-real.min_normal) == -1022); assert(ilogb(nextUp(-real.min_normal)) == -1023); assert(ilogb(nextUp(-real(0.0))) == -1074); } // test integer types assert(ilogb(0) == FP_ILOGB0); assert(ilogb(int.max) == 30); assert(ilogb(int.min) == 31); assert(ilogb(uint.max) == 31); assert(ilogb(long.max) == 62); assert(ilogb(long.min) == 63); assert(ilogb(ulong.max) == 63); } /******************************************* * Compute n * 2$(SUPERSCRIPT exp) * References: frexp */ real ldexp(real n, int exp) @nogc @safe pure nothrow { pragma(inline, true); return core.math.ldexp(n, exp); } //FIXME ///ditto double ldexp(double n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) n, exp); } //FIXME ///ditto float ldexp(float n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) n, exp); } /// @nogc @safe pure nothrow unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { T r; r = ldexp(3.0L, 3); assert(r == 24); r = ldexp(cast(T) 3.0, cast(int) 3); assert(r == 24); T n = 3.0; int exp = 3; r = ldexp(n, exp); assert(r == 24); } } @safe pure nothrow @nogc unittest { static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { assert(ldexp(1.0L, -16384) == 0x1p-16384L); assert(ldexp(1.0L, -16382) == 0x1p-16382L); int x; real n = frexp(0x1p-16384L, x); assert(n == 0.5L); assert(x==-16383); assert(ldexp(n, x)==0x1p-16384L); } else static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { assert(ldexp(1.0L, -1024) == 0x1p-1024L); assert(ldexp(1.0L, -1022) == 0x1p-1022L); int x; real n = frexp(0x1p-1024L, x); assert(n == 0.5L); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024L); } else static assert(false, "Floating point type real not supported"); } /* workaround Issue 14718, float parsing depends on platform strtold typed_allocator.d @safe pure nothrow @nogc unittest { assert(ldexp(1.0, -1024) == 0x1p-1024); assert(ldexp(1.0, -1022) == 0x1p-1022); int x; double n = frexp(0x1p-1024, x); assert(n == 0.5); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024); } @safe pure nothrow @nogc unittest { assert(ldexp(1.0f, -128) == 0x1p-128f); assert(ldexp(1.0f, -126) == 0x1p-126f); int x; float n = frexp(0x1p-128f, x); assert(n == 0.5f); assert(x==-127); assert(ldexp(n, x)==0x1p-128f); } */ @system unittest { static real[3][] vals = // value,exp,ldexp [ [ 0, 0, 0], [ 1, 0, 1], [ -1, 0, -1], [ 1, 1, 2], [ 123, 10, 125952], [ real.max, int.max, real.infinity], [ real.max, -int.max, 0], [ real.min_normal, -int.max, 0], ]; int i; for (i = 0; i < vals.length; i++) { real x = vals[i][0]; int exp = cast(int) vals[i][1]; real z = vals[i][2]; real l = ldexp(x, exp); assert(equalsDigit(z, l, 7)); } real function(real, int) pldexp = &ldexp; assert(pldexp != null); } private { version (INLINE_YL2X) {} else { static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) static immutable real[13] logCoeffsP = [ 1.313572404063446165910279910527789794488E4L, 7.771154681358524243729929227226708890930E4L, 2.014652742082537582487669938141683759923E5L, 3.007007295140399532324943111654767187848E5L, 2.854829159639697837788887080758954924001E5L, 1.797628303815655343403735250238293741397E5L, 7.594356839258970405033155585486712125861E4L, 2.128857716871515081352991964243375186031E4L, 3.824952356185897735160588078446136783779E3L, 4.114517881637811823002128927449878962058E2L, 2.321125933898420063925789532045674660756E1L, 4.998469661968096229986658302195402690910E-1L, 1.538612243596254322971797716843006400388E-6L ]; static immutable real[13] logCoeffsQ = [ 3.940717212190338497730839731583397586124E4L, 2.626900195321832660448791748036714883242E5L, 7.777690340007566932935753241556479363645E5L, 1.347518538384329112529391120390701166528E6L, 1.514882452993549494932585972882995548426E6L, 1.158019977462989115839826904108208787040E6L, 6.132189329546557743179177159925690841200E5L, 2.248234257620569139969141618556349415120E5L, 5.605842085972455027590989944010492125825E4L, 9.147150349299596453976674231612674085381E3L, 9.104928120962988414618126155557301584078E2L, 4.839208193348159620282142911143429644326E1L, 1.0 ]; // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) // where z = 2(x-1)/(x+1) static immutable real[6] logCoeffsR = [ -8.828896441624934385266096344596648080902E-1L, 8.057002716646055371965756206836056074715E1L, -2.024301798136027039250415126250455056397E3L, 2.048819892795278657810231591630928516206E4L, -8.977257995689735303686582344659576526998E4L, 1.418134209872192732479751274970992665513E5L ]; static immutable real[6] logCoeffsS = [ 1.701761051846631278975701529965589676574E6L -1.332535117259762928288745111081235577029E6L, 4.001557694070773974936904547424676279307E5L, -5.748542087379434595104154610899551484314E4L, 3.998526750980007367835804959888064681098E3L, -1.186359407982897997337150403816839480438E2L, 1.0 ]; } else { // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) static immutable real[7] logCoeffsP = [ 2.0039553499201281259648E1L, 5.7112963590585538103336E1L, 6.0949667980987787057556E1L, 2.9911919328553073277375E1L, 6.5787325942061044846969E0L, 4.9854102823193375972212E-1L, 4.5270000862445199635215E-5L, ]; static immutable real[7] logCoeffsQ = [ 6.0118660497603843919306E1L, 2.1642788614495947685003E2L, 3.0909872225312059774938E2L, 2.2176239823732856465394E2L, 8.3047565967967209469434E1L, 1.5062909083469192043167E1L, 1.0000000000000000000000E0L, ]; // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) // where z = 2(x-1)/(x+1) static immutable real[4] logCoeffsR = [ -3.5717684488096787370998E1L, 1.0777257190312272158094E1L, -7.1990767473014147232598E-1L, 1.9757429581415468984296E-3L, ]; static immutable real[4] logCoeffsS = [ -4.2861221385716144629696E2L, 1.9361891836232102174846E2L, -2.6201045551331104417768E1L, 1.0000000000000000000000E0L, ]; } } } /************************************** * Calculate the natural logarithm of x. * * $(TABLE_SV * $(TR $(TH x) $(TH log(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) * ) */ real log(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, LN2); else { // C1 + C2 = LN2. enum real C1 = 6.93145751953125E-1L; enum real C2 = 1.428606820309417232121458176568075500134E-6L; // Special cases. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; z = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); z += exp * C2; z += x; z += exp * C1; return z; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else { x = x - 1.0; } z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y += exp * C2; z = y - ldexp(z, -1); // Note, the sum of above terms does not exceed x/4, // so it contributes at most about 1/4 lsb to the error. z += x; z += exp * C1; return z; } } /// @safe pure nothrow @nogc unittest { assert(log(E) == 1); } /************************************** * Calculate the base-10 logarithm of x. * * $(TABLE_SV * $(TR $(TH x) $(TH log10(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) * ) */ real log10(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, LOG2); else { // log10(2) split into two parts. enum real L102A = 0.3125L; enum real L102B = -1.14700043360188047862611052755069732318101185E-2L; // log10(e) split into two parts. enum real L10EA = 0.5L; enum real L10EB = -6.570551809674817234887108108339491770560299E-2L; // Special cases are the same as for log. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); goto Ldone; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else x = x - 1.0; z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y = y - ldexp(z, -1); // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). // This sequence of operations is critical and it may be horribly // defeated by some compiler optimizers. Ldone: z = y * L10EB; z += x * L10EB; z += exp * L102B; z += y * L10EA; z += x * L10EA; z += exp * L102A; return z; } } /// @safe pure nothrow @nogc unittest { assert(fabs(log10(1000) - 3) < .000001); } /****************************************** * Calculates the natural logarithm of 1 + x. * * For very small x, log1p(x) will be more accurate than * log(1 + x). * * $(TABLE_SV * $(TR $(TH x) $(TH log1p(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) $(TD no)) * $(TR $(TD -1.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD -$(INFIN)) $(TD no) $(TD no)) * ) */ real log1p(real x) @safe pure nothrow @nogc { version(INLINE_YL2X) { // On x87, yl2xp1 is valid if and only if -0.5 <= lg(x) <= 0.5, // ie if -0.29 <= x <= 0.414 return (fabs(x) <= 0.25) ? core.math.yl2xp1(x, LN2) : core.math.yl2x(x+1, LN2); } else { // Special cases. if (isNaN(x) || x == 0.0) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == -1.0) return -real.infinity; if (x < -1.0) return real.nan; return log(x + 1.0); } } /*************************************** * Calculates the base-2 logarithm of x: * $(SUB log, 2)x * * $(TABLE_SV * $(TR $(TH x) $(TH log2(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no) ) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no) ) * ) */ real log2(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, 1); else { // Special cases are the same as for log. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); goto Ldone; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else x = x - 1.0; z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y = y - ldexp(z, -1); // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). // This sequence of operations is critical and it may be horribly // defeated by some compiler optimizers. Ldone: z = y * (LOG2E - 1.0); z += x * (LOG2E - 1.0); z += y; z += x; z += exp; return z; } } /// @system unittest { // check if values are equal to 19 decimal digits of precision assert(equalsDigit(log2(1024.0L), 10, 19)); } /***************************************** * Extracts the exponent of x as a signed integral value. * * If x is subnormal, it is treated as if it were normalized. * For a positive, finite x: * * 1 $(LT)= $(I x) * FLT_RADIX$(SUPERSCRIPT -logb(x)) $(LT) FLT_RADIX * * $(TABLE_SV * $(TR $(TH x) $(TH logb(x)) $(TH divide by 0?) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) $(TD no)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) ) * ) */ real logb(real x) @trusted nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fxtract ; fstp ST(0) ; ret ; } } else version (CRuntime_Microsoft) { asm pure nothrow @nogc { fld x ; fxtract ; fstp ST(0) ; } } else return core.stdc.math.logbl(x); } /************************************ * Calculates the remainder from the calculation x/y. * Returns: * The value of x - i * y, where i is the number of times that y can * be completely subtracted from x. The result has the same sign as x. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH fmod(x, y)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD not 0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD $(NAN)) $(TD yes)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD !=$(PLUSMNINF)) $(TD $(PLUSMNINF)) $(TD x) $(TD no)) * ) */ real fmod(real x, real y) @trusted nothrow @nogc { version (CRuntime_Microsoft) { return x % y; } else return core.stdc.math.fmodl(x, y); } /************************************ * Breaks x into an integral part and a fractional part, each of which has * the same sign as x. The integral part is stored in i. * Returns: * The fractional part of x. * * $(TABLE_SV * $(TR $(TH x) $(TH i (on input)) $(TH modf(x, i)) $(TH i (on return))) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(PLUSMNINF))) * ) */ real modf(real x, ref real i) @trusted nothrow @nogc { version (CRuntime_Microsoft) { i = trunc(x); return copysign(isInfinity(x) ? 0.0 : x - i, x); } else return core.stdc.math.modfl(x,&i); } /************************************* * Efficiently calculates x * 2$(SUPERSCRIPT n). * * scalbn handles underflow and overflow in * the same fashion as the basic arithmetic operators. * * $(TABLE_SV * $(TR $(TH x) $(TH scalb(x))) * $(TR $(TD $(PLUSMNINF)) $(TD $(PLUSMNINF)) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) ) * ) */ real scalbn(real x, int n) @trusted nothrow @nogc { version(InlineAsm_X86_Any) { // scalbnl is not supported on DMD-Windows, so use asm pure nothrow @nogc. version (Win64) { asm pure nothrow @nogc { naked ; mov 16[RSP],RCX ; fild word ptr 16[RSP] ; fld real ptr [RDX] ; fscale ; fstp ST(1) ; ret ; } } else { asm pure nothrow @nogc { fild n; fld x; fscale; fstp ST(1); } } } else { return core.stdc.math.scalbnl(x, n); } } /// @safe nothrow @nogc unittest { assert(scalbn(-real.infinity, 5) == -real.infinity); } /*************** * Calculates the cube root of x. * * $(TABLE_SV * $(TR $(TH $(I x)) $(TH cbrt(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)$(INFIN)) $(TD no) ) * ) */ real cbrt(real x) @trusted nothrow @nogc { version (CRuntime_Microsoft) { version (INLINE_YL2X) return copysign(exp2(core.math.yl2x(fabs(x), 1.0L/3.0L)), x); else return core.stdc.math.cbrtl(x); } else return core.stdc.math.cbrtl(x); } /******************************* * Returns |x| * * $(TABLE_SV * $(TR $(TH x) $(TH fabs(x))) * $(TR $(TD $(PLUSMN)0.0) $(TD +0.0) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) ) * ) */ real fabs(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.fabs(x); } //FIXME ///ditto double fabs(double x) @safe pure nothrow @nogc { return fabs(cast(real) x); } //FIXME ///ditto float fabs(float x) @safe pure nothrow @nogc { return fabs(cast(real) x); } @safe unittest { real function(real) pfabs = &fabs; assert(pfabs != null); } /*********************************************************************** * Calculates the length of the * hypotenuse of a right-angled triangle with sides of length x and y. * The hypotenuse is the value of the square root of * the sums of the squares of x and y: * * sqrt($(POWER x, 2) + $(POWER y, 2)) * * Note that hypot(x, y), hypot(y, x) and * hypot(x, -y) are equivalent. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH hypot(x, y)) $(TH invalid?)) * $(TR $(TD x) $(TD $(PLUSMN)0.0) $(TD |x|) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD y) $(TD +$(INFIN)) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD $(NAN)) $(TD +$(INFIN)) $(TD no)) * ) */ real hypot(real x, real y) @safe pure nothrow @nogc { // Scale x and y to avoid underflow and overflow. // If one is huge and the other tiny, return the larger. // If both are huge, avoid overflow by scaling by 1/sqrt(real.max/2). // If both are tiny, avoid underflow by scaling by sqrt(real.min_normal*real.epsilon). enum real SQRTMIN = 0.5 * sqrt(real.min_normal); // This is a power of 2. enum real SQRTMAX = 1.0L / SQRTMIN; // 2^^((max_exp)/2) = nextUp(sqrt(real.max)) static assert(2*(SQRTMAX/2)*(SQRTMAX/2) <= real.max); // Proves that sqrt(real.max) ~~ 0.5/sqrt(real.min_normal) static assert(real.min_normal*real.max > 2 && real.min_normal*real.max <= 4); real u = fabs(x); real v = fabs(y); if (!(u >= v)) // check for NaN as well. { v = u; u = fabs(y); if (u == real.infinity) return u; // hypot(inf, nan) == inf if (v == real.infinity) return v; // hypot(nan, inf) == inf } // Now u >= v, or else one is NaN. if (v >= SQRTMAX*0.5) { // hypot(huge, huge) -- avoid overflow u *= SQRTMIN*0.5; v *= SQRTMIN*0.5; return sqrt(u*u + v*v) * SQRTMAX * 2.0; } if (u <= SQRTMIN) { // hypot (tiny, tiny) -- avoid underflow // This is only necessary to avoid setting the underflow // flag. u *= SQRTMAX / real.epsilon; v *= SQRTMAX / real.epsilon; return sqrt(u*u + v*v) * SQRTMIN * real.epsilon; } if (u * real.epsilon > v) { // hypot (huge, tiny) = huge return u; } // both are in the normal range return sqrt(u*u + v*v); } @safe unittest { static real[3][] vals = // x,y,hypot [ [ 0.0, 0.0, 0.0], [ 0.0, -0.0, 0.0], [ -0.0, -0.0, 0.0], [ 3.0, 4.0, 5.0], [ -300, -400, 500], [0.0, 7.0, 7.0], [9.0, 9*real.epsilon, 9.0], [88/(64*sqrt(real.min_normal)), 105/(64*sqrt(real.min_normal)), 137/(64*sqrt(real.min_normal))], [88/(128*sqrt(real.min_normal)), 105/(128*sqrt(real.min_normal)), 137/(128*sqrt(real.min_normal))], [3*real.min_normal*real.epsilon, 4*real.min_normal*real.epsilon, 5*real.min_normal*real.epsilon], [ real.min_normal, real.min_normal, sqrt(2.0L)*real.min_normal], [ real.max/sqrt(2.0L), real.max/sqrt(2.0L), real.max], [ real.infinity, real.nan, real.infinity], [ real.nan, real.infinity, real.infinity], [ real.nan, real.nan, real.nan], [ real.nan, real.max, real.nan], [ real.max, real.nan, real.nan], ]; for (int i = 0; i < vals.length; i++) { real x = vals[i][0]; real y = vals[i][1]; real z = vals[i][2]; real h = hypot(x, y); assert(isIdentical(z,h) || feqrel(z, h) >= real.mant_dig - 1); } } /************************************** * Returns the value of x rounded upward to the next integer * (toward positive infinity). */ real ceil(real x) @trusted pure nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x08 ; // round to +infinity mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version(CRuntime_Microsoft) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x08 ; // round to +infinity mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else { // Special cases. if (isNaN(x) || isInfinity(x)) return x; real y = floorImpl(x); if (y < x) y += 1.0; return y; } } /// @safe pure nothrow @nogc unittest { assert(ceil(+123.456L) == +124); assert(ceil(-123.456L) == -123); assert(ceil(-1.234L) == -1); assert(ceil(-0.123L) == 0); assert(ceil(0.0L) == 0); assert(ceil(+0.123L) == 1); assert(ceil(+1.234L) == 2); assert(ceil(real.infinity) == real.infinity); assert(isNaN(ceil(real.nan))); assert(isNaN(ceil(real.init))); } // ditto double ceil(double x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x)) return x; double y = floorImpl(x); if (y < x) y += 1.0; return y; } @safe pure nothrow @nogc unittest { assert(ceil(+123.456) == +124); assert(ceil(-123.456) == -123); assert(ceil(-1.234) == -1); assert(ceil(-0.123) == 0); assert(ceil(0.0) == 0); assert(ceil(+0.123) == 1); assert(ceil(+1.234) == 2); assert(ceil(double.infinity) == double.infinity); assert(isNaN(ceil(double.nan))); assert(isNaN(ceil(double.init))); } // ditto float ceil(float x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x)) return x; float y = floorImpl(x); if (y < x) y += 1.0; return y; } @safe pure nothrow @nogc unittest { assert(ceil(+123.456f) == +124); assert(ceil(-123.456f) == -123); assert(ceil(-1.234f) == -1); assert(ceil(-0.123f) == 0); assert(ceil(0.0f) == 0); assert(ceil(+0.123f) == 1); assert(ceil(+1.234f) == 2); assert(ceil(float.infinity) == float.infinity); assert(isNaN(ceil(float.nan))); assert(isNaN(ceil(float.init))); } /************************************** * Returns the value of x rounded downward to the next integer * (toward negative infinity). */ real floor(real x) @trusted pure nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x04 ; // round to -infinity mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version(CRuntime_Microsoft) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x04 ; // round to -infinity mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } } /// @safe pure nothrow @nogc unittest { assert(floor(+123.456L) == +123); assert(floor(-123.456L) == -124); assert(floor(-1.234L) == -2); assert(floor(-0.123L) == -1); assert(floor(0.0L) == 0); assert(floor(+0.123L) == 0); assert(floor(+1.234L) == 1); assert(floor(real.infinity) == real.infinity); assert(isNaN(floor(real.nan))); assert(isNaN(floor(real.init))); } // ditto double floor(double x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } @safe pure nothrow @nogc unittest { assert(floor(+123.456) == +123); assert(floor(-123.456) == -124); assert(floor(-1.234) == -2); assert(floor(-0.123) == -1); assert(floor(0.0) == 0); assert(floor(+0.123) == 0); assert(floor(+1.234) == 1); assert(floor(double.infinity) == double.infinity); assert(isNaN(floor(double.nan))); assert(isNaN(floor(double.init))); } // ditto float floor(float x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } @safe pure nothrow @nogc unittest { assert(floor(+123.456f) == +123); assert(floor(-123.456f) == -124); assert(floor(-1.234f) == -2); assert(floor(-0.123f) == -1); assert(floor(0.0f) == 0); assert(floor(+0.123f) == 0); assert(floor(+1.234f) == 1); assert(floor(float.infinity) == float.infinity); assert(isNaN(floor(float.nan))); assert(isNaN(floor(float.init))); } /** * Round `val` to a multiple of `unit`. `rfunc` specifies the rounding * function to use; by default this is `rint`, which uses the current * rounding mode. */ Unqual!F quantize(alias rfunc = rint, F)(const F val, const F unit) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { typeof(return) ret = val; if (unit != 0) { const scaled = val / unit; if (!scaled.isInfinity) ret = rfunc(scaled) * unit; } return ret; } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize(0.01L) == 12345.68L); assert(12345.6789L.quantize!floor(0.01L) == 12345.67L); assert(12345.6789L.quantize(22.0L) == 12342.0L); } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize(0) == 12345.6789L); assert(12345.6789L.quantize(real.infinity).isNaN); assert(12345.6789L.quantize(real.nan).isNaN); assert(real.infinity.quantize(0.01L) == real.infinity); assert(real.infinity.quantize(real.nan).isNaN); assert(real.nan.quantize(0.01L).isNaN); assert(real.nan.quantize(real.infinity).isNaN); assert(real.nan.quantize(real.nan).isNaN); } /** * Round `val` to a multiple of `pow(base, exp)`. `rfunc` specifies the * rounding function to use; by default this is `rint`, which uses the * current rounding mode. */ Unqual!F quantize(real base, alias rfunc = rint, F, E)(const F val, const E exp) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F && isIntegral!E) { // TODO: Compile-time optimization for power-of-two bases? return quantize!rfunc(val, pow(cast(F) base, exp)); } /// ditto Unqual!F quantize(real base, long exp = 1, alias rfunc = rint, F)(const F val) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { enum unit = cast(F) pow(base, exp); return quantize!rfunc(val, unit); } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize!10(-2) == 12345.68L); assert(12345.6789L.quantize!(10, -2) == 12345.68L); assert(12345.6789L.quantize!(10, floor)(-2) == 12345.67L); assert(12345.6789L.quantize!(10, -2, floor) == 12345.67L); assert(12345.6789L.quantize!22(1) == 12342.0L); assert(12345.6789L.quantize!22 == 12342.0L); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; foreach (F; AliasSeq!(real, double, float)) { const maxL10 = cast(int) F.max.log10.floor; const maxR10 = pow(cast(F) 10, maxL10); assert((cast(F) 0.9L * maxR10).quantize!10(maxL10) == maxR10); assert((cast(F)-0.9L * maxR10).quantize!10(maxL10) == -maxR10); assert(F.max.quantize(F.min_normal) == F.max); assert((-F.max).quantize(F.min_normal) == -F.max); assert(F.min_normal.quantize(F.max) == 0); assert((-F.min_normal).quantize(F.max) == 0); assert(F.min_normal.quantize(F.min_normal) == F.min_normal); assert((-F.min_normal).quantize(F.min_normal) == -F.min_normal); } } /****************************************** * Rounds x to the nearest integer value, using the current rounding * mode. * * Unlike the rint functions, nearbyint does not raise the * FE_INEXACT exception. */ real nearbyint(real x) @trusted nothrow @nogc { version (CRuntime_Microsoft) { assert(0); // not implemented in C library } else return core.stdc.math.nearbyintl(x); } /********************************** * Rounds x to the nearest integer value, using the current rounding * mode. * If the return value is not equal to x, the FE_INEXACT * exception is raised. * $(B nearbyint) performs * the same operation, but does not set the FE_INEXACT exception. */ real rint(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.rint(x); } //FIXME ///ditto double rint(double x) @safe pure nothrow @nogc { return rint(cast(real) x); } //FIXME ///ditto float rint(float x) @safe pure nothrow @nogc { return rint(cast(real) x); } @safe unittest { real function(real) print = &rint; assert(print != null); } /*************************************** * Rounds x to the nearest integer value, using the current rounding * mode. * * This is generally the fastest method to convert a floating-point number * to an integer. Note that the results from this function * depend on the rounding mode, if the fractional part of x is exactly 0.5. * If using the default rounding mode (ties round to even integers) * lrint(4.5) == 4, lrint(5.5)==6. */ long lrint(real x) @trusted pure nothrow @nogc { version(InlineAsm_X86_Any) { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [RCX]; fistp qword ptr 8[RSP]; mov RAX,8[RSP]; ret; } } else { long n; asm pure nothrow @nogc { fld x; fistp n; } return n; } } else { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { long result; // Rounding limit when casting from real(double) to ulong. enum real OF = 4.50359962737049600000E15L; uint* vi = cast(uint*)(&x); // Find the exponent and sign uint msb = vi[MANTISSA_MSB]; uint lsb = vi[MANTISSA_LSB]; int exp = ((msb >> 20) & 0x7ff) - 0x3ff; const int sign = msb >> 31; msb &= 0xfffff; msb |= 0x100000; if (exp < 63) { if (exp >= 52) result = (cast(long) msb << (exp - 20)) | (lsb << (exp - 52)); else { // Adjust x and check result. const real j = sign ? -OF : OF; x = (j + x) - j; msb = vi[MANTISSA_MSB]; lsb = vi[MANTISSA_LSB]; exp = ((msb >> 20) & 0x7ff) - 0x3ff; msb &= 0xfffff; msb |= 0x100000; if (exp < 0) result = 0; else if (exp < 20) result = cast(long) msb >> (20 - exp); else if (exp == 20) result = cast(long) msb; else result = (cast(long) msb << (exp - 20)) | (lsb >> (52 - exp)); } } else { // It is left implementation defined when the number is too large. return cast(long) x; } return sign ? -result : result; } else static if (F.realFormat == RealFormat.ieeeExtended) { long result; // Rounding limit when casting from real(80-bit) to ulong. enum real OF = 9.22337203685477580800E18L; ushort* vu = cast(ushort*)(&x); uint* vi = cast(uint*)(&x); // Find the exponent and sign int exp = (vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; const int sign = (vu[F.EXPPOS_SHORT] >> 15) & 1; if (exp < 63) { // Adjust x and check result. const real j = sign ? -OF : OF; x = (j + x) - j; exp = (vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) { if (exp < 0) result = 0; else if (exp <= 31) result = vi[1] >> (31 - exp); else result = (cast(long) vi[1] << (exp - 31)) | (vi[0] >> (63 - exp)); } else { if (exp < 0) result = 0; else if (exp <= 31) result = vi[1] >> (31 - exp); else result = (cast(long) vi[1] << (exp - 31)) | (vi[2] >> (63 - exp)); } } else { // It is left implementation defined when the number is too large // to fit in a 64bit long. return cast(long) x; } return sign ? -result : result; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const vu = cast(ushort*)(&x); // Find the exponent and sign const sign = (vu[F.EXPPOS_SHORT] >> 15) & 1; if ((vu[F.EXPPOS_SHORT] & F.EXPMASK) - (F.EXPBIAS + 1) > 63) { // The result is left implementation defined when the number is // too large to fit in a 64 bit long. return cast(long) x; } // Force rounding of lower bits according to current rounding // mode by adding ±2^-112 and subtracting it again. enum OF = 5.19229685853482762853049632922009600E33L; const j = sign ? -OF : OF; x = (j + x) - j; const implicitOne = 1UL << 48; auto vl = cast(ulong*)(&x); vl[MANTISSA_MSB] &= implicitOne - 1; vl[MANTISSA_MSB] |= implicitOne; long result; const exp = (vu[F.EXPPOS_SHORT] & F.EXPMASK) - (F.EXPBIAS + 1); if (exp < 0) result = 0; else if (exp <= 48) result = vl[MANTISSA_MSB] >> (48 - exp); else result = (vl[MANTISSA_MSB] << (exp - 48)) | (vl[MANTISSA_LSB] >> (112 - exp)); return sign ? -result : result; } else { static assert(false, "real type not supported by lrint()"); } } } /// @safe pure nothrow @nogc unittest { assert(lrint(4.5) == 4); assert(lrint(5.5) == 6); assert(lrint(-4.5) == -4); assert(lrint(-5.5) == -6); assert(lrint(int.max - 0.5) == 2147483646L); assert(lrint(int.max + 0.5) == 2147483648L); assert(lrint(int.min - 0.5) == -2147483648L); assert(lrint(int.min + 0.5) == -2147483648L); } static if (real.mant_dig >= long.sizeof * 8) { @safe pure nothrow @nogc unittest { assert(lrint(long.max - 1.5L) == long.max - 1); assert(lrint(long.max - 0.5L) == long.max - 1); assert(lrint(long.min + 0.5L) == long.min); assert(lrint(long.min + 1.5L) == long.min + 2); } } /******************************************* * Return the value of x rounded to the nearest integer. * If the fractional part of x is exactly 0.5, the return value is * rounded away from zero. */ real round(real x) @trusted nothrow @nogc { version (CRuntime_Microsoft) { auto old = FloatingPointControl.getControlState(); FloatingPointControl.setControlState( (old & ~FloatingPointControl.ROUNDING_MASK) | FloatingPointControl.roundToZero ); x = rint((x >= 0) ? x + 0.5 : x - 0.5); FloatingPointControl.setControlState(old); return x; } else return core.stdc.math.roundl(x); } /********************************************** * Return the value of x rounded to the nearest integer. * * If the fractional part of x is exactly 0.5, the return value is rounded * away from zero. * * $(BLUE This function is Posix-Only.) */ long lround(real x) @trusted nothrow @nogc { version (Posix) return core.stdc.math.llroundl(x); else assert(0, "lround not implemented"); } version(Posix) { @safe nothrow @nogc unittest { assert(lround(0.49) == 0); assert(lround(0.5) == 1); assert(lround(1.5) == 2); } } /**************************************************** * Returns the integer portion of x, dropping the fractional portion. * * This is also known as "chop" rounding. */ real trunc(real x) @trusted nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x0C ; // round to 0 mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version(CRuntime_Microsoft) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x0C ; // round to 0 mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else return core.stdc.math.truncl(x); } /**************************************************** * Calculate the remainder x REM y, following IEC 60559. * * REM is the value of x - y * n, where n is the integer nearest the exact * value of x / y. * If |n - x / y| == 0.5, n is even. * If the result is zero, it has the same sign as x. * Otherwise, the sign of the result is the sign of x / y. * Precision mode has no effect on the remainder functions. * * remquo returns n in the parameter n. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH remainder(x, y)) $(TH n) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD not 0.0) $(TD $(PLUSMN)0.0) $(TD 0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD $(NAN)) $(TD ?) $(TD yes)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(NAN)) $(TD ?) $(TD yes)) * $(TR $(TD != $(PLUSMNINF)) $(TD $(PLUSMNINF)) $(TD x) $(TD ?) $(TD no)) * ) * * $(BLUE `remquo` and `remainder` not supported on Windows.) */ real remainder(real x, real y) @trusted nothrow @nogc { version (CRuntime_Microsoft) { int n; return remquo(x, y, n); } else return core.stdc.math.remainderl(x, y); } real remquo(real x, real y, out int n) @trusted nothrow @nogc /// ditto { version (Posix) return core.stdc.math.remquol(x, y, &n); else assert(0, "remquo not implemented"); } /** IEEE exception status flags ('sticky bits') These flags indicate that an exceptional floating-point condition has occurred. They indicate that a NaN or an infinity has been generated, that a result is inexact, or that a signalling NaN has been encountered. If floating-point exceptions are enabled (unmasked), a hardware exception will be generated instead of setting these flags. */ struct IeeeFlags { private: // The x87 FPU status register is 16 bits. // The Pentium SSE2 status register is 32 bits. uint flags; version (X86_Any) { // Applies to both x87 status word (16 bits) and SSE2 status word(32 bits). enum : int { INEXACT_MASK = 0x20, UNDERFLOW_MASK = 0x10, OVERFLOW_MASK = 0x08, DIVBYZERO_MASK = 0x04, INVALID_MASK = 0x01, EXCEPTIONS_MASK = 0b11_1111 } // Don't bother about subnormals, they are not supported on most CPUs. // SUBNORMAL_MASK = 0x02; } else version (PPC_Any) { // PowerPC FPSCR is a 32-bit register. enum : int { INEXACT_MASK = 0x02000000, DIVBYZERO_MASK = 0x04000000, UNDERFLOW_MASK = 0x08000000, OVERFLOW_MASK = 0x10000000, INVALID_MASK = 0x20000000 // Summary as PowerPC has five types of invalid exceptions. } } else version (ARM) { // ARM FPSCR is a 32bit register enum : int { INEXACT_MASK = 0x10, UNDERFLOW_MASK = 0x08, OVERFLOW_MASK = 0x04, DIVBYZERO_MASK = 0x02, INVALID_MASK = 0x01 } } else version(SPARC) { // SPARC FSR is a 32bit register //(64 bits for Sparc 7 & 8, but high 32 bits are uninteresting). enum : int { INEXACT_MASK = 0x020, UNDERFLOW_MASK = 0x080, OVERFLOW_MASK = 0x100, DIVBYZERO_MASK = 0x040, INVALID_MASK = 0x200 } } else static assert(0, "Not implemented"); private: static uint getIeeeFlags() { version(InlineAsm_X86_Any) { ushort sw; asm pure nothrow @nogc { fstsw sw; } // OR the result with the SSE2 status register (MXCSR). if (haveSSE) { uint mxcsr; asm pure nothrow @nogc { stmxcsr mxcsr; } return (sw | mxcsr) & EXCEPTIONS_MASK; } else return sw & EXCEPTIONS_MASK; } else version (SPARC) { /* int retval; asm pure nothrow @nogc { st %fsr, retval; } return retval; */ assert(0, "Not yet supported"); } else version (ARM) { assert(false, "Not yet supported."); } else assert(0, "Not yet supported"); } static void resetIeeeFlags() @nogc { version(InlineAsm_X86_Any) { asm pure nothrow @nogc { fnclex; } // Also clear exception flags in MXCSR, SSE's control register. if (haveSSE) { uint mxcsr; asm nothrow @nogc { stmxcsr mxcsr; } mxcsr &= ~EXCEPTIONS_MASK; asm nothrow @nogc { ldmxcsr mxcsr; } } } else { /* SPARC: int tmpval; asm pure nothrow @nogc { st %fsr, tmpval; } tmpval &=0xFFFF_FC00; asm pure nothrow @nogc { ld tmpval, %fsr; } */ assert(0, "Not yet supported"); } } public: version (IeeeFlagsSupport) { /** * The result cannot be represented exactly, so rounding occurred. * Example: `x = sin(0.1);` */ @property bool inexact() const { return (flags & INEXACT_MASK) != 0; } /** * A zero was generated by underflow * Example: `x = real.min*real.epsilon/2;` */ @property bool underflow() const { return (flags & UNDERFLOW_MASK) != 0; } /** * An infinity was generated by overflow * Example: `x = real.max*2;` */ @property bool overflow() const { return (flags & OVERFLOW_MASK) != 0; } /** * An infinity was generated by division by zero * Example: `x = 3/0.0;` */ @property bool divByZero() const { return (flags & DIVBYZERO_MASK) != 0; } /** * A machine NaN was generated. * Example: `x = real.infinity * 0.0;` */ @property bool invalid() const { return (flags & INVALID_MASK) != 0; } } } /// @system unittest { static void func() { int a = 10 * 10; } real a=3.5; // Set all the flags to zero resetIeeeFlags(); assert(!ieeeFlags.divByZero); // Perform a division by zero. a/=0.0L; assert(a == real.infinity); assert(ieeeFlags.divByZero); // Create a NaN a*=0.0L; assert(ieeeFlags.invalid); assert(isNaN(a)); // Check that calling func() has no effect on the // status flags. IeeeFlags f = ieeeFlags; func(); assert(ieeeFlags == f); } @system unittest { import std.meta : AliasSeq; static struct Test { void delegate() action; bool function() ieeeCheck; } foreach (T; AliasSeq!(float, double, real)) { T x; /* Needs to be here to trick -O. It would optimize away the calculations if x were local to the function literals. */ auto tests = [ Test( () { x = 1; x += 0.1; }, () => ieeeFlags.inexact ), Test( () { x = T.min_normal; x /= T.max; }, () => ieeeFlags.underflow ), Test( () { x = T.max; x += T.max; }, () => ieeeFlags.overflow ), Test( () { x = 1; x /= 0; }, () => ieeeFlags.divByZero ), Test( () { x = 0; x /= 0; }, () => ieeeFlags.invalid ) ]; foreach (test; tests) { resetIeeeFlags(); assert(!test.ieeeCheck()); test.action(); assert(test.ieeeCheck()); } } } version(X86_Any) { version = IeeeFlagsSupport; } else version(ARM) { version = IeeeFlagsSupport; } /// Set all of the floating-point status flags to false. void resetIeeeFlags() @nogc { IeeeFlags.resetIeeeFlags(); } /// Returns: snapshot of the current state of the floating-point status flags @property IeeeFlags ieeeFlags() { return IeeeFlags(IeeeFlags.getIeeeFlags()); } /** Control the Floating point hardware Change the IEEE754 floating-point rounding mode and the floating-point hardware exceptions. By default, the rounding mode is roundToNearest and all hardware exceptions are disabled. For most applications, debugging is easier if the $(I division by zero), $(I overflow), and $(I invalid operation) exceptions are enabled. These three are combined into a $(I severeExceptions) value for convenience. Note in particular that if $(I invalidException) is enabled, a hardware trap will be generated whenever an uninitialized floating-point variable is used. All changes are temporary. The previous state is restored at the end of the scope. Example: ---- { FloatingPointControl fpctrl; // Enable hardware exceptions for division by zero, overflow to infinity, // invalid operations, and uninitialized floating-point variables. fpctrl.enableExceptions(FloatingPointControl.severeExceptions); // This will generate a hardware exception, if x is a // default-initialized floating point variable: real x; // Add `= 0` or even `= real.nan` to not throw the exception. real y = x * 3.0; // The exception is only thrown for default-uninitialized NaN-s. // NaN-s with other payload are valid: real z = y * real.nan; // ok // Changing the rounding mode: fpctrl.rounding = FloatingPointControl.roundUp; assert(rint(1.1) == 2); // The set hardware exceptions will be disabled when leaving this scope. // The original rounding mode will also be restored. } // Ensure previous values are returned: assert(!FloatingPointControl.enabledExceptions); assert(FloatingPointControl.rounding == FloatingPointControl.roundToNearest); assert(rint(1.1) == 1); ---- */ struct FloatingPointControl { alias RoundingMode = uint; /// version(StdDdoc) { enum : RoundingMode { /** IEEE rounding modes. * The default mode is roundToNearest. */ roundToNearest, roundDown, /// ditto roundUp, /// ditto roundToZero /// ditto } } else version(ARM) { enum : RoundingMode { roundToNearest = 0x000000, roundDown = 0x800000, roundUp = 0x400000, roundToZero = 0xC00000 } } else version(PPC_Any) { enum : RoundingMode { roundToNearest = 0x00000000, roundDown = 0x00000003, roundUp = 0x00000002, roundToZero = 0x00000001 } } else { enum : RoundingMode { roundToNearest = 0x0000, roundDown = 0x0400, roundUp = 0x0800, roundToZero = 0x0C00 } } //// Change the floating-point hardware rounding mode @property void rounding(RoundingMode newMode) @nogc { initialize(); setControlState((getControlState() & (-1 - ROUNDING_MASK)) | (newMode & ROUNDING_MASK)); } /// Returns: the currently active rounding mode @property static RoundingMode rounding() @nogc { return cast(RoundingMode)(getControlState() & ROUNDING_MASK); } version(StdDdoc) { enum : uint { /** IEEE hardware exceptions. * By default, all exceptions are masked (disabled). * * severeExceptions = The overflow, division by zero, and invalid * exceptions. */ subnormalException, inexactException, /// ditto underflowException, /// ditto overflowException, /// ditto divByZeroException, /// ditto invalidException, /// ditto severeExceptions, /// ditto allExceptions, /// ditto } } else version(ARM) { enum : uint { subnormalException = 0x8000, inexactException = 0x1000, underflowException = 0x0800, overflowException = 0x0400, divByZeroException = 0x0200, invalidException = 0x0100, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException | subnormalException, } } else version(PPC_Any) { enum : uint { inexactException = 0x0008, divByZeroException = 0x0010, underflowException = 0x0020, overflowException = 0x0040, invalidException = 0x0080, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else { enum : uint { inexactException = 0x20, underflowException = 0x10, overflowException = 0x08, divByZeroException = 0x04, subnormalException = 0x02, invalidException = 0x01, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException | subnormalException, } } private: version(ARM) { enum uint EXCEPTION_MASK = 0x9F00; enum uint ROUNDING_MASK = 0xC00000; } else version(PPC_Any) { enum uint EXCEPTION_MASK = 0x00F8; enum uint ROUNDING_MASK = 0x0003; } else version(X86) { enum ushort EXCEPTION_MASK = 0x3F; enum ushort ROUNDING_MASK = 0xC00; } else version(X86_64) { enum ushort EXCEPTION_MASK = 0x3F; enum ushort ROUNDING_MASK = 0xC00; } else static assert(false, "Architecture not supported"); public: /// Returns: true if the current FPU supports exception trapping @property static bool hasExceptionTraps() @safe nothrow @nogc { version(X86_Any) return true; else version(PPC_Any) return true; else version(ARM) { auto oldState = getControlState(); // If exceptions are not supported, we set the bit but read it back as zero // https://sourceware.org/ml/libc-ports/2012-06/msg00091.html setControlState(oldState | (divByZeroException & EXCEPTION_MASK)); immutable result = (getControlState() & EXCEPTION_MASK) != 0; setControlState(oldState); return result; } else static assert(false, "Not implemented for this architecture"); } /// Enable (unmask) specific hardware exceptions. Multiple exceptions may be ORed together. void enableExceptions(uint exceptions) @nogc { assert(hasExceptionTraps); initialize(); version(X86_Any) setControlState(getControlState() & ~(exceptions & EXCEPTION_MASK)); else setControlState(getControlState() | (exceptions & EXCEPTION_MASK)); } /// Disable (mask) specific hardware exceptions. Multiple exceptions may be ORed together. void disableExceptions(uint exceptions) @nogc { assert(hasExceptionTraps); initialize(); version(X86_Any) setControlState(getControlState() | (exceptions & EXCEPTION_MASK)); else setControlState(getControlState() & ~(exceptions & EXCEPTION_MASK)); } /// Returns: the exceptions which are currently enabled (unmasked) @property static uint enabledExceptions() @nogc { assert(hasExceptionTraps); version(X86_Any) return (getControlState() & EXCEPTION_MASK) ^ EXCEPTION_MASK; else return (getControlState() & EXCEPTION_MASK); } /// Clear all pending exceptions, then restore the original exception state and rounding mode. ~this() @nogc { clearExceptions(); if (initialized) setControlState(savedState); } private: ControlState savedState; bool initialized = false; version(ARM) { alias ControlState = uint; } else version(PPC_Any) { alias ControlState = uint; } else { alias ControlState = ushort; } void initialize() @nogc { // BUG: This works around the absence of this() constructors. if (initialized) return; clearExceptions(); savedState = getControlState(); initialized = true; } // Clear all pending exceptions static void clearExceptions() @nogc { resetIeeeFlags(); } // Read from the control register static ControlState getControlState() @trusted nothrow @nogc { version (D_InlineAsm_X86) { short cont; asm nothrow @nogc { xor EAX, EAX; fstcw cont; } return cont; } else version (D_InlineAsm_X86_64) { short cont; asm nothrow @nogc { xor RAX, RAX; fstcw cont; } return cont; } else assert(0, "Not yet supported"); } // Set the control register static void setControlState(ControlState newState) @trusted nothrow @nogc { version (InlineAsm_X86_Any) { asm nothrow @nogc { fclex; fldcw newState; } // Also update MXCSR, SSE's control register. if (haveSSE) { uint mxcsr; asm nothrow @nogc { stmxcsr mxcsr; } /* In the FPU control register, rounding mode is in bits 10 and 11. In MXCSR it's in bits 13 and 14. */ enum ROUNDING_MASK_SSE = ROUNDING_MASK << 3; immutable newRoundingModeSSE = (newState & ROUNDING_MASK) << 3; mxcsr &= ~ROUNDING_MASK_SSE; // delete old rounding mode mxcsr |= newRoundingModeSSE; // write new rounding mode /* In the FPU control register, masks are bits 0 through 5. In MXCSR they're 7 through 12. */ enum EXCEPTION_MASK_SSE = EXCEPTION_MASK << 7; immutable newExceptionMasks = (newState & EXCEPTION_MASK) << 7; mxcsr &= ~EXCEPTION_MASK_SSE; // delete old masks mxcsr |= newExceptionMasks; // write new exception masks asm nothrow @nogc { ldmxcsr mxcsr; } } } else assert(0, "Not yet supported"); } } @system unittest { void ensureDefaults() { assert(FloatingPointControl.rounding == FloatingPointControl.roundToNearest); if (FloatingPointControl.hasExceptionTraps) assert(FloatingPointControl.enabledExceptions == 0); } { FloatingPointControl ctrl; } ensureDefaults(); version(D_HardFloat) { { FloatingPointControl ctrl; ctrl.rounding = FloatingPointControl.roundDown; assert(FloatingPointControl.rounding == FloatingPointControl.roundDown); } ensureDefaults(); } if (FloatingPointControl.hasExceptionTraps) { FloatingPointControl ctrl; ctrl.enableExceptions(FloatingPointControl.divByZeroException | FloatingPointControl.overflowException); assert(ctrl.enabledExceptions == (FloatingPointControl.divByZeroException | FloatingPointControl.overflowException)); ctrl.rounding = FloatingPointControl.roundUp; assert(FloatingPointControl.rounding == FloatingPointControl.roundUp); } ensureDefaults(); } @system unittest // rounding { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { FloatingPointControl fpctrl; fpctrl.rounding = FloatingPointControl.roundUp; T u = 1; u += 0.1; fpctrl.rounding = FloatingPointControl.roundDown; T d = 1; d += 0.1; fpctrl.rounding = FloatingPointControl.roundToZero; T z = 1; z += 0.1; assert(u > d); assert(z == d); fpctrl.rounding = FloatingPointControl.roundUp; u = -1; u -= 0.1; fpctrl.rounding = FloatingPointControl.roundDown; d = -1; d -= 0.1; fpctrl.rounding = FloatingPointControl.roundToZero; z = -1; z -= 0.1; assert(u > d); assert(z == u); } } /********************************* * Determines if $(D_PARAM x) is NaN. * Params: * x = a floating point number. * Returns: * $(D true) if $(D_PARAM x) is Nan. */ bool isNaN(X)(X x) @nogc @trusted pure nothrow if (isFloatingPoint!(X)) { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { const uint p = *cast(uint *)&x; return ((p & 0x7F80_0000) == 0x7F80_0000) && p & 0x007F_FFFF; // not infinity } else static if (F.realFormat == RealFormat.ieeeDouble) { const ulong p = *cast(ulong *)&x; return ((p & 0x7FF0_0000_0000_0000) == 0x7FF0_0000_0000_0000) && p & 0x000F_FFFF_FFFF_FFFF; // not infinity } else static if (F.realFormat == RealFormat.ieeeExtended) { const ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; const ulong ps = *cast(ulong *)&x; return e == F.EXPMASK && ps & 0x7FFF_FFFF_FFFF_FFFF; // not infinity } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; const ulong psLsb = (cast(ulong *)&x)[MANTISSA_LSB]; const ulong psMsb = (cast(ulong *)&x)[MANTISSA_MSB]; return e == F.EXPMASK && (psLsb | (psMsb& 0x0000_FFFF_FFFF_FFFF)) != 0; } else { return x != x; } } /// @safe pure nothrow @nogc unittest { assert( isNaN(float.init)); assert( isNaN(-double.init)); assert( isNaN(real.nan)); assert( isNaN(-real.nan)); assert(!isNaN(cast(float) 53.6)); assert(!isNaN(cast(real)-53.6)); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { // CTFE-able tests assert(isNaN(T.init)); assert(isNaN(-T.init)); assert(isNaN(T.nan)); assert(isNaN(-T.nan)); assert(!isNaN(T.infinity)); assert(!isNaN(-T.infinity)); assert(!isNaN(cast(T) 53.6)); assert(!isNaN(cast(T)-53.6)); // Runtime tests shared T f; f = T.init; assert(isNaN(f)); assert(isNaN(-f)); f = T.nan; assert(isNaN(f)); assert(isNaN(-f)); f = T.infinity; assert(!isNaN(f)); assert(!isNaN(-f)); f = cast(T) 53.6; assert(!isNaN(f)); assert(!isNaN(-f)); } } /********************************* * Determines if $(D_PARAM x) is finite. * Params: * x = a floating point number. * Returns: * $(D true) if $(D_PARAM x) is finite. */ bool isFinite(X)(X x) @trusted pure nothrow @nogc { alias F = floatTraits!(X); ushort* pe = cast(ushort *)&x; return (pe[F.EXPPOS_SHORT] & F.EXPMASK) != F.EXPMASK; } /// @safe pure nothrow @nogc unittest { assert( isFinite(1.23f)); assert( isFinite(float.max)); assert( isFinite(float.min_normal)); assert(!isFinite(float.nan)); assert(!isFinite(float.infinity)); } @safe pure nothrow @nogc unittest { assert(isFinite(1.23)); assert(isFinite(double.max)); assert(isFinite(double.min_normal)); assert(!isFinite(double.nan)); assert(!isFinite(double.infinity)); assert(isFinite(1.23L)); assert(isFinite(real.max)); assert(isFinite(real.min_normal)); assert(!isFinite(real.nan)); assert(!isFinite(real.infinity)); } /********************************* * Determines if $(D_PARAM x) is normalized. * * A normalized number must not be zero, subnormal, infinite nor $(NAN). * * Params: * x = a floating point number. * Returns: * $(D true) if $(D_PARAM x) is normalized. */ /* Need one for each format because subnormal floats might * be converted to normal reals. */ bool isNormal(X)(X x) @trusted pure nothrow @nogc { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ibmExtended) { // doubledouble is normal if the least significant part is normal. return isNormal((cast(double*)&x)[MANTISSA_LSB]); } else { ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; return (e != F.EXPMASK && e != 0); } } /// @safe pure nothrow @nogc unittest { float f = 3; double d = 500; real e = 10e+48; assert(isNormal(f)); assert(isNormal(d)); assert(isNormal(e)); f = d = e = 0; assert(!isNormal(f)); assert(!isNormal(d)); assert(!isNormal(e)); assert(!isNormal(real.infinity)); assert(isNormal(-real.max)); assert(!isNormal(real.min_normal/4)); } /********************************* * Determines if $(D_PARAM x) is subnormal. * * Subnormals (also known as "denormal number"), have a 0 exponent * and a 0 most significant mantissa bit. * * Params: * x = a floating point number. * Returns: * $(D true) if $(D_PARAM x) is a denormal number. */ bool isSubnormal(X)(X x) @trusted pure nothrow @nogc { /* Need one for each format because subnormal floats might be converted to normal reals. */ alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { uint *p = cast(uint *)&x; return (*p & F.EXPMASK_INT) == 0 && *p & F.MANTISSAMASK_INT; } else static if (F.realFormat == RealFormat.ieeeDouble) { uint *p = cast(uint *)&x; return (p[MANTISSA_MSB] & F.EXPMASK_INT) == 0 && (p[MANTISSA_LSB] || p[MANTISSA_MSB] & F.MANTISSAMASK_INT); } else static if (F.realFormat == RealFormat.ieeeQuadruple) { ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; long* ps = cast(long *)&x; return (e == 0 && ((ps[MANTISSA_LSB]|(ps[MANTISSA_MSB]& 0x0000_FFFF_FFFF_FFFF)) != 0)); } else static if (F.realFormat == RealFormat.ieeeExtended) { ushort* pe = cast(ushort *)&x; long* ps = cast(long *)&x; return (pe[F.EXPPOS_SHORT] & F.EXPMASK) == 0 && *ps > 0; } else static if (F.realFormat == RealFormat.ibmExtended) { return isSubnormal((cast(double*)&x)[MANTISSA_MSB]); } else { static assert(false, "Not implemented for this architecture"); } } /// @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { T f; for (f = 1.0; !isSubnormal(f); f /= 2) assert(f != 0); } } /********************************* * Determines if $(D_PARAM x) is $(PLUSMN)$(INFIN). * Params: * x = a floating point number. * Returns: * $(D true) if $(D_PARAM x) is $(PLUSMN)$(INFIN). */ bool isInfinity(X)(X x) @nogc @trusted pure nothrow if (isFloatingPoint!(X)) { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { return ((*cast(uint *)&x) & 0x7FFF_FFFF) == 0x7F80_0000; } else static if (F.realFormat == RealFormat.ieeeDouble) { return ((*cast(ulong *)&x) & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FF0_0000_0000_0000; } else static if (F.realFormat == RealFormat.ieeeExtended) { const ushort e = cast(ushort)(F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]); const ulong ps = *cast(ulong *)&x; // On Motorola 68K, infinity can have hidden bit = 1 or 0. On x86, it is always 1. return e == F.EXPMASK && (ps & 0x7FFF_FFFF_FFFF_FFFF) == 0; } else static if (F.realFormat == RealFormat.ibmExtended) { return (((cast(ulong *)&x)[MANTISSA_MSB]) & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FF8_0000_0000_0000; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const long psLsb = (cast(long *)&x)[MANTISSA_LSB]; const long psMsb = (cast(long *)&x)[MANTISSA_MSB]; return (psLsb == 0) && (psMsb & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FFF_0000_0000_0000; } else { return (x < -X.max) || (X.max < x); } } /// @nogc @safe pure nothrow unittest { assert(!isInfinity(float.init)); assert(!isInfinity(-float.init)); assert(!isInfinity(float.nan)); assert(!isInfinity(-float.nan)); assert(isInfinity(float.infinity)); assert(isInfinity(-float.infinity)); assert(isInfinity(-1.0f / 0.0f)); } @safe pure nothrow @nogc unittest { // CTFE-able tests assert(!isInfinity(double.init)); assert(!isInfinity(-double.init)); assert(!isInfinity(double.nan)); assert(!isInfinity(-double.nan)); assert(isInfinity(double.infinity)); assert(isInfinity(-double.infinity)); assert(isInfinity(-1.0 / 0.0)); assert(!isInfinity(real.init)); assert(!isInfinity(-real.init)); assert(!isInfinity(real.nan)); assert(!isInfinity(-real.nan)); assert(isInfinity(real.infinity)); assert(isInfinity(-real.infinity)); assert(isInfinity(-1.0L / 0.0L)); // Runtime tests shared float f; f = float.init; assert(!isInfinity(f)); assert(!isInfinity(-f)); f = float.nan; assert(!isInfinity(f)); assert(!isInfinity(-f)); f = float.infinity; assert(isInfinity(f)); assert(isInfinity(-f)); f = (-1.0f / 0.0f); assert(isInfinity(f)); shared double d; d = double.init; assert(!isInfinity(d)); assert(!isInfinity(-d)); d = double.nan; assert(!isInfinity(d)); assert(!isInfinity(-d)); d = double.infinity; assert(isInfinity(d)); assert(isInfinity(-d)); d = (-1.0 / 0.0); assert(isInfinity(d)); shared real e; e = real.init; assert(!isInfinity(e)); assert(!isInfinity(-e)); e = real.nan; assert(!isInfinity(e)); assert(!isInfinity(-e)); e = real.infinity; assert(isInfinity(e)); assert(isInfinity(-e)); e = (-1.0L / 0.0L); assert(isInfinity(e)); } /********************************* * Is the binary representation of x identical to y? * * Same as ==, except that positive and negative zero are not identical, * and two $(NAN)s are identical if they have the same 'payload'. */ bool isIdentical(real x, real y) @trusted pure nothrow @nogc { // We're doing a bitwise comparison so the endianness is irrelevant. long* pxs = cast(long *)&x; long* pys = cast(long *)&y; alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { return pxs[0] == pys[0]; } else static if (F.realFormat == RealFormat.ieeeQuadruple || F.realFormat == RealFormat.ibmExtended) { return pxs[0] == pys[0] && pxs[1] == pys[1]; } else { ushort* pxe = cast(ushort *)&x; ushort* pye = cast(ushort *)&y; return pxe[4] == pye[4] && pxs[0] == pys[0]; } } /********************************* * Return 1 if sign bit of e is set, 0 if not. */ int signbit(X)(X x) @nogc @trusted pure nothrow { alias F = floatTraits!(X); return ((cast(ubyte *)&x)[F.SIGNPOS_BYTE] & 0x80) != 0; } /// @nogc @safe pure nothrow unittest { assert(!signbit(float.nan)); assert(signbit(-float.nan)); assert(!signbit(168.1234f)); assert(signbit(-168.1234f)); assert(!signbit(0.0f)); assert(signbit(-0.0f)); assert(signbit(-float.max)); assert(!signbit(float.max)); assert(!signbit(double.nan)); assert(signbit(-double.nan)); assert(!signbit(168.1234)); assert(signbit(-168.1234)); assert(!signbit(0.0)); assert(signbit(-0.0)); assert(signbit(-double.max)); assert(!signbit(double.max)); assert(!signbit(real.nan)); assert(signbit(-real.nan)); assert(!signbit(168.1234L)); assert(signbit(-168.1234L)); assert(!signbit(0.0L)); assert(signbit(-0.0L)); assert(signbit(-real.max)); assert(!signbit(real.max)); } /********************************* * Return a value composed of to with from's sign bit. */ R copysign(R, X)(R to, X from) @trusted pure nothrow @nogc if (isFloatingPoint!(R) && isFloatingPoint!(X)) { ubyte* pto = cast(ubyte *)&to; const ubyte* pfrom = cast(ubyte *)&from; alias T = floatTraits!(R); alias F = floatTraits!(X); pto[T.SIGNPOS_BYTE] &= 0x7F; pto[T.SIGNPOS_BYTE] |= pfrom[F.SIGNPOS_BYTE] & 0x80; return to; } // ditto R copysign(R, X)(X to, R from) @trusted pure nothrow @nogc if (isIntegral!(X) && isFloatingPoint!(R)) { return copysign(cast(R) to, from); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; foreach (X; AliasSeq!(float, double, real, int, long)) { foreach (Y; AliasSeq!(float, double, real)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 X x = 21; Y y = 23.8; Y e = void; e = copysign(x, y); assert(e == 21.0); e = copysign(-x, y); assert(e == 21.0); e = copysign(x, -y); assert(e == -21.0); e = copysign(-x, -y); assert(e == -21.0); static if (isFloatingPoint!X) { e = copysign(X.nan, y); assert(isNaN(e) && !signbit(e)); e = copysign(X.nan, -y); assert(isNaN(e) && signbit(e)); } }(); } } /********************************* Returns $(D -1) if $(D x < 0), $(D x) if $(D x == 0), $(D 1) if $(D x > 0), and $(NAN) if x==$(NAN). */ F sgn(F)(F x) @safe pure nothrow @nogc { // @@@TODO@@@: make this faster return x > 0 ? 1 : x < 0 ? -1 : x; } /// @safe pure nothrow @nogc unittest { assert(sgn(168.1234) == 1); assert(sgn(-168.1234) == -1); assert(sgn(0.0) == 0); assert(sgn(-0.0) == 0); } // Functions for NaN payloads /* * A 'payload' can be stored in the significand of a $(NAN). One bit is required * to distinguish between a quiet and a signalling $(NAN). This leaves 22 bits * of payload for a float; 51 bits for a double; 62 bits for an 80-bit real; * and 111 bits for a 128-bit quad. */ /** * Create a quiet $(NAN), storing an integer inside the payload. * * For floats, the largest possible payload is 0x3F_FFFF. * For doubles, it is 0x3_FFFF_FFFF_FFFF. * For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF. */ real NaN(ulong payload) @trusted pure nothrow @nogc { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeExtended) { // real80 (in x86 real format, the implied bit is actually // not implied but a real bit which is stored in the real) ulong v = 3; // implied bit = 1, quiet bit = 1 } else { ulong v = 1; // no implied bit. quiet bit = 1 } ulong a = payload; // 22 Float bits ulong w = a & 0x3F_FFFF; a -= w; v <<=22; v |= w; a >>=22; // 29 Double bits v <<=29; w = a & 0xFFF_FFFF; v |= w; a -= w; a >>=29; static if (F.realFormat == RealFormat.ieeeDouble) { v |= 0x7FF0_0000_0000_0000; real x; * cast(ulong *)(&x) = v; return x; } else { v <<=11; a &= 0x7FF; v |= a; real x = real.nan; // Extended real bits static if (F.realFormat == RealFormat.ieeeQuadruple) { v <<= 1; // there's no implicit bit version(LittleEndian) { *cast(ulong*)(6+cast(ubyte*)(&x)) = v; } else { *cast(ulong*)(2+cast(ubyte*)(&x)) = v; } } else { *cast(ulong *)(&x) = v; } return x; } } @system pure nothrow @nogc unittest // not @safe because taking address of local. { static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { auto x = NaN(1); auto xl = *cast(ulong*)&x; assert(xl & 0x8_0000_0000_0000UL); //non-signaling bit, bit 52 assert((xl & 0x7FF0_0000_0000_0000UL) == 0x7FF0_0000_0000_0000UL); //all exp bits set } } /** * Extract an integral payload from a $(NAN). * * Returns: * the integer payload as a ulong. * * For floats, the largest possible payload is 0x3F_FFFF. * For doubles, it is 0x3_FFFF_FFFF_FFFF. * For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF. */ ulong getNaNPayload(real x) @trusted pure nothrow @nogc { // assert(isNaN(x)); alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { ulong m = *cast(ulong *)(&x); // Make it look like an 80-bit significand. // Skip exponent, and quiet bit m &= 0x0007_FFFF_FFFF_FFFF; m <<= 11; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { version(LittleEndian) { ulong m = *cast(ulong*)(6+cast(ubyte*)(&x)); } else { ulong m = *cast(ulong*)(2+cast(ubyte*)(&x)); } m >>= 1; // there's no implicit bit } else { ulong m = *cast(ulong *)(&x); } // ignore implicit bit and quiet bit const ulong f = m & 0x3FFF_FF00_0000_0000L; ulong w = f >>> 40; w |= (m & 0x00FF_FFFF_F800L) << (22 - 11); w |= (m & 0x7FF) << 51; return w; } debug(UnitTest) { @safe pure nothrow @nogc unittest { real nan4 = NaN(0x789_ABCD_EF12_3456); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended || floatTraits!(real).realFormat == RealFormat.ieeeQuadruple) { assert(getNaNPayload(nan4) == 0x789_ABCD_EF12_3456); } else { assert(getNaNPayload(nan4) == 0x1_ABCD_EF12_3456); } double nan5 = nan4; assert(getNaNPayload(nan5) == 0x1_ABCD_EF12_3456); float nan6 = nan4; assert(getNaNPayload(nan6) == 0x12_3456); nan4 = NaN(0xFABCD); assert(getNaNPayload(nan4) == 0xFABCD); nan6 = nan4; assert(getNaNPayload(nan6) == 0xFABCD); nan5 = NaN(0x100_0000_0000_3456); assert(getNaNPayload(nan5) == 0x0000_0000_3456); } } /** * Calculate the next largest floating point value after x. * * Return the least number greater than x that is representable as a real; * thus, it gives the next point on the IEEE number line. * * $(TABLE_SV * $(SVH x, nextUp(x) ) * $(SV -$(INFIN), -real.max ) * $(SV $(PLUSMN)0.0, real.min_normal*real.epsilon ) * $(SV real.max, $(INFIN) ) * $(SV $(INFIN), $(INFIN) ) * $(SV $(NAN), $(NAN) ) * ) */ real nextUp(real x) @trusted pure nothrow @nogc { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { return nextUp(cast(double) x); } else static if (F.realFormat == RealFormat.ieeeQuadruple) { ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; if (e == F.EXPMASK) { // NaN or Infinity if (x == -real.infinity) return -real.max; return x; // +Inf and NaN are unchanged. } auto ps = cast(ulong *)&x; if (ps[MANTISSA_MSB] & 0x8000_0000_0000_0000) { // Negative number if (ps[MANTISSA_LSB] == 0 && ps[MANTISSA_MSB] == 0x8000_0000_0000_0000) { // it was negative zero, change to smallest subnormal ps[MANTISSA_LSB] = 1; ps[MANTISSA_MSB] = 0; return x; } if (ps[MANTISSA_LSB] == 0) --ps[MANTISSA_MSB]; --ps[MANTISSA_LSB]; } else { // Positive number ++ps[MANTISSA_LSB]; if (ps[MANTISSA_LSB] == 0) ++ps[MANTISSA_MSB]; } return x; } else static if (F.realFormat == RealFormat.ieeeExtended) { // For 80-bit reals, the "implied bit" is a nuisance... ushort *pe = cast(ushort *)&x; ulong *ps = cast(ulong *)&x; if ((pe[F.EXPPOS_SHORT] & F.EXPMASK) == F.EXPMASK) { // First, deal with NANs and infinity if (x == -real.infinity) return -real.max; return x; // +Inf and NaN are unchanged. } if (pe[F.EXPPOS_SHORT] & 0x8000) { // Negative number -- need to decrease the significand --*ps; // Need to mask with 0x7FFF... so subnormals are treated correctly. if ((*ps & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FFF_FFFF_FFFF_FFFF) { if (pe[F.EXPPOS_SHORT] == 0x8000) // it was negative zero { *ps = 1; pe[F.EXPPOS_SHORT] = 0; // smallest subnormal. return x; } --pe[F.EXPPOS_SHORT]; if (pe[F.EXPPOS_SHORT] == 0x8000) return x; // it's become a subnormal, implied bit stays low. *ps = 0xFFFF_FFFF_FFFF_FFFF; // set the implied bit return x; } return x; } else { // Positive number -- need to increase the significand. // Works automatically for positive zero. ++*ps; if ((*ps & 0x7FFF_FFFF_FFFF_FFFF) == 0) { // change in exponent ++pe[F.EXPPOS_SHORT]; *ps = 0x8000_0000_0000_0000; // set the high bit } } return x; } else // static if (F.realFormat == RealFormat.ibmExtended) { assert(0, "nextUp not implemented"); } } /** ditto */ double nextUp(double x) @trusted pure nothrow @nogc { ulong *ps = cast(ulong *)&x; if ((*ps & 0x7FF0_0000_0000_0000) == 0x7FF0_0000_0000_0000) { // First, deal with NANs and infinity if (x == -x.infinity) return -x.max; return x; // +INF and NAN are unchanged. } if (*ps & 0x8000_0000_0000_0000) // Negative number { if (*ps == 0x8000_0000_0000_0000) // it was negative zero { *ps = 0x0000_0000_0000_0001; // change to smallest subnormal return x; } --*ps; } else { // Positive number ++*ps; } return x; } /** ditto */ float nextUp(float x) @trusted pure nothrow @nogc { uint *ps = cast(uint *)&x; if ((*ps & 0x7F80_0000) == 0x7F80_0000) { // First, deal with NANs and infinity if (x == -x.infinity) return -x.max; return x; // +INF and NAN are unchanged. } if (*ps & 0x8000_0000) // Negative number { if (*ps == 0x8000_0000) // it was negative zero { *ps = 0x0000_0001; // change to smallest subnormal return x; } --*ps; } else { // Positive number ++*ps; } return x; } /** * Calculate the next smallest floating point value before x. * * Return the greatest number less than x that is representable as a real; * thus, it gives the previous point on the IEEE number line. * * $(TABLE_SV * $(SVH x, nextDown(x) ) * $(SV $(INFIN), real.max ) * $(SV $(PLUSMN)0.0, -real.min_normal*real.epsilon ) * $(SV -real.max, -$(INFIN) ) * $(SV -$(INFIN), -$(INFIN) ) * $(SV $(NAN), $(NAN) ) * ) */ real nextDown(real x) @safe pure nothrow @nogc { return -nextUp(-x); } /** ditto */ double nextDown(double x) @safe pure nothrow @nogc { return -nextUp(-x); } /** ditto */ float nextDown(float x) @safe pure nothrow @nogc { return -nextUp(-x); } /// @safe pure nothrow @nogc unittest { assert( nextDown(1.0 + real.epsilon) == 1.0); } @safe pure nothrow @nogc unittest { static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { // Tests for 80-bit reals assert(isIdentical(nextUp(NaN(0xABC)), NaN(0xABC))); // negative numbers assert( nextUp(-real.infinity) == -real.max ); assert( nextUp(-1.0L-real.epsilon) == -1.0 ); assert( nextUp(-2.0L) == -2.0 + real.epsilon); // subnormals and zero assert( nextUp(-real.min_normal) == -real.min_normal*(1-real.epsilon) ); assert( nextUp(-real.min_normal*(1-real.epsilon)) == -real.min_normal*(1-2*real.epsilon) ); assert( isIdentical(-0.0L, nextUp(-real.min_normal*real.epsilon)) ); assert( nextUp(-0.0L) == real.min_normal*real.epsilon ); assert( nextUp(0.0L) == real.min_normal*real.epsilon ); assert( nextUp(real.min_normal*(1-real.epsilon)) == real.min_normal ); assert( nextUp(real.min_normal) == real.min_normal*(1+real.epsilon) ); // positive numbers assert( nextUp(1.0L) == 1.0 + real.epsilon ); assert( nextUp(2.0L-real.epsilon) == 2.0 ); assert( nextUp(real.max) == real.infinity ); assert( nextUp(real.infinity)==real.infinity ); } double n = NaN(0xABC); assert(isIdentical(nextUp(n), n)); // negative numbers assert( nextUp(-double.infinity) == -double.max ); assert( nextUp(-1-double.epsilon) == -1.0 ); assert( nextUp(-2.0) == -2.0 + double.epsilon); // subnormals and zero assert( nextUp(-double.min_normal) == -double.min_normal*(1-double.epsilon) ); assert( nextUp(-double.min_normal*(1-double.epsilon)) == -double.min_normal*(1-2*double.epsilon) ); assert( isIdentical(-0.0, nextUp(-double.min_normal*double.epsilon)) ); assert( nextUp(0.0) == double.min_normal*double.epsilon ); assert( nextUp(-0.0) == double.min_normal*double.epsilon ); assert( nextUp(double.min_normal*(1-double.epsilon)) == double.min_normal ); assert( nextUp(double.min_normal) == double.min_normal*(1+double.epsilon) ); // positive numbers assert( nextUp(1.0) == 1.0 + double.epsilon ); assert( nextUp(2.0-double.epsilon) == 2.0 ); assert( nextUp(double.max) == double.infinity ); float fn = NaN(0xABC); assert(isIdentical(nextUp(fn), fn)); float f = -float.min_normal*(1-float.epsilon); float f1 = -float.min_normal; assert( nextUp(f1) == f); f = 1.0f+float.epsilon; f1 = 1.0f; assert( nextUp(f1) == f ); f1 = -0.0f; assert( nextUp(f1) == float.min_normal*float.epsilon); assert( nextUp(float.infinity)==float.infinity ); assert(nextDown(1.0L+real.epsilon)==1.0); assert(nextDown(1.0+double.epsilon)==1.0); f = 1.0f+float.epsilon; assert(nextDown(f)==1.0); assert(nextafter(1.0+real.epsilon, -real.infinity)==1.0); } /****************************************** * Calculates the next representable value after x in the direction of y. * * If y > x, the result will be the next largest floating-point value; * if y < x, the result will be the next smallest value. * If x == y, the result is y. * * Remarks: * This function is not generally very useful; it's almost always better to use * the faster functions nextUp() or nextDown() instead. * * The FE_INEXACT and FE_OVERFLOW exceptions will be raised if x is finite and * the function result is infinite. The FE_INEXACT and FE_UNDERFLOW * exceptions will be raised if the function value is subnormal, and x is * not equal to y. */ T nextafter(T)(const T x, const T y) @safe pure nothrow @nogc { if (x == y) return y; return ((y>x) ? nextUp(x) : nextDown(x)); } /// @safe pure nothrow @nogc unittest { float a = 1; assert(is(typeof(nextafter(a, a)) == float)); assert(nextafter(a, a.infinity) > a); double b = 2; assert(is(typeof(nextafter(b, b)) == double)); assert(nextafter(b, b.infinity) > b); real c = 3; assert(is(typeof(nextafter(c, c)) == real)); assert(nextafter(c, c.infinity) > c); } //real nexttoward(real x, real y) { return core.stdc.math.nexttowardl(x, y); } /******************************************* * Returns the positive difference between x and y. * Returns: * $(TABLE_SV * $(TR $(TH x, y) $(TH fdim(x, y))) * $(TR $(TD x $(GT) y) $(TD x - y)) * $(TR $(TD x $(LT)= y) $(TD +0.0)) * ) */ real fdim(real x, real y) @safe pure nothrow @nogc { return (x > y) ? x - y : +0.0; } /**************************************** * Returns the larger of x and y. */ real fmax(real x, real y) @safe pure nothrow @nogc { return x > y ? x : y; } /**************************************** * Returns the smaller of x and y. */ real fmin(real x, real y) @safe pure nothrow @nogc { return x < y ? x : y; } /************************************** * Returns (x * y) + z, rounding only once according to the * current rounding mode. * * BUGS: Not currently implemented - rounds twice. */ real fma(real x, real y, real z) @safe pure nothrow @nogc { return (x * y) + z; } /******************************************************************* * Compute the value of x $(SUPERSCRIPT n), where n is an integer */ Unqual!F pow(F, G)(F x, G n) @nogc @trusted pure nothrow if (isFloatingPoint!(F) && isIntegral!(G)) { import std.traits : Unsigned; real p = 1.0, v = void; Unsigned!(Unqual!G) m = n; if (n < 0) { switch (n) { case -1: return 1 / x; case -2: return 1 / (x * x); default: } m = cast(typeof(m))(0 - n); v = p / x; } else { switch (n) { case 0: return 1.0; case 1: return x; case 2: return x * x; default: } v = x; } while (1) { if (m & 1) p *= v; m >>= 1; if (!m) break; v *= v; } return p; } @safe pure nothrow @nogc unittest { // Make sure it instantiates and works properly on immutable values and // with various integer and float types. immutable real x = 46; immutable float xf = x; immutable double xd = x; immutable uint one = 1; immutable ushort two = 2; immutable ubyte three = 3; immutable ulong eight = 8; immutable int neg1 = -1; immutable short neg2 = -2; immutable byte neg3 = -3; immutable long neg8 = -8; assert(pow(x,0) == 1.0); assert(pow(xd,one) == x); assert(pow(xf,two) == x * x); assert(pow(x,three) == x * x * x); assert(pow(x,eight) == (x * x) * (x * x) * (x * x) * (x * x)); assert(pow(x, neg1) == 1 / x); version(X86_64) { pragma(msg, "test disabled on x86_64, see bug 5628"); } else version(ARM) { pragma(msg, "test disabled on ARM, see bug 5628"); } else { assert(pow(xd, neg2) == 1 / (x * x)); assert(pow(xf, neg8) == 1 / ((x * x) * (x * x) * (x * x) * (x * x))); } assert(feqrel(pow(x, neg3), 1 / (x * x * x)) >= real.mant_dig - 1); } @system unittest { assert(equalsDigit(pow(2.0L, 10.0L), 1024, 19)); } /** Compute the value of an integer x, raised to the power of a positive * integer n. * * If both x and n are 0, the result is 1. * If n is negative, an integer divide error will occur at runtime, * regardless of the value of x. */ typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pure nothrow if (isIntegral!(F) && isIntegral!(G)) { if (n<0) return x/0; // Only support positive powers typeof(return) p, v = void; Unqual!G m = n; switch (m) { case 0: p = 1; break; case 1: p = x; break; case 2: p = x * x; break; default: v = x; p = 1; while (1) { if (m & 1) p *= v; m >>= 1; if (!m) break; v *= v; } break; } return p; } /// @safe pure nothrow @nogc unittest { immutable int one = 1; immutable byte two = 2; immutable ubyte three = 3; immutable short four = 4; immutable long ten = 10; assert(pow(two, three) == 8); assert(pow(two, ten) == 1024); assert(pow(one, ten) == 1); assert(pow(ten, four) == 10_000); assert(pow(four, 10) == 1_048_576); assert(pow(three, four) == 81); } /**Computes integer to floating point powers.*/ real pow(I, F)(I x, F y) @nogc @trusted pure nothrow if (isIntegral!I && isFloatingPoint!F) { return pow(cast(real) x, cast(Unqual!F) y); } /********************************************* * Calculates x$(SUPERSCRIPT y). * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH pow(x, y)) * $(TH div 0) $(TH invalid?)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD 1.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(GT) 1) $(TD +$(INFIN)) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(LT) 1) $(TD +$(INFIN)) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(GT) 1) $(TD -$(INFIN)) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(LT) 1) $(TD -$(INFIN)) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD +$(INFIN)) $(TD $(GT) 0.0) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD +$(INFIN)) $(TD $(LT) 0.0) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD odd integer $(GT) 0.0) $(TD -$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD $(GT) 0.0, not odd integer) $(TD +$(INFIN)) * $(TD no) $(TD no)) * $(TR $(TD -$(INFIN)) $(TD odd integer $(LT) 0.0) $(TD -0.0) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD $(LT) 0.0, not odd integer) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD $(PLUSMN)1.0) $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) * $(TD no) $(TD yes) ) * $(TR $(TD $(LT) 0.0) $(TD finite, nonintegral) $(TD $(NAN)) * $(TD no) $(TD yes)) * $(TR $(TD $(PLUSMN)0.0) $(TD odd integer $(LT) 0.0) $(TD $(PLUSMNINF)) * $(TD yes) $(TD no) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(LT) 0.0, not odd integer) $(TD +$(INFIN)) * $(TD yes) $(TD no)) * $(TR $(TD $(PLUSMN)0.0) $(TD odd integer $(GT) 0.0) $(TD $(PLUSMN)0.0) * $(TD no) $(TD no) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(GT) 0.0, not odd integer) $(TD +0.0) * $(TD no) $(TD no) ) * ) */ Unqual!(Largest!(F, G)) pow(F, G)(F x, G y) @nogc @trusted pure nothrow if (isFloatingPoint!(F) && isFloatingPoint!(G)) { alias Float = typeof(return); static real impl(real x, real y) @nogc pure nothrow { // Special cases. if (isNaN(y)) return y; if (isNaN(x) && y != 0.0) return x; // Even if x is NaN. if (y == 0.0) return 1.0; if (y == 1.0) return x; if (isInfinity(y)) { if (fabs(x) > 1) { if (signbit(y)) return +0.0; else return F.infinity; } else if (fabs(x) == 1) { return y * 0; // generate NaN. } else // < 1 { if (signbit(y)) return F.infinity; else return +0.0; } } if (isInfinity(x)) { if (signbit(x)) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } else if (y < 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } } else { if (y > 0.0) return F.infinity; else if (y < 0.0) return +0.0; } } if (x == 0.0) { if (signbit(x)) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } else if (y < 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } } else { if (y > 0.0) return +0.0; else if (y < 0.0) return F.infinity; } } if (x == 1.0) return 1.0; if (y >= F.max) { if ((x > 0.0 && x < 1.0) || (x > -1.0 && x < 0.0)) return 0.0; if (x > 1.0 || x < -1.0) return F.infinity; } if (y <= -F.max) { if ((x > 0.0 && x < 1.0) || (x > -1.0 && x < 0.0)) return F.infinity; if (x > 1.0 || x < -1.0) return 0.0; } if (x >= F.max) { if (y > 0.0) return F.infinity; else return 0.0; } if (x <= -F.max) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } else if (y < 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } } // Integer power of x. long iy = cast(long) y; if (iy == y && fabs(y) < 32_768.0) return pow(x, iy); real sign = 1.0; if (x < 0) { // Result is real only if y is an integer // Check for a non-zero fractional part enum maxOdd = pow(2.0L, real.mant_dig) - 1.0L; static if (maxOdd > ulong.max) { // Generic method, for any FP type if (floor(y) != y) return sqrt(x); // Complex result -- create a NaN const hy = ldexp(y, -1); if (floor(hy) != hy) sign = -1.0; } else { // Much faster, if ulong has enough precision const absY = fabs(y); if (absY <= maxOdd) { const uy = cast(ulong) absY; if (uy != absY) return sqrt(x); // Complex result -- create a NaN if (uy & 1) sign = -1.0; } } x = -x; } version(INLINE_YL2X) { // If x > 0, x ^^ y == 2 ^^ ( y * log2(x) ) // TODO: This is not accurate in practice. A fast and accurate // (though complicated) method is described in: // "An efficient rounding boundary test for pow(x, y) // in double precision", C.Q. Lauter and V. Lefèvre, INRIA (2007). return sign * exp2( core.math.yl2x(x, y) ); } else { // If x > 0, x ^^ y == 2 ^^ ( y * log2(x) ) // TODO: This is not accurate in practice. A fast and accurate // (though complicated) method is described in: // "An efficient rounding boundary test for pow(x, y) // in double precision", C.Q. Lauter and V. Lefèvre, INRIA (2007). Float w = exp2(y * log2(x)); return sign * w; } } return impl(x, y); } @safe pure nothrow @nogc unittest { // Test all the special values. These unittests can be run on Windows // by temporarily changing the version(linux) to version(all). immutable float zero = 0; immutable real one = 1; immutable double two = 2; immutable float three = 3; immutable float fnan = float.nan; immutable double dnan = double.nan; immutable real rnan = real.nan; immutable dinf = double.infinity; immutable rninf = -real.infinity; assert(pow(fnan, zero) == 1); assert(pow(dnan, zero) == 1); assert(pow(rnan, zero) == 1); assert(pow(two, dinf) == double.infinity); assert(isIdentical(pow(0.2f, dinf), +0.0)); assert(pow(0.99999999L, rninf) == real.infinity); assert(isIdentical(pow(1.000000001, rninf), +0.0)); assert(pow(dinf, 0.001) == dinf); assert(isIdentical(pow(dinf, -0.001), +0.0)); assert(pow(rninf, 3.0L) == rninf); assert(pow(rninf, 2.0L) == real.infinity); assert(isIdentical(pow(rninf, -3.0), -0.0)); assert(isIdentical(pow(rninf, -2.0), +0.0)); // @@@BUG@@@ somewhere version(OSX) {} else assert(isNaN(pow(one, dinf))); version(OSX) {} else assert(isNaN(pow(-one, dinf))); assert(isNaN(pow(-0.2, PI))); // boundary cases. Note that epsilon == 2^^-n for some n, // so 1/epsilon == 2^^n is always even. assert(pow(-1.0L, 1/real.epsilon - 1.0L) == -1.0L); assert(pow(-1.0L, 1/real.epsilon) == 1.0L); assert(isNaN(pow(-1.0L, 1/real.epsilon-0.5L))); assert(isNaN(pow(-1.0L, -1/real.epsilon+0.5L))); assert(pow(0.0, -3.0) == double.infinity); assert(pow(-0.0, -3.0) == -double.infinity); assert(pow(0.0, -PI) == double.infinity); assert(pow(-0.0, -PI) == double.infinity); assert(isIdentical(pow(0.0, 5.0), 0.0)); assert(isIdentical(pow(-0.0, 5.0), -0.0)); assert(isIdentical(pow(0.0, 6.0), 0.0)); assert(isIdentical(pow(-0.0, 6.0), 0.0)); // Issue #14786 fixed immutable real maxOdd = pow(2.0L, real.mant_dig) - 1.0L; assert(pow(-1.0L, maxOdd) == -1.0L); assert(pow(-1.0L, -maxOdd) == -1.0L); assert(pow(-1.0L, maxOdd + 1.0L) == 1.0L); assert(pow(-1.0L, -maxOdd + 1.0L) == 1.0L); assert(pow(-1.0L, maxOdd - 1.0L) == 1.0L); assert(pow(-1.0L, -maxOdd - 1.0L) == 1.0L); // Now, actual numbers. assert(approxEqual(pow(two, three), 8.0)); assert(approxEqual(pow(two, -2.5), 0.1767767)); // Test integer to float power. immutable uint twoI = 2; assert(approxEqual(pow(twoI, three), 8.0)); } /************************************** * To what precision is x equal to y? * * Returns: the number of mantissa bits which are equal in x and y. * eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH feqrel(x, y))) * $(TR $(TD x) $(TD x) $(TD real.mant_dig)) * $(TR $(TD x) $(TD $(GT)= 2*x) $(TD 0)) * $(TR $(TD x) $(TD $(LT)= x/2) $(TD 0)) * $(TR $(TD $(NAN)) $(TD any) $(TD 0)) * $(TR $(TD any) $(TD $(NAN)) $(TD 0)) * ) */ int feqrel(X)(const X x, const X y) @trusted pure nothrow @nogc if (isFloatingPoint!(X)) { /* Public Domain. Author: Don Clugston, 18 Aug 2005. */ alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ibmExtended) { if (cast(double*)(&x)[MANTISSA_MSB] == cast(double*)(&y)[MANTISSA_MSB]) { return double.mant_dig + feqrel(cast(double*)(&x)[MANTISSA_LSB], cast(double*)(&y)[MANTISSA_LSB]); } else { return feqrel(cast(double*)(&x)[MANTISSA_MSB], cast(double*)(&y)[MANTISSA_MSB]); } } else { static assert(F.realFormat == RealFormat.ieeeSingle || F.realFormat == RealFormat.ieeeDouble || F.realFormat == RealFormat.ieeeExtended || F.realFormat == RealFormat.ieeeQuadruple); if (x == y) return X.mant_dig; // ensure diff != 0, cope with INF. Unqual!X diff = fabs(x - y); ushort *pa = cast(ushort *)(&x); ushort *pb = cast(ushort *)(&y); ushort *pd = cast(ushort *)(&diff); // The difference in abs(exponent) between x or y and abs(x-y) // is equal to the number of significand bits of x which are // equal to y. If negative, x and y have different exponents. // If positive, x and y are equal to 'bitsdiff' bits. // AND with 0x7FFF to form the absolute value. // To avoid out-by-1 errors, we subtract 1 so it rounds down // if the exponents were different. This means 'bitsdiff' is // always 1 lower than we want, except that if bitsdiff == 0, // they could have 0 or 1 bits in common. int bitsdiff = ((( (pa[F.EXPPOS_SHORT] & F.EXPMASK) + (pb[F.EXPPOS_SHORT] & F.EXPMASK) - (1 << F.EXPSHIFT)) >> 1) - (pd[F.EXPPOS_SHORT] & F.EXPMASK)) >> F.EXPSHIFT; if ( (pd[F.EXPPOS_SHORT] & F.EXPMASK) == 0) { // Difference is subnormal // For subnormals, we need to add the number of zeros that // lie at the start of diff's significand. // We do this by multiplying by 2^^real.mant_dig diff *= F.RECIP_EPSILON; return bitsdiff + X.mant_dig - ((pd[F.EXPPOS_SHORT] & F.EXPMASK) >> F.EXPSHIFT); } if (bitsdiff > 0) return bitsdiff + 1; // add the 1 we subtracted before // Avoid out-by-1 errors when factor is almost 2. if (bitsdiff == 0 && ((pa[F.EXPPOS_SHORT] ^ pb[F.EXPPOS_SHORT]) & F.EXPMASK) == 0) { return 1; } else return 0; } } @safe pure nothrow @nogc unittest { void testFeqrel(F)() { // Exact equality assert(feqrel(F.max, F.max) == F.mant_dig); assert(feqrel!(F)(0.0, 0.0) == F.mant_dig); assert(feqrel(F.infinity, F.infinity) == F.mant_dig); // a few bits away from exact equality F w=1; for (int i = 1; i < F.mant_dig - 1; ++i) { assert(feqrel!(F)(1.0 + w * F.epsilon, 1.0) == F.mant_dig-i); assert(feqrel!(F)(1.0 - w * F.epsilon, 1.0) == F.mant_dig-i); assert(feqrel!(F)(1.0, 1 + (w-1) * F.epsilon) == F.mant_dig - i + 1); w*=2; } assert(feqrel!(F)(1.5+F.epsilon, 1.5) == F.mant_dig-1); assert(feqrel!(F)(1.5-F.epsilon, 1.5) == F.mant_dig-1); assert(feqrel!(F)(1.5-F.epsilon, 1.5+F.epsilon) == F.mant_dig-2); // Numbers that are close assert(feqrel!(F)(0x1.Bp+84, 0x1.B8p+84) == 5); assert(feqrel!(F)(0x1.8p+10, 0x1.Cp+10) == 2); assert(feqrel!(F)(1.5 * (1 - F.epsilon), 1.0L) == 2); assert(feqrel!(F)(1.5, 1.0) == 1); assert(feqrel!(F)(2 * (1 - F.epsilon), 1.0L) == 1); // Factors of 2 assert(feqrel(F.max, F.infinity) == 0); assert(feqrel!(F)(2 * (1 - F.epsilon), 1.0L) == 1); assert(feqrel!(F)(1.0, 2.0) == 0); assert(feqrel!(F)(4.0, 1.0) == 0); // Extreme inequality assert(feqrel(F.nan, F.nan) == 0); assert(feqrel!(F)(0.0L, -F.nan) == 0); assert(feqrel(F.nan, F.infinity) == 0); assert(feqrel(F.infinity, -F.infinity) == 0); assert(feqrel(F.max, -F.max) == 0); assert(feqrel(F.min_normal / 8, F.min_normal / 17) == 3); const F Const = 2; immutable F Immutable = 2; auto Compiles = feqrel(Const, Immutable); } assert(feqrel(7.1824L, 7.1824L) == real.mant_dig); testFeqrel!(real)(); testFeqrel!(double)(); testFeqrel!(float)(); } package: // Not public yet /* Return the value that lies halfway between x and y on the IEEE number line. * * Formally, the result is the arithmetic mean of the binary significands of x * and y, multiplied by the geometric mean of the binary exponents of x and y. * x and y must have the same sign, and must not be NaN. * Note: this function is useful for ensuring O(log n) behaviour in algorithms * involving a 'binary chop'. * * Special cases: * If x and y are within a factor of 2, (ie, feqrel(x, y) > 0), the return value * is the arithmetic mean (x + y) / 2. * If x and y are even powers of 2, the return value is the geometric mean, * ieeeMean(x, y) = sqrt(x * y). * */ T ieeeMean(T)(const T x, const T y) @trusted pure nothrow @nogc in { // both x and y must have the same sign, and must not be NaN. assert(signbit(x) == signbit(y)); assert(x == x && y == y); } body { // Runtime behaviour for contract violation: // If signs are opposite, or one is a NaN, return 0. if (!((x >= 0 && y >= 0) || (x <= 0 && y <= 0))) return 0.0; // The implementation is simple: cast x and y to integers, // average them (avoiding overflow), and cast the result back to a floating-point number. alias F = floatTraits!(T); T u; static if (F.realFormat == RealFormat.ieeeExtended) { // There's slight additional complexity because they are actually // 79-bit reals... ushort *ue = cast(ushort *)&u; ulong *ul = cast(ulong *)&u; ushort *xe = cast(ushort *)&x; ulong *xl = cast(ulong *)&x; ushort *ye = cast(ushort *)&y; ulong *yl = cast(ulong *)&y; // Ignore the useless implicit bit. (Bonus: this prevents overflows) ulong m = ((*xl) & 0x7FFF_FFFF_FFFF_FFFFL) + ((*yl) & 0x7FFF_FFFF_FFFF_FFFFL); // @@@ BUG? @@@ // Cast shouldn't be here ushort e = cast(ushort) ((xe[F.EXPPOS_SHORT] & F.EXPMASK) + (ye[F.EXPPOS_SHORT] & F.EXPMASK)); if (m & 0x8000_0000_0000_0000L) { ++e; m &= 0x7FFF_FFFF_FFFF_FFFFL; } // Now do a multi-byte right shift const uint c = e & 1; // carry e >>= 1; m >>>= 1; if (c) m |= 0x4000_0000_0000_0000L; // shift carry into significand if (e) *ul = m | 0x8000_0000_0000_0000L; // set implicit bit... else *ul = m; // ... unless exponent is 0 (subnormal or zero). ue[4]= e | (xe[F.EXPPOS_SHORT]& 0x8000); // restore sign bit } else static if (F.realFormat == RealFormat.ieeeQuadruple) { // This would be trivial if 'ucent' were implemented... ulong *ul = cast(ulong *)&u; ulong *xl = cast(ulong *)&x; ulong *yl = cast(ulong *)&y; // Multi-byte add, then multi-byte right shift. import core.checkedint : addu; bool carry; ulong ml = addu(xl[MANTISSA_LSB], yl[MANTISSA_LSB], carry); ulong mh = carry + (xl[MANTISSA_MSB] & 0x7FFF_FFFF_FFFF_FFFFL) + (yl[MANTISSA_MSB] & 0x7FFF_FFFF_FFFF_FFFFL); ul[MANTISSA_MSB] = (mh >>> 1) | (xl[MANTISSA_MSB] & 0x8000_0000_0000_0000); ul[MANTISSA_LSB] = (ml >>> 1) | (mh & 1) << 63; } else static if (F.realFormat == RealFormat.ieeeDouble) { ulong *ul = cast(ulong *)&u; ulong *xl = cast(ulong *)&x; ulong *yl = cast(ulong *)&y; ulong m = (((*xl) & 0x7FFF_FFFF_FFFF_FFFFL) + ((*yl) & 0x7FFF_FFFF_FFFF_FFFFL)) >>> 1; m |= ((*xl) & 0x8000_0000_0000_0000L); *ul = m; } else static if (F.realFormat == RealFormat.ieeeSingle) { uint *ul = cast(uint *)&u; uint *xl = cast(uint *)&x; uint *yl = cast(uint *)&y; uint m = (((*xl) & 0x7FFF_FFFF) + ((*yl) & 0x7FFF_FFFF)) >>> 1; m |= ((*xl) & 0x8000_0000); *ul = m; } else { assert(0, "Not implemented"); } return u; } @safe pure nothrow @nogc unittest { assert(ieeeMean(-0.0,-1e-20)<0); assert(ieeeMean(0.0,1e-20)>0); assert(ieeeMean(1.0L,4.0L)==2L); assert(ieeeMean(2.0*1.013,8.0*1.013)==4*1.013); assert(ieeeMean(-1.0L,-4.0L)==-2L); assert(ieeeMean(-1.0,-4.0)==-2); assert(ieeeMean(-1.0f,-4.0f)==-2f); assert(ieeeMean(-1.0,-2.0)==-1.5); assert(ieeeMean(-1*(1+8*real.epsilon),-2*(1+8*real.epsilon)) ==-1.5*(1+5*real.epsilon)); assert(ieeeMean(0x1p60,0x1p-10)==0x1p25); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { assert(ieeeMean(1.0L,real.infinity)==0x1p8192L); assert(ieeeMean(0.0L,real.infinity)==1.5); } assert(ieeeMean(0.5*real.min_normal*(1-4*real.epsilon),0.5*real.min_normal) == 0.5*real.min_normal*(1-2*real.epsilon)); } public: /*********************************** * Evaluate polynomial A(x) = $(SUB a, 0) + $(SUB a, 1)x + $(SUB a, 2)$(POWER x,2) * + $(SUB a,3)$(POWER x,3); ... * * Uses Horner's rule A(x) = $(SUB a, 0) + x($(SUB a, 1) + x($(SUB a, 2) * + x($(SUB a, 3) + ...))) * Params: * x = the value to evaluate. * A = array of coefficients $(SUB a, 0), $(SUB a, 1), etc. */ Unqual!(CommonType!(T1, T2)) poly(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc if (isFloatingPoint!T1 && isFloatingPoint!T2) in { assert(A.length > 0); } body { static if (is(Unqual!T2 == real)) { return polyImpl(x, A); } else { return polyImplBase(x, A); } } /// @safe nothrow @nogc unittest { real x = 3.1; static real[] pp = [56.1, 32.7, 6]; assert(poly(x, pp) == (56.1L + (32.7L + 6.0L * x) * x)); } @safe nothrow @nogc unittest { double x = 3.1; static double[] pp = [56.1, 32.7, 6]; double y = x; y *= 6.0; y += 32.7; y *= x; y += 56.1; assert(poly(x, pp) == y); } @safe unittest { static assert(poly(3.0, [1.0, 2.0, 3.0]) == 34); } private Unqual!(CommonType!(T1, T2)) polyImplBase(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc if (isFloatingPoint!T1 && isFloatingPoint!T2) { ptrdiff_t i = A.length - 1; typeof(return) r = A[i]; while (--i >= 0) { r *= x; r += A[i]; } return r; } private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc { version (D_InlineAsm_X86) { if (__ctfe) { return polyImplBase(x, A); } version (Windows) { // BUG: This code assumes a frame pointer in EBP. asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX][ECX*8] ; add EDX,ECX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -10[EDX] ; sub EDX,10 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (linux) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (OSX) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; add EDX,EDX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -16[EDX] ; sub EDX,16 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (FreeBSD) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else version (Solaris) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; ; } } else { static assert(0); } } else { return polyImplBase(x, A); } } /** Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference. Params: lhs = First item to compare. rhs = Second item to compare. maxRelDiff = Maximum allowable difference relative to `rhs`. maxAbsDiff = Maximum absolute difference. Returns: `true` if the two items are approximately equal under either criterium. If one item is a range, and the other is a single value, then the result is the logical and-ing of calling `approxEqual` on each element of the ranged item against the single item. If both items are ranges, then `approxEqual` returns `true` if and only if the ranges have the same number of elements and if `approxEqual` evaluates to `true` for each pair of elements. */ bool approxEqual(T, U, V)(T lhs, U rhs, V maxRelDiff, V maxAbsDiff = 1e-5) { import std.range.primitives : empty, front, isInputRange, popFront; static if (isInputRange!T) { static if (isInputRange!U) { // Two ranges for (;; lhs.popFront(), rhs.popFront()) { if (lhs.empty) return rhs.empty; if (rhs.empty) return lhs.empty; if (!approxEqual(lhs.front, rhs.front, maxRelDiff, maxAbsDiff)) return false; } } else static if (isIntegral!U) { // convert rhs to real return approxEqual(lhs, real(rhs), maxRelDiff, maxAbsDiff); } else { // lhs is range, rhs is number for (; !lhs.empty; lhs.popFront()) { if (!approxEqual(lhs.front, rhs, maxRelDiff, maxAbsDiff)) return false; } return true; } } else { static if (isInputRange!U) { // lhs is number, rhs is range for (; !rhs.empty; rhs.popFront()) { if (!approxEqual(lhs, rhs.front, maxRelDiff, maxAbsDiff)) return false; } return true; } else static if (isIntegral!T || isIntegral!U) { // convert both lhs and rhs to real return approxEqual(real(lhs), real(rhs), maxRelDiff, maxAbsDiff); } else { // two numbers //static assert(is(T : real) && is(U : real)); if (rhs == 0) { return fabs(lhs) <= maxAbsDiff; } static if (is(typeof(lhs.infinity)) && is(typeof(rhs.infinity))) { if (lhs == lhs.infinity && rhs == rhs.infinity || lhs == -lhs.infinity && rhs == -rhs.infinity) return true; } return fabs((lhs - rhs) / rhs) <= maxRelDiff || maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff; } } } /** Returns $(D approxEqual(lhs, rhs, 1e-2, 1e-5)). */ bool approxEqual(T, U)(T lhs, U rhs) { return approxEqual(lhs, rhs, 1e-2, 1e-5); } /// @safe pure nothrow unittest { assert(approxEqual(1.0, 1.0099)); assert(!approxEqual(1.0, 1.011)); float[] arr1 = [ 1.0, 2.0, 3.0 ]; double[] arr2 = [ 1.001, 1.999, 3 ]; assert(approxEqual(arr1, arr2)); real num = real.infinity; assert(num == real.infinity); // Passes. assert(approxEqual(num, real.infinity)); // Fails. num = -real.infinity; assert(num == -real.infinity); // Passes. assert(approxEqual(num, -real.infinity)); // Fails. assert(!approxEqual(3, 0)); assert(approxEqual(3, 3)); assert(approxEqual(3.0, 3)); assert(approxEqual([3, 3, 3], 3.0)); assert(approxEqual([3.0, 3.0, 3.0], 3)); int a = 10; assert(approxEqual(10, a)); } @safe pure nothrow @nogc unittest { real num = real.infinity; assert(num == real.infinity); // Passes. assert(approxEqual(num, real.infinity)); // Fails. } @safe pure nothrow @nogc unittest { float f = sqrt(2.0f); assert(fabs(f * f - 2.0f) < .00001); double d = sqrt(2.0); assert(fabs(d * d - 2.0) < .00001); real r = sqrt(2.0L); assert(fabs(r * r - 2.0) < .00001); } @safe pure nothrow @nogc unittest { float f = fabs(-2.0f); assert(f == 2); double d = fabs(-2.0); assert(d == 2); real r = fabs(-2.0L); assert(r == 2); } @safe pure nothrow @nogc unittest { float f = sin(-2.0f); assert(fabs(f - -0.909297f) < .00001); double d = sin(-2.0); assert(fabs(d - -0.909297f) < .00001); real r = sin(-2.0L); assert(fabs(r - -0.909297f) < .00001); } @safe pure nothrow @nogc unittest { float f = cos(-2.0f); assert(fabs(f - -0.416147f) < .00001); double d = cos(-2.0); assert(fabs(d - -0.416147f) < .00001); real r = cos(-2.0L); assert(fabs(r - -0.416147f) < .00001); } @safe pure nothrow @nogc unittest { float f = tan(-2.0f); assert(fabs(f - 2.18504f) < .00001); double d = tan(-2.0); assert(fabs(d - 2.18504f) < .00001); real r = tan(-2.0L); assert(fabs(r - 2.18504f) < .00001); // Verify correct behavior for large inputs assert(!isNaN(tan(0x1p63))); assert(!isNaN(tan(0x1p300L))); assert(!isNaN(tan(-0x1p63))); assert(!isNaN(tan(-0x1p300L))); } @safe pure nothrow unittest { // issue 6381: floor/ceil should be usable in pure function. auto x = floor(1.2); auto y = ceil(1.2); } @safe pure nothrow unittest { // relative comparison depends on rhs, make sure proper side is used when // comparing range to single value. Based on bugzilla issue 15763 auto a = [2e-3 - 1e-5]; auto b = 2e-3 + 1e-5; assert(a[0].approxEqual(b)); assert(!b.approxEqual(a[0])); assert(a.approxEqual(b)); assert(!b.approxEqual(a)); } /*********************************** * Defines a total order on all floating-point numbers. * * The order is defined as follows: * $(UL * $(LI All numbers in [-$(INFIN), +$(INFIN)] are ordered * the same way as by built-in comparison, with the exception of * -0.0, which is less than +0.0;) * $(LI If the sign bit is set (that is, it's 'negative'), $(NAN) is less * than any number; if the sign bit is not set (it is 'positive'), * $(NAN) is greater than any number;) * $(LI $(NAN)s of the same sign are ordered by the payload ('negative' * ones - in reverse order).) * ) * * Returns: * negative value if $(D x) precedes $(D y) in the order specified above; * 0 if $(D x) and $(D y) are identical, and positive value otherwise. * * See_Also: * $(MYREF isIdentical) * Standards: Conforms to IEEE 754-2008 */ int cmp(T)(const(T) x, const(T) y) @nogc @trusted pure nothrow if (isFloatingPoint!T) { alias F = floatTraits!T; static if (F.realFormat == RealFormat.ieeeSingle || F.realFormat == RealFormat.ieeeDouble) { static if (T.sizeof == 4) alias UInt = uint; else alias UInt = ulong; union Repainter { T number; UInt bits; } enum msb = ~(UInt.max >>> 1); import std.typecons : Tuple; Tuple!(Repainter, Repainter) vars = void; vars[0].number = x; vars[1].number = y; foreach (ref var; vars) if (var.bits & msb) var.bits = ~var.bits; else var.bits |= msb; if (vars[0].bits < vars[1].bits) return -1; else if (vars[0].bits > vars[1].bits) return 1; else return 0; } else static if (F.realFormat == RealFormat.ieeeExtended53 || F.realFormat == RealFormat.ieeeExtended || F.realFormat == RealFormat.ieeeQuadruple) { static if (F.realFormat == RealFormat.ieeeQuadruple) alias RemT = ulong; else alias RemT = ushort; struct Bits { ulong bulk; RemT rem; } union Repainter { T number; Bits bits; ubyte[T.sizeof] bytes; } import std.typecons : Tuple; Tuple!(Repainter, Repainter) vars = void; vars[0].number = x; vars[1].number = y; foreach (ref var; vars) if (var.bytes[F.SIGNPOS_BYTE] & 0x80) { var.bits.bulk = ~var.bits.bulk; var.bits.rem = cast(typeof(var.bits.rem))(-1 - var.bits.rem); // ~var.bits.rem } else { var.bytes[F.SIGNPOS_BYTE] |= 0x80; } version(LittleEndian) { if (vars[0].bits.rem < vars[1].bits.rem) return -1; else if (vars[0].bits.rem > vars[1].bits.rem) return 1; else if (vars[0].bits.bulk < vars[1].bits.bulk) return -1; else if (vars[0].bits.bulk > vars[1].bits.bulk) return 1; else return 0; } else { if (vars[0].bits.bulk < vars[1].bits.bulk) return -1; else if (vars[0].bits.bulk > vars[1].bits.bulk) return 1; else if (vars[0].bits.rem < vars[1].bits.rem) return -1; else if (vars[0].bits.rem > vars[1].bits.rem) return 1; else return 0; } } else { // IBM Extended doubledouble does not follow the general // sign-exponent-significand layout, so has to be handled generically const int xSign = signbit(x), ySign = signbit(y); if (xSign == 1 && ySign == 1) return cmp(-y, -x); else if (xSign == 1) return -1; else if (ySign == 1) return 1; else if (x < y) return -1; else if (x == y) return 0; else if (x > y) return 1; else if (isNaN(x) && !isNaN(y)) return 1; else if (isNaN(y) && !isNaN(x)) return -1; else if (getNaNPayload(x) < getNaNPayload(y)) return -1; else if (getNaNPayload(x) > getNaNPayload(y)) return 1; else return 0; } } /// Most numbers are ordered naturally. @safe unittest { assert(cmp(-double.infinity, -double.max) < 0); assert(cmp(-double.max, -100.0) < 0); assert(cmp(-100.0, -0.5) < 0); assert(cmp(-0.5, 0.0) < 0); assert(cmp(0.0, 0.5) < 0); assert(cmp(0.5, 100.0) < 0); assert(cmp(100.0, double.max) < 0); assert(cmp(double.max, double.infinity) < 0); assert(cmp(1.0, 1.0) == 0); } /// Positive and negative zeroes are distinct. @safe unittest { assert(cmp(-0.0, +0.0) < 0); assert(cmp(+0.0, -0.0) > 0); } /// Depending on the sign, $(NAN)s go to either end of the spectrum. @safe unittest { assert(cmp(-double.nan, -double.infinity) < 0); assert(cmp(double.infinity, double.nan) < 0); assert(cmp(-double.nan, double.nan) < 0); } /// $(NAN)s of the same sign are ordered by the payload. @safe unittest { assert(cmp(NaN(10), NaN(20)) < 0); assert(cmp(-NaN(20), -NaN(10)) < 0); } @safe unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { T[] values = [-cast(T) NaN(20), -cast(T) NaN(10), -T.nan, -T.infinity, -T.max, -T.max / 2, T(-16.0), T(-1.0).nextDown, T(-1.0), T(-1.0).nextUp, T(-0.5), -T.min_normal, (-T.min_normal).nextUp, -2 * T.min_normal * T.epsilon, -T.min_normal * T.epsilon, T(-0.0), T(0.0), T.min_normal * T.epsilon, 2 * T.min_normal * T.epsilon, T.min_normal.nextDown, T.min_normal, T(0.5), T(1.0).nextDown, T(1.0), T(1.0).nextUp, T(16.0), T.max / 2, T.max, T.infinity, T.nan, cast(T) NaN(10), cast(T) NaN(20)]; foreach (i, x; values) { foreach (y; values[i + 1 .. $]) { assert(cmp(x, y) < 0); assert(cmp(y, x) > 0); } assert(cmp(x, x) == 0); } } } private enum PowType { floor, ceil } pragma(inline, true) private T powIntegralImpl(PowType type, T)(T val) { import core.bitop : bsr; if (val == 0 || (type == PowType.ceil && (val > T.max / 2 || val == T.min))) return 0; else { static if (isSigned!T) return cast(Unqual!T) (val < 0 ? -(T(1) << bsr(0 - val) + type) : T(1) << bsr(val) + type); else return cast(Unqual!T) (T(1) << bsr(val) + type); } } private T powFloatingPointImpl(PowType type, T)(T x) { if (!x.isFinite) return x; if (!x) return x; int exp; auto y = frexp(x, exp); static if (type == PowType.ceil) y = ldexp(cast(T) 0.5, exp + 1); else y = ldexp(cast(T) 0.5, exp); if (!y.isFinite) return cast(T) 0.0; y = copysign(y, x); return y; } /** * Gives the next power of two after $(D val). `T` can be any built-in * numerical type. * * If the operation would lead to an over/underflow, this function will * return `0`. * * Params: * val = any number * * Returns: * the next power of two after $(D val) */ T nextPow2(T)(const T val) if (isIntegral!T) { return powIntegralImpl!(PowType.ceil)(val); } /// ditto T nextPow2(T)(const T val) if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.ceil)(val); } /// @safe @nogc pure nothrow unittest { assert(nextPow2(2) == 4); assert(nextPow2(10) == 16); assert(nextPow2(4000) == 4096); assert(nextPow2(-2) == -4); assert(nextPow2(-10) == -16); assert(nextPow2(uint.max) == 0); assert(nextPow2(uint.min) == 0); assert(nextPow2(size_t.max) == 0); assert(nextPow2(size_t.min) == 0); assert(nextPow2(int.max) == 0); assert(nextPow2(int.min) == 0); assert(nextPow2(long.max) == 0); assert(nextPow2(long.min) == 0); } /// @safe @nogc pure nothrow unittest { assert(nextPow2(2.1) == 4.0); assert(nextPow2(-2.0) == -4.0); assert(nextPow2(0.25) == 0.5); assert(nextPow2(-4.0) == -8.0); assert(nextPow2(double.max) == 0.0); assert(nextPow2(double.infinity) == double.infinity); } @safe @nogc pure nothrow unittest { assert(nextPow2(ubyte(2)) == 4); assert(nextPow2(ubyte(10)) == 16); assert(nextPow2(byte(2)) == 4); assert(nextPow2(byte(10)) == 16); assert(nextPow2(short(2)) == 4); assert(nextPow2(short(10)) == 16); assert(nextPow2(short(4000)) == 4096); assert(nextPow2(ushort(2)) == 4); assert(nextPow2(ushort(10)) == 16); assert(nextPow2(ushort(4000)) == 4096); } @safe @nogc pure nothrow unittest { foreach (ulong i; 1 .. 62) { assert(nextPow2(1UL << i) == 2UL << i); assert(nextPow2((1UL << i) - 1) == 1UL << i); assert(nextPow2((1UL << i) + 1) == 2UL << i); assert(nextPow2((1UL << i) + (1UL<<(i-1))) == 2UL << i); } } @safe @nogc pure nothrow unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { enum T subNormal = T.min_normal / 2; static if (subNormal) assert(nextPow2(subNormal) == T.min_normal); assert(nextPow2(T(0.0)) == 0.0); assert(nextPow2(T(2.0)) == 4.0); assert(nextPow2(T(2.1)) == 4.0); assert(nextPow2(T(3.1)) == 4.0); assert(nextPow2(T(4.0)) == 8.0); assert(nextPow2(T(0.25)) == 0.5); assert(nextPow2(T(-2.0)) == -4.0); assert(nextPow2(T(-2.1)) == -4.0); assert(nextPow2(T(-3.1)) == -4.0); assert(nextPow2(T(-4.0)) == -8.0); assert(nextPow2(T(-0.25)) == -0.5); assert(nextPow2(T.max) == 0); assert(nextPow2(-T.max) == 0); assert(nextPow2(T.infinity) == T.infinity); assert(nextPow2(T.init).isNaN); } } @safe @nogc pure nothrow unittest // Issue 15973 { assert(nextPow2(uint.max / 2) == uint.max / 2 + 1); assert(nextPow2(uint.max / 2 + 2) == 0); assert(nextPow2(int.max / 2) == int.max / 2 + 1); assert(nextPow2(int.max / 2 + 2) == 0); assert(nextPow2(int.min + 1) == int.min); } /** * Gives the last power of two before $(D val). $(T) can be any built-in * numerical type. * * Params: * val = any number * * Returns: * the last power of two before $(D val) */ T truncPow2(T)(const T val) if (isIntegral!T) { return powIntegralImpl!(PowType.floor)(val); } /// ditto T truncPow2(T)(const T val) if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.floor)(val); } /// @safe @nogc pure nothrow unittest { assert(truncPow2(3) == 2); assert(truncPow2(4) == 4); assert(truncPow2(10) == 8); assert(truncPow2(4000) == 2048); assert(truncPow2(-5) == -4); assert(truncPow2(-20) == -16); assert(truncPow2(uint.max) == int.max + 1); assert(truncPow2(uint.min) == 0); assert(truncPow2(ulong.max) == long.max + 1); assert(truncPow2(ulong.min) == 0); assert(truncPow2(int.max) == (int.max / 2) + 1); assert(truncPow2(int.min) == int.min); assert(truncPow2(long.max) == (long.max / 2) + 1); assert(truncPow2(long.min) == long.min); } /// @safe @nogc pure nothrow unittest { assert(truncPow2(2.1) == 2.0); assert(truncPow2(7.0) == 4.0); assert(truncPow2(-1.9) == -1.0); assert(truncPow2(0.24) == 0.125); assert(truncPow2(-7.0) == -4.0); assert(truncPow2(double.infinity) == double.infinity); } @safe @nogc pure nothrow unittest { assert(truncPow2(ubyte(3)) == 2); assert(truncPow2(ubyte(4)) == 4); assert(truncPow2(ubyte(10)) == 8); assert(truncPow2(byte(3)) == 2); assert(truncPow2(byte(4)) == 4); assert(truncPow2(byte(10)) == 8); assert(truncPow2(ushort(3)) == 2); assert(truncPow2(ushort(4)) == 4); assert(truncPow2(ushort(10)) == 8); assert(truncPow2(ushort(4000)) == 2048); assert(truncPow2(short(3)) == 2); assert(truncPow2(short(4)) == 4); assert(truncPow2(short(10)) == 8); assert(truncPow2(short(4000)) == 2048); } @safe @nogc pure nothrow unittest { foreach (ulong i; 1 .. 62) { assert(truncPow2(2UL << i) == 2UL << i); assert(truncPow2((2UL << i) + 1) == 2UL << i); assert(truncPow2((2UL << i) - 1) == 1UL << i); assert(truncPow2((2UL << i) - (2UL<<(i-1))) == 1UL << i); } } @safe @nogc pure nothrow unittest { import std.meta : AliasSeq; foreach (T; AliasSeq!(float, double, real)) { assert(truncPow2(T(0.0)) == 0.0); assert(truncPow2(T(4.0)) == 4.0); assert(truncPow2(T(2.1)) == 2.0); assert(truncPow2(T(3.5)) == 2.0); assert(truncPow2(T(7.0)) == 4.0); assert(truncPow2(T(0.24)) == 0.125); assert(truncPow2(T(-2.0)) == -2.0); assert(truncPow2(T(-2.1)) == -2.0); assert(truncPow2(T(-3.1)) == -2.0); assert(truncPow2(T(-7.0)) == -4.0); assert(truncPow2(T(-0.24)) == -0.125); assert(truncPow2(T.infinity) == T.infinity); assert(truncPow2(T.init).isNaN); } } /** Check whether a number is an integer power of two. Note that only positive numbers can be integer powers of two. This function always return `false` if `x` is negative or zero. Params: x = the number to test Returns: `true` if `x` is an integer power of two. */ bool isPowerOf2(X)(const X x) pure @safe nothrow @nogc if (isNumeric!X) { static if (isFloatingPoint!X) { int exp; const X sig = frexp(x, exp); return (exp != int.min) && (sig is cast(X) 0.5L); } else { static if (isSigned!X) { auto y = cast(typeof(x + 0))x; return y > 0 && !(y & (y - 1)); } else { auto y = cast(typeof(x + 0u))x; return (y & -y) > (y - 1); } } } /// @safe unittest { assert( isPowerOf2(1.0L)); assert( isPowerOf2(2.0L)); assert( isPowerOf2(0.5L)); assert( isPowerOf2(pow(2.0L, 96))); assert( isPowerOf2(pow(2.0L, -77))); assert(!isPowerOf2(-2.0L)); assert(!isPowerOf2(-0.5L)); assert(!isPowerOf2(0.0L)); assert(!isPowerOf2(4.315)); assert(!isPowerOf2(1.0L / 3.0L)); assert(!isPowerOf2(real.nan)); assert(!isPowerOf2(real.infinity)); } /// @safe unittest { assert( isPowerOf2(1)); assert( isPowerOf2(2)); assert( isPowerOf2(1uL << 63)); assert(!isPowerOf2(-4)); assert(!isPowerOf2(0)); assert(!isPowerOf2(1337u)); } @safe unittest { import std.meta : AliasSeq; immutable smallP2 = pow(2.0L, -62); immutable bigP2 = pow(2.0L, 50); immutable smallP7 = pow(7.0L, -35); immutable bigP7 = pow(7.0L, 30); foreach (X; AliasSeq!(float, double, real)) { immutable min_sub = X.min_normal * X.epsilon; foreach (x; AliasSeq!(smallP2, min_sub, X.min_normal, .25L, 0.5L, 1.0L, 2.0L, 8.0L, pow(2.0L, X.max_exp - 1), bigP2)) { assert( isPowerOf2(cast(X) x)); assert(!isPowerOf2(cast(X)-x)); } foreach (x; AliasSeq!(0.0L, 3 * min_sub, smallP7, 0.1L, 1337.0L, bigP7, X.max, real.nan, real.infinity)) { assert(!isPowerOf2(cast(X) x)); assert(!isPowerOf2(cast(X)-x)); } } foreach (X; AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong)) { foreach (x; [1, 2, 4, 8, (X.max >>> 1) + 1]) { assert( isPowerOf2(cast(X) x)); static if (isSigned!X) assert(!isPowerOf2(cast(X)-x)); } foreach (x; [0, 3, 5, 13, 77, X.min, X.max]) assert(!isPowerOf2(cast(X) x)); } }
D
// Written in the D programming language. /** Functions for starting and interacting with other processes, and for working with the current _process' execution environment. Process_handling: $(UL $(LI $(LREF spawnProcess) spawns a new _process, optionally assigning it an arbitrary set of standard input, output, and error streams. The function returns immediately, leaving the child _process to execute in parallel with its parent. All other functions in this module that spawn processes are built around $(D spawnProcess).) $(LI $(LREF wait) makes the parent _process wait for a child _process to terminate. In general one should always do this, to avoid child processes becoming "zombies" when the parent _process exits. Scope guards are perfect for this – see the $(LREF spawnProcess) documentation for examples. $(LREF tryWait) is similar to $(D wait), but does not block if the _process has not yet terminated.) $(LI $(LREF pipeProcess) also spawns a child _process which runs in parallel with its parent. However, instead of taking arbitrary streams, it automatically creates a set of pipes that allow the parent to communicate with the child through the child's standard input, output, and/or error streams. This function corresponds roughly to C's $(D popen) function.) $(LI $(LREF execute) starts a new _process and waits for it to complete before returning. Additionally, it captures the _process' standard output and error streams and returns the output of these as a string.) $(LI $(LREF spawnShell), $(LREF pipeShell) and $(LREF executeShell) work like $(D spawnProcess), $(D pipeProcess) and $(D execute), respectively, except that they take a single command string and run it through the current user's default command interpreter. $(D executeShell) corresponds roughly to C's $(D system) function.) $(LI $(LREF kill) attempts to terminate a running _process.) ) The following table compactly summarises the different _process creation functions and how they relate to each other: $(BOOKTABLE, $(TR $(TH ) $(TH Runs program directly) $(TH Runs shell command)) $(TR $(TD Low-level _process creation) $(TD $(LREF spawnProcess)) $(TD $(LREF spawnShell))) $(TR $(TD Automatic input/output redirection using pipes) $(TD $(LREF pipeProcess)) $(TD $(LREF pipeShell))) $(TR $(TD Execute and wait for completion, collect output) $(TD $(LREF execute)) $(TD $(LREF executeShell))) ) Other_functionality: $(UL $(LI $(LREF pipe) is used to create unidirectional pipes.) $(LI $(LREF environment) is an interface through which the current _process' environment variables can be read and manipulated.) $(LI $(LREF escapeShellCommand) and $(LREF escapeShellFileName) are useful for constructing shell command lines in a portable way.) ) Authors: $(LINK2 https://github.com/kyllingstad, Lars Tandle Kyllingstad), $(LINK2 https://github.com/schveiguy, Steven Schveighoffer), $(WEB thecybershadow.net, Vladimir Panteleev) Copyright: Copyright (c) 2013, the authors. All rights reserved. Source: $(PHOBOSSRC std/_process.d) Macros: WIKI=Phobos/StdProcess OBJECTREF=$(D $(LINK2 object.html#$0,$0)) LREF=$(D $(LINK2 #.$0,$0)) */ module std.process; version (Posix) { import core.stdc.errno; import core.stdc.string; import core.sys.posix.stdio; import core.sys.posix.unistd; import core.sys.posix.sys.wait; } version (Windows) { import core.stdc.stdio; import core.sys.windows.windows; import std.utf; import std.windows.syserror; } import std.algorithm; import std.array; import std.conv; import std.exception; import std.path; import std.stdio; import std.string; import std.internal.processinit; // When the DMC runtime is used, we have to use some custom functions // to convert between Windows file handles and FILE*s. version (Win32) version (DigitalMars) version = DMC_RUNTIME; // Some of the following should be moved to druntime. private { // Microsoft Visual C Runtime (MSVCRT) declarations. version (Windows) { version (DMC_RUNTIME) { } else { import core.stdc.stdint; enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2, } } } // POSIX API declarations. version (Posix) { version (OSX) { extern(C) char*** _NSGetEnviron() nothrow; private __gshared const(char**)* environPtr; extern(C) void std_process_shared_static_this() { environPtr = _NSGetEnviron(); } const(char**) environ() @property @trusted nothrow { return *environPtr; } } else { // Made available by the C runtime: extern(C) extern __gshared const char** environ; } unittest { new Thread({assert(environ !is null);}).start(); } } } // private // ============================================================================= // Functions and classes for process management. // ============================================================================= /** Spawns a new _process, optionally assigning it an arbitrary set of standard input, output, and error streams. The function returns immediately, leaving the child _process to execute in parallel with its parent. It is recommended to always call $(LREF wait) on the returned $(LREF Pid), as detailed in the documentation for $(D wait). Command_line: There are four overloads of this function. The first two take an array of strings, $(D args), which should contain the program name as the zeroth element and any command-line arguments in subsequent elements. The third and fourth versions are included for convenience, and may be used when there are no command-line arguments. They take a single string, $(D program), which specifies the program name. Unless a directory is specified in $(D args[0]) or $(D program), $(D spawnProcess) will search for the program in a platform-dependent manner. On POSIX systems, it will look for the executable in the directories listed in the PATH environment variable, in the order they are listed. On Windows, it will search for the executable in the following sequence: $(OL $(LI The directory from which the application loaded.) $(LI The current directory for the parent process.) $(LI The 32-bit Windows system directory.) $(LI The 16-bit Windows system directory.) $(LI The Windows directory.) $(LI The directories listed in the PATH environment variable.) ) --- // Run an executable called "prog" located in the current working // directory: auto pid = spawnProcess("./prog"); scope(exit) wait(pid); // We can do something else while the program runs. The scope guard // ensures that the process is waited for at the end of the scope. ... // Run DMD on the file "myprog.d", specifying a few compiler switches: auto dmdPid = spawnProcess(["dmd", "-O", "-release", "-inline", "myprog.d" ]); if (wait(dmdPid) != 0) writeln("Compilation failed!"); --- Environment_variables: By default, the child process inherits the environment of the parent process, along with any additional variables specified in the $(D env) parameter. If the same variable exists in both the parent's environment and in $(D env), the latter takes precedence. If the $(LREF Config.newEnv) flag is set in $(D config), the child process will $(I not) inherit the parent's environment. Its entire environment will then be determined by $(D env). --- wait(spawnProcess("myapp", ["foo" : "bar"], Config.newEnv)); --- Standard_streams: The optional arguments $(D stdin), $(D stdout) and $(D stderr) may be used to assign arbitrary $(XREF stdio,File) objects as the standard input, output and error streams, respectively, of the child process. The former must be opened for reading, while the latter two must be opened for writing. The default is for the child process to inherit the standard streams of its parent. --- // Run DMD on the file myprog.d, logging any error messages to a // file named errors.log. auto logFile = File("errors.log", "w"); auto pid = spawnProcess(["dmd", "myprog.d"], std.stdio.stdin, std.stdio.stdout, logFile); if (wait(pid) != 0) writeln("Compilation failed. See errors.log for details."); --- Note that if you pass a $(D File) object that is $(I not) one of the standard input/output/error streams of the parent process, that stream will by default be $(I closed) in the parent process when this function returns. See the $(LREF Config) documentation below for information about how to disable this behaviour. Beware of buffering issues when passing $(D File) objects to $(D spawnProcess). The child process will inherit the low-level raw read/write offset associated with the underlying file descriptor, but it will not be aware of any buffered data. In cases where this matters (e.g. when a file should be aligned before being passed on to the child process), it may be a good idea to use unbuffered streams, or at least ensure all relevant buffers are flushed. Params: args = An array which contains the program name as the zeroth element and any command-line arguments in the following elements. stdin = The standard input stream of the child process. This can be any $(XREF stdio,File) that is opened for reading. By default the child process inherits the parent's input stream. stdout = The standard output stream of the child process. This can be any $(XREF stdio,File) that is opened for writing. By default the child process inherits the parent's output stream. stderr = The standard error stream of the child process. This can be any $(XREF stdio,File) that is opened for writing. By default the child process inherits the parent's error stream. env = Additional environment variables for the child process. config = Flags that control process creation. See $(LREF Config) for an overview of available flags. workDir = The working directory for the new process. By default the child process inherits the parent's working directory. Returns: A $(LREF Pid) object that corresponds to the spawned process. Throws: $(LREF ProcessException) on failure to start the process.$(BR) $(XREF stdio,StdioException) on failure to pass one of the streams to the child process (Windows only).$(BR) $(CXREF exception,RangeError) if $(D args) is empty. */ Pid spawnProcess(in char[][] args, File stdin = std.stdio.stdin, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted // TODO: Should be @safe { version (Windows) auto args2 = escapeShellArguments(args); else version (Posix) alias args2 = args; return spawnProcessImpl(args2, stdin, stdout, stderr, env, config, workDir); } /// ditto Pid spawnProcess(in char[][] args, const string[string] env, Config config = Config.none, in char[] workDir = null) @trusted // TODO: Should be @safe { return spawnProcess(args, std.stdio.stdin, std.stdio.stdout, std.stdio.stderr, env, config, workDir); } /// ditto Pid spawnProcess(in char[] program, File stdin = std.stdio.stdin, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted { return spawnProcess((&program)[0 .. 1], stdin, stdout, stderr, env, config, workDir); } /// ditto Pid spawnProcess(in char[] program, const string[string] env, Config config = Config.none, in char[] workDir = null) @trusted { return spawnProcess((&program)[0 .. 1], env, config, workDir); } /* Implementation of spawnProcess() for POSIX. envz should be a zero-terminated array of zero-terminated strings on the form "var=value". */ version (Posix) private Pid spawnProcessImpl(in char[][] args, File stdin, File stdout, File stderr, const string[string] env, Config config, in char[] workDir) @trusted // TODO: Should be @safe { import core.exception: RangeError; if (args.empty) throw new RangeError(); const(char)[] name = args[0]; if (any!isDirSeparator(name)) { if (!isExecutable(name)) throw new ProcessException(text("Not an executable file: ", name)); } else { name = searchPathFor(name); if (name is null) throw new ProcessException(text("Executable file not found: ", args[0])); } // Convert program name and arguments to C-style strings. auto argz = new const(char)*[args.length+1]; argz[0] = toStringz(name); foreach (i; 1 .. args.length) argz[i] = toStringz(args[i]); argz[$-1] = null; // Prepare environment. auto envz = createEnv(env, !(config & Config.newEnv)); // Open the working directory. // We use open in the parent and fchdir in the child // so that most errors (directory doesn't exist, not a directory) // can be propagated as exceptions before forking. int workDirFD = 0; scope(exit) if (workDirFD > 0) close(workDirFD); if (workDir) { import core.sys.posix.fcntl; workDirFD = open(toStringz(workDir), O_RDONLY); if (workDirFD < 0) throw ProcessException.newFromErrno("Failed to open working directory"); stat_t s; if (fstat(workDirFD, &s) < 0) throw ProcessException.newFromErrno("Failed to stat working directory"); if (!S_ISDIR(s.st_mode)) throw new ProcessException("Not a directory: " ~ cast(string)workDir); } // Get the file descriptors of the streams. // These could potentially be invalid, but that is OK. If so, later calls // to dup2() and close() will just silently fail without causing any harm. auto stdinFD = core.stdc.stdio.fileno(stdin.getFP()); auto stdoutFD = core.stdc.stdio.fileno(stdout.getFP()); auto stderrFD = core.stdc.stdio.fileno(stderr.getFP()); auto id = fork(); if (id < 0) throw ProcessException.newFromErrno("Failed to spawn new process"); if (id == 0) { // Child process // Set the working directory. if (workDirFD) { if (fchdir(workDirFD) < 0) { // Fail. It is dangerous to run a program // in an unexpected working directory. core.sys.posix.stdio.perror("spawnProcess(): " ~ "Failed to set working directory"); core.sys.posix.unistd._exit(1); assert(0); } close(workDirFD); } // Redirect streams and close the old file descriptors. // In the case that stderr is redirected to stdout, we need // to backup the file descriptor since stdout may be redirected // as well. if (stderrFD == STDOUT_FILENO) stderrFD = dup(stderrFD); dup2(stdinFD, STDIN_FILENO); dup2(stdoutFD, STDOUT_FILENO); dup2(stderrFD, STDERR_FILENO); // Ensure that the standard streams aren't closed on execute, and // optionally close all other file descriptors. setCLOEXEC(STDIN_FILENO, false); setCLOEXEC(STDOUT_FILENO, false); setCLOEXEC(STDERR_FILENO, false); if (!(config & Config.inheritFDs)) { import core.sys.posix.sys.resource; rlimit r; getrlimit(RLIMIT_NOFILE, &r); foreach (i; 3 .. cast(int) r.rlim_cur) close(i); } // Close the old file descriptors, unless they are // either of the standard streams. if (stdinFD > STDERR_FILENO) close(stdinFD); if (stdoutFD > STDERR_FILENO) close(stdoutFD); if (stderrFD > STDERR_FILENO) close(stderrFD); // Execute program. core.sys.posix.unistd.execve(argz[0], argz.ptr, envz); // If execution fails, exit as quickly as possible. core.sys.posix.stdio.perror("spawnProcess(): Failed to execute program"); core.sys.posix.unistd._exit(1); assert (0); } else { // Parent process: Close streams and return. if (stdinFD > STDERR_FILENO && !(config & Config.retainStdin)) stdin.close(); if (stdoutFD > STDERR_FILENO && !(config & Config.retainStdout)) stdout.close(); if (stderrFD > STDERR_FILENO && !(config & Config.retainStderr)) stderr.close(); return new Pid(id); } } /* Implementation of spawnProcess() for Windows. commandLine must contain the entire command line, properly quoted/escaped as required by CreateProcessW(). envz must be a pointer to a block of UTF-16 characters on the form "var1=value1\0var2=value2\0...varN=valueN\0\0". */ version (Windows) private Pid spawnProcessImpl(in char[] commandLine, File stdin, File stdout, File stderr, const string[string] env, Config config, in char[] workDir) @trusted { import core.exception: RangeError; if (commandLine.empty) throw new RangeError("Command line is empty"); auto commandz = toUTFz!(wchar*)(commandLine); auto workDirz = workDir is null ? null : toUTFz!(wchar*)(workDir); // Prepare environment. auto envz = createEnv(env, !(config & Config.newEnv)); // Startup info for CreateProcessW(). STARTUPINFO_W startinfo; startinfo.cb = startinfo.sizeof; startinfo.dwFlags = STARTF_USESTDHANDLES; // Extract file descriptors and HANDLEs from the streams and make the // handles inheritable. static void prepareStream(ref File file, DWORD stdHandle, string which, out int fileDescriptor, out HANDLE handle) { fileDescriptor = file.isOpen ? file.fileno() : -1; if (fileDescriptor < 0) handle = GetStdHandle(stdHandle); else handle = file.windowsHandle; DWORD dwFlags; if (GetHandleInformation(handle, &dwFlags)) { if (!(dwFlags & HANDLE_FLAG_INHERIT)) { if (!SetHandleInformation(handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) { throw new StdioException( "Failed to make "~which~" stream inheritable by child process (" ~sysErrorString(GetLastError()) ~ ')', 0); } } } } int stdinFD = -1, stdoutFD = -1, stderrFD = -1; prepareStream(stdin, STD_INPUT_HANDLE, "stdin" , stdinFD, startinfo.hStdInput ); prepareStream(stdout, STD_OUTPUT_HANDLE, "stdout", stdoutFD, startinfo.hStdOutput); prepareStream(stderr, STD_ERROR_HANDLE, "stderr", stderrFD, startinfo.hStdError ); // Create process. PROCESS_INFORMATION pi; DWORD dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | ((config & Config.suppressConsole) ? CREATE_NO_WINDOW : 0); if (!CreateProcessW(null, commandz, null, null, true, dwCreationFlags, envz, workDirz, &startinfo, &pi)) throw ProcessException.newFromLastError("Failed to spawn new process"); // figure out if we should close any of the streams if (stdinFD > STDERR_FILENO && !(config & Config.retainStdin)) stdin.close(); if (stdoutFD > STDERR_FILENO && !(config & Config.retainStdout)) stdout.close(); if (stderrFD > STDERR_FILENO && !(config & Config.retainStderr)) stderr.close(); // close the thread handle in the process info structure CloseHandle(pi.hThread); return new Pid(pi.dwProcessId, pi.hProcess); } // Converts childEnv to a zero-terminated array of zero-terminated strings // on the form "name=value", optionally adding those of the current process' // environment strings that are not present in childEnv. If the parent's // environment should be inherited without modification, this function // returns environ directly. version (Posix) private const(char*)* createEnv(const string[string] childEnv, bool mergeWithParentEnv) { // Determine the number of strings in the parent's environment. int parentEnvLength = 0; if (mergeWithParentEnv) { if (childEnv.length == 0) return environ; while (environ[parentEnvLength] != null) ++parentEnvLength; } // Convert the "new" variables to C-style strings. auto envz = new const(char)*[parentEnvLength + childEnv.length + 1]; int pos = 0; foreach (var, val; childEnv) envz[pos++] = (var~'='~val~'\0').ptr; // Add the parent's environment. foreach (environStr; environ[0 .. parentEnvLength]) { int eqPos = 0; while (environStr[eqPos] != '=' && environStr[eqPos] != '\0') ++eqPos; if (environStr[eqPos] != '=') continue; auto var = environStr[0 .. eqPos]; if (var in childEnv) continue; envz[pos++] = environStr; } envz[pos] = null; return envz.ptr; } version (Posix) unittest { auto e1 = createEnv(null, false); assert (e1 != null && *e1 == null); auto e2 = createEnv(null, true); assert (e2 != null); int i = 0; for (; environ[i] != null; ++i) { assert (e2[i] != null); import core.stdc.string; assert (strcmp(e2[i], environ[i]) == 0); } assert (e2[i] == null); auto e3 = createEnv(["foo" : "bar", "hello" : "world"], false); assert (e3 != null && e3[0] != null && e3[1] != null && e3[2] == null); assert ((e3[0][0 .. 8] == "foo=bar\0" && e3[1][0 .. 12] == "hello=world\0") || (e3[0][0 .. 12] == "hello=world\0" && e3[1][0 .. 8] == "foo=bar\0")); } // Converts childEnv to a Windows environment block, which is on the form // "name1=value1\0name2=value2\0...nameN=valueN\0\0", optionally adding // those of the current process' environment strings that are not present // in childEnv. Returns null if the parent's environment should be // inherited without modification, as this is what is expected by // CreateProcess(). version (Windows) private LPVOID createEnv(const string[string] childEnv, bool mergeWithParentEnv) { if (mergeWithParentEnv && childEnv.length == 0) return null; auto envz = appender!(wchar[])(); void put(string var, string val) { envz.put(var); envz.put('='); envz.put(val); envz.put(cast(wchar) '\0'); } // Add the variables in childEnv, removing them from parentEnv // if they exist there too. auto parentEnv = mergeWithParentEnv ? environment.toAA() : null; foreach (k, v; childEnv) { auto uk = toUpper(k); put(uk, v); if (uk in parentEnv) parentEnv.remove(uk); } // Add remaining parent environment variables. foreach (k, v; parentEnv) put(k, v); // Two final zeros are needed in case there aren't any environment vars, // and the last one does no harm when there are. envz.put("\0\0"w); return envz.data.ptr; } version (Windows) unittest { assert (createEnv(null, true) == null); assert ((cast(wchar*) createEnv(null, false))[0 .. 2] == "\0\0"w); auto e1 = (cast(wchar*) createEnv(["foo":"bar", "ab":"c"], false))[0 .. 14]; assert (e1 == "FOO=bar\0AB=c\0\0"w || e1 == "AB=c\0FOO=bar\0\0"w); } // Searches the PATH variable for the given executable file, // (checking that it is in fact executable). version (Posix) private string searchPathFor(in char[] executable) @trusted //TODO: @safe nothrow { auto pathz = core.stdc.stdlib.getenv("PATH"); if (pathz == null) return null; foreach (dir; splitter(to!string(pathz), ':')) { auto execPath = buildPath(dir, executable); if (isExecutable(execPath)) return execPath; } return null; } // Checks whether the file exists and can be executed by the // current user. version (Posix) private bool isExecutable(in char[] path) @trusted //TODO: @safe nothrow { return (access(toStringz(path), X_OK) == 0); } version (Posix) unittest { auto unamePath = searchPathFor("uname"); assert (!unamePath.empty); assert (unamePath[0] == '/'); assert (unamePath.endsWith("uname")); auto unlikely = searchPathFor("lkmqwpoialhggyaofijadsohufoiqezm"); assert (unlikely is null, "Are you kidding me?"); } // Sets or unsets the FD_CLOEXEC flag on the given file descriptor. version (Posix) private void setCLOEXEC(int fd, bool on) { import core.sys.posix.fcntl; auto flags = fcntl(fd, F_GETFD); if (flags >= 0) { if (on) flags |= FD_CLOEXEC; else flags &= ~(cast(typeof(flags)) FD_CLOEXEC); flags = fcntl(fd, F_SETFD, flags); } assert (flags != -1 || .errno == EBADF); } unittest // Command line arguments in spawnProcess(). { version (Windows) TestScript prog = "if not [%~1]==[foo] ( exit 1 ) if not [%~2]==[bar] ( exit 2 ) exit 0"; else version (Posix) TestScript prog = `if test "$1" != "foo"; then exit 1; fi if test "$2" != "bar"; then exit 2; fi exit 0`; assert (wait(spawnProcess(prog.path)) == 1); assert (wait(spawnProcess([prog.path])) == 1); assert (wait(spawnProcess([prog.path, "foo"])) == 2); assert (wait(spawnProcess([prog.path, "foo", "baz"])) == 2); assert (wait(spawnProcess([prog.path, "foo", "bar"])) == 0); } unittest // Environment variables in spawnProcess(). { // We really should use set /a on Windows, but Wine doesn't support it. version (Windows) TestScript envProg = `if [%STD_PROCESS_UNITTEST1%] == [1] ( if [%STD_PROCESS_UNITTEST2%] == [2] (exit 3) exit 1 ) if [%STD_PROCESS_UNITTEST1%] == [4] ( if [%STD_PROCESS_UNITTEST2%] == [2] (exit 6) exit 4 ) if [%STD_PROCESS_UNITTEST2%] == [2] (exit 2) exit 0`; version (Posix) TestScript envProg = `if test "$std_process_unittest1" = ""; then std_process_unittest1=0 fi if test "$std_process_unittest2" = ""; then std_process_unittest2=0 fi exit $(($std_process_unittest1+$std_process_unittest2))`; environment.remove("std_process_unittest1"); // Just in case. environment.remove("std_process_unittest2"); assert (wait(spawnProcess(envProg.path)) == 0); assert (wait(spawnProcess(envProg.path, null, Config.newEnv)) == 0); environment["std_process_unittest1"] = "1"; assert (wait(spawnProcess(envProg.path)) == 1); assert (wait(spawnProcess(envProg.path, null, Config.newEnv)) == 0); auto env = ["std_process_unittest2" : "2"]; assert (wait(spawnProcess(envProg.path, env)) == 3); assert (wait(spawnProcess(envProg.path, env, Config.newEnv)) == 2); env["std_process_unittest1"] = "4"; assert (wait(spawnProcess(envProg.path, env)) == 6); assert (wait(spawnProcess(envProg.path, env, Config.newEnv)) == 6); environment.remove("std_process_unittest1"); assert (wait(spawnProcess(envProg.path, env)) == 6); assert (wait(spawnProcess(envProg.path, env, Config.newEnv)) == 6); } unittest // Stream redirection in spawnProcess(). { version (Windows) TestScript prog = "set /p INPUT= echo %INPUT% output %~1 echo %INPUT% error %~2 1>&2"; else version (Posix) TestScript prog = "read INPUT echo $INPUT output $1 echo $INPUT error $2 >&2"; // Pipes auto pipei = pipe(); auto pipeo = pipe(); auto pipee = pipe(); auto pid = spawnProcess([prog.path, "foo", "bar"], pipei.readEnd, pipeo.writeEnd, pipee.writeEnd); pipei.writeEnd.writeln("input"); pipei.writeEnd.flush(); assert (pipeo.readEnd.readln().chomp() == "input output foo"); assert (pipee.readEnd.readln().chomp().stripRight() == "input error bar"); wait(pid); // Files import std.ascii, std.file, std.uuid; auto pathi = buildPath(tempDir(), randomUUID().toString()); auto patho = buildPath(tempDir(), randomUUID().toString()); auto pathe = buildPath(tempDir(), randomUUID().toString()); std.file.write(pathi, "INPUT"~std.ascii.newline); auto filei = File(pathi, "r"); auto fileo = File(patho, "w"); auto filee = File(pathe, "w"); pid = spawnProcess([prog.path, "bar", "baz" ], filei, fileo, filee); wait(pid); assert (readText(patho).chomp() == "INPUT output bar"); assert (readText(pathe).chomp().stripRight() == "INPUT error baz"); remove(pathi); remove(patho); remove(pathe); } unittest // Error handling in spawnProcess() { assertThrown!ProcessException(spawnProcess("ewrgiuhrifuheiohnmnvqweoijwf")); assertThrown!ProcessException(spawnProcess("./rgiuhrifuheiohnmnvqweoijwf")); } unittest // Specifying a working directory. { TestScript prog = "echo foo>bar"; auto directory = uniqueTempPath(); mkdir(directory); scope(exit) rmdirRecurse(directory); auto pid = spawnProcess([prog.path], null, Config.none, directory); wait(pid); assert(exists(buildPath(directory, "bar"))); } unittest // Specifying a bad working directory. { TestScript prog = "echo"; auto directory = uniqueTempPath(); assertThrown!ProcessException(spawnProcess([prog.path], null, Config.none, directory)); std.file.write(directory, "foo"); scope(exit) remove(directory); assertThrown!ProcessException(spawnProcess([prog.path], null, Config.none, directory)); } /** A variation on $(LREF spawnProcess) that runs the given _command through the current user's preferred _command interpreter (aka. shell). The string $(D command) is passed verbatim to the shell, and is therefore subject to its rules about _command structure, argument/filename quoting and escaping of special characters. The path to the shell executable is determined by the $(LREF userShell) function. In all other respects this function works just like $(D spawnProcess). Please refer to the $(LREF spawnProcess) documentation for descriptions of the other function parameters, the return value and any exceptions that may be thrown. --- // Run the command/program "foo" on the file named "my file.txt", and // redirect its output into foo.log. auto pid = spawnShell(`foo "my file.txt" > foo.log`); wait(pid); --- See_also: $(LREF escapeShellCommand), which may be helpful in constructing a properly quoted and escaped shell _command line for the current platform. */ Pid spawnShell(in char[] command, File stdin = std.stdio.stdin, File stdout = std.stdio.stdout, File stderr = std.stdio.stderr, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted // TODO: Should be @safe { version (Windows) { // CMD does not parse its arguments like other programs. // It does not use CommandLineToArgvW. // Instead, it treats the first and last quote specially. // See CMD.EXE /? for details. auto args = escapeShellFileName(userShell) ~ ` ` ~ shellSwitch ~ ` "` ~ command ~ `"`; } else version (Posix) { const(char)[][3] args; args[0] = userShell; args[1] = shellSwitch; args[2] = command; } return spawnProcessImpl(args, stdin, stdout, stderr, env, config, workDir); } /// ditto Pid spawnShell(in char[] command, const string[string] env, Config config = Config.none, in char[] workDir = null) @trusted // TODO: Should be @safe { return spawnShell(command, std.stdio.stdin, std.stdio.stdout, std.stdio.stderr, env, config, workDir); } unittest { version (Windows) auto cmd = "echo %FOO%"; else version (Posix) auto cmd = "echo $foo"; import std.file; auto tmpFile = uniqueTempPath(); scope(exit) if (exists(tmpFile)) remove(tmpFile); auto redir = "> \""~tmpFile~'"'; auto env = ["foo" : "bar"]; assert (wait(spawnShell(cmd~redir, env)) == 0); auto f = File(tmpFile, "a"); version(Win64) f.seek(0, SEEK_END); // MSVCRT probably seeks to the end when writing, not before assert (wait(spawnShell(cmd, std.stdio.stdin, f, std.stdio.stderr, env)) == 0); f.close(); auto output = std.file.readText(tmpFile); assert (output == "bar\nbar\n" || output == "bar\r\nbar\r\n"); } version (Windows) unittest { TestScript prog = "echo %0 %*"; auto outputFn = uniqueTempPath(); scope(exit) if (exists(outputFn)) remove(outputFn); auto args = [`a b c`, `a\b\c\`, `a"b"c"`]; auto result = executeShell( escapeShellCommand([prog.path] ~ args) ~ " > " ~ escapeShellFileName(outputFn)); assert(result.status == 0); auto args2 = outputFn.readText().strip().parseCommandLine()[1..$]; assert(args == args2, text(args2)); } /** Flags that control the behaviour of $(LREF spawnProcess) and $(LREF spawnShell). Use bitwise OR to combine flags. Example: --- auto logFile = File("myapp_error.log", "w"); // Start program, suppressing the console window (Windows only), // redirect its error stream to logFile, and leave logFile open // in the parent process as well. auto pid = spawnProcess("myapp", stdin, stdout, logFile, Config.retainStderr | Config.suppressConsole); scope(exit) { auto exitCode = wait(pid); logFile.writeln("myapp exited with code ", exitCode); logFile.close(); } --- */ enum Config { none = 0, /** By default, the child process inherits the parent's environment, and any environment variables passed to $(LREF spawnProcess) will be added to it. If this flag is set, the only variables in the child process' environment will be those given to spawnProcess. */ newEnv = 1, /** Unless the child process inherits the standard input/output/error streams of its parent, one almost always wants the streams closed in the parent when $(LREF spawnProcess) returns. Therefore, by default, this is done. If this is not desirable, pass any of these options to spawnProcess. */ retainStdin = 2, retainStdout = 4, /// ditto retainStderr = 8, /// ditto /** On Windows, if the child process is a console application, this flag will prevent the creation of a console window. Otherwise, it will be ignored. On POSIX, $(D suppressConsole) has no effect. */ suppressConsole = 16, /** On POSIX, open $(LINK2 http://en.wikipedia.org/wiki/File_descriptor,file descriptors) are by default inherited by the child process. As this may lead to subtle bugs when pipes or multiple threads are involved, $(LREF spawnProcess) ensures that all file descriptors except the ones that correspond to standard input/output/error are closed in the child process when it starts. Use $(D inheritFDs) to prevent this. On Windows, this option has no effect, and any handles which have been explicitly marked as inheritable will always be inherited by the child process. */ inheritFDs = 32, } /// A handle that corresponds to a spawned process. final class Pid { /** The process ID number. This is a number that uniquely identifies the process on the operating system, for at least as long as the process is running. Once $(LREF wait) has been called on the $(LREF Pid), this method will return an invalid process ID. */ @property int processID() const @safe pure nothrow { return _processID; } /** An operating system handle to the process. This handle is used to specify the process in OS-specific APIs. On POSIX, this function returns a $(D core.sys.posix.sys.types.pid_t) with the same value as $(LREF Pid.processID), while on Windows it returns a $(D core.sys.windows.windows.HANDLE). Once $(LREF wait) has been called on the $(LREF Pid), this method will return an invalid handle. */ // Note: Since HANDLE is a reference, this function cannot be const. version (Windows) @property HANDLE osHandle() @safe pure nothrow { return _handle; } else version (Posix) @property pid_t osHandle() @safe pure nothrow { return _processID; } private: /* Pid.performWait() does the dirty work for wait() and nonBlockingWait(). If block == true, this function blocks until the process terminates, sets _processID to terminated, and returns the exit code or terminating signal as described in the wait() documentation. If block == false, this function returns immediately, regardless of the status of the process. If the process has terminated, the function has the exact same effect as the blocking version. If not, it returns 0 and does not modify _processID. */ version (Posix) int performWait(bool block) @trusted { if (_processID == terminated) return _exitCode; int exitCode; while(true) { int status; auto check = waitpid(_processID, &status, block ? 0 : WNOHANG); if (check == -1) { if (errno == ECHILD) { throw new ProcessException( "Process does not exist or is not a child process."); } else { // waitpid() was interrupted by a signal. We simply // restart it. assert (errno == EINTR); continue; } } if (!block && check == 0) return 0; if (WIFEXITED(status)) { exitCode = WEXITSTATUS(status); break; } else if (WIFSIGNALED(status)) { exitCode = -WTERMSIG(status); break; } // We check again whether the call should be blocking, // since we don't care about other status changes besides // "exited" and "terminated by signal". if (!block) return 0; // Process has stopped, but not terminated, so we continue waiting. } // Mark Pid as terminated, and cache and return exit code. _processID = terminated; _exitCode = exitCode; return exitCode; } else version (Windows) { int performWait(bool block) @trusted { if (_processID == terminated) return _exitCode; assert (_handle != INVALID_HANDLE_VALUE); if (block) { auto result = WaitForSingleObject(_handle, INFINITE); if (result != WAIT_OBJECT_0) throw ProcessException.newFromLastError("Wait failed."); } if (!GetExitCodeProcess(_handle, cast(LPDWORD)&_exitCode)) throw ProcessException.newFromLastError(); if (!block && _exitCode == STILL_ACTIVE) return 0; CloseHandle(_handle); _handle = INVALID_HANDLE_VALUE; _processID = terminated; return _exitCode; } ~this() { if(_handle != INVALID_HANDLE_VALUE) { CloseHandle(_handle); _handle = INVALID_HANDLE_VALUE; } } } // Special values for _processID. enum invalid = -1, terminated = -2; // OS process ID number. Only nonnegative IDs correspond to // running processes. int _processID = invalid; // Exit code cached by wait(). This is only expected to hold a // sensible value if _processID == terminated. int _exitCode; // Pids are only meant to be constructed inside this module, so // we make the constructor private. version (Windows) { HANDLE _handle = INVALID_HANDLE_VALUE; this(int pid, HANDLE handle) @safe pure nothrow { _processID = pid; _handle = handle; } } else { this(int id) @safe pure nothrow { _processID = id; } } } /** Waits for the process associated with $(D pid) to terminate, and returns its exit status. In general one should always _wait for child processes to terminate before exiting the parent process. Otherwise, they may become "$(WEB en.wikipedia.org/wiki/Zombie_process,zombies)" – processes that are defunct, yet still occupy a slot in the OS process table. If the process has already terminated, this function returns directly. The exit code is cached, so that if wait() is called multiple times on the same $(LREF Pid) it will always return the same value. POSIX_specific: If the process is terminated by a signal, this function returns a negative number whose absolute value is the signal number. Since POSIX restricts normal exit codes to the range 0-255, a negative return value will always indicate termination by signal. Signal codes are defined in the $(D core.sys.posix.signal) module (which corresponds to the $(D signal.h) POSIX header). Throws: $(LREF ProcessException) on failure. Examples: See the $(LREF spawnProcess) documentation. See_also: $(LREF tryWait), for a non-blocking function. */ int wait(Pid pid) @safe { assert(pid !is null, "Called wait on a null Pid."); return pid.performWait(true); } unittest // Pid and wait() { version (Windows) TestScript prog = "exit %~1"; else version (Posix) TestScript prog = "exit $1"; assert (wait(spawnProcess([prog.path, "0"])) == 0); assert (wait(spawnProcess([prog.path, "123"])) == 123); auto pid = spawnProcess([prog.path, "10"]); assert (pid.processID > 0); version (Windows) assert (pid.osHandle != INVALID_HANDLE_VALUE); else version (Posix) assert (pid.osHandle == pid.processID); assert (wait(pid) == 10); assert (wait(pid) == 10); // cached exit code assert (pid.processID < 0); version (Windows) assert (pid.osHandle == INVALID_HANDLE_VALUE); else version (Posix) assert (pid.osHandle < 0); } /** A non-blocking version of $(LREF wait). If the process associated with $(D pid) has already terminated, $(D tryWait) has the exact same effect as $(D wait). In this case, it returns a tuple where the $(D terminated) field is set to $(D true) and the $(D status) field has the same interpretation as the return value of $(D wait). If the process has $(I not) yet terminated, this function differs from $(D wait) in that does not wait for this to happen, but instead returns immediately. The $(D terminated) field of the returned tuple will then be set to $(D false), while the $(D status) field will always be 0 (zero). $(D wait) or $(D tryWait) should then be called again on the same $(D Pid) at some later time; not only to get the exit code, but also to avoid the process becoming a "zombie" when it finally terminates. (See $(LREF wait) for details). Returns: An $(D std.typecons.Tuple!(bool, "terminated", int, "status")). Throws: $(LREF ProcessException) on failure. Example: --- auto pid = spawnProcess("dmd myapp.d"); scope(exit) wait(pid); ... auto dmd = tryWait(pid); if (dmd.terminated) { if (dmd.status == 0) writeln("Compilation succeeded!"); else writeln("Compilation failed"); } else writeln("Still compiling..."); ... --- Note that in this example, the first $(D wait) call will have no effect if the process has already terminated by the time $(D tryWait) is called. In the opposite case, however, the $(D scope) statement ensures that we always wait for the process if it hasn't terminated by the time we reach the end of the scope. */ auto tryWait(Pid pid) @safe { import std.typecons : Tuple; assert(pid !is null, "Called tryWait on a null Pid."); auto code = pid.performWait(false); return Tuple!(bool, "terminated", int, "status")(pid._processID == Pid.terminated, code); } // unittest: This function is tested together with kill() below. /** Attempts to terminate the process associated with $(D pid). The effect of this function, as well as the meaning of $(D codeOrSignal), is highly platform dependent. Details are given below. Common to all platforms is that this function only $(I initiates) termination of the process, and returns immediately. It does not wait for the process to end, nor does it guarantee that the process does in fact get terminated. Always call $(LREF wait) to wait for a process to complete, even if $(D kill) has been called on it. Windows_specific: The process will be $(LINK2 http://msdn.microsoft.com/en-us/library/windows/desktop/ms686714%28v=vs.100%29.aspx, forcefully and abruptly terminated). If $(D codeOrSignal) is specified, it must be a nonnegative number which will be used as the exit code of the process. If not, the process wil exit with code 1. Do not use $(D codeOrSignal = 259), as this is a special value (aka. $(LINK2 http://msdn.microsoft.com/en-us/library/windows/desktop/ms683189.aspx,STILL_ACTIVE)) used by Windows to signal that a process has in fact $(I not) terminated yet. --- auto pid = spawnProcess("some_app"); kill(pid, 10); assert (wait(pid) == 10); --- POSIX_specific: A $(LINK2 http://en.wikipedia.org/wiki/Unix_signal,signal) will be sent to the process, whose value is given by $(D codeOrSignal). Depending on the signal sent, this may or may not terminate the process. Symbolic constants for various $(LINK2 http://en.wikipedia.org/wiki/Unix_signal#POSIX_signals, POSIX signals) are defined in $(D core.sys.posix.signal), which corresponds to the $(LINK2 http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html, $(D signal.h) POSIX header). If $(D codeOrSignal) is omitted, the $(D SIGTERM) signal will be sent. (This matches the behaviour of the $(LINK2 http://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html, $(D _kill)) shell command.) --- import core.sys.posix.signal: SIGKILL; auto pid = spawnProcess("some_app"); kill(pid, SIGKILL); assert (wait(pid) == -SIGKILL); // Negative return value on POSIX! --- Throws: $(LREF ProcessException) on error (e.g. if codeOrSignal is invalid). Note that failure to terminate the process is considered a "normal" outcome, not an error.$(BR) */ void kill(Pid pid) { version (Windows) kill(pid, 1); else version (Posix) { import core.sys.posix.signal: SIGTERM; kill(pid, SIGTERM); } } /// ditto void kill(Pid pid, int codeOrSignal) { version (Windows) { if (codeOrSignal < 0) throw new ProcessException("Invalid exit code"); // On Windows, TerminateProcess() appears to terminate the // *current* process if it is passed an invalid handle... if (pid.osHandle == INVALID_HANDLE_VALUE) throw new ProcessException("Invalid process handle"); if (!TerminateProcess(pid.osHandle, codeOrSignal)) throw ProcessException.newFromLastError(); } else version (Posix) { import core.sys.posix.signal; if (kill(pid.osHandle, codeOrSignal) == -1) throw ProcessException.newFromErrno(); } } unittest // tryWait() and kill() { import core.thread; // The test script goes into an infinite loop. version (Windows) { TestScript prog = ":loop goto loop"; } else version (Posix) { import core.sys.posix.signal: SIGTERM, SIGKILL; TestScript prog = "while true; do sleep 1; done"; } auto pid = spawnProcess(prog.path); Thread.sleep(dur!"seconds"(1)); kill(pid); version (Windows) assert (wait(pid) == 1); else version (Posix) assert (wait(pid) == -SIGTERM); pid = spawnProcess(prog.path); Thread.sleep(dur!"seconds"(1)); auto s = tryWait(pid); assert (!s.terminated && s.status == 0); assertThrown!ProcessException(kill(pid, -123)); // Negative code not allowed. version (Windows) kill(pid, 123); else version (Posix) kill(pid, SIGKILL); do { s = tryWait(pid); } while (!s.terminated); version (Windows) assert (s.status == 123); else version (Posix) assert (s.status == -SIGKILL); assertThrown!ProcessException(kill(pid)); } /** Creates a unidirectional _pipe. Data is written to one end of the _pipe and read from the other. --- auto p = pipe(); p.writeEnd.writeln("Hello World"); assert (p.readEnd.readln().chomp() == "Hello World"); --- Pipes can, for example, be used for interprocess communication by spawning a new process and passing one end of the _pipe to the child, while the parent uses the other end. (See also $(LREF pipeProcess) and $(LREF pipeShell) for an easier way of doing this.) --- // Use cURL to download the dlang.org front page, pipe its // output to grep to extract a list of links to ZIP files, // and write the list to the file "D downloads.txt": auto p = pipe(); auto outFile = File("D downloads.txt", "w"); auto cpid = spawnProcess(["curl", "http://dlang.org/download.html"], std.stdio.stdin, p.writeEnd); scope(exit) wait(cpid); auto gpid = spawnProcess(["grep", "-o", `http://\S*\.zip`], p.readEnd, outFile); scope(exit) wait(gpid); --- Returns: A $(LREF Pipe) object that corresponds to the created _pipe. Throws: $(XREF stdio,StdioException) on failure. */ version (Posix) Pipe pipe() @trusted //TODO: @safe { int[2] fds; if (core.sys.posix.unistd.pipe(fds) != 0) throw new StdioException("Unable to create pipe"); Pipe p; auto readFP = fdopen(fds[0], "r"); if (readFP == null) throw new StdioException("Cannot open read end of pipe"); p._read = File(readFP, null); auto writeFP = fdopen(fds[1], "w"); if (writeFP == null) throw new StdioException("Cannot open write end of pipe"); p._write = File(writeFP, null); return p; } else version (Windows) Pipe pipe() @trusted //TODO: @safe { // use CreatePipe to create an anonymous pipe HANDLE readHandle; HANDLE writeHandle; if (!CreatePipe(&readHandle, &writeHandle, null, 0)) { throw new StdioException( "Error creating pipe (" ~ sysErrorString(GetLastError()) ~ ')', 0); } scope(failure) { CloseHandle(readHandle); CloseHandle(writeHandle); } try { Pipe p; p._read .windowsHandleOpen(readHandle , "r"); p._write.windowsHandleOpen(writeHandle, "a"); return p; } catch (Exception e) { throw new StdioException("Error attaching pipe (" ~ e.msg ~ ")", 0); } } /// An interface to a pipe created by the $(LREF pipe) function. struct Pipe { /// The read end of the pipe. @property File readEnd() @trusted /*TODO: @safe nothrow*/ { return _read; } /// The write end of the pipe. @property File writeEnd() @trusted /*TODO: @safe nothrow*/ { return _write; } /** Closes both ends of the pipe. Normally it is not necessary to do this manually, as $(XREF stdio,File) objects are automatically closed when there are no more references to them. Note that if either end of the pipe has been passed to a child process, it will only be closed in the parent process. (What happens in the child process is platform dependent.) */ void close() @trusted //TODO: @safe nothrow { _read.close(); _write.close(); } private: File _read, _write; } unittest { auto p = pipe(); p.writeEnd.writeln("Hello World"); p.writeEnd.flush(); assert (p.readEnd.readln().chomp() == "Hello World"); p.close(); assert (!p.readEnd.isOpen); assert (!p.writeEnd.isOpen); } /** Starts a new process, creating pipes to redirect its standard input, output and/or error streams. $(D pipeProcess) and $(D pipeShell) are convenient wrappers around $(LREF spawnProcess) and $(LREF spawnShell), respectively, and automate the task of redirecting one or more of the child process' standard streams through pipes. Like the functions they wrap, these functions return immediately, leaving the child process to execute in parallel with the invoking process. It is recommended to always call $(LREF wait) on the returned $(LREF ProcessPipes.pid), as detailed in the documentation for $(D wait). The $(D args)/$(D program)/$(D command), $(D env) and $(D config) parameters are forwarded straight to the underlying spawn functions, and we refer to their documentation for details. Params: args = An array which contains the program name as the zeroth element and any command-line arguments in the following elements. (See $(LREF spawnProcess) for details.) program = The program name, $(I without) command-line arguments. (See $(LREF spawnProcess) for details.) command = A shell command which is passed verbatim to the command interpreter. (See $(LREF spawnShell) for details.) redirect = Flags that determine which streams are redirected, and how. See $(LREF Redirect) for an overview of available flags. env = Additional environment variables for the child process. (See $(LREF spawnProcess) for details.) config = Flags that control process creation. See $(LREF Config) for an overview of available flags, and note that the $(D retainStd...) flags have no effect in this function. workDir = The working directory for the new process. By default the child process inherits the parent's working directory. Returns: A $(LREF ProcessPipes) object which contains $(XREF stdio,File) handles that communicate with the redirected streams of the child process, along with a $(LREF Pid) object that corresponds to the spawned process. Throws: $(LREF ProcessException) on failure to start the process.$(BR) $(XREF stdio,StdioException) on failure to redirect any of the streams.$(BR) Example: --- auto pipes = pipeProcess("my_application", Redirect.stdout | Redirect.stderr); scope(exit) wait(pipes.pid); // Store lines of output. string[] output; foreach (line; pipes.stdout.byLine) output ~= line.idup; // Store lines of errors. string[] errors; foreach (line; pipes.stderr.byLine) errors ~= line.idup; --- */ ProcessPipes pipeProcess(in char[][] args, Redirect redirect = Redirect.all, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted //TODO: @safe { return pipeProcessImpl!spawnProcess(args, redirect, env, config, workDir); } /// ditto ProcessPipes pipeProcess(in char[] program, Redirect redirect = Redirect.all, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted { return pipeProcessImpl!spawnProcess(program, redirect, env, config, workDir); } /// ditto ProcessPipes pipeShell(in char[] command, Redirect redirect = Redirect.all, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @safe { return pipeProcessImpl!spawnShell(command, redirect, env, config, workDir); } // Implementation of the pipeProcess() family of functions. private ProcessPipes pipeProcessImpl(alias spawnFunc, Cmd) (Cmd command, Redirect redirectFlags, const string[string] env = null, Config config = Config.none, in char[] workDir = null) @trusted //TODO: @safe { File childStdin, childStdout, childStderr; ProcessPipes pipes; pipes._redirectFlags = redirectFlags; if (redirectFlags & Redirect.stdin) { auto p = pipe(); childStdin = p.readEnd; pipes._stdin = p.writeEnd; } else { childStdin = std.stdio.stdin; } if (redirectFlags & Redirect.stdout) { if ((redirectFlags & Redirect.stdoutToStderr) != 0) throw new StdioException("Cannot create pipe for stdout AND " ~"redirect it to stderr", 0); auto p = pipe(); childStdout = p.writeEnd; pipes._stdout = p.readEnd; } else { childStdout = std.stdio.stdout; } if (redirectFlags & Redirect.stderr) { if ((redirectFlags & Redirect.stderrToStdout) != 0) throw new StdioException("Cannot create pipe for stderr AND " ~"redirect it to stdout", 0); auto p = pipe(); childStderr = p.writeEnd; pipes._stderr = p.readEnd; } else { childStderr = std.stdio.stderr; } if (redirectFlags & Redirect.stdoutToStderr) { if (redirectFlags & Redirect.stderrToStdout) { // We know that neither of the other options have been // set, so we assign the std.stdio.std* streams directly. childStdout = std.stdio.stderr; childStderr = std.stdio.stdout; } else { childStdout = childStderr; } } else if (redirectFlags & Redirect.stderrToStdout) { childStderr = childStdout; } config &= ~(Config.retainStdin | Config.retainStdout | Config.retainStderr); pipes._pid = spawnFunc(command, childStdin, childStdout, childStderr, env, config, workDir); return pipes; } /** Flags that can be passed to $(LREF pipeProcess) and $(LREF pipeShell) to specify which of the child process' standard streams are redirected. Use bitwise OR to combine flags. */ enum Redirect { /// Redirect the standard input, output or error streams, respectively. stdin = 1, stdout = 2, /// ditto stderr = 4, /// ditto /** Redirect _all three streams. This is equivalent to $(D Redirect.stdin | Redirect.stdout | Redirect.stderr). */ all = stdin | stdout | stderr, /** Redirect the standard error stream into the standard output stream. This can not be combined with $(D Redirect.stderr). */ stderrToStdout = 8, /** Redirect the standard output stream into the standard error stream. This can not be combined with $(D Redirect.stdout). */ stdoutToStderr = 16, } unittest { version (Windows) TestScript prog = "call :sub %~1 %~2 0 call :sub %~1 %~2 1 call :sub %~1 %~2 2 call :sub %~1 %~2 3 exit 3 :sub set /p INPUT= if -%INPUT%-==-stop- ( exit %~3 ) echo %INPUT% %~1 echo %INPUT% %~2 1>&2"; else version (Posix) TestScript prog = `for EXITCODE in 0 1 2 3; do read INPUT if test "$INPUT" = stop; then break; fi echo "$INPUT $1" echo "$INPUT $2" >&2 done exit $EXITCODE`; auto pp = pipeProcess([prog.path, "bar", "baz"]); pp.stdin.writeln("foo"); pp.stdin.flush(); assert (pp.stdout.readln().chomp() == "foo bar"); assert (pp.stderr.readln().chomp().stripRight() == "foo baz"); pp.stdin.writeln("1234567890"); pp.stdin.flush(); assert (pp.stdout.readln().chomp() == "1234567890 bar"); assert (pp.stderr.readln().chomp().stripRight() == "1234567890 baz"); pp.stdin.writeln("stop"); pp.stdin.flush(); assert (wait(pp.pid) == 2); pp = pipeProcess([prog.path, "12345", "67890"], Redirect.stdin | Redirect.stdout | Redirect.stderrToStdout); pp.stdin.writeln("xyz"); pp.stdin.flush(); assert (pp.stdout.readln().chomp() == "xyz 12345"); assert (pp.stdout.readln().chomp().stripRight() == "xyz 67890"); pp.stdin.writeln("stop"); pp.stdin.flush(); assert (wait(pp.pid) == 1); pp = pipeShell(escapeShellCommand(prog.path, "AAAAA", "BBB"), Redirect.stdin | Redirect.stdoutToStderr | Redirect.stderr); pp.stdin.writeln("ab"); pp.stdin.flush(); assert (pp.stderr.readln().chomp() == "ab AAAAA"); assert (pp.stderr.readln().chomp().stripRight() == "ab BBB"); pp.stdin.writeln("stop"); pp.stdin.flush(); assert (wait(pp.pid) == 1); } unittest { TestScript prog = "exit 0"; assertThrown!StdioException(pipeProcess( prog.path, Redirect.stdout | Redirect.stdoutToStderr)); assertThrown!StdioException(pipeProcess( prog.path, Redirect.stderr | Redirect.stderrToStdout)); auto p = pipeProcess(prog.path, Redirect.stdin); assertThrown!Error(p.stdout); assertThrown!Error(p.stderr); wait(p.pid); p = pipeProcess(prog.path, Redirect.stderr); assertThrown!Error(p.stdin); assertThrown!Error(p.stdout); wait(p.pid); } /** Object which contains $(XREF stdio,File) handles that allow communication with a child process through its standard streams. */ struct ProcessPipes { /// The $(LREF Pid) of the child process. @property Pid pid() @safe nothrow { assert(_pid !is null); return _pid; } /** An $(XREF stdio,File) that allows writing to the child process' standard input stream. Throws: $(OBJECTREF Error) if the child process' standard input stream hasn't been redirected. */ @property File stdin() @trusted //TODO: @safe nothrow { if ((_redirectFlags & Redirect.stdin) == 0) throw new Error("Child process' standard input stream hasn't " ~"been redirected."); return _stdin; } /** An $(XREF stdio,File) that allows reading from the child process' standard output stream. Throws: $(OBJECTREF Error) if the child process' standard output stream hasn't been redirected. */ @property File stdout() @trusted //TODO: @safe nothrow { if ((_redirectFlags & Redirect.stdout) == 0) throw new Error("Child process' standard output stream hasn't " ~"been redirected."); return _stdout; } /** An $(XREF stdio,File) that allows reading from the child process' standard error stream. Throws: $(OBJECTREF Error) if the child process' standard error stream hasn't been redirected. */ @property File stderr() @trusted //TODO: @safe nothrow { if ((_redirectFlags & Redirect.stderr) == 0) throw new Error("Child process' standard error stream hasn't " ~"been redirected."); return _stderr; } private: Redirect _redirectFlags; Pid _pid; File _stdin, _stdout, _stderr; } /** Executes the given program or shell command and returns its exit code and output. $(D execute) and $(D executeShell) start a new process using $(LREF spawnProcess) and $(LREF spawnShell), respectively, and wait for the process to complete before returning. The functions capture what the child process prints to both its standard output and standard error streams, and return this together with its exit code. --- auto dmd = execute(["dmd", "myapp.d"]); if (dmd.status != 0) writeln("Compilation failed:\n", dmd.output); auto ls = executeShell("ls -l"); if (ls.status != 0) writeln("Failed to retrieve file listing"); else writeln(ls.output); --- The $(D args)/$(D program)/$(D command), $(D env) and $(D config) parameters are forwarded straight to the underlying spawn functions, and we refer to their documentation for details. Params: args = An array which contains the program name as the zeroth element and any command-line arguments in the following elements. (See $(LREF spawnProcess) for details.) program = The program name, $(I without) command-line arguments. (See $(LREF spawnProcess) for details.) command = A shell command which is passed verbatim to the command interpreter. (See $(LREF spawnShell) for details.) env = Additional environment variables for the child process. (See $(LREF spawnProcess) for details.) config = Flags that control process creation. See $(LREF Config) for an overview of available flags, and note that the $(D retainStd...) flags have no effect in this function. maxOutput = The maximum number of bytes of output that should be captured. workDir = The working directory for the new process. By default the child process inherits the parent's working directory. Returns: An $(D std.typecons.Tuple!(int, "status", string, "output")). POSIX_specific: If the process is terminated by a signal, the $(D status) field of the return value will contain a negative number whose absolute value is the signal number. (See $(LREF wait) for details.) Throws: $(LREF ProcessException) on failure to start the process.$(BR) $(XREF stdio,StdioException) on failure to capture output. */ auto execute(in char[][] args, const string[string] env = null, Config config = Config.none, size_t maxOutput = size_t.max, in char[] workDir = null) @trusted //TODO: @safe { return executeImpl!pipeProcess(args, env, config, maxOutput, workDir); } /// ditto auto execute(in char[] program, const string[string] env = null, Config config = Config.none, size_t maxOutput = size_t.max, in char[] workDir = null) @trusted //TODO: @safe { return executeImpl!pipeProcess(program, env, config, maxOutput, workDir); } /// ditto auto executeShell(in char[] command, const string[string] env = null, Config config = Config.none, size_t maxOutput = size_t.max, in char[] workDir = null) @trusted //TODO: @safe { return executeImpl!pipeShell(command, env, config, maxOutput, workDir); } // Does the actual work for execute() and executeShell(). private auto executeImpl(alias pipeFunc, Cmd)( Cmd commandLine, const string[string] env = null, Config config = Config.none, size_t maxOutput = size_t.max, in char[] workDir = null) { import std.typecons : Tuple; auto p = pipeFunc(commandLine, Redirect.stdout | Redirect.stderrToStdout, env, config, workDir); auto a = appender!(ubyte[])(); enum size_t defaultChunkSize = 4096; immutable chunkSize = min(maxOutput, defaultChunkSize); // Store up to maxOutput bytes in a. foreach (ubyte[] chunk; p.stdout.byChunk(chunkSize)) { immutable size_t remain = maxOutput - a.data.length; if (chunk.length < remain) a.put(chunk); else { a.put(chunk[0 .. remain]); break; } } // Exhaust the stream, if necessary. foreach (ubyte[] chunk; p.stdout.byChunk(defaultChunkSize)) { } return Tuple!(int, "status", string, "output")(wait(p.pid), cast(string) a.data); } unittest { // To avoid printing the newline characters, we use the echo|set trick on // Windows, and printf on POSIX (neither echo -n nor echo \c are portable). version (Windows) TestScript prog = "echo|set /p=%~1 echo|set /p=%~2 1>&2 exit 123"; else version (Posix) TestScript prog = `printf '%s' $1 printf '%s' $2 >&2 exit 123`; auto r = execute([prog.path, "foo", "bar"]); assert (r.status == 123); assert (r.output.stripRight() == "foobar"); auto s = execute([prog.path, "Hello", "World"]); assert (s.status == 123); assert (s.output.stripRight() == "HelloWorld"); } unittest { auto r1 = executeShell("echo foo"); assert (r1.status == 0); assert (r1.output.chomp() == "foo"); auto r2 = executeShell("echo bar 1>&2"); assert (r2.status == 0); assert (r2.output.chomp().stripRight() == "bar"); auto r3 = executeShell("exit 123"); assert (r3.status == 123); assert (r3.output.empty); } unittest { import std.typecons : Tuple; void foo() //Just test the compilation { auto ret1 = execute(["dummy", "arg"]); auto ret2 = executeShell("dummy arg"); static assert(is(typeof(ret1) == typeof(ret2))); Tuple!(int, string) ret3 = execute(["dummy", "arg"]); } } /// An exception that signals a problem with starting or waiting for a process. class ProcessException : Exception { // Standard constructor. this(string msg, string file = __FILE__, size_t line = __LINE__) { super(msg, file, line); } // Creates a new ProcessException based on errno. static ProcessException newFromErrno(string customMsg = null, string file = __FILE__, size_t line = __LINE__) { import core.stdc.errno; import core.stdc.string; version (linux) { char[1024] buf; auto errnoMsg = to!string( core.stdc.string.strerror_r(errno, buf.ptr, buf.length)); } else { auto errnoMsg = to!string(core.stdc.string.strerror(errno)); } auto msg = customMsg.empty ? errnoMsg : customMsg ~ " (" ~ errnoMsg ~ ')'; return new ProcessException(msg, file, line); } // Creates a new ProcessException based on GetLastError() (Windows only). version (Windows) static ProcessException newFromLastError(string customMsg = null, string file = __FILE__, size_t line = __LINE__) { auto lastMsg = sysErrorString(GetLastError()); auto msg = customMsg.empty ? lastMsg : customMsg ~ " (" ~ lastMsg ~ ')'; return new ProcessException(msg, file, line); } } /** Determines the path to the current user's default command interpreter. On Windows, this function returns the contents of the COMSPEC environment variable, if it exists. Otherwise, it returns the string $(D "cmd.exe"). On POSIX, $(D userShell) returns the contents of the SHELL environment variable, if it exists and is non-empty. Otherwise, it returns $(D "/bin/sh"). */ @property string userShell() @safe //TODO: nothrow { version (Windows) return environment.get("COMSPEC", "cmd.exe"); else version (Posix) return environment.get("SHELL", "/bin/sh"); } // A command-line switch that indicates to the shell that it should // interpret the following argument as a command to be executed. version (Posix) private immutable string shellSwitch = "-c"; version (Windows) private immutable string shellSwitch = "/C"; /// Returns the process ID number of the current process. @property int thisProcessID() @trusted //TODO: @safe nothrow { version (Windows) return GetCurrentProcessId(); else version (Posix) return getpid(); } // Unittest support code: TestScript takes a string that contains a // shell script for the current platform, and writes it to a temporary // file. On Windows the file name gets a .cmd extension, while on // POSIX its executable permission bit is set. The file is // automatically deleted when the object goes out of scope. version (unittest) private struct TestScript { this(string code) { import std.ascii, std.file; version (Windows) { auto ext = ".cmd"; auto firstLine = "@echo off"; } else version (Posix) { auto ext = ""; version(Android) auto firstLine = "#!" ~ userShell; else auto firstLine = "#!/bin/sh"; } path = uniqueTempPath()~ext; std.file.write(path, firstLine~std.ascii.newline~code~std.ascii.newline); version (Posix) { import core.sys.posix.sys.stat; chmod(toStringz(path), octal!777); } } ~this() { import std.file; if (!path.empty && exists(path)) { try { remove(path); } catch (Exception e) { debug std.stdio.stderr.writeln(e.msg); } } } string path; } version (unittest) private string uniqueTempPath() { import std.file, std.uuid; // Path should contain spaces to test escaping whitespace return buildPath(tempDir(), "std.process temporary file " ~ randomUUID().toString()); } // ============================================================================= // Functions for shell command quoting/escaping. // ============================================================================= /* Command line arguments exist in three forms: 1) string or char* array, as received by main. Also used internally on POSIX systems. 2) Command line string, as used in Windows' CreateProcess and CommandLineToArgvW functions. A specific quoting and escaping algorithm is used to distinguish individual arguments. 3) Shell command string, as written at a shell prompt or passed to cmd /C - this one may contain shell control characters, e.g. > or | for redirection / piping - thus, yet another layer of escaping is used to distinguish them from program arguments. Except for escapeWindowsArgument, the intermediary format (2) is hidden away from the user in this module. */ /** Escapes an argv-style argument array to be used with $(LREF spawnShell), $(LREF pipeShell) or $(LREF executeShell). --- string url = "http://dlang.org/"; executeShell(escapeShellCommand("wget", url, "-O", "dlang-index.html")); --- Concatenate multiple $(D escapeShellCommand) and $(LREF escapeShellFileName) results to use shell redirection or piping operators. --- executeShell( escapeShellCommand("curl", "http://dlang.org/download.html") ~ "|" ~ escapeShellCommand("grep", "-o", `http://\S*\.zip`) ~ ">" ~ escapeShellFileName("D download links.txt")); --- Throws: $(OBJECTREF Exception) if any part of the command line contains unescapable characters (NUL on all platforms, as well as CR and LF on Windows). */ string escapeShellCommand(in char[][] args...) //TODO: @safe pure nothrow { if (args.empty) return null; version (Windows) { // Do not ^-escape the first argument (the program path), // as the shell parses it differently from parameters. // ^-escaping a program path that contains spaces will fail. string result = escapeShellFileName(args[0]); if (args.length > 1) { result ~= " " ~ escapeShellCommandString( escapeShellArguments(args[1..$])); } return result; } version (Posix) { return escapeShellCommandString(escapeShellArguments(args)); } } unittest { // This is a simple unit test without any special requirements, // in addition to the unittest_burnin one below which requires // special preparation. struct TestVector { string[] args; string windows, posix; } TestVector[] tests = [ { args : ["foo bar"], windows : `"foo bar"`, posix : `'foo bar'` }, { args : ["foo bar", "hello"], windows : `"foo bar" ^"hello^"`, posix : `'foo bar' 'hello'` }, { args : ["foo bar", "hello world"], windows : `"foo bar" ^"hello world^"`, posix : `'foo bar' 'hello world'` }, { args : ["foo bar", "hello", "world"], windows : `"foo bar" ^"hello^" ^"world^"`, posix : `'foo bar' 'hello' 'world'` }, { args : ["foo bar", `'"^\`], windows : `"foo bar" ^"'\^"^^\\^"`, posix : `'foo bar' ''\''"^\'` }, ]; foreach (test; tests) version (Windows) assert(escapeShellCommand(test.args) == test.windows); else assert(escapeShellCommand(test.args) == test.posix ); } private string escapeShellCommandString(string command) //TODO: @safe pure nothrow { version (Windows) return escapeWindowsShellCommand(command); else return command; } private string escapeWindowsShellCommand(in char[] command) //TODO: @safe pure nothrow (prevented by Appender) { auto result = appender!string(); result.reserve(command.length); foreach (c; command) switch (c) { case '\0': throw new Exception("Cannot put NUL in command line"); case '\r': case '\n': throw new Exception("CR/LF are not escapable"); case '\x01': .. case '\x09': case '\x0B': .. case '\x0C': case '\x0E': .. case '\x1F': case '"': case '^': case '&': case '<': case '>': case '|': result.put('^'); goto default; default: result.put(c); } return result.data; } private string escapeShellArguments(in char[][] args...) @trusted pure nothrow { char[] buf; @safe nothrow char[] allocator(size_t size) { if (buf.length == 0) return buf = new char[size]; else { auto p = buf.length; buf.length = buf.length + 1 + size; buf[p++] = ' '; return buf[p..p+size]; } } foreach (arg; args) escapeShellArgument!allocator(arg); return assumeUnique(buf); } private auto escapeShellArgument(alias allocator)(in char[] arg) @safe nothrow { // The unittest for this function requires special // preparation - see below. version (Windows) return escapeWindowsArgumentImpl!allocator(arg); else return escapePosixArgumentImpl!allocator(arg); } /** Quotes a command-line argument in a manner conforming to the behavior of $(LINK2 http://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx, CommandLineToArgvW). */ string escapeWindowsArgument(in char[] arg) @trusted pure nothrow { // Rationale for leaving this function as public: // this algorithm of escaping paths is also used in other software, // e.g. DMD's response files. auto buf = escapeWindowsArgumentImpl!charAllocator(arg); return assumeUnique(buf); } private char[] charAllocator(size_t size) @safe pure nothrow { return new char[size]; } private char[] escapeWindowsArgumentImpl(alias allocator)(in char[] arg) @safe nothrow if (is(typeof(allocator(size_t.init)[0] = char.init))) { // References: // * http://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx // * http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx // Calculate the total string size. // Trailing backslashes must be escaped bool escaping = true; // Result size = input size + 2 for surrounding quotes + 1 for the // backslash for each escaped character. size_t size = 1 + arg.length + 1; foreach_reverse (char c; arg) { if (c == '"') { escaping = true; size++; } else if (c == '\\') { if (escaping) size++; } else escaping = false; } // Construct result string. auto buf = allocator(size); size_t p = size; buf[--p] = '"'; escaping = true; foreach_reverse (char c; arg) { if (c == '"') escaping = true; else if (c != '\\') escaping = false; buf[--p] = c; if (escaping) buf[--p] = '\\'; } buf[--p] = '"'; assert(p == 0); return buf; } version(Windows) version(unittest) { import core.sys.windows.windows; import core.stdc.stddef; extern (Windows) wchar_t** CommandLineToArgvW(wchar_t*, int*); extern (C) size_t wcslen(in wchar *); string[] parseCommandLine(string line) { LPWSTR lpCommandLine = (to!(wchar[])(line) ~ "\0"w).ptr; int numArgs; LPWSTR* args = CommandLineToArgvW(lpCommandLine, &numArgs); scope(exit) LocalFree(args); return args[0..numArgs] .map!(arg => to!string(arg[0..wcslen(arg)])) .array(); } unittest { string[] testStrings = [ `Hello`, `Hello, world`, `Hello, "world"`, `C:\`, `C:\dmd`, `C:\Program Files\`, ]; enum CHARS = `_x\" *&^`; // _ is placeholder for nothing foreach (c1; CHARS) foreach (c2; CHARS) foreach (c3; CHARS) foreach (c4; CHARS) testStrings ~= [c1, c2, c3, c4].replace("_", ""); foreach (s; testStrings) { auto q = escapeWindowsArgument(s); auto args = parseCommandLine("Dummy.exe " ~ q); assert(args.length==2, s ~ " => " ~ q ~ " #" ~ text(args.length-1)); assert(args[1] == s, s ~ " => " ~ q ~ " => " ~ args[1]); } } } private string escapePosixArgument(in char[] arg) @trusted pure nothrow { auto buf = escapePosixArgumentImpl!charAllocator(arg); return assumeUnique(buf); } private char[] escapePosixArgumentImpl(alias allocator)(in char[] arg) @safe nothrow if (is(typeof(allocator(size_t.init)[0] = char.init))) { // '\'' means: close quoted part of argument, append an escaped // single quote, and reopen quotes // Below code is equivalent to: // return `'` ~ std.array.replace(arg, `'`, `'\''`) ~ `'`; size_t size = 1 + arg.length + 1; foreach (char c; arg) if (c == '\'') size += 3; auto buf = allocator(size); size_t p = 0; buf[p++] = '\''; foreach (char c; arg) if (c == '\'') { buf[p..p+4] = `'\''`; p += 4; } else buf[p++] = c; buf[p++] = '\''; assert(p == size); return buf; } /** Escapes a filename to be used for shell redirection with $(LREF spawnShell), $(LREF pipeShell) or $(LREF executeShell). */ string escapeShellFileName(in char[] fileName) @trusted pure nothrow { // The unittest for this function requires special // preparation - see below. version (Windows) return cast(string)('"' ~ fileName ~ '"'); else return escapePosixArgument(fileName); } // Loop generating strings with random characters //version = unittest_burnin; version(unittest_burnin) unittest { // There are no readily-available commands on all platforms suitable // for properly testing command escaping. The behavior of CMD's "echo" // built-in differs from the POSIX program, and Windows ports of POSIX // environments (Cygwin, msys, gnuwin32) may interfere with their own // "echo" ports. // To run this unit test, create std_process_unittest_helper.d with the // following content and compile it: // import std.stdio, std.array; void main(string[] args) { write(args.join("\0")); } // Then, test this module with: // rdmd --main -unittest -version=unittest_burnin process.d auto helper = absolutePath("std_process_unittest_helper"); assert(shell(helper ~ " hello").split("\0")[1..$] == ["hello"], "Helper malfunction"); void test(string[] s, string fn) { string e; string[] g; e = escapeShellCommand(helper ~ s); { scope(failure) writefln("shell() failed.\nExpected:\t%s\nEncoded:\t%s", s, [e]); g = shell(e).split("\0")[1..$]; } assert(s == g, format("shell() test failed.\nExpected:\t%s\nGot:\t\t%s\nEncoded:\t%s", s, g, [e])); e = escapeShellCommand(helper ~ s) ~ ">" ~ escapeShellFileName(fn); { scope(failure) writefln("system() failed.\nExpected:\t%s\nFilename:\t%s\nEncoded:\t%s", s, [fn], [e]); system(e); g = readText(fn).split("\0")[1..$]; } remove(fn); assert(s == g, format("system() test failed.\nExpected:\t%s\nGot:\t\t%s\nEncoded:\t%s", s, g, [e])); } while (true) { string[] args; foreach (n; 0..uniform(1, 4)) { string arg; foreach (l; 0..uniform(0, 10)) { dchar c; while (true) { version (Windows) { // As long as DMD's system() uses CreateProcessA, // we can't reliably pass Unicode c = uniform(0, 128); } else c = uniform!ubyte(); if (c == 0) continue; // argv-strings are zero-terminated version (Windows) if (c == '\r' || c == '\n') continue; // newlines are unescapable on Windows break; } arg ~= c; } args ~= arg; } // generate filename string fn = "test_"; foreach (l; 0..uniform(1, 10)) { dchar c; while (true) { version (Windows) c = uniform(0, 128); // as above else c = uniform!ubyte(); if (c == 0 || c == '/') continue; // NUL and / are the only characters // forbidden in POSIX filenames version (Windows) if (c < '\x20' || c == '<' || c == '>' || c == ':' || c == '"' || c == '\\' || c == '|' || c == '?' || c == '*') continue; // http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx break; } fn ~= c; } test(args, fn); } } // ============================================================================= // Environment variable manipulation. // ============================================================================= /** Manipulates _environment variables using an associative-array-like interface. This class contains only static methods, and cannot be instantiated. See below for examples of use. */ abstract final class environment { static: /** Retrieves the value of the environment variable with the given $(D name). --- auto path = environment["PATH"]; --- Throws: $(OBJECTREF Exception) if the environment variable does not exist. See_also: $(LREF environment.get), which doesn't throw on failure. */ string opIndex(in char[] name) @safe { string value; enforce(getImpl(name, value), "Environment variable not found: "~name); return value; } /** Retrieves the value of the environment variable with the given $(D name), or a default value if the variable doesn't exist. Unlike $(LREF environment.opIndex), this function never throws. --- auto sh = environment.get("SHELL", "/bin/sh"); --- This function is also useful in checking for the existence of an environment variable. --- auto myVar = environment.get("MYVAR"); if (myVar is null) { // Environment variable doesn't exist. // Note that we have to use 'is' for the comparison, since // myVar == null is also true if the variable exists but is // empty. } --- */ string get(in char[] name, string defaultValue = null) @safe //TODO: nothrow { string value; auto found = getImpl(name, value); return found ? value : defaultValue; } /** Assigns the given $(D value) to the environment variable with the given $(D name). If the variable does not exist, it will be created. If it already exists, it will be overwritten. --- environment["foo"] = "bar"; --- Throws: $(OBJECTREF Exception) if the environment variable could not be added (e.g. if the name is invalid). */ inout(char)[] opIndexAssign(inout char[] value, in char[] name) @trusted { version (Posix) { if (core.sys.posix.stdlib.setenv(toStringz(name), toStringz(value), 1) != -1) { return value; } // The default errno error message is very uninformative // in the most common case, so we handle it manually. enforce(errno != EINVAL, "Invalid environment variable name: '"~name~"'"); errnoEnforce(false, "Failed to add environment variable"); assert(0); } else version (Windows) { enforce( SetEnvironmentVariableW(toUTF16z(name), toUTF16z(value)), sysErrorString(GetLastError()) ); return value; } else static assert(0); } /** Removes the environment variable with the given $(D name). If the variable isn't in the environment, this function returns successfully without doing anything. */ void remove(in char[] name) @trusted // TODO: @safe nothrow { version (Windows) SetEnvironmentVariableW(toUTF16z(name), null); else version (Posix) core.sys.posix.stdlib.unsetenv(toStringz(name)); else static assert(0); } /** Copies all environment variables into an associative array. Windows_specific: While Windows environment variable names are case insensitive, D's built-in associative arrays are not. This function will store all variable names in uppercase (e.g. $(D PATH)). Throws: $(OBJECTREF Exception) if the environment variables could not be retrieved (Windows only). */ string[string] toAA() @trusted { string[string] aa; version (Posix) { for (int i=0; environ[i] != null; ++i) { immutable varDef = to!string(environ[i]); immutable eq = std.string.indexOf(varDef, '='); assert (eq >= 0); immutable name = varDef[0 .. eq]; immutable value = varDef[eq+1 .. $]; // In POSIX, environment variables may be defined more // than once. This is a security issue, which we avoid // by checking whether the key already exists in the array. // For more info: // http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/environment-variables.html if (name !in aa) aa[name] = value; } } else version (Windows) { auto envBlock = GetEnvironmentStringsW(); enforce(envBlock, "Failed to retrieve environment variables."); scope(exit) FreeEnvironmentStringsW(envBlock); for (int i=0; envBlock[i] != '\0'; ++i) { auto start = i; while (envBlock[i] != '=') ++i; immutable name = toUTF8(toUpper(envBlock[start .. i])); start = i+1; while (envBlock[i] != '\0') ++i; // Just like in POSIX systems, environment variables may be // defined more than once in an environment block on Windows, // and it is just as much of a security issue there. Moreso, // in fact, due to the case insensensitivity of variable names, // which is not handled correctly by all programs. if (name !in aa) aa[name] = toUTF8(envBlock[start .. i]); } } else static assert(0); return aa; } private: // Returns the length of an environment variable (in number of // wchars, including the null terminator), or 0 if it doesn't exist. version (Windows) int varLength(LPCWSTR namez) @trusted nothrow { return GetEnvironmentVariableW(namez, null, 0); } // Retrieves the environment variable, returns false on failure. bool getImpl(in char[] name, out string value) @trusted //TODO: nothrow { version (Windows) { const namez = toUTF16z(name); immutable len = varLength(namez); if (len == 0) return false; if (len == 1) { value = ""; return true; } auto buf = new WCHAR[len]; GetEnvironmentVariableW(namez, buf.ptr, to!DWORD(buf.length)); value = toUTF8(buf[0 .. $-1]); return true; } else version (Posix) { const vz = core.sys.posix.stdlib.getenv(toStringz(name)); if (vz == null) return false; auto v = vz[0 .. strlen(vz)]; // Cache the last call's result. static string lastResult; if (v != lastResult) lastResult = v.idup; value = lastResult; return true; } else static assert(0); } } unittest { // New variable environment["std_process"] = "foo"; assert (environment["std_process"] == "foo"); // Set variable again environment["std_process"] = "bar"; assert (environment["std_process"] == "bar"); // Remove variable environment.remove("std_process"); // Remove again, should succeed environment.remove("std_process"); // Throw on not found. assertThrown(environment["std_process"]); // get() without default value assert (environment.get("std_process") == null); // get() with default value assert (environment.get("std_process", "baz") == "baz"); // Convert to associative array auto aa = environment.toAA(); assert (aa.length > 0); foreach (n, v; aa) { // Wine has some bugs related to environment variables: // - Wine allows the existence of an env. variable with the name // "\0", but GetEnvironmentVariable refuses to retrieve it. // - If an env. variable has zero length, i.e. is "\0", // GetEnvironmentVariable should return 1. Instead it returns // 0, indicating the variable doesn't exist. version (Windows) if (n.length == 0 || v.length == 0) continue; assert (v == environment[n]); } } // ============================================================================= // Everything below this line was part of the old std.process, and most of // it will be deprecated and removed. // ============================================================================= /* Macros: WIKI=Phobos/StdProcess Copyright: Copyright Digital Mars 2007 - 2009. License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. Authors: $(WEB digitalmars.com, Walter Bright), $(WEB erdani.org, Andrei Alexandrescu), $(WEB thecybershadow.net, Vladimir Panteleev) Source: $(PHOBOSSRC std/_process.d) */ /* Copyright Digital Mars 2007 - 2009. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ import core.stdc.stdlib; import std.c.stdlib; import core.stdc.errno; import core.thread; import std.c.process; import core.stdc.string; version (Windows) { import std.format, std.random, std.file; } version (Posix) { import core.sys.posix.stdlib; } version (unittest) { import std.file, std.conv, std.random; } /** Execute $(D command) in a _command shell. $(RED This function is scheduled for deprecation. Please use $(LREF spawnShell) or $(LREF executeShell) instead.) Returns: If $(D command) is null, returns nonzero if the _command interpreter is found, and zero otherwise. If $(D command) is not null, returns -1 on error, or the exit status of command (which may in turn signal an error in command's execution). Note: On Unix systems, the homonym C function (which is accessible to D programs as $(LINK2 std_c_process.html, std.c._system)) returns a code in the same format as $(LUCKY waitpid, waitpid), meaning that C programs must use the $(D WEXITSTATUS) macro to extract the actual exit code from the $(D system) call. D's $(D system) automatically extracts the exit status. */ int system(string command) { if (!command.ptr) return std.c.process.system(null); const commandz = toStringz(command); immutable status = std.c.process.system(commandz); if (status == -1) return status; version (Posix) { if (exited(status)) return exitstatus(status); // Abnormal termination, return -1. return -1; } else version (Windows) return status; else static assert(0, "system not implemented for this OS."); } private void toAStringz(in string[] a, const(char)**az) { foreach(string s; a) { *az++ = toStringz(s); } *az = null; } /* ========================================================== */ //version (Windows) //{ // int spawnvp(int mode, string pathname, string[] argv) // { // char** argv_ = cast(char**)alloca((char*).sizeof * (1 + argv.length)); // // toAStringz(argv, argv_); // // return std.c.process.spawnvp(mode, toStringz(pathname), argv_); // } //} // Incorporating idea (for spawnvp() on Posix) from Dave Fladebo alias P_WAIT = std.c.process._P_WAIT; alias P_NOWAIT = std.c.process._P_NOWAIT; int spawnvp(int mode, string pathname, string[] argv) { auto argv_ = cast(const(char)**)alloca((char*).sizeof * (1 + argv.length)); toAStringz(argv, argv_); version (Posix) { return _spawnvp(mode, toStringz(pathname), argv_); } else version (Windows) { return std.c.process.spawnvp(mode, toStringz(pathname), argv_); } else static assert(0, "spawnvp not implemented for this OS."); } version (Posix) { private import core.sys.posix.unistd; private import core.sys.posix.sys.wait; int _spawnvp(int mode, in char *pathname, in char **argv) { int retval = 0; pid_t pid = fork(); if(!pid) { // child std.c.process.execvp(pathname, argv); goto Lerror; } else if(pid > 0) { // parent if(mode == _P_NOWAIT) { retval = pid; // caller waits } else { while(1) { int status; pid_t wpid = waitpid(pid, &status, 0); if(exited(status)) { retval = exitstatus(status); break; } else if(signaled(status)) { retval = -termsig(status); break; } else if(stopped(status)) // ptrace support continue; else goto Lerror; } } return retval; } Lerror: retval = errno; char[80] buf = void; throw new Exception( "Cannot spawn " ~ to!string(pathname) ~ "; " ~ to!string(strerror_r(retval, buf.ptr, buf.length)) ~ " [errno " ~ to!string(retval) ~ "]"); } // _spawnvp private { alias stopped = WIFSTOPPED; alias signaled = WIFSIGNALED; alias termsig = WTERMSIG; alias exited = WIFEXITED; alias exitstatus = WEXITSTATUS; } // private } // version (Posix) /* ========================================================== */ /** * Replace the current process by executing a command, $(D pathname), with * the arguments in $(D argv). * * $(RED These functions are scheduled for deprecation. Please use * $(LREF spawnShell) instead (or, alternatively, the homonymous C * functions declared in $(D std.c.process).)) * * Typically, the first element of $(D argv) is * the command being executed, i.e. $(D argv[0] == pathname). The 'p' * versions of $(D exec) search the PATH environment variable for $(D * pathname). The 'e' versions additionally take the new process' * environment variables as an array of strings of the form key=value. * * Does not return on success (the current process will have been * replaced). Returns -1 on failure with no indication of the * underlying error. */ int execv(in string pathname, in string[] argv) { auto argv_ = cast(const(char)**)alloca((char*).sizeof * (1 + argv.length)); toAStringz(argv, argv_); return std.c.process.execv(toStringz(pathname), argv_); } /** ditto */ int execve(in string pathname, in string[] argv, in string[] envp) { auto argv_ = cast(const(char)**)alloca((char*).sizeof * (1 + argv.length)); auto envp_ = cast(const(char)**)alloca((char*).sizeof * (1 + envp.length)); toAStringz(argv, argv_); toAStringz(envp, envp_); return std.c.process.execve(toStringz(pathname), argv_, envp_); } /** ditto */ int execvp(in string pathname, in string[] argv) { auto argv_ = cast(const(char)**)alloca((char*).sizeof * (1 + argv.length)); toAStringz(argv, argv_); return std.c.process.execvp(toStringz(pathname), argv_); } /** ditto */ int execvpe(in string pathname, in string[] argv, in string[] envp) { version(Posix) { // Is pathname rooted? if(pathname[0] == '/') { // Yes, so just call execve() return execve(pathname, argv, envp); } else { // No, so must traverse PATHs, looking for first match string[] envPaths = std.array.split( to!string(core.stdc.stdlib.getenv("PATH")), ":"); int iRet = 0; // Note: if any call to execve() succeeds, this process will cease // execution, so there's no need to check the execve() result through // the loop. foreach(string pathDir; envPaths) { string composite = cast(string) (pathDir ~ "/" ~ pathname); iRet = execve(composite, argv, envp); } if(0 != iRet) { iRet = execve(pathname, argv, envp); } return iRet; } } else version(Windows) { auto argv_ = cast(const(char)**)alloca((char*).sizeof * (1 + argv.length)); auto envp_ = cast(const(char)**)alloca((char*).sizeof * (1 + envp.length)); toAStringz(argv, argv_); toAStringz(envp, envp_); return std.c.process.execvpe(toStringz(pathname), argv_, envp_); } else { static assert(0); } // version } /** * Returns the process ID of the calling process, which is guaranteed to be * unique on the system. This call is always successful. * * $(RED This function is scheduled for deprecation. Please use * $(LREF thisProcessID) instead.) * * Example: * --- * writefln("Current process id: %s", getpid()); * --- */ alias getpid = core.thread.getpid; /** Runs $(D_PARAM cmd) in a shell and returns its standard output. If the process could not be started or exits with an error code, throws ErrnoException. $(RED This function is scheduled for deprecation. Please use $(LREF executeShell) instead.) Example: ---- auto tempFilename = chomp(shell("mcookie")); auto f = enforce(fopen(tempFilename), "w"); scope(exit) { fclose(f) == 0 || assert(false); system(escapeShellCommand("rm", tempFilename)); } ... use f ... ---- */ string shell(string cmd) { version(Windows) { // Generate a random filename auto a = appender!string(); foreach (ref e; 0 .. 8) { formattedWrite(a, "%x", rndGen.front); rndGen.popFront(); } auto filename = a.data; scope(exit) if (exists(filename)) remove(filename); // We can't use escapeShellCommands here because we don't know // if cmd is escaped (wrapped in quotes) or not, without relying // on shady heuristics. The current code shouldn't cause much // trouble unless filename contained spaces (it won't). errnoEnforce(system(cmd ~ "> " ~ filename) == 0); return readText(filename); } else version(Posix) { File f; f.popen(cmd, "r"); char[] line; string result; while (f.readln(line)) { result ~= line; } f.close(); return result; } else static assert(0, "shell not implemented for this OS."); } unittest { auto x = shell("echo wyda"); // @@@ This fails on wine //assert(x == "wyda" ~ newline, text(x.length)); import std.exception; // Issue 9444 version(windows) string cmd = "98c10ec7e253a11cdff45f807b984a81 2>NUL"; else string cmd = "98c10ec7e253a11cdff45f807b984a81 2>/dev/null"; assertThrown!ErrnoException(shell(cmd)); } /** Gets the value of environment variable $(D name) as a string. Calls $(LINK2 std_c_stdlib.html#_getenv, std.c.stdlib._getenv) internally. $(RED This function is scheduled for deprecation. Please use $(LREF environment.get) instead.) */ string getenv(in char[] name) { // Cache the last call's result static string lastResult; auto p = core.stdc.stdlib.getenv(toStringz(name)); if (!p) return null; auto value = p[0 .. strlen(p)]; if (value == lastResult) return lastResult; return lastResult = value.idup; } /** Sets the value of environment variable $(D name) to $(D value). If the value was written, or the variable was already present and $(D overwrite) is false, returns normally. Otherwise, it throws an exception. Calls $(LINK2 std_c_stdlib.html#_setenv, std.c.stdlib._setenv) internally. $(RED This function is scheduled for deprecation. Please use $(LREF environment.opIndexAssign) instead.) */ version(StdDdoc) void setenv(in char[] name, in char[] value, bool overwrite); else version(Posix) void setenv(in char[] name, in char[] value, bool overwrite) { errnoEnforce( std.c.stdlib.setenv(toStringz(name), toStringz(value), overwrite) == 0); } /** Removes variable $(D name) from the environment. Calls $(LINK2 std_c_stdlib.html#_unsetenv, std.c.stdlib._unsetenv) internally. $(RED This function is scheduled for deprecation. Please use $(LREF environment.remove) instead.) */ version(StdDdoc) void unsetenv(in char[] name); else version(Posix) void unsetenv(in char[] name) { errnoEnforce(std.c.stdlib.unsetenv(toStringz(name)) == 0); } version (Posix) unittest { setenv("wyda", "geeba", true); assert(getenv("wyda") == "geeba"); // Get again to make sure caching works assert(getenv("wyda") == "geeba"); unsetenv("wyda"); assert(getenv("wyda") is null); } /* ////////////////////////////////////////////////////////////////////////// */ version(MainTest) { int main(string[] args) { if(args.length < 2) { printf("Must supply executable (and optional arguments)\n"); return 1; } else { string[] dummy_env; dummy_env ~= "VAL0=value"; dummy_env ~= "VAL1=value"; /+ foreach(string arg; args) { printf("%.*s\n", arg); } +/ // int i = execv(args[1], args[1 .. args.length]); // int i = execvp(args[1], args[1 .. args.length]); int i = execvpe(args[1], args[1 .. args.length], dummy_env); printf("exec??() has returned! Error code: %d; errno: %d\n", i, /* errno */-1); return 0; } } } /* ////////////////////////////////////////////////////////////////////////// */ version(StdDdoc) { /**************************************** * Start up the browser and set it to viewing the page at url. */ void browse(string url); } else version (Windows) { import core.sys.windows.windows; pragma(lib,"shell32.lib"); void browse(string url) { ShellExecuteW(null, "open", toUTF16z(url), null, null, SW_SHOWNORMAL); } } else version (OSX) { import core.stdc.stdio; import core.stdc.string; import core.sys.posix.unistd; void browse(string url) { const(char)*[5] args; const(char)* browser = core.stdc.stdlib.getenv("BROWSER"); if (browser) { browser = strdup(browser); args[0] = browser; args[1] = toStringz(url); args[2] = null; } else { args[0] = "open".ptr; args[1] = toStringz(url); args[2] = null; } auto childpid = fork(); if (childpid == 0) { core.sys.posix.unistd.execvp(args[0], cast(char**)args.ptr); perror(args[0]); // failed to execute return; } if (browser) free(cast(void*)browser); } } else version (Posix) { import core.stdc.stdio; import core.stdc.string; import core.sys.posix.unistd; void browse(string url) { const(char)*[3] args; const(char)* browser = core.stdc.stdlib.getenv("BROWSER"); if (browser) { browser = strdup(browser); args[0] = browser; } else //args[0] = "x-www-browser".ptr; // doesn't work on some systems args[0] = "xdg-open".ptr; args[1] = toStringz(url); args[2] = null; auto childpid = fork(); if (childpid == 0) { core.sys.posix.unistd.execvp(args[0], cast(char**)args.ptr); perror(args[0]); // failed to execute return; } if (browser) free(cast(void*)browser); } } else static assert(0, "os not supported");
D
a usually malignant tumor arising from connective tissue (bone or muscle etc.
D
module automem.test_utils; mixin template TestUtils() { version(unittest) { import unit_threaded; import test_allocator; @Setup void before() { } @Shutdown void after() { reset; } void reset() { Struct.numStructs = 0; Class.numClasses = 0; SharedStruct.numStructs = 0; NoGcStruct.numStructs = 0; } void _writelnUt(T...)(T args) { try { () @trusted { writelnUt(args); }(); } catch(Exception ex) { assert(false); } } private struct Struct { int i; static int numStructs = 0; this(int i) @safe nothrow { this.i = i; ++numStructs; _writelnUt("Struct ", &this, " normal ctor, i=", i, ", N=", numStructs); } this(this) @safe nothrow { ++numStructs; _writelnUt("Struct ", &this, " postBlit ctor, i=", i, ", N=", numStructs); } ~this() @safe nothrow const { --numStructs; _writelnUt("Struct ", &this, " dtor, i=", i, ", N=", numStructs); } int twice() @safe pure const nothrow { return i * 2; } } private struct SharedStruct { int i; static int numStructs = 0; this(int i) @safe nothrow shared { this.i = i; ++numStructs; try () @trusted { _writelnUt("Struct normal ctor ", &this, ", i=", i, ", N=", numStructs); }(); catch(Exception ex) {} } this(this) @safe nothrow shared { ++numStructs; try () @trusted { _writelnUt("Struct postBlit ctor ", &this, ", i=", i, ", N=", numStructs); }(); catch(Exception ex) {} } ~this() @safe nothrow shared { --numStructs; try () @trusted { _writelnUt("Struct dtor ", &this, ", i=", i, ", N=", numStructs); }(); catch(Exception ex) {} } int twice() @safe pure const nothrow shared { return i * 2; } } private class Class { int i; static int numClasses = 0; this(int i) @safe nothrow { this.i = i; ++numClasses; } ~this() @safe nothrow { --numClasses; } int twice() @safe pure const nothrow { return i * 2; } } private struct SafeAllocator { import std.experimental.allocator.mallocator: Mallocator; void[] allocate(this T)(size_t i) @trusted nothrow @nogc { return Mallocator.instance.allocate(i); } void deallocate(this T)(void[] bytes) @trusted nothrow @nogc { Mallocator.instance.deallocate(bytes); } } static struct NoGcStruct { int i; static int numStructs = 0; this(int i) @safe @nogc nothrow { this.i = i; ++numStructs; } this(this) @safe @nogc nothrow { ++numStructs; } ~this() @safe @nogc nothrow { --numStructs; } } } }
D
import core.stdc.time : time_t; import vibe.core.core : runApplication; import vibe.http.server; import vibe.stream.operations : readAllUTF8; import asdf; struct Request { @serializationScoped { @serializationFlexible string id; string first_name, last_name; } } string date(string format, time_t time) { import core.stdc.time : strftime, localtime; import std.string : toStringz; char[256] buf; auto size = strftime(buf.ptr, buf.sizeof, format.toStringz(), localtime(&time)); return buf[0..size].idup; } void handler(scope HTTPServerRequest req, scope HTTPServerResponse res) { import std.digest.md; import std.datetime.systime; import std.format : format; auto data = req.bodyReader .readAllUTF8() .deserialize!Request; res.headers.addField("Content-Type", "application/json"); res.writeBody(`{"id":%s,"first_name":"%s","last_name":"%s","current_time":"%s","say":"Dlang is the best"}` .format( data.id, "%s %s".format(data.first_name, data.first_name.md5Of.toHexString()), "%s %s".format(data.last_name, data.last_name.md5Of.toHexString()), date("%F %T %z", Clock.currTime.toUnixTime()) ) ); } void main() { listenHTTP("0.0.0.0:8080", &handler); runApplication(); }
D
module org.serviio.upnp.protocol.soap.OperationResult; import java.lang.String; import java.util.LinkedHashMap; import java.util.Map; import org.serviio.upnp.protocol.soap.InvocationError; public class OperationResult { private Map!(String, Object) outputParameters = new LinkedHashMap!(String, Object)(); private InvocationError error; public this() { } public this(InvocationError error) { this.error = error; } public void addOutputParameter(String name, Object value) { outputParameters.put(name, value); } public Map!(String, Object) getOutputParameters() { return outputParameters; } public InvocationError getError() { return error; } public void setError(InvocationError error) { this.error = error; } } /* Location: D:\Program Files\Serviio\lib\serviio.jar * Qualified Name: org.serviio.upnp.protocol.soap.OperationResult * JD-Core Version: 0.6.2 */
D
/Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Strings.swift.o : /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/ifaddrs-android.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/CNIODarwin.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/CNIOLinux.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Strings~partial.swiftmodule : /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/ifaddrs-android.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/CNIODarwin.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/CNIOLinux.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Strings~partial.swiftdoc : /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/godemodegame/Desktop/ATMApp/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/ifaddrs-android.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/CNIODarwin.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/CNIOAtomics.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/CNIOLinux.h /Users/godemodegame/Desktop/ATMApp/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/godemodegame/Desktop/ATMApp/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
D
/** * Authors: The D DBI project * * Version: 0.2.5 * * Copyright: BSD license */ module dbi.msql.MsqlDatabase; private import dbi.DataBase, dbi.DBIException, dbi.Result, dbi.Row, dbi.Statement; private import dbi.msql.imp, dbi.msql.MsqlResult; /** * An implementation of БазаДанных for use with mSQL databases. * * Bugs: * БазаДанных-specific ошибка codes are not converted to КодОшибки. * * See_Also: * БазаДанных is the interface that this provides an implementation of. */ class MsqlDatabase : БазаДанных { public: /** * Create a new instance of MsqlDatabase, but don't подключись. */ this () { } /** * Create a new instance of MsqlDatabase and подключись to a server. * * See_Also: * подключись */ this (ткст парамы, ткст имя_пользователя = пусто, ткст пароль = пусто) { this(); подключись(парамы, имя_пользователя, пароль); } /** * */ override проц подключись (ткст парамы, ткст имя_пользователя = пусто, ткст пароль = пусто) { } /** * Close the current подключение to the бд. */ override проц закрой () { } /** * Execute a SQL statement that returns no результаты. * * Params: * эскюэл = The SQL statement to выполни. */ override проц выполни (ткст эскюэл) { } /** * Query the бд. * * Params: * эскюэл = The SQL statement to выполни. * * Returns: * A Результат object with the queried information. */ override РезультатМЭсКюЭл запрос (ткст эскюэл) { return пусто; } /** * Get the ошибка code. * * Deprecated: * This functionality now есть in ИсклДБИ. This will be * removed in version 0.3.0. * * Returns: * The бд specific ошибка code. */ deprecated override цел дайКодОшибки () { return 0; } /** * Get the ошибка message. * * Deprecated: * This functionality now есть in ИсклДБИ. This will be * removed in version 0.3.0. * * Returns: * The бд specific ошибка message. */ deprecated override ткст дайСообОшибки () { return ""; } private: }
D
/** * Compiler implementation of the * $(LINK2 http://www.dlang.org, D programming language). * * Copyright: Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/dsymbol.d, _dsymbol.d) * Documentation: https://dlang.org/phobos/dmd_dsymbol.html * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/dsymbol.d */ module dmd.dsymbol; import core.stdc.stdarg; import core.stdc.stdio; import core.stdc.string; import core.stdc.stdlib; import dmd.aggregate; import dmd.aliasthis; import dmd.arraytypes; import dmd.attrib; import dmd.ast_node; import dmd.gluelayer; import dmd.dclass; import dmd.declaration; import dmd.denum; import dmd.dimport; import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbolsem; import dmd.dtemplate; import dmd.errors; import dmd.expression; import dmd.expressionsem; import dmd.func; import dmd.globals; import dmd.id; import dmd.identifier; import dmd.init; import dmd.lexer; import dmd.mtype; import dmd.nspace; import dmd.opover; import dmd.root.aav; import dmd.root.rmem; import dmd.root.rootobject; import dmd.root.speller; import dmd.statement; import dmd.tokens; import dmd.visitor; /*************************************** * Calls dg(Dsymbol *sym) for each Dsymbol. * If dg returns !=0, stops and returns that value else returns 0. * Params: * symbols = Dsymbols * dg = delegate to call for each Dsymbol * Returns: * last value returned by dg() */ int foreachDsymbol(Dsymbols* symbols, scope int delegate(Dsymbol) dg) { assert(dg); if (symbols) { /* Do not use foreach, as the size of the array may expand during iteration */ for (size_t i = 0; i < symbols.dim; ++i) { Dsymbol s = (*symbols)[i]; const result = dg(s); if (result) return result; } } return 0; } /*************************************** * Calls dg(Dsymbol *sym) for each Dsymbol. * Params: * symbols = Dsymbols * dg = delegate to call for each Dsymbol */ void foreachDsymbol(Dsymbols* symbols, scope void delegate(Dsymbol) dg) { assert(dg); if (symbols) { /* Do not use foreach, as the size of the array may expand during iteration */ for (size_t i = 0; i < symbols.dim; ++i) { Dsymbol s = (*symbols)[i]; dg(s); } } } struct Ungag { uint oldgag; extern (D) this(uint old) { this.oldgag = old; } extern (C++) ~this() { global.gag = oldgag; } } struct Prot { /// enum Kind : int { undefined, none, // no access private_, package_, protected_, public_, export_, } Kind kind; Package pkg; extern (D) this(Prot.Kind kind) pure nothrow @nogc @safe { this.kind = kind; } extern (C++): /** * Checks if `this` is superset of `other` restrictions. * For example, "protected" is more restrictive than "public". */ bool isMoreRestrictiveThan(const Prot other) const { return this.kind < other.kind; } /** * Checks if `this` is absolutely identical protection attribute to `other` */ bool opEquals(ref const Prot other) const { if (this.kind == other.kind) { if (this.kind == Prot.Kind.package_) return this.pkg == other.pkg; return true; } return false; } /** * Checks if parent defines different access restrictions than this one. * * Params: * parent = protection attribute for scope that hosts this one * * Returns: * 'true' if parent is already more restrictive than this one and thus * no differentiation is needed. */ bool isSubsetOf(ref const Prot parent) const { if (this.kind != parent.kind) return false; if (this.kind == Prot.Kind.package_) { if (!this.pkg) return true; if (!parent.pkg) return false; if (parent.pkg.isAncestorPackageOf(this.pkg)) return true; } return true; } } enum PASS : int { init, // initial state semantic, // semantic() started semanticdone, // semantic() done semantic2, // semantic2() started semantic2done, // semantic2() done semantic3, // semantic3() started semantic3done, // semantic3() done inline, // inline started inlinedone, // inline done obj, // toObjFile() run } // Search options enum : int { IgnoreNone = 0x00, // default IgnorePrivateImports = 0x01, // don't search private imports IgnoreErrors = 0x02, // don't give error messages IgnoreAmbiguous = 0x04, // return NULL if ambiguous SearchLocalsOnly = 0x08, // only look at locals (don't search imports) SearchImportsOnly = 0x10, // only look in imports SearchUnqualifiedModule = 0x20, // the module scope search is unqualified, // meaning don't search imports in that scope, // because qualified module searches search // their imports IgnoreSymbolVisibility = 0x80, // also find private and package protected symbols } extern (C++) alias Dsymbol_apply_ft_t = int function(Dsymbol, void*); /*********************************************************** */ extern (C++) class Dsymbol : ASTNode { Identifier ident; Dsymbol parent; /// C++ namespace this symbol belongs to CPPNamespaceDeclaration namespace; Symbol* csym; // symbol for code generator Symbol* isym; // import version of csym const(char)* comment; // documentation comment for this Dsymbol const Loc loc; // where defined Scope* _scope; // !=null means context to use for semantic() const(char)* prettystring; // cached value of toPrettyChars() bool errors; // this symbol failed to pass semantic() PASS semanticRun = PASS.init; DeprecatedDeclaration depdecl; // customized deprecation message UserAttributeDeclaration userAttribDecl; // user defined attributes // !=null means there's a ddoc unittest associated with this symbol // (only use this with ddoc) UnitTestDeclaration ddocUnittest; final extern (D) this() { //printf("Dsymbol::Dsymbol(%p)\n", this); loc = Loc(null, 0, 0); } final extern (D) this(Identifier ident) { //printf("Dsymbol::Dsymbol(%p, ident)\n", this); this.loc = Loc(null, 0, 0); this.ident = ident; } final extern (D) this(const ref Loc loc, Identifier ident) { //printf("Dsymbol::Dsymbol(%p, ident)\n", this); this.loc = loc; this.ident = ident; } static Dsymbol create(Identifier ident) { return new Dsymbol(ident); } override const(char)* toChars() { return ident ? ident.toChars() : "__anonymous"; } // helper to print fully qualified (template) arguments const(char)* toPrettyCharsHelper() { return toChars(); } final const(Loc) getLoc() { if (!loc.isValid()) // avoid bug 5861. if (const m = getModule()) return Loc(m.srcfile.toChars(), 0, 0); return loc; } final const(char)* locToChars() { return getLoc().toChars(); } override bool equals(RootObject o) { if (this == o) return true; if (o.dyncast() != DYNCAST.dsymbol) return false; auto s = cast(Dsymbol)o; // Overload sets don't have an ident if (s && ident && s.ident && ident.equals(s.ident)) return true; return false; } bool isAnonymous() { return ident is null; } final void error(const ref Loc loc, const(char)* format, ...) { va_list ap; va_start(ap, format); const cstr = toPrettyChars(); const pretty = '`' ~ cstr[0 .. strlen(cstr)] ~ "`\0"; .verror(loc, format, ap, kind(), pretty.ptr); va_end(ap); } final void error(const(char)* format, ...) { va_list ap; va_start(ap, format); const cstr = toPrettyChars(); const pretty = '`' ~ cstr[0 .. strlen(cstr)] ~ "`\0"; const loc = getLoc(); .verror(loc, format, ap, kind(), pretty.ptr); va_end(ap); } final void deprecation(const ref Loc loc, const(char)* format, ...) { va_list ap; va_start(ap, format); const cstr = toPrettyChars(); const pretty = '`' ~ cstr[0 .. strlen(cstr)] ~ "`\0"; .vdeprecation(loc, format, ap, kind(), pretty.ptr); va_end(ap); } final void deprecation(const(char)* format, ...) { va_list ap; va_start(ap, format); const cstr = toPrettyChars(); const pretty = '`' ~ cstr[0 .. strlen(cstr)] ~ "`\0"; const loc = getLoc(); .vdeprecation(loc, format, ap, kind(), pretty.ptr); va_end(ap); } final bool checkDeprecated(const ref Loc loc, Scope* sc) { if (global.params.useDeprecated != DiagnosticReporting.off && isDeprecated()) { // Don't complain if we're inside a deprecated symbol's scope if (sc.isDeprecated()) return false; const(char)* message = null; for (Dsymbol p = this; p; p = p.parent) { message = p.depdecl ? p.depdecl.getMessage() : null; if (message) break; } if (message) deprecation(loc, "is deprecated - %s", message); else deprecation(loc, "is deprecated"); return true; } return false; } /********************************** * Determine which Module a Dsymbol is in. */ final Module getModule() { //printf("Dsymbol::getModule()\n"); if (TemplateInstance ti = isInstantiated()) return ti.tempdecl.getModule(); Dsymbol s = this; while (s) { //printf("\ts = %s '%s'\n", s.kind(), s.toPrettyChars()); Module m = s.isModule(); if (m) return m; s = s.parent; } return null; } /********************************** * Determine which Module a Dsymbol is in, as far as access rights go. */ final Module getAccessModule() { //printf("Dsymbol::getAccessModule()\n"); if (TemplateInstance ti = isInstantiated()) return ti.tempdecl.getAccessModule(); Dsymbol s = this; while (s) { //printf("\ts = %s '%s'\n", s.kind(), s.toPrettyChars()); Module m = s.isModule(); if (m) return m; TemplateInstance ti = s.isTemplateInstance(); if (ti && ti.enclosing) { /* Because of local template instantiation, the parent isn't where the access * rights come from - it's the template declaration */ s = ti.tempdecl; } else s = s.parent; } return null; } /** * `pastMixin` returns the enclosing symbol if this is a template mixin. * * `pastMixinAndNspace` does likewise, additionally skipping over Nspaces that * are mangleOnly. * * See also `parent`, `toParent` and `toParent2`. */ final inout(Dsymbol) pastMixin() inout { //printf("Dsymbol::pastMixin() %s\n", toChars()); if (!isTemplateMixin() && !isForwardingAttribDeclaration() && !isForwardingScopeDsymbol()) return this; if (!parent) return null; return parent.pastMixin(); } /********************************** * `parent` field returns a lexically enclosing scope symbol this is a member of. * * `toParent()` returns a logically enclosing scope symbol this is a member of. * It skips over TemplateMixin's. * * `toParent2()` returns an enclosing scope symbol this is living at runtime. * It skips over both TemplateInstance's and TemplateMixin's. * It's used when looking for the 'this' pointer of the enclosing function/class. * * `toParentDecl()` similar to `toParent2()` but always follows the template declaration scope * instead of the instantiation scope. * * `toParentLocal()` similar to `toParentDecl()` but follows the instantiation scope * if a template declaration is non-local i.e. global or static. * * Examples: * module mod; * template Foo(alias a) { mixin Bar!(); } * mixin template Bar() { * public { // ProtDeclaration * void baz() { a = 2; } * } * } * void test() { * int v = 1; * alias foo = Foo!(v); * foo.baz(); * assert(v == 2); * } * * // s == FuncDeclaration('mod.test.Foo!().Bar!().baz()') * // s.parent == TemplateMixin('mod.test.Foo!().Bar!()') * // s.toParent() == TemplateInstance('mod.test.Foo!()') * // s.toParent2() == FuncDeclaration('mod.test') * // s.toParentDecl() == Module('mod') * // s.toParentLocal() == FuncDeclaration('mod.test') */ final inout(Dsymbol) toParent() inout { return parent ? parent.pastMixin() : null; } /// ditto final inout(Dsymbol) toParent2() inout { if (!parent || !parent.isTemplateInstance && !parent.isForwardingAttribDeclaration() && !parent.isForwardingScopeDsymbol()) return parent; return parent.toParent2; } /// ditto final inout(Dsymbol) toParentDecl() inout { return toParentDeclImpl(false); } /// ditto final inout(Dsymbol) toParentLocal() inout { return toParentDeclImpl(true); } private inout(Dsymbol) toParentDeclImpl(bool localOnly) inout { auto p = toParent(); if (!p || !p.isTemplateInstance()) return p; auto ti = p.isTemplateInstance(); if (ti.tempdecl && (!localOnly || !(cast(TemplateDeclaration)ti.tempdecl).isstatic)) return ti.tempdecl.toParentDeclImpl(localOnly); return parent.toParentDeclImpl(localOnly); } final inout(TemplateInstance) isInstantiated() inout { if (!parent) return null; auto ti = parent.isTemplateInstance(); if (ti && !ti.isTemplateMixin()) return ti; return parent.isInstantiated(); } // Check if this function is a member of a template which has only been // instantiated speculatively, eg from inside is(typeof()). // Return the speculative template instance it is part of, // or NULL if not speculative. final inout(TemplateInstance) isSpeculative() inout { if (!parent) return null; auto ti = parent.isTemplateInstance(); if (ti && ti.gagged) return ti; if (!parent.toParent()) return null; return parent.isSpeculative(); } final Ungag ungagSpeculative() const { uint oldgag = global.gag; if (global.gag && !isSpeculative() && !toParent2().isFuncDeclaration()) global.gag = 0; return Ungag(oldgag); } // kludge for template.isSymbol() override final DYNCAST dyncast() const { return DYNCAST.dsymbol; } /************************************* * Do syntax copy of an array of Dsymbol's. */ extern (D) static Dsymbols* arraySyntaxCopy(Dsymbols* a) { Dsymbols* b = null; if (a) { b = a.copy(); for (size_t i = 0; i < b.dim; i++) { (*b)[i] = (*b)[i].syntaxCopy(null); } } return b; } Identifier getIdent() { return ident; } const(char)* toPrettyChars(bool QualifyTypes = false) { if (prettystring && !QualifyTypes) return prettystring; //printf("Dsymbol::toPrettyChars() '%s'\n", toChars()); if (!parent) { auto s = toChars(); if (!QualifyTypes) prettystring = s; return s; } // Computer number of components size_t complength = 0; for (Dsymbol p = this; p; p = p.parent) ++complength; // Allocate temporary array comp[] alias T = const(char)[]; auto compptr = cast(T*)malloc(complength * T.sizeof); if (!compptr) Mem.error(); auto comp = compptr[0 .. complength]; // Fill in comp[] and compute length of final result size_t length = 0; int i; for (Dsymbol p = this; p; p = p.parent) { const s = QualifyTypes ? p.toPrettyCharsHelper() : p.toChars(); const len = strlen(s); comp[i] = s[0 .. len]; ++i; length += len + 1; } auto s = cast(char*)mem.xmalloc(length); auto q = s + length - 1; *q = 0; foreach (j; 0 .. complength) { const t = comp[j].ptr; const len = comp[j].length; q -= len; memcpy(q, t, len); if (q == s) break; *--q = '.'; } free(comp.ptr); if (!QualifyTypes) prettystring = s; return s; } const(char)* kind() const pure nothrow @nogc @safe { return "symbol"; } /********************************* * If this symbol is really an alias for another, * return that other. * If needed, semantic() is invoked due to resolve forward reference. */ Dsymbol toAlias() { return this; } /********************************* * Resolve recursive tuple expansion in eponymous template. */ Dsymbol toAlias2() { return toAlias(); } /********************************* * Iterate this dsymbol or members of this scoped dsymbol, then * call `fp` with the found symbol and `param`. * Params: * fp = function pointer to process the iterated symbol. * If it returns nonzero, the iteration will be aborted. * param = a parameter passed to fp. * Returns: * nonzero if the iteration is aborted by the return value of fp, * or 0 if it's completed. */ int apply(Dsymbol_apply_ft_t fp, void* param) { return (*fp)(this, param); } void addMember(Scope* sc, ScopeDsymbol sds) { //printf("Dsymbol::addMember('%s')\n", toChars()); //printf("Dsymbol::addMember(this = %p, '%s' scopesym = '%s')\n", this, toChars(), sds.toChars()); //printf("Dsymbol::addMember(this = %p, '%s' sds = %p, sds.symtab = %p)\n", this, toChars(), sds, sds.symtab); parent = sds; if (!isAnonymous()) // no name, so can't add it to symbol table { if (!sds.symtabInsert(this)) // if name is already defined { if (isAliasDeclaration() && !_scope) setScope(sc); Dsymbol s2 = sds.symtabLookup(this,ident); if (!s2.overloadInsert(this)) { sds.multiplyDefined(Loc.initial, this, s2); errors = true; } } if (sds.isAggregateDeclaration() || sds.isEnumDeclaration()) { if (ident == Id.__sizeof || ident == Id.__xalignof || ident == Id._mangleof) { error("`.%s` property cannot be redefined", ident.toChars()); errors = true; } } } } /************************************* * Set scope for future semantic analysis so we can * deal better with forward references. */ void setScope(Scope* sc) { //printf("Dsymbol::setScope() %p %s, %p stc = %llx\n", this, toChars(), sc, sc.stc); if (!sc.nofree) sc.setNoFree(); // may need it even after semantic() finishes _scope = sc; if (sc.depdecl) depdecl = sc.depdecl; if (!userAttribDecl) userAttribDecl = sc.userAttribDecl; } void importAll(Scope* sc) { } /********************************************* * Search for ident as member of s. * Params: * loc = location to print for error messages * ident = identifier to search for * flags = IgnoreXXXX * Returns: * null if not found */ Dsymbol search(const ref Loc loc, Identifier ident, int flags = IgnoreNone) { //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident.toChars()); return null; } extern (D) final Dsymbol search_correct(Identifier ident) { /*************************************************** * Search for symbol with correct spelling. */ extern (D) Dsymbol symbol_search_fp(const(char)[] seed, ref int cost) { /* If not in the lexer's string table, it certainly isn't in the symbol table. * Doing this first is a lot faster. */ if (!seed.length) return null; Identifier id = Identifier.lookup(seed); if (!id) return null; cost = 0; Dsymbol s = this; Module.clearCache(); return s.search(Loc.initial, id, IgnoreErrors); } if (global.gag) return null; // don't do it for speculative compiles; too time consuming // search for exact name first if (auto s = search(Loc.initial, ident, IgnoreErrors)) return s; return speller!symbol_search_fp(ident.toString()); } /*************************************** * Search for identifier id as a member of `this`. * `id` may be a template instance. * * Params: * loc = location to print the error messages * sc = the scope where the symbol is located * id = the id of the symbol * flags = the search flags which can be `SearchLocalsOnly` or `IgnorePrivateImports` * * Returns: * symbol found, NULL if not */ extern (D) final Dsymbol searchX(const ref Loc loc, Scope* sc, RootObject id, int flags) { //printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident.toChars()); Dsymbol s = toAlias(); Dsymbol sm; if (Declaration d = s.isDeclaration()) { if (d.inuse) { .error(loc, "circular reference to `%s`", d.toPrettyChars()); return null; } } switch (id.dyncast()) { case DYNCAST.identifier: sm = s.search(loc, cast(Identifier)id, flags); break; case DYNCAST.dsymbol: { // It's a template instance //printf("\ttemplate instance id\n"); Dsymbol st = cast(Dsymbol)id; TemplateInstance ti = st.isTemplateInstance(); sm = s.search(loc, ti.name); if (!sm) { sm = s.search_correct(ti.name); if (sm) .error(loc, "template identifier `%s` is not a member of %s `%s`, did you mean %s `%s`?", ti.name.toChars(), s.kind(), s.toPrettyChars(), sm.kind(), sm.toChars()); else .error(loc, "template identifier `%s` is not a member of %s `%s`", ti.name.toChars(), s.kind(), s.toPrettyChars()); return null; } sm = sm.toAlias(); TemplateDeclaration td = sm.isTemplateDeclaration(); if (!td) { .error(loc, "`%s.%s` is not a template, it is a %s", s.toPrettyChars(), ti.name.toChars(), sm.kind()); return null; } ti.tempdecl = td; if (!ti.semanticRun) ti.dsymbolSemantic(sc); sm = ti.toAlias(); break; } case DYNCAST.type: case DYNCAST.expression: default: assert(0); } return sm; } bool overloadInsert(Dsymbol s) { //printf("Dsymbol::overloadInsert('%s')\n", s.toChars()); return false; } /********************************* * Returns: * SIZE_INVALID when the size cannot be determined */ d_uns64 size(const ref Loc loc) { error("Dsymbol `%s` has no size", toChars()); return SIZE_INVALID; } bool isforwardRef() { return false; } // is a 'this' required to access the member inout(AggregateDeclaration) isThis() inout { return null; } // is Dsymbol exported? bool isExport() const { return false; } // is Dsymbol imported? bool isImportedSymbol() const { return false; } // is Dsymbol deprecated? bool isDeprecated() const { return false; } bool isOverloadable() const { return false; } // is this a LabelDsymbol()? LabelDsymbol isLabel() { return null; } /// Returns an AggregateDeclaration when toParent() is that. final inout(AggregateDeclaration) isMember() inout { //printf("Dsymbol::isMember() %s\n", toChars()); auto p = toParent(); //printf("parent is %s %s\n", p.kind(), p.toChars()); return p ? p.isAggregateDeclaration() : null; } /// Returns an AggregateDeclaration when toParent2() is that. final inout(AggregateDeclaration) isMember2() inout { //printf("Dsymbol::isMember2() '%s'\n", toChars()); auto p = toParent2(); //printf("parent is %s %s\n", p.kind(), p.toChars()); return p ? p.isAggregateDeclaration() : null; } /// Returns an AggregateDeclaration when toParentDecl() is that. final inout(AggregateDeclaration) isMemberDecl() inout { //printf("Dsymbol::isMemberDecl() '%s'\n", toChars()); auto p = toParentDecl(); //printf("parent is %s %s\n", p.kind(), p.toChars()); return p ? p.isAggregateDeclaration() : null; } /// Returns an AggregateDeclaration when toParentLocal() is that. final inout(AggregateDeclaration) isMemberLocal() inout { //printf("Dsymbol::isMemberLocal() '%s'\n", toChars()); auto p = toParentLocal(); //printf("parent is %s %s\n", p.kind(), p.toChars()); return p ? p.isAggregateDeclaration() : null; } // is this a member of a ClassDeclaration? final ClassDeclaration isClassMember() { auto ad = isMember(); return ad ? ad.isClassDeclaration() : null; } // is this a type? Type getType() { return null; } // need a 'this' pointer? bool needThis() { return false; } /************************************* */ Prot prot() pure nothrow @nogc @safe { return Prot(Prot.Kind.public_); } /************************************** * Copy the syntax. * Used for template instantiations. * If s is NULL, allocate the new object, otherwise fill it in. */ Dsymbol syntaxCopy(Dsymbol s) { printf("%s %s\n", kind(), toChars()); assert(0); } /************************************** * Determine if this symbol is only one. * Returns: * false, *ps = NULL: There are 2 or more symbols * true, *ps = NULL: There are zero symbols * true, *ps = symbol: The one and only one symbol */ bool oneMember(Dsymbol* ps, Identifier ident) { //printf("Dsymbol::oneMember()\n"); *ps = this; return true; } /***************************************** * Same as Dsymbol::oneMember(), but look at an array of Dsymbols. */ extern (D) static bool oneMembers(Dsymbols* members, Dsymbol* ps, Identifier ident) { //printf("Dsymbol::oneMembers() %d\n", members ? members.dim : 0); Dsymbol s = null; if (members) { for (size_t i = 0; i < members.dim; i++) { Dsymbol sx = (*members)[i]; bool x = sx.oneMember(ps, ident); //printf("\t[%d] kind %s = %d, s = %p\n", i, sx.kind(), x, *ps); if (!x) { //printf("\tfalse 1\n"); assert(*ps is null); return false; } if (*ps) { assert(ident); if (!(*ps).ident || !(*ps).ident.equals(ident)) continue; if (!s) s = *ps; else if (s.isOverloadable() && (*ps).isOverloadable()) { // keep head of overload set FuncDeclaration f1 = s.isFuncDeclaration(); FuncDeclaration f2 = (*ps).isFuncDeclaration(); if (f1 && f2) { assert(!f1.isFuncAliasDeclaration()); assert(!f2.isFuncAliasDeclaration()); for (; f1 != f2; f1 = f1.overnext0) { if (f1.overnext0 is null) { f1.overnext0 = f2; break; } } } } else // more than one symbol { *ps = null; //printf("\tfalse 2\n"); return false; } } } } *ps = s; // s is the one symbol, null if none //printf("\ttrue\n"); return true; } void setFieldOffset(AggregateDeclaration ad, uint* poffset, bool isunion) { } /***************************************** * Is Dsymbol a variable that contains pointers? */ bool hasPointers() { //printf("Dsymbol::hasPointers() %s\n", toChars()); return false; } bool hasStaticCtorOrDtor() { //printf("Dsymbol::hasStaticCtorOrDtor() %s\n", toChars()); return false; } void addLocalClass(ClassDeclarations*) { } void addObjcSymbols(ClassDeclarations* classes, ClassDeclarations* categories) { } void checkCtorConstInit() { } /**************************************** * Add documentation comment to Dsymbol. * Ignore NULL comments. */ void addComment(const(char)* comment) { //if (comment) // printf("adding comment '%s' to symbol %p '%s'\n", comment, this, toChars()); if (!this.comment) this.comment = comment; else if (comment && strcmp(cast(char*)comment, cast(char*)this.comment) != 0) { // Concatenate the two this.comment = Lexer.combineComments(this.comment, comment, true); } } /**************************************** * Returns true if this symbol is defined in a non-root module without instantiation. */ final bool inNonRoot() { Dsymbol s = parent; for (; s; s = s.toParent()) { if (auto ti = s.isTemplateInstance()) { return false; } if (auto m = s.isModule()) { if (!m.isRoot()) return true; break; } } return false; } /************ */ override void accept(Visitor v) { v.visit(this); } pure nothrow @safe @nogc: // Eliminate need for dynamic_cast inout(Package) isPackage() inout { return null; } inout(Module) isModule() inout { return null; } inout(EnumMember) isEnumMember() inout { return null; } inout(TemplateDeclaration) isTemplateDeclaration() inout { return null; } inout(TemplateInstance) isTemplateInstance() inout { return null; } inout(TemplateMixin) isTemplateMixin() inout { return null; } inout(ForwardingAttribDeclaration) isForwardingAttribDeclaration() inout { return null; } inout(Nspace) isNspace() inout { return null; } inout(Declaration) isDeclaration() inout { return null; } inout(StorageClassDeclaration) isStorageClassDeclaration() inout { return null; } inout(ExpressionDsymbol) isExpressionDsymbol() inout { return null; } inout(ThisDeclaration) isThisDeclaration() inout { return null; } inout(TypeInfoDeclaration) isTypeInfoDeclaration() inout { return null; } inout(TupleDeclaration) isTupleDeclaration() inout { return null; } inout(AliasDeclaration) isAliasDeclaration() inout { return null; } inout(AggregateDeclaration) isAggregateDeclaration() inout { return null; } inout(FuncDeclaration) isFuncDeclaration() inout { return null; } inout(FuncAliasDeclaration) isFuncAliasDeclaration() inout { return null; } inout(OverDeclaration) isOverDeclaration() inout { return null; } inout(FuncLiteralDeclaration) isFuncLiteralDeclaration() inout { return null; } inout(CtorDeclaration) isCtorDeclaration() inout { return null; } inout(PostBlitDeclaration) isPostBlitDeclaration() inout { return null; } inout(DtorDeclaration) isDtorDeclaration() inout { return null; } inout(StaticCtorDeclaration) isStaticCtorDeclaration() inout { return null; } inout(StaticDtorDeclaration) isStaticDtorDeclaration() inout { return null; } inout(SharedStaticCtorDeclaration) isSharedStaticCtorDeclaration() inout { return null; } inout(SharedStaticDtorDeclaration) isSharedStaticDtorDeclaration() inout { return null; } inout(InvariantDeclaration) isInvariantDeclaration() inout { return null; } inout(UnitTestDeclaration) isUnitTestDeclaration() inout { return null; } inout(NewDeclaration) isNewDeclaration() inout { return null; } inout(VarDeclaration) isVarDeclaration() inout { return null; } inout(ClassDeclaration) isClassDeclaration() inout { return null; } inout(StructDeclaration) isStructDeclaration() inout { return null; } inout(UnionDeclaration) isUnionDeclaration() inout { return null; } inout(InterfaceDeclaration) isInterfaceDeclaration() inout { return null; } inout(ScopeDsymbol) isScopeDsymbol() inout { return null; } inout(ForwardingScopeDsymbol) isForwardingScopeDsymbol() inout { return null; } inout(WithScopeSymbol) isWithScopeSymbol() inout { return null; } inout(ArrayScopeSymbol) isArrayScopeSymbol() inout { return null; } inout(Import) isImport() inout { return null; } inout(EnumDeclaration) isEnumDeclaration() inout { return null; } inout(DeleteDeclaration) isDeleteDeclaration() inout { return null; } inout(SymbolDeclaration) isSymbolDeclaration() inout { return null; } inout(AttribDeclaration) isAttribDeclaration() inout { return null; } inout(AnonDeclaration) isAnonDeclaration() inout { return null; } inout(CPPNamespaceDeclaration) isCPPNamespaceDeclaration() inout { return null; } inout(ProtDeclaration) isProtDeclaration() inout { return null; } inout(OverloadSet) isOverloadSet() inout { return null; } inout(CompileDeclaration) isCompileDeclaration() inout { return null; } } /*********************************************************** * Dsymbol that generates a scope */ extern (C++) class ScopeDsymbol : Dsymbol { Dsymbols* members; // all Dsymbol's in this scope DsymbolTable symtab; // members[] sorted into table uint endlinnum; // the linnumber of the statement after the scope (0 if unknown) private: /// symbols whose members have been imported, i.e. imported modules and template mixins Dsymbols* importedScopes; Prot.Kind* prots; // array of Prot.Kind, one for each import import dmd.root.array : BitArray; BitArray accessiblePackages, privateAccessiblePackages;// whitelists of accessible (imported) packages public: final extern (D) this() { } final extern (D) this(Identifier ident) { super(ident); } final extern (D) this(const ref Loc loc, Identifier ident) { super(loc, ident); } override Dsymbol syntaxCopy(Dsymbol s) { //printf("ScopeDsymbol::syntaxCopy('%s')\n", toChars()); ScopeDsymbol sds = s ? cast(ScopeDsymbol)s : new ScopeDsymbol(ident); sds.members = arraySyntaxCopy(members); sds.endlinnum = endlinnum; return sds; } /***************************************** * This function is #1 on the list of functions that eat cpu time. * Be very, very careful about slowing it down. */ override Dsymbol search(const ref Loc loc, Identifier ident, int flags = SearchLocalsOnly) { //printf("%s.ScopeDsymbol::search(ident='%s', flags=x%x)\n", toChars(), ident.toChars(), flags); //if (strcmp(ident.toChars(),"c") == 0) *(char*)0=0; // Look in symbols declared in this module if (symtab && !(flags & SearchImportsOnly)) { //printf(" look in locals\n"); auto s1 = symtab.lookup(ident); if (s1) { //printf("\tfound in locals = '%s.%s'\n",toChars(),s1.toChars()); return s1; } } //printf(" not found in locals\n"); // Look in imported scopes if (!importedScopes) return null; //printf(" look in imports\n"); Dsymbol s = null; OverloadSet a = null; // Look in imported modules for (size_t i = 0; i < importedScopes.dim; i++) { // If private import, don't search it if ((flags & IgnorePrivateImports) && prots[i] == Prot.Kind.private_) continue; int sflags = flags & (IgnoreErrors | IgnoreAmbiguous); // remember these in recursive searches Dsymbol ss = (*importedScopes)[i]; //printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss.toChars(), prots[i], ss.isModule(), ss.isImport()); if (ss.isModule()) { if (flags & SearchLocalsOnly) continue; } else // mixin template { if (flags & SearchImportsOnly) continue; sflags |= SearchLocalsOnly; } /* Don't find private members if ss is a module */ Dsymbol s2 = ss.search(loc, ident, sflags | (ss.isModule() ? IgnorePrivateImports : IgnoreNone)); import dmd.access : symbolIsVisible; if (!s2 || !(flags & IgnoreSymbolVisibility) && !symbolIsVisible(this, s2)) continue; if (!s) { s = s2; if (s && s.isOverloadSet()) a = mergeOverloadSet(ident, a, s); } else if (s2 && s != s2) { if (s.toAlias() == s2.toAlias() || s.getType() == s2.getType() && s.getType()) { /* After following aliases, we found the same * symbol, so it's not an ambiguity. But if one * alias is deprecated or less accessible, prefer * the other. */ if (s.isDeprecated() || s.prot().isMoreRestrictiveThan(s2.prot()) && s2.prot().kind != Prot.Kind.none) s = s2; } else { /* Two imports of the same module should be regarded as * the same. */ Import i1 = s.isImport(); Import i2 = s2.isImport(); if (!(i1 && i2 && (i1.mod == i2.mod || (!i1.parent.isImport() && !i2.parent.isImport() && i1.ident.equals(i2.ident))))) { /* https://issues.dlang.org/show_bug.cgi?id=8668 * Public selective import adds AliasDeclaration in module. * To make an overload set, resolve aliases in here and * get actual overload roots which accessible via s and s2. */ s = s.toAlias(); s2 = s2.toAlias(); /* If both s2 and s are overloadable (though we only * need to check s once) */ if ((s2.isOverloadSet() || s2.isOverloadable()) && (a || s.isOverloadable())) { if (symbolIsVisible(this, s2)) { a = mergeOverloadSet(ident, a, s2); } if (!symbolIsVisible(this, s)) s = s2; continue; } if (flags & IgnoreAmbiguous) // if return NULL on ambiguity return null; if (!(flags & IgnoreErrors)) ScopeDsymbol.multiplyDefined(loc, s, s2); break; } } } } if (s) { /* Build special symbol if we had multiple finds */ if (a) { if (!s.isOverloadSet()) a = mergeOverloadSet(ident, a, s); s = a; } //printf("\tfound in imports %s.%s\n", toChars(), s.toChars()); return s; } //printf(" not found in imports\n"); return null; } extern (D) private OverloadSet mergeOverloadSet(Identifier ident, OverloadSet os, Dsymbol s) { if (!os) { os = new OverloadSet(ident); os.parent = this; } if (OverloadSet os2 = s.isOverloadSet()) { // Merge the cross-module overload set 'os2' into 'os' if (os.a.dim == 0) { os.a.setDim(os2.a.dim); memcpy(os.a.tdata(), os2.a.tdata(), (os.a[0]).sizeof * os2.a.dim); } else { for (size_t i = 0; i < os2.a.dim; i++) { os = mergeOverloadSet(ident, os, os2.a[i]); } } } else { assert(s.isOverloadable()); /* Don't add to os[] if s is alias of previous sym */ for (size_t j = 0; j < os.a.dim; j++) { Dsymbol s2 = os.a[j]; if (s.toAlias() == s2.toAlias()) { if (s2.isDeprecated() || (s2.prot().isMoreRestrictiveThan(s.prot()) && s.prot().kind != Prot.Kind.none)) { os.a[j] = s; } goto Lcontinue; } } os.push(s); Lcontinue: } return os; } void importScope(Dsymbol s, Prot protection) { //printf("%s.ScopeDsymbol::importScope(%s, %d)\n", toChars(), s.toChars(), protection); // No circular or redundant import's if (s != this) { if (!importedScopes) importedScopes = new Dsymbols(); else { for (size_t i = 0; i < importedScopes.dim; i++) { Dsymbol ss = (*importedScopes)[i]; if (ss == s) // if already imported { if (protection.kind > prots[i]) prots[i] = protection.kind; // upgrade access return; } } } importedScopes.push(s); prots = cast(Prot.Kind*)mem.xrealloc(prots, importedScopes.dim * (prots[0]).sizeof); prots[importedScopes.dim - 1] = protection.kind; } } extern (D) final void addAccessiblePackage(Package p, Prot protection) { // https://issues.dlang.org/show_bug.cgi?id=17991 // An import of truly empty file/package can happen if (p is null) return; auto pary = protection.kind == Prot.Kind.private_ ? &privateAccessiblePackages : &accessiblePackages; if (pary.length <= p.tag) pary.length = p.tag + 1; (*pary)[p.tag] = true; } bool isPackageAccessible(Package p, Prot protection, int flags = 0) { if (p.tag < accessiblePackages.length && accessiblePackages[p.tag] || protection.kind == Prot.Kind.private_ && p.tag < privateAccessiblePackages.length && privateAccessiblePackages[p.tag]) return true; foreach (i, ss; importedScopes ? (*importedScopes)[] : null) { // only search visible scopes && imported modules should ignore private imports if (protection.kind <= prots[i] && ss.isScopeDsymbol.isPackageAccessible(p, protection, IgnorePrivateImports)) return true; } return false; } override final bool isforwardRef() { return (members is null); } static void multiplyDefined(const ref Loc loc, Dsymbol s1, Dsymbol s2) { version (none) { printf("ScopeDsymbol::multiplyDefined()\n"); printf("s1 = %p, '%s' kind = '%s', parent = %s\n", s1, s1.toChars(), s1.kind(), s1.parent ? s1.parent.toChars() : ""); printf("s2 = %p, '%s' kind = '%s', parent = %s\n", s2, s2.toChars(), s2.kind(), s2.parent ? s2.parent.toChars() : ""); } if (loc.isValid()) { .error(loc, "`%s` at %s conflicts with `%s` at %s", s1.toPrettyChars(), s1.locToChars(), s2.toPrettyChars(), s2.locToChars()); } else { s1.error(s1.loc, "conflicts with %s `%s` at %s", s2.kind(), s2.toPrettyChars(), s2.locToChars()); } } override const(char)* kind() const { return "ScopeDsymbol"; } /******************************************* * Look for member of the form: * const(MemberInfo)[] getMembers(string); * Returns NULL if not found */ final FuncDeclaration findGetMembers() { Dsymbol s = search_function(this, Id.getmembers); FuncDeclaration fdx = s ? s.isFuncDeclaration() : null; version (none) { // Finish __gshared TypeFunction tfgetmembers; if (!tfgetmembers) { Scope sc; auto parameters = new Parameters(); Parameters* p = new Parameter(STC.in_, Type.tchar.constOf().arrayOf(), null, null); parameters.push(p); Type tret = null; tfgetmembers = new TypeFunction(parameters, tret, VarArg.none, LINK.d); tfgetmembers = cast(TypeFunction)tfgetmembers.dsymbolSemantic(Loc.initial, &sc); } if (fdx) fdx = fdx.overloadExactMatch(tfgetmembers); } if (fdx && fdx.isVirtual()) fdx = null; return fdx; } Dsymbol symtabInsert(Dsymbol s) { return symtab.insert(s); } /**************************************** * Look up identifier in symbol table. */ Dsymbol symtabLookup(Dsymbol s, Identifier id) { return symtab.lookup(id); } /**************************************** * Return true if any of the members are static ctors or static dtors, or if * any members have members that are. */ override bool hasStaticCtorOrDtor() { if (members) { for (size_t i = 0; i < members.dim; i++) { Dsymbol member = (*members)[i]; if (member.hasStaticCtorOrDtor()) return true; } } return false; } extern (D) alias ForeachDg = int delegate(size_t idx, Dsymbol s); /*************************************** * Expands attribute declarations in members in depth first * order. Calls dg(size_t symidx, Dsymbol *sym) for each * member. * If dg returns !=0, stops and returns that value else returns 0. * Use this function to avoid the O(N + N^2/2) complexity of * calculating dim and calling N times getNth. * Returns: * last value returned by dg() */ extern (D) static int _foreach(Scope* sc, Dsymbols* members, scope ForeachDg dg, size_t* pn = null) { assert(dg); if (!members) return 0; size_t n = pn ? *pn : 0; // take over index int result = 0; foreach (size_t i; 0 .. members.dim) { Dsymbol s = (*members)[i]; if (AttribDeclaration a = s.isAttribDeclaration()) result = _foreach(sc, a.include(sc), dg, &n); else if (TemplateMixin tm = s.isTemplateMixin()) result = _foreach(sc, tm.members, dg, &n); else if (s.isTemplateInstance()) { } else if (s.isUnitTestDeclaration()) { } else result = dg(n++, s); if (result) break; } if (pn) *pn = n; // update index return result; } override final inout(ScopeDsymbol) isScopeDsymbol() inout { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * With statement scope */ extern (C++) final class WithScopeSymbol : ScopeDsymbol { WithStatement withstate; extern (D) this(WithStatement withstate) { this.withstate = withstate; } override Dsymbol search(const ref Loc loc, Identifier ident, int flags = SearchLocalsOnly) { //printf("WithScopeSymbol.search(%s)\n", ident.toChars()); if (flags & SearchImportsOnly) return null; // Acts as proxy to the with class declaration Dsymbol s = null; Expression eold = null; for (Expression e = withstate.exp; e != eold; e = resolveAliasThis(_scope, e)) { if (e.op == TOK.scope_) { s = (cast(ScopeExp)e).sds; } else if (e.op == TOK.type) { s = e.type.toDsymbol(null); } else { Type t = e.type.toBasetype(); s = t.toDsymbol(null); } if (s) { s = s.search(loc, ident, flags); if (s) return s; } eold = e; } return null; } override inout(WithScopeSymbol) isWithScopeSymbol() inout { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Array Index/Slice scope */ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol { Expression exp; // IndexExp or SliceExp TypeTuple type; // for tuple[length] TupleDeclaration td; // for tuples of objects Scope* sc; extern (D) this(Scope* sc, Expression exp) { super(exp.loc, null); assert(exp.op == TOK.index || exp.op == TOK.slice || exp.op == TOK.array); this.exp = exp; this.sc = sc; } extern (D) this(Scope* sc, TypeTuple type) { this.type = type; this.sc = sc; } extern (D) this(Scope* sc, TupleDeclaration td) { this.td = td; this.sc = sc; } override Dsymbol search(const ref Loc loc, Identifier ident, int flags = IgnoreNone) { //printf("ArrayScopeSymbol::search('%s', flags = %d)\n", ident.toChars(), flags); if (ident != Id.dollar) return null; VarDeclaration* pvar; Expression ce; L1: if (td) { /* $ gives the number of elements in the tuple */ auto v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, null); Expression e = new IntegerExp(Loc.initial, td.objects.dim, Type.tsize_t); v._init = new ExpInitializer(Loc.initial, e); v.storage_class |= STC.temp | STC.static_ | STC.const_; v.dsymbolSemantic(sc); return v; } if (type) { /* $ gives the number of type entries in the type tuple */ auto v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, null); Expression e = new IntegerExp(Loc.initial, type.arguments.dim, Type.tsize_t); v._init = new ExpInitializer(Loc.initial, e); v.storage_class |= STC.temp | STC.static_ | STC.const_; v.dsymbolSemantic(sc); return v; } if (exp.op == TOK.index) { /* array[index] where index is some function of $ */ IndexExp ie = cast(IndexExp)exp; pvar = &ie.lengthVar; ce = ie.e1; } else if (exp.op == TOK.slice) { /* array[lwr .. upr] where lwr or upr is some function of $ */ SliceExp se = cast(SliceExp)exp; pvar = &se.lengthVar; ce = se.e1; } else if (exp.op == TOK.array) { /* array[e0, e1, e2, e3] where e0, e1, e2 are some function of $ * $ is a opDollar!(dim)() where dim is the dimension(0,1,2,...) */ ArrayExp ae = cast(ArrayExp)exp; pvar = &ae.lengthVar; ce = ae.e1; } else { /* Didn't find $, look in enclosing scope(s). */ return null; } while (ce.op == TOK.comma) ce = (cast(CommaExp)ce).e2; /* If we are indexing into an array that is really a type * tuple, rewrite this as an index into a type tuple and * try again. */ if (ce.op == TOK.type) { Type t = (cast(TypeExp)ce).type; if (t.ty == Ttuple) { type = cast(TypeTuple)t; goto L1; } } /* *pvar is lazily initialized, so if we refer to $ * multiple times, it gets set only once. */ if (!*pvar) // if not already initialized { /* Create variable v and set it to the value of $ */ VarDeclaration v; Type t; if (ce.op == TOK.tuple) { /* It is for an expression tuple, so the * length will be a const. */ Expression e = new IntegerExp(Loc.initial, (cast(TupleExp)ce).exps.dim, Type.tsize_t); v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, new ExpInitializer(Loc.initial, e)); v.storage_class |= STC.temp | STC.static_ | STC.const_; } else if (ce.type && (t = ce.type.toBasetype()) !is null && (t.ty == Tstruct || t.ty == Tclass)) { // Look for opDollar assert(exp.op == TOK.array || exp.op == TOK.slice); AggregateDeclaration ad = isAggregate(t); assert(ad); Dsymbol s = ad.search(loc, Id.opDollar); if (!s) // no dollar exists -- search in higher scope return null; s = s.toAlias(); Expression e = null; // Check for multi-dimensional opDollar(dim) template. if (TemplateDeclaration td = s.isTemplateDeclaration()) { dinteger_t dim = 0; if (exp.op == TOK.array) { dim = (cast(ArrayExp)exp).currentDimension; } else if (exp.op == TOK.slice) { dim = 0; // slices are currently always one-dimensional } else { assert(0); } auto tiargs = new Objects(); Expression edim = new IntegerExp(Loc.initial, dim, Type.tsize_t); edim = edim.expressionSemantic(sc); tiargs.push(edim); e = new DotTemplateInstanceExp(loc, ce, td.ident, tiargs); } else { /* opDollar exists, but it's not a template. * This is acceptable ONLY for single-dimension indexing. * Note that it's impossible to have both template & function opDollar, * because both take no arguments. */ if (exp.op == TOK.array && (cast(ArrayExp)exp).arguments.dim != 1) { exp.error("`%s` only defines opDollar for one dimension", ad.toChars()); return null; } Declaration d = s.isDeclaration(); assert(d); e = new DotVarExp(loc, ce, d); } e = e.expressionSemantic(sc); if (!e.type) exp.error("`%s` has no value", e.toChars()); t = e.type.toBasetype(); if (t && t.ty == Tfunction) e = new CallExp(e.loc, e); v = new VarDeclaration(loc, null, Id.dollar, new ExpInitializer(Loc.initial, e)); v.storage_class |= STC.temp | STC.ctfe | STC.rvalue; } else { /* For arrays, $ will either be a compile-time constant * (in which case its value in set during constant-folding), * or a variable (in which case an expression is created in * toir.c). */ auto e = new VoidInitializer(Loc.initial); e.type = Type.tsize_t; v = new VarDeclaration(loc, Type.tsize_t, Id.dollar, e); v.storage_class |= STC.temp | STC.ctfe; // it's never a true static variable } *pvar = v; } (*pvar).dsymbolSemantic(sc); return (*pvar); } override inout(ArrayScopeSymbol) isArrayScopeSymbol() inout { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Overload Sets */ extern (C++) final class OverloadSet : Dsymbol { Dsymbols a; // array of Dsymbols extern (D) this(Identifier ident, OverloadSet os = null) { super(ident); if (os) { a.pushSlice(os.a[]); } } void push(Dsymbol s) { a.push(s); } override inout(OverloadSet) isOverloadSet() inout { return this; } override const(char)* kind() const { return "overloadset"; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Forwarding ScopeDsymbol. Used by ForwardingAttribDeclaration and * ForwardingScopeDeclaration to forward symbol insertions to another * scope. See `dmd.attrib.ForwardingAttribDeclaration` for more * details. */ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol { /************************* * Symbol to forward insertions to. * Can be `null` before being lazily initialized. */ ScopeDsymbol forward; extern (D) this(ScopeDsymbol forward) { super(null); this.forward = forward; } override Dsymbol symtabInsert(Dsymbol s) { assert(forward); if (auto d = s.isDeclaration()) { if (d.storage_class & STC.local) { // Symbols with storage class STC.local are not // forwarded, but stored in the local symbol // table. (Those are the `static foreach` variables.) if (!symtab) { symtab = new DsymbolTable(); } return super.symtabInsert(s); // insert locally } } if (!forward.symtab) { forward.symtab = new DsymbolTable(); } // Non-STC.local symbols are forwarded to `forward`. return forward.symtabInsert(s); } /************************ * This override handles the following two cases: * static foreach (i, i; [0]) { ... } * and * static foreach (i; [0]) { enum i = 2; } */ override Dsymbol symtabLookup(Dsymbol s, Identifier id) { assert(forward); // correctly diagnose clashing foreach loop variables. if (auto d = s.isDeclaration()) { if (d.storage_class & STC.local) { if (!symtab) { symtab = new DsymbolTable(); } return super.symtabLookup(s,id); } } // Declarations within `static foreach` do not clash with // `static foreach` loop variables. if (!forward.symtab) { forward.symtab = new DsymbolTable(); } return forward.symtabLookup(s,id); } override void importScope(Dsymbol s, Prot protection) { forward.importScope(s, protection); } override const(char)* kind()const{ return "local scope"; } override inout(ForwardingScopeDsymbol) isForwardingScopeDsymbol() inout { return this; } } /** * Class that holds an expression in a Dsymbol wraper. * This is not an AST node, but a class used to pass * an expression as a function parameter of type Dsymbol. */ extern (C++) final class ExpressionDsymbol : Dsymbol { Expression exp; this(Expression exp) { super(); this.exp = exp; } override inout(ExpressionDsymbol) isExpressionDsymbol() inout { return this; } } /*********************************************************** * Table of Dsymbol's */ extern (C++) final class DsymbolTable : RootObject { AssocArray!(Identifier, Dsymbol) tab; // Look up Identifier. Return Dsymbol if found, NULL if not. Dsymbol lookup(const Identifier ident) { //printf("DsymbolTable::lookup(%s)\n", ident.toChars()); return tab[ident]; } // Insert Dsymbol in table. Return NULL if already there. Dsymbol insert(Dsymbol s) { //printf("DsymbolTable::insert(this = %p, '%s')\n", this, s.ident.toChars()); return insert(s.ident, s); } // Look for Dsymbol in table. If there, return it. If not, insert s and return that. Dsymbol update(Dsymbol s) { const ident = s.ident; Dsymbol* ps = tab.getLvalue(ident); *ps = s; return s; } // when ident and s are not the same Dsymbol insert(const Identifier ident, Dsymbol s) { //printf("DsymbolTable::insert()\n"); Dsymbol* ps = tab.getLvalue(ident); if (*ps) return null; // already in table *ps = s; return s; } /***** * Returns: * number of symbols in symbol table */ uint len() const pure { return cast(uint)tab.length; } }
D
/* * Copyright (c) 2004-2009 Derelict Developers * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the names 'Derelict', 'DerelictGL', nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ module derelict.opengl.extension.ext.compiled_vertex_array; private { import derelict.opengl.gltypes; import derelict.opengl.gl; import derelict.opengl.extension.loader; import derelict.util.wrapper; } private bool enabled = false; struct EXTCompiledVertexArray { static bool load(char[] extString) { if(extString.findStr("GL_EXT_compiled_vertex_array") == -1) return false; if(!glBindExtFunc(cast(void**)&glLockArraysEXT, "glLockArraysEXT")) return false; if(!glBindExtFunc(cast(void**)&glUnlockArraysEXT, "glUnlockArraysEXT")) return false; enabled = true; return true; } static bool isEnabled() { return enabled; } } version(DerelictGL_NoExtensionLoaders) { } else { static this() { DerelictGL.registerExtensionLoader(&EXTCompiledVertexArray.load); } } enum : GLenum { GL_ARRAY_ELEMENT_LOCK_FIRST_EXT = 0x81A8, GL_ARRAY_ELEMENT_LOCK_COUNT_EXT = 0x81A9, } extern(System) { void function(GLint, GLsizei) glLockArraysEXT; void function() glUnlockArraysEXT; }
D
/Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/ParameterEncoding.o : /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartFormData.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartUpload.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AlamofireExtended.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Protected.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPMethod.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Combine.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/OperationQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/StringEncoding+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Result+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLRequest+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Response.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/SessionDelegate.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoding.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Session.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Validation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ServerTrustEvaluation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ResponseSerialization.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestTaskMap.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLEncodedFormEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/CachedResponseHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RedirectHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AFError.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/EventMonitor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AuthenticationInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Notifications.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPHeaders.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Request.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RetryPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/ParameterEncoding~partial.swiftmodule : /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartFormData.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartUpload.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AlamofireExtended.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Protected.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPMethod.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Combine.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/OperationQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/StringEncoding+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Result+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLRequest+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Response.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/SessionDelegate.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoding.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Session.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Validation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ServerTrustEvaluation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ResponseSerialization.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestTaskMap.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLEncodedFormEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/CachedResponseHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RedirectHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AFError.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/EventMonitor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AuthenticationInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Notifications.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPHeaders.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Request.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RetryPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/ParameterEncoding~partial.swiftdoc : /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartFormData.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartUpload.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AlamofireExtended.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Protected.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPMethod.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Combine.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/OperationQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/StringEncoding+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Result+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLRequest+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Response.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/SessionDelegate.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoding.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Session.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Validation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ServerTrustEvaluation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ResponseSerialization.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestTaskMap.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLEncodedFormEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/CachedResponseHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RedirectHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AFError.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/EventMonitor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AuthenticationInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Notifications.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPHeaders.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Request.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RetryPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/ParameterEncoding~partial.swiftsourceinfo : /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartFormData.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/MultipartUpload.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AlamofireExtended.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Protected.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPMethod.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Combine.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/OperationQueue+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/StringEncoding+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Result+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLRequest+Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Alamofire.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Response.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/SessionDelegate.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoding.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Session.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Validation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ServerTrustEvaluation.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ResponseSerialization.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestTaskMap.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/URLEncodedFormEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/ParameterEncoder.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/CachedResponseHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RedirectHandler.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AFError.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/EventMonitor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/AuthenticationInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RequestInterceptor.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Notifications.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/HTTPHeaders.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/Request.swift /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Alamofire/Source/RetryPolicy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/ObjectiveC.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreImage.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/QuartzCore.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Dispatch.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Metal.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Darwin.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Foundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreFoundation.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/CoreGraphics.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Swift.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/UIKit.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/SwiftOnoneSupport.swiftmodule/x86_64.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/prebuilt-modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftmodule /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/GuoYanjun/Desktop/TestDemo/WanAndroid_IOS/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/apinotes/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
<?xml version="1.0" encoding="ASCII" standalone="no"?> <di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0"> <pageList> <availablePage> <emfPageIdentifier href="VAR_28_BeT-1817514433.notation#_copSALmGEeKQQp7P9cQvNQ"/> </availablePage> </pageList> <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> <windows> <children xsi:type="di:TabFolder"> <children> <emfPageIdentifier href="VAR_28_BeT-1817514433.notation#_copSALmGEeKQQp7P9cQvNQ"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>
D
prototype Mst_Default_IceGolem(C_Npc) { name[0] = "Ледяной голем"; guild = GIL_ICEGOLEM; aivar[AIV_MM_REAL_ID] = ID_ICEGOLEM; level = 35; bodyStateInterruptableOverride = TRUE; attribute[ATR_STRENGTH] = 300; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 2000; attribute[ATR_HITPOINTS] = 2000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 375; damagetype = DAM_BLUNT | DAM_MAGIC | DAM_FLY; damage[DAM_INDEX_BLUNT] = 350; damage[DAM_INDEX_MAGIC] = 250; damage[DAM_INDEX_FLY] = 100; fight_tactic = FAI_STONEGOLEM; senses = SENSE_HEAR | SENSE_SEE | SENSE_SMELL; senses_range = PERC_DIST_MONSTER_ACTIVE_MAX; aivar[AIV_MM_FollowTime] = FOLLOWTIME_MEDIUM; aivar[AIV_MM_FollowInWater] = TRUE; start_aistate = ZS_MM_AllScheduler; Npc_SetTalentSkill(self,NPC_TALENT_MAGE,6); aivar[AIV_MM_RestStart] = OnlyRoutine; }; func void B_SetVisuals_IceGolem() { Mdl_SetVisual(self,"Golem.mds"); Mdl_ApplyOverlayMds(self,"Golem_Icegolem.mds"); Mdl_SetVisualBody(self,"Gol_Ice_Body",DEFAULT,DEFAULT,"",DEFAULT,DEFAULT,-1); }; func void b_setvisuals_icegolem_water() { Mdl_SetVisual(self,"Golem.mds"); Mdl_SetVisualBody(self,"Gol_Wat_Body",DEFAULT,DEFAULT,"",DEFAULT,DEFAULT,-1); }; func void B_SetVisuals_Ice_Elemental() { Mdl_SetVisual(self,"Avatar.mds"); Mdl_SetVisualBody(self,"Avatar_Body_Ice",DEFAULT,DEFAULT,"",DEFAULT,DEFAULT,-1); }; instance IceGolem(Mst_Default_IceGolem) { name[0] = "Ледяной голем"; level = 35; attribute[ATR_STRENGTH] = 300; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 2000; attribute[ATR_HITPOINTS] = 2000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 375; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance IceGolem_Dragon(Mst_Default_IceGolem) { name[0] = "Ледяной элементаль"; level = 1; attribute[ATR_STRENGTH] = 250; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 1000; attribute[ATR_HITPOINTS] = 1000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 170; protection[PROT_EDGE] = 170; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 300; B_SetVisuals_Ice_Elemental(); Mdl_SetModelScale(self,0.6,0.6,0.6); Npc_SetToFistMode(self); }; instance IceGolem_Avatar(Mst_Default_IceGolem) { name[0] = "Ледяной голем"; level = 35; attribute[ATR_STRENGTH] = 300; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 1000; attribute[ATR_HITPOINTS] = 1000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 375; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance ICEGOLEM_NOEXP(Mst_Default_IceGolem) { level = 1; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance IceGolem_Sylvio1(Mst_Default_IceGolem) { name[0] = "Ледяной голем"; level = 35; attribute[ATR_STRENGTH] = 300; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 2000; attribute[ATR_HITPOINTS] = 2000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 375; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance IceGolem_Sylvio2(Mst_Default_IceGolem) { name[0] = "Ледяной голем"; level = 35; attribute[ATR_STRENGTH] = 300; attribute[ATR_DEXTERITY] = 160; attribute[ATR_HITPOINTS_MAX] = 2000; attribute[ATR_HITPOINTS] = 2000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 375; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance SUMMONED_ICEGOLEM(Mst_Default_IceGolem) { name[0] = "Рунный ледяной голем"; guild = GIL_SUMMONED_GOLEM; aivar[AIV_MM_REAL_ID] = ID_SUMMONED_GOLEM; level = 0; attribute[ATR_STRENGTH] = 280; attribute[ATR_DEXTERITY] = 260; attribute[ATR_HITPOINTS_MAX] = 2500; attribute[ATR_HITPOINTS] = 2500; attribute[ATR_MANA_MAX] = 4; attribute[ATR_MANA] = 4; protection[PROT_BLUNT] = 190; protection[PROT_EDGE] = 190; protection[PROT_POINT] = 225; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 75; aivar[AIV_PARTYMEMBER] = TRUE; effect = "SPELLFX_MOON_SMOKE"; B_SetAttitude(self,ATT_FRIENDLY); start_aistate = ZS_MM_Rtn_Summoned; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); }; instance ICEGOLEM_UNIQ(Mst_Default_IceGolem) { name[0] = "Октогор"; level = 75; attribute[ATR_STRENGTH] = 500; attribute[ATR_DEXTERITY] = 250; attribute[ATR_HITPOINTS_MAX] = 6000; attribute[ATR_HITPOINTS] = 6000; attribute[ATR_MANA_MAX] = 100; attribute[ATR_MANA] = 100; protection[PROT_BLUNT] = 250; protection[PROT_EDGE] = 250; protection[PROT_POINT] = 400; protection[PROT_FIRE] = 0; protection[PROT_FLY] = 50; protection[PROT_MAGIC] = 475; aivar[90] = TRUE; aivar[94] = NPC_UNCOMMON; B_SetVisuals_IceGolem(); Npc_SetToFistMode(self); CreateInvItems(self,ItMi_Emerald,1); CreateInvItems(self,ItMi_Mutagen_Mana_Low,1); };
D
module windows.offlinefiles; public import system; public import windows.automation; public import windows.com; public import windows.systemservices; public import windows.windowsandmessaging; public import windows.windowsprogramming; extern(Windows): const GUID CLSID_OfflineFilesSetting = {0xFD3659E9, 0xA920, 0x4123, [0xAD, 0x64, 0x7F, 0xC7, 0x6C, 0x7A, 0xAC, 0xDF]}; @GUID(0xFD3659E9, 0xA920, 0x4123, [0xAD, 0x64, 0x7F, 0xC7, 0x6C, 0x7A, 0xAC, 0xDF]); struct OfflineFilesSetting; const GUID CLSID_OfflineFilesCache = {0x48C6BE7C, 0x3871, 0x43CC, [0xB4, 0x6F, 0x14, 0x49, 0xA1, 0xBB, 0x2F, 0xF3]}; @GUID(0x48C6BE7C, 0x3871, 0x43CC, [0xB4, 0x6F, 0x14, 0x49, 0xA1, 0xBB, 0x2F, 0xF3]); struct OfflineFilesCache; enum OFFLINEFILES_ITEM_TYPE { OFFLINEFILES_ITEM_TYPE_FILE = 0, OFFLINEFILES_ITEM_TYPE_DIRECTORY = 1, OFFLINEFILES_ITEM_TYPE_SHARE = 2, OFFLINEFILES_ITEM_TYPE_SERVER = 3, } enum OFFLINEFILES_ITEM_COPY { OFFLINEFILES_ITEM_COPY_LOCAL = 0, OFFLINEFILES_ITEM_COPY_REMOTE = 1, OFFLINEFILES_ITEM_COPY_ORIGINAL = 2, } enum OFFLINEFILES_CONNECT_STATE { OFFLINEFILES_CONNECT_STATE_UNKNOWN = 0, OFFLINEFILES_CONNECT_STATE_OFFLINE = 1, OFFLINEFILES_CONNECT_STATE_ONLINE = 2, OFFLINEFILES_CONNECT_STATE_TRANSPARENTLY_CACHED = 3, OFFLINEFILES_CONNECT_STATE_PARTLY_TRANSPARENTLY_CACHED = 4, } enum OFFLINEFILES_OFFLINE_REASON { OFFLINEFILES_OFFLINE_REASON_UNKNOWN = 0, OFFLINEFILES_OFFLINE_REASON_NOT_APPLICABLE = 1, OFFLINEFILES_OFFLINE_REASON_CONNECTION_FORCED = 2, OFFLINEFILES_OFFLINE_REASON_CONNECTION_SLOW = 3, OFFLINEFILES_OFFLINE_REASON_CONNECTION_ERROR = 4, OFFLINEFILES_OFFLINE_REASON_ITEM_VERSION_CONFLICT = 5, OFFLINEFILES_OFFLINE_REASON_ITEM_SUSPENDED = 6, } enum OFFLINEFILES_CACHING_MODE { OFFLINEFILES_CACHING_MODE_NONE = 0, OFFLINEFILES_CACHING_MODE_NOCACHING = 1, OFFLINEFILES_CACHING_MODE_MANUAL = 2, OFFLINEFILES_CACHING_MODE_AUTO_DOC = 3, OFFLINEFILES_CACHING_MODE_AUTO_PROGANDDOC = 4, } enum OFFLINEFILES_OP_RESPONSE { OFFLINEFILES_OP_CONTINUE = 0, OFFLINEFILES_OP_RETRY = 1, OFFLINEFILES_OP_ABORT = 2, } enum OFFLINEFILES_EVENTS { OFFLINEFILES_EVENT_CACHEMOVED = 0, OFFLINEFILES_EVENT_CACHEISFULL = 1, OFFLINEFILES_EVENT_CACHEISCORRUPTED = 2, OFFLINEFILES_EVENT_ENABLED = 3, OFFLINEFILES_EVENT_ENCRYPTIONCHANGED = 4, OFFLINEFILES_EVENT_SYNCBEGIN = 5, OFFLINEFILES_EVENT_SYNCFILERESULT = 6, OFFLINEFILES_EVENT_SYNCCONFLICTRECADDED = 7, OFFLINEFILES_EVENT_SYNCCONFLICTRECUPDATED = 8, OFFLINEFILES_EVENT_SYNCCONFLICTRECREMOVED = 9, OFFLINEFILES_EVENT_SYNCEND = 10, OFFLINEFILES_EVENT_BACKGROUNDSYNCBEGIN = 11, OFFLINEFILES_EVENT_BACKGROUNDSYNCEND = 12, OFFLINEFILES_EVENT_NETTRANSPORTARRIVED = 13, OFFLINEFILES_EVENT_NONETTRANSPORTS = 14, OFFLINEFILES_EVENT_ITEMDISCONNECTED = 15, OFFLINEFILES_EVENT_ITEMRECONNECTED = 16, OFFLINEFILES_EVENT_ITEMAVAILABLEOFFLINE = 17, OFFLINEFILES_EVENT_ITEMNOTAVAILABLEOFFLINE = 18, OFFLINEFILES_EVENT_ITEMPINNED = 19, OFFLINEFILES_EVENT_ITEMNOTPINNED = 20, OFFLINEFILES_EVENT_ITEMMODIFIED = 21, OFFLINEFILES_EVENT_ITEMADDEDTOCACHE = 22, OFFLINEFILES_EVENT_ITEMDELETEDFROMCACHE = 23, OFFLINEFILES_EVENT_ITEMRENAMED = 24, OFFLINEFILES_EVENT_DATALOST = 25, OFFLINEFILES_EVENT_PING = 26, OFFLINEFILES_EVENT_ITEMRECONNECTBEGIN = 27, OFFLINEFILES_EVENT_ITEMRECONNECTEND = 28, OFFLINEFILES_EVENT_CACHEEVICTBEGIN = 29, OFFLINEFILES_EVENT_CACHEEVICTEND = 30, OFFLINEFILES_EVENT_POLICYCHANGEDETECTED = 31, OFFLINEFILES_EVENT_PREFERENCECHANGEDETECTED = 32, OFFLINEFILES_EVENT_SETTINGSCHANGESAPPLIED = 33, OFFLINEFILES_EVENT_TRANSPARENTCACHEITEMNOTIFY = 34, OFFLINEFILES_EVENT_PREFETCHFILEBEGIN = 35, OFFLINEFILES_EVENT_PREFETCHFILEEND = 36, OFFLINEFILES_EVENT_PREFETCHCLOSEHANDLEBEGIN = 37, OFFLINEFILES_EVENT_PREFETCHCLOSEHANDLEEND = 38, OFFLINEFILES_NUM_EVENTS = 39, } enum OFFLINEFILES_PATHFILTER_MATCH { OFFLINEFILES_PATHFILTER_SELF = 0, OFFLINEFILES_PATHFILTER_CHILD = 1, OFFLINEFILES_PATHFILTER_DESCENDENT = 2, OFFLINEFILES_PATHFILTER_SELFORCHILD = 3, OFFLINEFILES_PATHFILTER_SELFORDESCENDENT = 4, } enum OFFLINEFILES_SYNC_CONFLICT_RESOLVE { OFFLINEFILES_SYNC_CONFLICT_RESOLVE_NONE = 0, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_KEEPLOCAL = 1, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_KEEPREMOTE = 2, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_KEEPALLCHANGES = 3, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_KEEPLATEST = 4, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_LOG = 5, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_SKIP = 6, OFFLINEFILES_SYNC_CONFLICT_ABORT = 7, OFFLINEFILES_SYNC_CONFLICT_RESOLVE_NUMCODES = 8, } enum OFFLINEFILES_ITEM_TIME { OFFLINEFILES_ITEM_TIME_CREATION = 0, OFFLINEFILES_ITEM_TIME_LASTACCESS = 1, OFFLINEFILES_ITEM_TIME_LASTWRITE = 2, } enum OFFLINEFILES_COMPARE { OFFLINEFILES_COMPARE_EQ = 0, OFFLINEFILES_COMPARE_NEQ = 1, OFFLINEFILES_COMPARE_LT = 2, OFFLINEFILES_COMPARE_GT = 3, OFFLINEFILES_COMPARE_LTE = 4, OFFLINEFILES_COMPARE_GTE = 5, } enum OFFLINEFILES_SETTING_VALUE_TYPE { OFFLINEFILES_SETTING_VALUE_UI4 = 0, OFFLINEFILES_SETTING_VALUE_BSTR = 1, OFFLINEFILES_SETTING_VALUE_BSTR_DBLNULTERM = 2, OFFLINEFILES_SETTING_VALUE_2DIM_ARRAY_BSTR_UI4 = 3, OFFLINEFILES_SETTING_VALUE_2DIM_ARRAY_BSTR_BSTR = 4, } enum OFFLINEFILES_SYNC_OPERATION { OFFLINEFILES_SYNC_OPERATION_CREATE_COPY_ON_SERVER = 0, OFFLINEFILES_SYNC_OPERATION_CREATE_COPY_ON_CLIENT = 1, OFFLINEFILES_SYNC_OPERATION_SYNC_TO_SERVER = 2, OFFLINEFILES_SYNC_OPERATION_SYNC_TO_CLIENT = 3, OFFLINEFILES_SYNC_OPERATION_DELETE_SERVER_COPY = 4, OFFLINEFILES_SYNC_OPERATION_DELETE_CLIENT_COPY = 5, OFFLINEFILES_SYNC_OPERATION_PIN = 6, OFFLINEFILES_SYNC_OPERATION_PREPARE = 7, } enum OFFLINEFILES_SYNC_STATE { OFFLINEFILES_SYNC_STATE_Stable = 0, OFFLINEFILES_SYNC_STATE_FileOnClient_DirOnServer = 1, OFFLINEFILES_SYNC_STATE_FileOnClient_NoServerCopy = 2, OFFLINEFILES_SYNC_STATE_DirOnClient_FileOnServer = 3, OFFLINEFILES_SYNC_STATE_DirOnClient_FileChangedOnServer = 4, OFFLINEFILES_SYNC_STATE_DirOnClient_NoServerCopy = 5, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_NoServerCopy = 6, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_FileChangedOnServer = 7, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_DirChangedOnServer = 8, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_FileOnServer = 9, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_DirOnServer = 10, OFFLINEFILES_SYNC_STATE_FileCreatedOnClient_DeletedOnServer = 11, OFFLINEFILES_SYNC_STATE_FileChangedOnClient_ChangedOnServer = 12, OFFLINEFILES_SYNC_STATE_FileChangedOnClient_DirOnServer = 13, OFFLINEFILES_SYNC_STATE_FileChangedOnClient_DirChangedOnServer = 14, OFFLINEFILES_SYNC_STATE_FileChangedOnClient_DeletedOnServer = 15, OFFLINEFILES_SYNC_STATE_FileSparseOnClient_ChangedOnServer = 16, OFFLINEFILES_SYNC_STATE_FileSparseOnClient_DeletedOnServer = 17, OFFLINEFILES_SYNC_STATE_FileSparseOnClient_DirOnServer = 18, OFFLINEFILES_SYNC_STATE_FileSparseOnClient_DirChangedOnServer = 19, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_NoServerCopy = 20, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_DirOnServer = 21, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_FileOnServer = 22, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_FileChangedOnServer = 23, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_DirChangedOnServer = 24, OFFLINEFILES_SYNC_STATE_DirCreatedOnClient_DeletedOnServer = 25, OFFLINEFILES_SYNC_STATE_DirChangedOnClient_FileOnServer = 26, OFFLINEFILES_SYNC_STATE_DirChangedOnClient_FileChangedOnServer = 27, OFFLINEFILES_SYNC_STATE_DirChangedOnClient_ChangedOnServer = 28, OFFLINEFILES_SYNC_STATE_DirChangedOnClient_DeletedOnServer = 29, OFFLINEFILES_SYNC_STATE_NoClientCopy_FileOnServer = 30, OFFLINEFILES_SYNC_STATE_NoClientCopy_DirOnServer = 31, OFFLINEFILES_SYNC_STATE_NoClientCopy_FileChangedOnServer = 32, OFFLINEFILES_SYNC_STATE_NoClientCopy_DirChangedOnServer = 33, OFFLINEFILES_SYNC_STATE_DeletedOnClient_FileOnServer = 34, OFFLINEFILES_SYNC_STATE_DeletedOnClient_DirOnServer = 35, OFFLINEFILES_SYNC_STATE_DeletedOnClient_FileChangedOnServer = 36, OFFLINEFILES_SYNC_STATE_DeletedOnClient_DirChangedOnServer = 37, OFFLINEFILES_SYNC_STATE_FileSparseOnClient = 38, OFFLINEFILES_SYNC_STATE_FileChangedOnClient = 39, OFFLINEFILES_SYNC_STATE_FileRenamedOnClient = 40, OFFLINEFILES_SYNC_STATE_DirSparseOnClient = 41, OFFLINEFILES_SYNC_STATE_DirChangedOnClient = 42, OFFLINEFILES_SYNC_STATE_DirRenamedOnClient = 43, OFFLINEFILES_SYNC_STATE_FileChangedOnServer = 44, OFFLINEFILES_SYNC_STATE_FileRenamedOnServer = 45, OFFLINEFILES_SYNC_STATE_FileDeletedOnServer = 46, OFFLINEFILES_SYNC_STATE_DirChangedOnServer = 47, OFFLINEFILES_SYNC_STATE_DirRenamedOnServer = 48, OFFLINEFILES_SYNC_STATE_DirDeletedOnServer = 49, OFFLINEFILES_SYNC_STATE_FileReplacedAndDeletedOnClient_FileOnServer = 50, OFFLINEFILES_SYNC_STATE_FileReplacedAndDeletedOnClient_FileChangedOnServer = 51, OFFLINEFILES_SYNC_STATE_FileReplacedAndDeletedOnClient_DirOnServer = 52, OFFLINEFILES_SYNC_STATE_FileReplacedAndDeletedOnClient_DirChangedOnServer = 53, OFFLINEFILES_SYNC_STATE_NUMSTATES = 54, } const GUID IID_IOfflineFilesEvents = {0xE25585C1, 0x0CAA, 0x4EB1, [0x87, 0x3B, 0x1C, 0xAE, 0x5B, 0x77, 0xC3, 0x14]}; @GUID(0xE25585C1, 0x0CAA, 0x4EB1, [0x87, 0x3B, 0x1C, 0xAE, 0x5B, 0x77, 0xC3, 0x14]); interface IOfflineFilesEvents : IUnknown { HRESULT CacheMoved(const(wchar)* pszOldPath, const(wchar)* pszNewPath); HRESULT CacheIsFull(); HRESULT CacheIsCorrupted(); HRESULT Enabled(BOOL bEnabled); HRESULT EncryptionChanged(BOOL bWasEncrypted, BOOL bWasPartial, BOOL bIsEncrypted, BOOL bIsPartial); HRESULT SyncBegin(const(Guid)* rSyncId); HRESULT SyncFileResult(const(Guid)* rSyncId, const(wchar)* pszFile, HRESULT hrResult); HRESULT SyncConflictRecAdded(const(wchar)* pszConflictPath, const(FILETIME)* pftConflictDateTime, OFFLINEFILES_SYNC_STATE ConflictSyncState); HRESULT SyncConflictRecUpdated(const(wchar)* pszConflictPath, const(FILETIME)* pftConflictDateTime, OFFLINEFILES_SYNC_STATE ConflictSyncState); HRESULT SyncConflictRecRemoved(const(wchar)* pszConflictPath, const(FILETIME)* pftConflictDateTime, OFFLINEFILES_SYNC_STATE ConflictSyncState); HRESULT SyncEnd(const(Guid)* rSyncId, HRESULT hrResult); HRESULT NetTransportArrived(); HRESULT NoNetTransports(); HRESULT ItemDisconnected(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemReconnected(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemAvailableOffline(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemNotAvailableOffline(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemPinned(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemNotPinned(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemModified(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType, BOOL bModifiedData, BOOL bModifiedAttributes); HRESULT ItemAddedToCache(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemDeletedFromCache(const(wchar)* pszPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT ItemRenamed(const(wchar)* pszOldPath, const(wchar)* pszNewPath, OFFLINEFILES_ITEM_TYPE ItemType); HRESULT DataLost(); HRESULT Ping(); } const GUID IID_IOfflineFilesEvents2 = {0x1EAD8F56, 0xFF76, 0x4FAA, [0xA7, 0x95, 0x6F, 0x6E, 0xF7, 0x92, 0x49, 0x8B]}; @GUID(0x1EAD8F56, 0xFF76, 0x4FAA, [0xA7, 0x95, 0x6F, 0x6E, 0xF7, 0x92, 0x49, 0x8B]); interface IOfflineFilesEvents2 : IOfflineFilesEvents { HRESULT ItemReconnectBegin(); HRESULT ItemReconnectEnd(); HRESULT CacheEvictBegin(); HRESULT CacheEvictEnd(); HRESULT BackgroundSyncBegin(uint dwSyncControlFlags); HRESULT BackgroundSyncEnd(uint dwSyncControlFlags); HRESULT PolicyChangeDetected(); HRESULT PreferenceChangeDetected(); HRESULT SettingsChangesApplied(); } const GUID IID_IOfflineFilesEvents3 = {0x9BA04A45, 0xEE69, 0x42F0, [0x9A, 0xB1, 0x7D, 0xB5, 0xC8, 0x80, 0x58, 0x08]}; @GUID(0x9BA04A45, 0xEE69, 0x42F0, [0x9A, 0xB1, 0x7D, 0xB5, 0xC8, 0x80, 0x58, 0x08]); interface IOfflineFilesEvents3 : IOfflineFilesEvents2 { HRESULT TransparentCacheItemNotify(const(wchar)* pszPath, OFFLINEFILES_EVENTS EventType, OFFLINEFILES_ITEM_TYPE ItemType, BOOL bModifiedData, BOOL bModifiedAttributes, const(wchar)* pzsOldPath); HRESULT PrefetchFileBegin(const(wchar)* pszPath); HRESULT PrefetchFileEnd(const(wchar)* pszPath, HRESULT hrResult); } const GUID IID_IOfflineFilesEvents4 = {0xDBD69B1E, 0xC7D2, 0x473E, [0xB3, 0x5F, 0x9D, 0x8C, 0x24, 0xC0, 0xC4, 0x84]}; @GUID(0xDBD69B1E, 0xC7D2, 0x473E, [0xB3, 0x5F, 0x9D, 0x8C, 0x24, 0xC0, 0xC4, 0x84]); interface IOfflineFilesEvents4 : IOfflineFilesEvents3 { HRESULT PrefetchCloseHandleBegin(); HRESULT PrefetchCloseHandleEnd(uint dwClosedHandleCount, uint dwOpenHandleCount, HRESULT hrResult); } const GUID IID_IOfflineFilesEventsFilter = {0x33FC4E1B, 0x0716, 0x40FA, [0xBA, 0x65, 0x6E, 0x62, 0xA8, 0x4A, 0x84, 0x6F]}; @GUID(0x33FC4E1B, 0x0716, 0x40FA, [0xBA, 0x65, 0x6E, 0x62, 0xA8, 0x4A, 0x84, 0x6F]); interface IOfflineFilesEventsFilter : IUnknown { HRESULT GetPathFilter(ushort** ppszFilter, OFFLINEFILES_PATHFILTER_MATCH* pMatch); HRESULT GetIncludedEvents(uint cElements, char* prgEvents, uint* pcEvents); HRESULT GetExcludedEvents(uint cElements, char* prgEvents, uint* pcEvents); } const GUID IID_IOfflineFilesErrorInfo = {0x7112FA5F, 0x7571, 0x435A, [0x8E, 0xB7, 0x19, 0x5C, 0x7C, 0x14, 0x29, 0xBC]}; @GUID(0x7112FA5F, 0x7571, 0x435A, [0x8E, 0xB7, 0x19, 0x5C, 0x7C, 0x14, 0x29, 0xBC]); interface IOfflineFilesErrorInfo : IUnknown { HRESULT GetRawData(BYTE_BLOB** ppBlob); HRESULT GetDescription(ushort** ppszDescription); } const GUID IID_IOfflineFilesSyncErrorItemInfo = {0xECDBAF0D, 0x6A18, 0x4D55, [0x80, 0x17, 0x10, 0x8F, 0x76, 0x60, 0xBA, 0x44]}; @GUID(0xECDBAF0D, 0x6A18, 0x4D55, [0x80, 0x17, 0x10, 0x8F, 0x76, 0x60, 0xBA, 0x44]); interface IOfflineFilesSyncErrorItemInfo : IUnknown { HRESULT GetFileAttributesA(uint* pdwAttributes); HRESULT GetFileTimes(FILETIME* pftLastWrite, FILETIME* pftChange); HRESULT GetFileSize(LARGE_INTEGER* pSize); } const GUID IID_IOfflineFilesSyncErrorInfo = {0x59F95E46, 0xEB54, 0x49D1, [0xBE, 0x76, 0xDE, 0x95, 0x45, 0x8D, 0x01, 0xB0]}; @GUID(0x59F95E46, 0xEB54, 0x49D1, [0xBE, 0x76, 0xDE, 0x95, 0x45, 0x8D, 0x01, 0xB0]); interface IOfflineFilesSyncErrorInfo : IOfflineFilesErrorInfo { HRESULT GetSyncOperation(OFFLINEFILES_SYNC_OPERATION* pSyncOp); HRESULT GetItemChangeFlags(uint* pdwItemChangeFlags); HRESULT InfoEnumerated(int* pbLocalEnumerated, int* pbRemoteEnumerated, int* pbOriginalEnumerated); HRESULT InfoAvailable(int* pbLocalInfo, int* pbRemoteInfo, int* pbOriginalInfo); HRESULT GetLocalInfo(IOfflineFilesSyncErrorItemInfo* ppInfo); HRESULT GetRemoteInfo(IOfflineFilesSyncErrorItemInfo* ppInfo); HRESULT GetOriginalInfo(IOfflineFilesSyncErrorItemInfo* ppInfo); } const GUID IID_IOfflineFilesProgress = {0xFAD63237, 0xC55B, 0x4911, [0x98, 0x50, 0xBC, 0xF9, 0x6D, 0x4C, 0x97, 0x9E]}; @GUID(0xFAD63237, 0xC55B, 0x4911, [0x98, 0x50, 0xBC, 0xF9, 0x6D, 0x4C, 0x97, 0x9E]); interface IOfflineFilesProgress : IUnknown { HRESULT Begin(int* pbAbort); HRESULT QueryAbort(int* pbAbort); HRESULT End(HRESULT hrResult); } const GUID IID_IOfflineFilesSimpleProgress = {0xC34F7F9B, 0xC43D, 0x4F9D, [0xA7, 0x76, 0xC0, 0xEB, 0x6D, 0xE5, 0xD4, 0x01]}; @GUID(0xC34F7F9B, 0xC43D, 0x4F9D, [0xA7, 0x76, 0xC0, 0xEB, 0x6D, 0xE5, 0xD4, 0x01]); interface IOfflineFilesSimpleProgress : IOfflineFilesProgress { HRESULT ItemBegin(const(wchar)* pszFile, OFFLINEFILES_OP_RESPONSE* pResponse); HRESULT ItemResult(const(wchar)* pszFile, HRESULT hrResult, OFFLINEFILES_OP_RESPONSE* pResponse); } const GUID IID_IOfflineFilesSyncProgress = {0x6931F49A, 0x6FC7, 0x4C1B, [0xB2, 0x65, 0x56, 0x79, 0x3F, 0xC4, 0x51, 0xB7]}; @GUID(0x6931F49A, 0x6FC7, 0x4C1B, [0xB2, 0x65, 0x56, 0x79, 0x3F, 0xC4, 0x51, 0xB7]); interface IOfflineFilesSyncProgress : IOfflineFilesProgress { HRESULT SyncItemBegin(const(wchar)* pszFile, OFFLINEFILES_OP_RESPONSE* pResponse); HRESULT SyncItemResult(const(wchar)* pszFile, HRESULT hrResult, IOfflineFilesSyncErrorInfo pErrorInfo, OFFLINEFILES_OP_RESPONSE* pResponse); } const GUID IID_IOfflineFilesSyncConflictHandler = {0xB6DD5092, 0xC65C, 0x46B6, [0x97, 0xB8, 0xFA, 0xDD, 0x08, 0xE7, 0xE1, 0xBE]}; @GUID(0xB6DD5092, 0xC65C, 0x46B6, [0x97, 0xB8, 0xFA, 0xDD, 0x08, 0xE7, 0xE1, 0xBE]); interface IOfflineFilesSyncConflictHandler : IUnknown { HRESULT ResolveConflict(const(wchar)* pszPath, uint fStateKnown, OFFLINEFILES_SYNC_STATE state, uint fChangeDetails, OFFLINEFILES_SYNC_CONFLICT_RESOLVE* pConflictResolution, ushort** ppszNewName); } const GUID IID_IOfflineFilesItemFilter = {0xF4B5A26C, 0xDC05, 0x4F20, [0xAD, 0xA4, 0x55, 0x1F, 0x10, 0x77, 0xBE, 0x5C]}; @GUID(0xF4B5A26C, 0xDC05, 0x4F20, [0xAD, 0xA4, 0x55, 0x1F, 0x10, 0x77, 0xBE, 0x5C]); interface IOfflineFilesItemFilter : IUnknown { HRESULT GetFilterFlags(ulong* pullFlags, ulong* pullMask); HRESULT GetTimeFilter(FILETIME* pftTime, int* pbEvalTimeOfDay, OFFLINEFILES_ITEM_TIME* pTimeType, OFFLINEFILES_COMPARE* pCompare); HRESULT GetPatternFilter(const(wchar)* pszPattern, uint cchPattern); } const GUID IID_IOfflineFilesItem = {0x4A753DA6, 0xE044, 0x4F12, [0xA7, 0x18, 0x5D, 0x14, 0xD0, 0x79, 0xA9, 0x06]}; @GUID(0x4A753DA6, 0xE044, 0x4F12, [0xA7, 0x18, 0x5D, 0x14, 0xD0, 0x79, 0xA9, 0x06]); interface IOfflineFilesItem : IUnknown { HRESULT GetItemType(OFFLINEFILES_ITEM_TYPE* pItemType); HRESULT GetPath(ushort** ppszPath); HRESULT GetParentItem(IOfflineFilesItem* ppItem); HRESULT Refresh(uint dwQueryFlags); HRESULT IsMarkedForDeletion(int* pbMarkedForDeletion); } const GUID IID_IOfflineFilesServerItem = {0x9B1C9576, 0xA92B, 0x4151, [0x8E, 0x9E, 0x7C, 0x7B, 0x3E, 0xC2, 0xE0, 0x16]}; @GUID(0x9B1C9576, 0xA92B, 0x4151, [0x8E, 0x9E, 0x7C, 0x7B, 0x3E, 0xC2, 0xE0, 0x16]); interface IOfflineFilesServerItem : IOfflineFilesItem { } const GUID IID_IOfflineFilesShareItem = {0xBAB7E48D, 0x4804, 0x41B5, [0xA4, 0x4D, 0x0F, 0x19, 0x9B, 0x06, 0xB1, 0x45]}; @GUID(0xBAB7E48D, 0x4804, 0x41B5, [0xA4, 0x4D, 0x0F, 0x19, 0x9B, 0x06, 0xB1, 0x45]); interface IOfflineFilesShareItem : IOfflineFilesItem { } const GUID IID_IOfflineFilesDirectoryItem = {0x2273597A, 0xA08C, 0x4A00, [0xA3, 0x7A, 0xC1, 0xAE, 0x4E, 0x9A, 0x1C, 0xFD]}; @GUID(0x2273597A, 0xA08C, 0x4A00, [0xA3, 0x7A, 0xC1, 0xAE, 0x4E, 0x9A, 0x1C, 0xFD]); interface IOfflineFilesDirectoryItem : IOfflineFilesItem { } const GUID IID_IOfflineFilesFileItem = {0x8DFADEAD, 0x26C2, 0x4EFF, [0x8A, 0x72, 0x6B, 0x50, 0x72, 0x3D, 0x9A, 0x00]}; @GUID(0x8DFADEAD, 0x26C2, 0x4EFF, [0x8A, 0x72, 0x6B, 0x50, 0x72, 0x3D, 0x9A, 0x00]); interface IOfflineFilesFileItem : IOfflineFilesItem { HRESULT IsSparse(int* pbIsSparse); HRESULT IsEncrypted(int* pbIsEncrypted); } const GUID IID_IEnumOfflineFilesItems = {0xDA70E815, 0xC361, 0x4407, [0xBC, 0x0B, 0x0D, 0x70, 0x46, 0xE5, 0xF2, 0xCD]}; @GUID(0xDA70E815, 0xC361, 0x4407, [0xBC, 0x0B, 0x0D, 0x70, 0x46, 0xE5, 0xF2, 0xCD]); interface IEnumOfflineFilesItems : IUnknown { HRESULT Next(uint celt, char* rgelt, uint* pceltFetched); HRESULT Skip(uint celt); HRESULT Reset(); HRESULT Clone(IEnumOfflineFilesItems* ppenum); } const GUID IID_IOfflineFilesItemContainer = {0x3836F049, 0x9413, 0x45DD, [0xBF, 0x46, 0xB5, 0xAA, 0xA8, 0x2D, 0xC3, 0x10]}; @GUID(0x3836F049, 0x9413, 0x45DD, [0xBF, 0x46, 0xB5, 0xAA, 0xA8, 0x2D, 0xC3, 0x10]); interface IOfflineFilesItemContainer : IUnknown { HRESULT EnumItems(uint dwQueryFlags, IEnumOfflineFilesItems* ppenum); HRESULT EnumItemsEx(IOfflineFilesItemFilter pIncludeFileFilter, IOfflineFilesItemFilter pIncludeDirFilter, IOfflineFilesItemFilter pExcludeFileFilter, IOfflineFilesItemFilter pExcludeDirFilter, uint dwEnumFlags, uint dwQueryFlags, IEnumOfflineFilesItems* ppenum); } const GUID IID_IOfflineFilesChangeInfo = {0xA96E6FA4, 0xE0D1, 0x4C29, [0x96, 0x0B, 0xEE, 0x50, 0x8F, 0xE6, 0x8C, 0x72]}; @GUID(0xA96E6FA4, 0xE0D1, 0x4C29, [0x96, 0x0B, 0xEE, 0x50, 0x8F, 0xE6, 0x8C, 0x72]); interface IOfflineFilesChangeInfo : IUnknown { HRESULT IsDirty(int* pbDirty); HRESULT IsDeletedOffline(int* pbDeletedOffline); HRESULT IsCreatedOffline(int* pbCreatedOffline); HRESULT IsLocallyModifiedData(int* pbLocallyModifiedData); HRESULT IsLocallyModifiedAttributes(int* pbLocallyModifiedAttributes); HRESULT IsLocallyModifiedTime(int* pbLocallyModifiedTime); } const GUID IID_IOfflineFilesDirtyInfo = {0x0F50CE33, 0xBAC9, 0x4EAA, [0xA1, 0x1D, 0xDA, 0x0E, 0x52, 0x7D, 0x04, 0x7D]}; @GUID(0x0F50CE33, 0xBAC9, 0x4EAA, [0xA1, 0x1D, 0xDA, 0x0E, 0x52, 0x7D, 0x04, 0x7D]); interface IOfflineFilesDirtyInfo : IUnknown { HRESULT LocalDirtyByteCount(LARGE_INTEGER* pDirtyByteCount); HRESULT RemoteDirtyByteCount(LARGE_INTEGER* pDirtyByteCount); } const GUID IID_IOfflineFilesFileSysInfo = {0xBC1A163F, 0x7BFD, 0x4D88, [0x9C, 0x66, 0x96, 0xEA, 0x9A, 0x6A, 0x3D, 0x6B]}; @GUID(0xBC1A163F, 0x7BFD, 0x4D88, [0x9C, 0x66, 0x96, 0xEA, 0x9A, 0x6A, 0x3D, 0x6B]); interface IOfflineFilesFileSysInfo : IUnknown { HRESULT GetAttributes(OFFLINEFILES_ITEM_COPY copy, uint* pdwAttributes); HRESULT GetTimes(OFFLINEFILES_ITEM_COPY copy, FILETIME* pftCreationTime, FILETIME* pftLastWriteTime, FILETIME* pftChangeTime, FILETIME* pftLastAccessTime); HRESULT GetFileSize(OFFLINEFILES_ITEM_COPY copy, LARGE_INTEGER* pSize); } const GUID IID_IOfflineFilesPinInfo = {0x5B2B0655, 0xB3FD, 0x497D, [0xAD, 0xEB, 0xBD, 0x15, 0x6B, 0xC8, 0x35, 0x5B]}; @GUID(0x5B2B0655, 0xB3FD, 0x497D, [0xAD, 0xEB, 0xBD, 0x15, 0x6B, 0xC8, 0x35, 0x5B]); interface IOfflineFilesPinInfo : IUnknown { HRESULT IsPinned(int* pbPinned); HRESULT IsPinnedForUser(int* pbPinnedForUser, int* pbInherit); HRESULT IsPinnedForUserByPolicy(int* pbPinnedForUser, int* pbInherit); HRESULT IsPinnedForComputer(int* pbPinnedForComputer, int* pbInherit); HRESULT IsPinnedForFolderRedirection(int* pbPinnedForFolderRedirection, int* pbInherit); } const GUID IID_IOfflineFilesPinInfo2 = {0x623C58A2, 0x42ED, 0x4AD7, [0xB6, 0x9A, 0x0F, 0x1B, 0x30, 0xA7, 0x2D, 0x0D]}; @GUID(0x623C58A2, 0x42ED, 0x4AD7, [0xB6, 0x9A, 0x0F, 0x1B, 0x30, 0xA7, 0x2D, 0x0D]); interface IOfflineFilesPinInfo2 : IOfflineFilesPinInfo { HRESULT IsPartlyPinned(int* pbPartlyPinned); } const GUID IID_IOfflineFilesTransparentCacheInfo = {0xBCAF4A01, 0x5B68, 0x4B56, [0xA6, 0xA1, 0x8D, 0x27, 0x86, 0xED, 0xE8, 0xE3]}; @GUID(0xBCAF4A01, 0x5B68, 0x4B56, [0xA6, 0xA1, 0x8D, 0x27, 0x86, 0xED, 0xE8, 0xE3]); interface IOfflineFilesTransparentCacheInfo : IUnknown { HRESULT IsTransparentlyCached(int* pbTransparentlyCached); } const GUID IID_IOfflineFilesGhostInfo = {0x2B09D48C, 0x8AB5, 0x464F, [0xA7, 0x55, 0xA5, 0x9D, 0x92, 0xF9, 0x94, 0x29]}; @GUID(0x2B09D48C, 0x8AB5, 0x464F, [0xA7, 0x55, 0xA5, 0x9D, 0x92, 0xF9, 0x94, 0x29]); interface IOfflineFilesGhostInfo : IUnknown { HRESULT IsGhosted(int* pbGhosted); } const GUID IID_IOfflineFilesConnectionInfo = {0xEFB23A09, 0xA867, 0x4BE8, [0x83, 0xA6, 0x86, 0x96, 0x9A, 0x7D, 0x08, 0x56]}; @GUID(0xEFB23A09, 0xA867, 0x4BE8, [0x83, 0xA6, 0x86, 0x96, 0x9A, 0x7D, 0x08, 0x56]); interface IOfflineFilesConnectionInfo : IUnknown { HRESULT GetConnectState(OFFLINEFILES_CONNECT_STATE* pConnectState, OFFLINEFILES_OFFLINE_REASON* pOfflineReason); HRESULT SetConnectState(HWND hwndParent, uint dwFlags, OFFLINEFILES_CONNECT_STATE ConnectState); HRESULT TransitionOnline(HWND hwndParent, uint dwFlags); HRESULT TransitionOffline(HWND hwndParent, uint dwFlags, BOOL bForceOpenFilesClosed, int* pbOpenFilesPreventedTransition); } const GUID IID_IOfflineFilesShareInfo = {0x7BCC43E7, 0x31CE, 0x4CA4, [0x8C, 0xCD, 0x1C, 0xFF, 0x2D, 0xC4, 0x94, 0xDA]}; @GUID(0x7BCC43E7, 0x31CE, 0x4CA4, [0x8C, 0xCD, 0x1C, 0xFF, 0x2D, 0xC4, 0x94, 0xDA]); interface IOfflineFilesShareInfo : IUnknown { HRESULT GetShareItem(IOfflineFilesShareItem* ppShareItem); HRESULT GetShareCachingMode(OFFLINEFILES_CACHING_MODE* pCachingMode); HRESULT IsShareDfsJunction(int* pbIsDfsJunction); } const GUID IID_IOfflineFilesSuspend = {0x62C4560F, 0xBC0B, 0x48CA, [0xAD, 0x9D, 0x34, 0xCB, 0x52, 0x8D, 0x99, 0xA9]}; @GUID(0x62C4560F, 0xBC0B, 0x48CA, [0xAD, 0x9D, 0x34, 0xCB, 0x52, 0x8D, 0x99, 0xA9]); interface IOfflineFilesSuspend : IUnknown { HRESULT SuspendRoot(BOOL bSuspend); } const GUID IID_IOfflineFilesSuspendInfo = {0xA457C25B, 0x4E9C, 0x4B04, [0x85, 0xAF, 0x89, 0x32, 0xCC, 0xD9, 0x78, 0x89]}; @GUID(0xA457C25B, 0x4E9C, 0x4B04, [0x85, 0xAF, 0x89, 0x32, 0xCC, 0xD9, 0x78, 0x89]); interface IOfflineFilesSuspendInfo : IUnknown { HRESULT IsSuspended(int* pbSuspended, int* pbSuspendedRoot); } const GUID IID_IOfflineFilesSetting = {0xD871D3F7, 0xF613, 0x48A1, [0x82, 0x7E, 0x7A, 0x34, 0xE5, 0x60, 0xFF, 0xF6]}; @GUID(0xD871D3F7, 0xF613, 0x48A1, [0x82, 0x7E, 0x7A, 0x34, 0xE5, 0x60, 0xFF, 0xF6]); interface IOfflineFilesSetting : IUnknown { HRESULT GetName(ushort** ppszName); HRESULT GetValueType(OFFLINEFILES_SETTING_VALUE_TYPE* pType); HRESULT GetPreference(VARIANT* pvarValue, uint dwScope); HRESULT GetPreferenceScope(uint* pdwScope); HRESULT SetPreference(const(VARIANT)* pvarValue, uint dwScope); HRESULT DeletePreference(uint dwScope); HRESULT GetPolicy(VARIANT* pvarValue, uint dwScope); HRESULT GetPolicyScope(uint* pdwScope); HRESULT GetValue(VARIANT* pvarValue, int* pbSetByPolicy); } const GUID IID_IEnumOfflineFilesSettings = {0x729680C4, 0x1A38, 0x47BC, [0x9E, 0x5C, 0x02, 0xC5, 0x15, 0x62, 0xAC, 0x30]}; @GUID(0x729680C4, 0x1A38, 0x47BC, [0x9E, 0x5C, 0x02, 0xC5, 0x15, 0x62, 0xAC, 0x30]); interface IEnumOfflineFilesSettings : IUnknown { HRESULT Next(uint celt, char* rgelt, uint* pceltFetched); HRESULT Skip(uint celt); HRESULT Reset(); HRESULT Clone(IEnumOfflineFilesSettings* ppenum); } const GUID IID_IOfflineFilesCache = {0x855D6203, 0x7914, 0x48B9, [0x8D, 0x40, 0x4C, 0x56, 0xF5, 0xAC, 0xFF, 0xC5]}; @GUID(0x855D6203, 0x7914, 0x48B9, [0x8D, 0x40, 0x4C, 0x56, 0xF5, 0xAC, 0xFF, 0xC5]); interface IOfflineFilesCache : IUnknown { HRESULT Synchronize(HWND hwndParent, char* rgpszPaths, uint cPaths, BOOL bAsync, uint dwSyncControl, IOfflineFilesSyncConflictHandler pISyncConflictHandler, IOfflineFilesSyncProgress pIProgress, Guid* pSyncId); HRESULT DeleteItems(char* rgpszPaths, uint cPaths, uint dwFlags, BOOL bAsync, IOfflineFilesSimpleProgress pIProgress); HRESULT DeleteItemsForUser(const(wchar)* pszUser, char* rgpszPaths, uint cPaths, uint dwFlags, BOOL bAsync, IOfflineFilesSimpleProgress pIProgress); HRESULT Pin(HWND hwndParent, char* rgpszPaths, uint cPaths, BOOL bDeep, BOOL bAsync, uint dwPinControlFlags, IOfflineFilesSyncProgress pIProgress); HRESULT Unpin(HWND hwndParent, char* rgpszPaths, uint cPaths, BOOL bDeep, BOOL bAsync, uint dwPinControlFlags, IOfflineFilesSyncProgress pIProgress); HRESULT GetEncryptionStatus(int* pbEncrypted, int* pbPartial); HRESULT Encrypt(HWND hwndParent, BOOL bEncrypt, uint dwEncryptionControlFlags, BOOL bAsync, IOfflineFilesSyncProgress pIProgress); HRESULT FindItem(const(wchar)* pszPath, uint dwQueryFlags, IOfflineFilesItem* ppItem); HRESULT FindItemEx(const(wchar)* pszPath, IOfflineFilesItemFilter pIncludeFileFilter, IOfflineFilesItemFilter pIncludeDirFilter, IOfflineFilesItemFilter pExcludeFileFilter, IOfflineFilesItemFilter pExcludeDirFilter, uint dwQueryFlags, IOfflineFilesItem* ppItem); HRESULT RenameItem(const(wchar)* pszPathOriginal, const(wchar)* pszPathNew, BOOL bReplaceIfExists); HRESULT GetLocation(ushort** ppszPath); HRESULT GetDiskSpaceInformationA(ulong* pcbVolumeTotal, ulong* pcbLimit, ulong* pcbUsed, ulong* pcbUnpinnedLimit, ulong* pcbUnpinnedUsed); HRESULT SetDiskSpaceLimits(ulong cbLimit, ulong cbUnpinnedLimit); HRESULT ProcessAdminPinPolicy(IOfflineFilesSyncProgress pPinProgress, IOfflineFilesSyncProgress pUnpinProgress); HRESULT GetSettingObject(const(wchar)* pszSettingName, IOfflineFilesSetting* ppSetting); HRESULT EnumSettingObjects(IEnumOfflineFilesSettings* ppEnum); HRESULT IsPathCacheable(const(wchar)* pszPath, int* pbCacheable, OFFLINEFILES_CACHING_MODE* pShareCachingMode); } const GUID IID_IOfflineFilesCache2 = {0x8C075039, 0x1551, 0x4ED9, [0x87, 0x81, 0x56, 0x70, 0x5C, 0x04, 0xD3, 0xC0]}; @GUID(0x8C075039, 0x1551, 0x4ED9, [0x87, 0x81, 0x56, 0x70, 0x5C, 0x04, 0xD3, 0xC0]); interface IOfflineFilesCache2 : IOfflineFilesCache { HRESULT RenameItemEx(const(wchar)* pszPathOriginal, const(wchar)* pszPathNew, BOOL bReplaceIfExists); } @DllImport("CSCAPI.dll") uint OfflineFilesEnable(BOOL bEnable, int* pbRebootRequired); @DllImport("CSCAPI.dll") uint OfflineFilesStart(); @DllImport("CSCAPI.dll") uint OfflineFilesQueryStatus(int* pbActive, int* pbEnabled); @DllImport("CSCAPI.dll") uint OfflineFilesQueryStatusEx(int* pbActive, int* pbEnabled, int* pbAvailable);
D
module org.serviio.library.dao.MetadataDescriptorDAOImpl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.serviio.db.DatabaseManager; import org.serviio.db.dao.InvalidArgumentException; import org.serviio.db.dao.PersistenceException; import org.serviio.library.entities.MetadataDescriptor; import org.serviio.library.local.metadata.extractor.ExtractorType; import org.serviio.util.JdbcUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MetadataDescriptorDAOImpl : MetadataDescriptorDAO { private static final Logger log = LoggerFactory.getLogger!(MetadataDescriptorDAOImpl)(); public long create(MetadataDescriptor newInstance) { if ((newInstance is null) || (newInstance.getExtractorType() is null) || (newInstance.getMediaItemId() is null) || (newInstance.getDateUpdated() is null)) { throw new InvalidArgumentException("Cannot create MetadataDescriptor. Required data is missing."); } log.debug_(String.format("Creating a new MetadataDescriptor (type = %s, mediaItemId = %s)", cast(Object[])[ newInstance.getExtractorType(), newInstance.getMediaItemId() ])); Connection con = null; PreparedStatement ps = null; try { con = DatabaseManager.getConnection(); ps = con.prepareStatement("INSERT INTO metadata_descriptor (extractor_type, date_updated, media_item_id, identifier) VALUES (?,?,?,?)", 1); ps.setString(1, newInstance.getExtractorType().toString()); ps.setTimestamp(2, new Timestamp(newInstance.getDateUpdated().getTime())); ps.setLong(3, newInstance.getMediaItemId().longValue()); JdbcUtils.setStringValueOnStatement(ps, 4, newInstance.getIdentifier()); ps.executeUpdate(); return JdbcUtils.retrieveGeneratedID(ps); } catch (SQLException e) { throw new PersistenceException(String.format("Cannot create MetadataDescriptor with type %s for mediaItem %s", cast(Object[])[ newInstance.getExtractorType(), newInstance.getMediaItemId() ]), e); } finally { JdbcUtils.closeStatement(ps); DatabaseManager.releaseConnection(con); } } public void delete_(Long id) { log.debug_(String.format("Deleting a MetadataDescriptor (id = %s)", cast(Object[])[ id ])); Connection con = null; PreparedStatement ps = null; try { con = DatabaseManager.getConnection(); ps = con.prepareStatement("DELETE FROM metadata_descriptor WHERE id = ?"); ps.setLong(1, id.longValue()); ps.executeUpdate(); } catch (SQLException e) { throw new PersistenceException(String.format("Cannot delete MetadataDescriptor with id = %s", cast(Object[])[ id ]), e); } finally { JdbcUtils.closeStatement(ps); DatabaseManager.releaseConnection(con); } } public MetadataDescriptor read(Long id) { log.debug_(String.format("Reading a MetadataDescriptor (id = %s)", cast(Object[])[ id ])); Connection con = null; PreparedStatement ps = null; try { con = DatabaseManager.getConnection(); ps = con.prepareStatement("SELECT id, extractor_type, date_updated, media_item_id, identifier FROM metadata_descriptor where id = ?"); ps.setLong(1, id.longValue()); ResultSet rs = ps.executeQuery(); return mapSingleResult(rs); } catch (SQLException e) { throw new PersistenceException(String.format("Cannot read MetadataDescriptor with id = %s", cast(Object[])[ id ]), e); } finally { JdbcUtils.closeStatement(ps); DatabaseManager.releaseConnection(con); } } public void update(MetadataDescriptor transientObject) { throw new UnsupportedOperationException("MetadataDescriptor update is not supported"); } public void removeMetadataDescriptorsForMedia(Long mediaItemId) { log.debug_(String.format("Deleting all MetadataDescriptors for MediaItem (id = %s)", cast(Object[])[ mediaItemId ])); Connection con = null; PreparedStatement ps = null; try { con = DatabaseManager.getConnection(); ps = con.prepareStatement("DELETE FROM metadata_descriptor WHERE media_item_id = ?"); ps.setLong(1, mediaItemId.longValue()); ps.executeUpdate(); } catch (SQLException e) { throw new PersistenceException(String.format("Cannot delete all MetadataDescriptors for MediaItem id = %s", cast(Object[])[ mediaItemId ]), e); } finally { JdbcUtils.closeStatement(ps); DatabaseManager.releaseConnection(con); } } public MetadataDescriptor retrieveMetadataDescriptorForMedia(Long mediaItemId, ExtractorType extractorType) { log.debug_(String.format("Reading MetadataDescriptor for MediaItem (id = %s) and extractor %s", cast(Object[])[ mediaItemId, extractorType.toString() ])); Connection con = null; PreparedStatement ps = null; try { con = DatabaseManager.getConnection(); ps = con.prepareStatement("SELECT id, extractor_type, date_updated, media_item_id, identifier FROM metadata_descriptor where media_item_id = ? and extractor_type = ?"); ps.setLong(1, mediaItemId.longValue()); ps.setString(2, extractorType.toString()); ResultSet rs = ps.executeQuery(); return mapSingleResult(rs); } catch (SQLException e) { throw new PersistenceException(String.format("Cannot read MetadataDescriptor for MediaItem id = %s and extractor %s", cast(Object[])[ mediaItemId, extractorType.toString() ]), e); } finally { JdbcUtils.closeStatement(ps); DatabaseManager.releaseConnection(con); } } protected MetadataDescriptor mapSingleResult(ResultSet rs) { if (rs.next()) { return initDescriptor(rs); } return null; } protected List!(MetadataDescriptor) mapResultSet(ResultSet rs) { List!(MetadataDescriptor) result = new ArrayList!(MetadataDescriptor)(); while (rs.next()) { result.add(initDescriptor(rs)); } return result; } private MetadataDescriptor initDescriptor(ResultSet rs) { Long id = Long.valueOf(rs.getLong("id")); ExtractorType extractorType = ExtractorType.valueOf(rs.getString("extractor_type")); Date dateUpdated = rs.getTimestamp("date_updated"); Long mediaItemId = Long.valueOf(rs.getLong("media_item_id")); String identifier = rs.getString("identifier"); MetadataDescriptor descriptor = new MetadataDescriptor(extractorType, mediaItemId, dateUpdated, identifier); descriptor.setId(id); return descriptor; } } /* Location: D:\Program Files\Serviio\lib\serviio.jar * Qualified Name: org.serviio.library.dao.MetadataDescriptorDAOImpl * JD-Core Version: 0.6.2 */
D
a Belgian maker of musical instruments who invented the saxophone (1814-1894) a single-reed woodwind with a conical bore
D
// PERMUTE_ARGS: -inline template compiles(int T) { bool compiles = true; } alias TypeTuple(T...) = T; /************************************************** 3901 Arbitrary struct assignment, ref return **************************************************/ struct ArrayRet { int x; } int arrayRetTest(int z) { ArrayRet[6] w; int q = (w[3].x = z); return q; } static assert(arrayRetTest(51) == 51); // Bugzilla 3842 -- must not segfault int ice3842(int z) { ArrayRet w; return arrayRetTest((*(&w)).x); } static assert(true || is(typeof(compiles!(ice3842(51))))); int arrayret2() { int[5] a; int[3] b; b[] = a[1 .. $-1] = 5; return b[1]; } static assert(arrayret2() == 5); struct DotVarTest { ArrayRet z; } struct DotVarTest2 { ArrayRet z; DotVarTest p; } int dotvar1() { DotVarTest w; w.z.x = 3; return w.z.x; } static assert(dotvar1() == 3); int dotvar2() { DotVarTest2[4] m; m[2].z.x = 3; m[1].p.z.x = 5; return m[2].z.x + 7; } static assert(dotvar2() == 10); struct RetRefStruct { int x; char c; } // Return value reference tests, for D2 only. ref RetRefStruct reffunc1(ref RetRefStruct a) { int y = a.x; return a; } ref RetRefStruct reffunc2(ref RetRefStruct a) { RetRefStruct z = a; return reffunc1(a); } ref int reffunc7(ref RetRefStruct aa) { return reffunc1(aa).x; } ref int reffunc3(ref int a) { return a; } struct RefTestStruct { RetRefStruct r; ref RefTestStruct reffunc4(ref RetRefStruct[3] a) { return this; } ref int reffunc6() { return this.r.x; } } ref RetRefStruct reffunc5(ref RetRefStruct[3] a) { int t = 1; for (int i = 0; i < 10; ++i) { if (i == 7) ++t; } return a[reffunc3(t)]; } int retRefTest1() { RetRefStruct b = RetRefStruct(0, 'a'); reffunc1(b).x = 3; return b.x - 1; } int retRefTest2() { RetRefStruct b = RetRefStruct(0, 'a'); reffunc2(b).x = 3; RetRefStruct[3] z; RefTestStruct w; w.reffunc4(z).reffunc4(z).r.x = 4; assert(w.r.x == 4); w.reffunc6() = 218; assert(w.r.x == 218); z[2].x = 3; int q = 4; int u = reffunc5(z).x + reffunc3(q); assert(u == 7); reffunc5(z).x += 7; assert(z[2].x == 10); RetRefStruct m = RetRefStruct(7, 'c'); m.x = 6; reffunc7(m) += 3; assert(m.x == 9); return b.x - 1; } int retRefTest3() { RetRefStruct b = RetRefStruct(0, 'a'); auto deleg = function (RetRefStruct a){ return a; }; typeof(deleg)[3] z; z[] = deleg; auto y = deleg(b).x + 27; b.x = 5; assert(y == 27); y = z[1](b).x + 22; return y - 1; } int retRefTest4() { RetRefStruct b = RetRefStruct(0, 'a'); reffunc3(b.x) = 218; assert(b.x == 218); return b.x; } static assert(retRefTest1() == 2); static assert(retRefTest2() == 2); static assert(retRefTest3() == 26); static assert(retRefTest4() == 218); /************************************************** Bug 7887 assign to returned reference **************************************************/ bool test7887() { ref int f(ref int x) { return x; } int a; f(a) = 42; return (a == 42); } static assert(test7887()); /************************************************** Bug 7473 struct non-ref **************************************************/ struct S7473 { int i; } static assert({ S7473 s = S7473(1); assert(s.i == 1); bug7473(s); assert(s.i == 1); return true; }()); void bug7473(S7473 s) { s.i = 2; } struct S7473b { S7473 m; } static assert({ S7473b s = S7473b(S7473(7)); assert(s.m.i == 7); bug7473b(s); assert(s.m.i == 7); return true; }()); void bug7473b(S7473b s) { s.m.i = 2; } /************************************************** Bug 4389 **************************************************/ int bug4389() { string s; dchar c = '\u2348'; s ~= c; assert(s.length == 3); dchar d = 'D'; s ~= d; assert(s.length == 4); s = ""; s ~= c; assert(s.length == 3); s ~= d; assert(s.length == 4); string z; wchar w = '\u0300'; z ~= w; assert(z.length == 2); z = ""; z ~= w; assert(z.length == 2); return 1; } static assert(bug4389()); // ICE(constfold.c) int ice4389() { string s; dchar c = '\u2348'; s ~= c; s = s ~ "xxx"; return 1; } static assert(ice4389()); // ICE(expression.c) string ice4390() { string s; dchar c = '`'; s ~= c; s ~= c; return s; } static assert(mixin(ice4390()) == ``); // bug 5248 (D1 + D2) struct Leaf5248 { string Compile_not_ovloaded() { return "expression"; } } struct Matrix5248 { Leaf5248 Right; string Compile() { return Right.Compile_not_ovloaded(); } }; static assert(Matrix5248().Compile()); /************************************************** 4837 >>>= **************************************************/ bool bug4837() { ushort x = 0x89AB; x >>>= 4; assert(x == 0x89A); byte y = 0x7C; y >>>= 2; assert(y == 0x1F); return true; } static assert(bug4837()); /************************************************** 10252 shift out of range **************************************************/ int lshr10252(int shift) { int a = 5; return a << shift; } int rshr10252(int shift) { int a = 5; return a >> shift; } int ushr10252(int shift) { int a = 5; return a >>> shift; } static assert( is(typeof(compiles!(lshr10252( 4))))); static assert(!is(typeof(compiles!(lshr10252(60))))); static assert( is(typeof(compiles!(rshr10252( 4))))); static assert(!is(typeof(compiles!(rshr10252(80))))); static assert( is(typeof(compiles!(ushr10252( 2))))); static assert(!is(typeof(compiles!(ushr10252(60))))); /************************************************** 1982 CTFE null problems **************************************************/ enum a1982 = [1, 2, 3]; static assert(a1982 !is null); string foo1982() { return null; } static assert(foo1982() is null); static assert(!foo1982().length); static assert(null is null); /************************************************** 7988 CTFE return values should be allowed in compile-time expressions **************************************************/ class X7988 { int y; this() { y = 2; } } static assert((new X7988).y == 2); /************************************************** 8253 ICE: calling of member function of non-CTFE class variable **************************************************/ class Bug8253 { bool j() { return true; } } Bug8253 m8253; static assert(!is(typeof(compiles!(m8253.j())))); /************************************************** 8285 Issue with slice returned from CTFE function **************************************************/ string foo8285() { string s = "ab"; return s[0 .. $]; } template T8285b(string s) { } template T8285a() { enum s = foo8285(); alias T8285b!(s) t2; } int bar8285() { alias T8285a!() t1; return 0; } int baz8285(int x) { return 0; } static assert(baz8285(bar8285()) == 0); // test case 2 string xbar8285() { string s = "ab"; return s[0 .. $]; } template xT8285a() { enum xT8285a = xbar8285()[0 .. $]; } string xbaz8285() { return xT8285a!(); } string xfoo8285(string s) { return s; } static assert(xfoo8285(xbaz8285()) == "ab"); /************************************************** 'this' parameter bug revealed during refactoring **************************************************/ int thisbug1(int x) { return x; } struct ThisBug1 { int m = 1; int wut() { return thisbug1(m); } } int thisbug2() { ThisBug1 spec; return spec.wut(); } static assert(thisbug2()); /************************************************** 6972 ICE with cast()cast()assign **************************************************/ int bug6972() { ubyte n = 6; n /= 2u; return n; } static assert(bug6972() == 3); /************************************************** Bug 6164 **************************************************/ size_t bug6164() { int[] ctfe2(int n) { int[] r = []; if (n != 0) r ~= [1] ~ ctfe2(n - 1); return r; } return ctfe2(2).length; } static assert(bug6164() == 2); /************************************************** Interpreter code coverage tests **************************************************/ int cov1(int a) { a %= 15382; a /= 5; a = ~ a; bool c = (a == 0); bool b = true && c; assert(b == 0); b = false && c; assert(b == 0); b = false || c; assert(b == 0); a ^= 0x45349; a = ~ a; a &= 0xFF3F; a >>>= 1; a = a ^ 0x7393; a = a >> 1; a = a >>> 1; a = a | 0x010101; return a; } static assert(cov1(534564) == 71589); int cov2() { int i = 0; do { goto DOLABEL; DOLABEL: if (i != 0) { goto IFLABEL; IFLABEL: switch(i) { case 3: break; case 6: goto SWITCHLABEL; SWITCHLABEL: i = 27; goto case 3; default: assert(0); } return i; } i = 6; } while(true); return 88; // unreachable } static assert(cov2() == 27); template CovTuple(T...) { alias T CovTuple; } alias CovTuple!(int, long) TCov3; int cov3(TCov3 t) { TCov3 s; s = t; assert(s[0] == 1); assert(s[1] == 2); return 7; } static assert(cov3(1, 2) == 7); int badassert1(int z) { assert(z == 5, "xyz"); return 1; } size_t badslice1(int[] z) { return z[0 .. 3].length; } size_t badslice2(int[] z) { return z[0 .. badassert1(1)].length; } size_t badslice3(int[] z) { return z[badassert1(1) .. 2].length; } static assert(!is(typeof(compiles!(badassert1(67))))); static assert( is(typeof(compiles!(badassert1(5))))); static assert(!is(typeof(compiles!(badslice1([1,2]))))); static assert(!is(typeof(compiles!(badslice2([1,2]))))); static assert(!is(typeof(compiles!(badslice3([1,2,3]))))); /*******************************************/ int bug7894() { for (int k = 0; k < 2; ++k) { goto Lagain; Lagain: ; } int m = 1; do { ++m; goto Ldo; Ldo: ; } while (m < 3); assert(m == 3); return 1; } static assert(bug7894()); /*******************************************/ size_t bug5524(int x, int[] more...) { int[0] zz; assert(zz.length == 0); return 7 + more.length + x; } static assert(bug5524(3) == 10); // 5722 static assert(("" ~ "\&copy;"[0]).length == 1); const char[] null5722 = null; static assert((null5722 ~ "\&copy;"[0]).length == 1); static assert(("\&copy;"[0] ~ null5722).length == 1); /******************************************* * Tests for CTFE Array support. * Including bugs 1330, 3801, 3835, 4050, * 4051, 5147, and major functionality *******************************************/ char[] bug1330StringIndex() { char[] blah = "foo".dup; assert(blah == "foo"); char[] s = blah[0 .. 2]; blah[0] = 'h'; assert(s == "ho"); s[0] = 'm'; return blah; } static assert(bug1330StringIndex() == "moo"); static assert(bug1330StringIndex() == "moo"); // check we haven't clobbered any string literals int[] bug1330ArrayIndex() { int[] blah = [1,2,3]; int[] s = blah; s = blah[0 .. 2]; int z = blah[0] = 6; assert(z == 6); assert(blah[0] == 6); assert(s[0] == 6); assert(s == [6, 2]); s[1] = 4; assert(z == 6); return blah; } static assert(bug1330ArrayIndex() == [6, 4, 3]); static assert(bug1330ArrayIndex() == [6, 4, 3]); // check we haven't clobbered any literals char[] bug1330StringSliceAssign() { char[] blah = "food".dup; assert(blah == "food"); char[] s = blah[1 .. 4]; blah[0 .. 2] = "hc"; assert(s == "cod"); s[0 .. 2] = ['a', 'b']; // Mix string + array literal assert(blah == "habd"); s[0 .. 2] = "mq"; return blah; } static assert(bug1330StringSliceAssign() == "hmqd"); static assert(bug1330StringSliceAssign() == "hmqd"); int[] bug1330ArraySliceAssign() { int[] blah = [1, 2, 3, 4]; int[] s = blah[1 .. 4]; blah[0 .. 2] = [7, 9]; assert(s == [9, 3, 4]); s[0 .. 2] = [8, 15]; return blah; } static assert(bug1330ArraySliceAssign() == [7, 8, 15, 4]); int[] bug1330ArrayBlockAssign() { int[] blah = [1, 2, 3, 4, 5]; int[] s = blah[1 .. 4]; blah[0 .. 2] = 17; assert(s == [17, 3, 4]); s[0 .. 2] = 9; return blah; } static assert(bug1330ArrayBlockAssign() == [17, 9, 9, 4, 5]); char[] bug1330StringBlockAssign() { char[] blah = "abcde".dup; char[] s = blah[1 .. 4]; blah[0 .. 2] = 'x'; assert(s == "xcd"); s[0 .. 2] = 'y'; return blah; } static assert(bug1330StringBlockAssign() == "xyyde"); int assignAA(int x) { int[int] aa; int[int] cc = aa; assert(cc.values.length == 0); assert(cc.keys.length == 0); aa[1] = 2; aa[x] = 6; int[int] bb = aa; assert(bb.keys.length == 2); assert(cc.keys.length == 0); // cc is not affected to aa, because it is null aa[500] = 65; assert(bb.keys.length == 3); // but bb is affected by changes to aa return aa[1] + aa[x]; } static assert(assignAA(12) == 8); template Compileable(int z) { bool OK; } int arraybounds(int j, int k) { int[] xxx = [1, 2, 3, 4, 5]; int[] s = xxx[1 .. $]; s = s[j .. k]; // slice of slice return s[$ - 1]; } static assert(!is(typeof(Compileable!(arraybounds(1, 14))))); static assert(!is(typeof(Compileable!(arraybounds(15, 3))))); static assert(arraybounds(2, 4) == 5); int arraybounds2(int j, int k) { int[] xxx = [1, 2, 3, 4, 5]; int[] s = xxx[j .. k]; // direct slice return 1; } static assert(!is(typeof(Compileable!(arraybounds2(1, 14))))); static assert(!is(typeof(Compileable!(arraybounds2(15, 3))))); static assert(arraybounds2(2, 4) == 1); int bug5147a() { int[1][2] a = 37; return a[0][0]; } static assert(bug5147a() == 37); int bug5147b() { int[4][2][3][17] a = 37; return a[0][0][0][0]; } static assert(bug5147b() == 37); int setlen() { int[][] zzz; zzz.length = 2; zzz[0].length = 10; assert(zzz.length == 2); assert(zzz[0].length == 10); assert(zzz[1].length == 0); return 2; } static assert(setlen() == 2); int[1][1] bug5147() { int[1][1] a = 1; return a; } static assert(bug5147() == [[1]]); enum int[1][1] enum5147 = bug5147(); static assert(enum5147 == [[1]]); immutable int[1][1] bug5147imm = bug5147(); // Index referencing int[2][2] indexref1() { int[2][2] a = 2; a[0] = 7; int[][] b = [null, null]; b[0 .. $] = a[0][0 .. 2]; assert(b[0][0] == 7); assert(b[0][1] == 7); int[] w; w = a[0]; assert(w[0] == 7); w[0 .. $] = 5; assert(a[0] != [7, 7]); assert(a[0] == [5, 5]); assert(b[0] == [5, 5]); return a; } int[2][2] indexref2() { int[2][2] a = 2; a[0] = 7; int[][2] b = null; b[0 .. $] = a[0]; assert(b[0][0] == 7); assert(b[0][1] == 7); assert(b == [[7, 7], [7, 7]]); int[] w; w = a[0]; assert(w[0] == 7); w[0 .. $] = 5; assert(a[0] != [7, 7]); assert(a[0] == [5, 5]); assert(b[0] == [5, 5]); return a; } int[2][2] indexref3() { int[2][2] a = 2; a[0]=7; int[][2] b = [null, null]; b[0 .. $] = a[0]; assert(b[0][0] == 7); assert(b[0][1] == 7); int[] w; w = a[0]; assert(w[0] == 7); w[0 .. $] = 5; assert(a[0] != [7, 7]); assert(a[0] == [5, 5]); assert(b[0] == [5, 5]); return a; } int[2][2] indexref4() { int[2][2] a = 2; a[0] = 7; int[][2] b =[[1, 2, 3], [1, 2, 3]]; // wrong code b[0] = a[0]; assert(b[0][0] == 7); assert(b[0][1] == 7); int[] w; w = a[0]; //[0 .. $]; assert(w[0] == 7); w[0 .. $] = 5; assert(a[0] != [7, 7]); assert(a[0] == [5, 5]); assert(b[0] == [5, 5]); return a; } static assert(indexref1() == [[5, 5], [2, 2]]); static assert(indexref2() == [[5, 5], [2, 2]]); static assert(indexref3() == [[5, 5], [2, 2]]); static assert(indexref4() == [[5, 5], [2, 2]]); int staticdynamic() { int[2][1] a = 2; assert(a == [[2, 2]]); int[][1] b = a[0][0 .. 1]; assert(b[0] == [2]); auto k = b[0]; auto m = a[0][0 .. 1]; assert(k == [2]); assert(m == k); return 0; } static assert(staticdynamic() == 0); int[] crashing() { int[12] cra; return (cra[2 .. $] = 3); } static assert(crashing()[9] == 3); int chainassign() { int[4] x = 6; int[] y = new int[4]; auto k = (y[] = (x[] = 2)); return k[0]; } static assert(chainassign() == 2); // index assignment struct S3801 { char c; int[3] arr; this(int x, int y) { c = 'x'; arr[0] = x; arr[1] = y; } } int bug3801() { S3801 xxx = S3801(17, 67); int[] w = xxx.arr; xxx.arr[1] = 89; assert(xxx.arr[0] == 17); assert(w[1] == 89); assert(w == [17, 89, 0]); return xxx.arr[1]; } enum : S3801 { bug3801e = S3801(17, 18) } static assert(bug3801e.arr == [17, 18, 0]); immutable S3801 bug3801u = S3801(17, 18); static assert(bug3801u.arr == [17, 18, 0]); static assert(bug3801() == 89); int bug3835() { int[4] arr; arr[] = 19; arr[0] = 4; int kk; foreach (ref el; arr) { el += 10; kk = el; } assert(arr[2] == 29); arr[0] += 3; return arr[0]; } static assert(bug3835() == 17); auto bug5852(const(string) s) { string[] r; r ~= s; assert(r.length == 1); return r[0].length; } static assert(bug5852("abc") == 3); // 7217 struct S7217 { int[] arr; } bool f7217() { auto s = S7217(); auto t = s.arr; return true; } static assert(f7217()); /******************************************* Set array length *******************************************/ static assert( { struct W { int[] z; } W w; w.z.length = 2; assert(w.z.length == 2); w.z.length = 6; assert(w.z.length == 6); return true; }()); // 7185 char[].length = n bool bug7185() { auto arr = new char[2]; auto arr2 = new char[2]; arr2[] = "ab"; arr.length = 1; arr2.length = 7; assert(arr.length == 1); assert(arr2.length == 7); assert(arr2[0 .. 2] == "ab"); return true; } static assert(bug7185()); bool bug9908() { static const int[3] sa = 1; return sa == [1, 1, 1]; } static assert(bug9908()); /******************************************* 6934 *******************************************/ struct Struct6934 { int[] x = [1, 2]; } void bar6934(ref int[] p) { p[0] = 12; assert(p[0] == 12); p[0 .. 1] = 17; assert(p[0] == 17); p = p[1 .. $]; } int bug6934() { Struct6934 q; bar6934(q.x); int[][] y = [[2, 5], [3, 6, 8]]; bar6934(y[0]); return 1; } static assert(bug6934()); /******************************************* Bug 5671 *******************************************/ static assert(['a', 'b'] ~ "c" == "abc"); /******************************************* 8624 *******************************************/ int evil8624() { long m = 0x1_0000_0000L; assert(m != 0); long[] a = [0x1_0000_0000L]; long[] b = [0x4_0000_0000L]; assert(a[] != b[]); return 1; } static assert(evil8624()); /******************************************* 8644 array literal >,< *******************************************/ int bug8644() { auto m = "a"; auto z = ['b']; auto c = "b7"; auto d = ['b', '6']; assert(m < z); assert(z > m); assert(z <= c); assert(c > z); assert(c > d); assert(d >= d); return true; } static assert(bug8644()); /******************************************* Bug 6159 *******************************************/ struct A6159 {} static assert({ return A6159.init is A6159.init; }()); static assert({ return [1] is [1]; }()); /******************************************* Bug 5685 *******************************************/ string bug5685() { return "xxx"; } struct Bug5865 { void test1() { enum file2 = (bug5685())[0 .. $]; } } /******************************************* 6235 - Regression ICE on $ in template *******************************************/ struct Bug6235(R) { enum XXX = is(typeof(R.init[0 .. $]) : const ubyte[]); } Bug6235!(ubyte[]) bug6235; /******************************************* 8673 ICE *******************************************/ enum dollar8673 = [0][(() => $ - 1)()]; /******************************************* Bug 5840 *******************************************/ struct Bug5840 { string g; int w; } int bug5840(int u) { // check for clobbering Bug5840 x = void; x.w = 4; x.g = "3gs"; if (u == 1) bug5840(2); if (u == 2) { x.g = "abc"; x.w = 3465; } else { assert(x.g == "3gs"); assert(x.w == 4); } return 56; } static assert(bug5840(1) == 56); /******************************************* 7810 *******************************************/ int bug7810() { int[1][3] x = void; x[0] = [2]; x[1] = [7]; assert(x[0][0] == 2); char[1][3] y = void; y[0] = "a"; y[1] = "b"; assert(y[0][0] == 'a'); return 1; } static assert(bug7810()); struct Bug7810 { int w; } int bug7810b(T)(T[] items...) { assert(items[0] == Bug7810(20)); return 42; } static assert(bug7810b(Bug7810(20), Bug7810(10)) == 42); /******************************************* std.datetime ICE (30 April 2011) *******************************************/ struct TimeOfDayZ { public: this(int hour) { } invariant() { } } const testTODsThrownZ = TimeOfDayZ(0); /******************************************* Bug 5954 *******************************************/ struct Bug5954 { int x; this(int xx) { this.x = xx; } } void bug5954() { enum f = Bug5954(10); static assert(f.x == 10); } /******************************************* Bug 5972 *******************************************/ int bug5972() { char[] z = "abc".dup; char[][] a = [null, null]; a[0] = z[0 .. 2]; char[] b = a[0]; assert(b == "ab"); a[0][1] = 'q'; assert(a[0] == "aq"); assert(b == "aq"); assert(b[1] == 'q'); //a[0][0 .. $ - 1][0 .. $] = a[0][0 .. $ - 1][0 .. $]; // overlap return 56; } static assert(bug5972() == 56); /******************************************* 2.053beta [CTFE]ICE 'global errors' *******************************************/ int wconcat(wstring replace) { wstring value; value = "A"w; value = value ~ replace; return 1; } static assert(wconcat("X"w)); /******************************************* 10397 string concat *******************************************/ static assert(!is(typeof(compiles!("abc" ~ undefined)))); static assert(!is(typeof(compiles!(otherundefined ~ "abc")))); /******************************************* 9634 struct concat *******************************************/ struct Bug9634 { int raw; } bool bug9634() { Bug9634[] jr = [Bug9634(42)]; Bug9634[] ir = null ~ jr; Bug9634[] kr = jr ~ null; Bug9634[] mr = jr ~ jr; jr[0].raw = 6; assert(ir[0].raw == 42); assert(kr[0].raw == 42); assert(jr[0].raw == 6); assert(&mr[0] != &mr[1]); return true; } static assert(bug9634()); /******************************************* Bug 4001: A Space Oddity *******************************************/ int space() { return 4001; } void oddity4001(int q) { const int bowie = space(); static assert(space() == 4001); static assert(bowie == 4001); } /******************************************* Bug 3779 *******************************************/ static const bug3779 = ["123"][0][$ - 1]; /******************************************* Bug 8893 ICE with bad struct literal *******************************************/ struct Foo8893 { char[3] data; } int bar8893(Foo8893 f) { return f.data[0]; } static assert(!is(typeof(compiles!(bar8893(Foo8893(['a','b'])))))); /******************************************* non-Cow struct literals *******************************************/ struct Zadok { int[3] z; char[4] s = void; ref int[] fog(ref int[] q) { return q; } int bfg() { z[0] = 56; auto zs = z[]; fog(zs) = [56, 6, 8]; assert(z[0] == 56); assert(z[1] == 61); assert(z[2] == 61); assert(zs[0] == 56); assert(zs[1] == 6); return zs[2]; } } struct Vug { Zadok p; int[] other; } int quop() { int[] heap = new int[5]; heap[] = 738; Zadok pong; pong.z = 3; int[] w = pong.z; assert(w[0] == 3); Zadok phong; phong.z = 61; pong = phong; assert(w[0] == 61); Vug b = Vug(Zadok(17, "abcd")); b = Vug(Zadok(17, "abcd"), heap); b.other[2] = 78; assert(heap[2] == 78); char[] y = b.p.s; assert(y[2] == 'c'); phong.s = ['z','x','f', 'g']; w = b.p.z; assert(y[2] == 'c'); assert(w[0] == 17); b.p = phong; assert(y[2] == 'f'); Zadok wok = Zadok(6, "xyzw"); b.p = wok; assert(y[2] == 'z'); b.p = phong; assert(w[0] == 61); Vug q; q.p = pong; return pong.bfg(); } static assert(quop() == 8); static assert(quop() == 8); // check for clobbering /************************************************** Bug 5676 tuple assign of struct that has void opAssign **************************************************/ struct S5676 { int x; void opAssign(S5676 rhs) { x = rhs.x; } } struct Tup5676(E...) { E g; void foo(E values) { g = values; } } bool ice5676() { Tup5676!(S5676) q; q.foo(S5676(3)); assert(q.g[0].x == 3); return true; } static assert(ice5676()); /************************************************** Bug 5682 Wrong CTFE with operator overloading **************************************************/ struct A { int n; auto opBinary(string op : "*")(A rhs) { return A(n * rhs.n); } } A foo(A[] lhs, A[] rhs) { A current; for (size_t k = 0; k < rhs.length; ++k) { current = lhs[k] * rhs[k]; } return current; } auto test() { return foo([A(1), A(2)], [A(3), A(4)]); } static assert(test().n == 8); /************************************************** Attempt to modify a read-only string literal **************************************************/ struct Xarg { char[] s; } int zfs(int n) { char[] m = "exy".dup; if (n == 1) { // it's OK to cast to const, then cast back string ss = cast(string)m; m = cast(char[])ss; m[2]='q'; return 56; } auto q = Xarg(cast(char[])"abc"); assert(q.s[1] == 'b'); if (n == 2) q.s[1] = 'p'; else if (n == 3) q.s[0 .. $] = 'p'; char* w = &q.s[2]; if (n == 4) *w = 'z'; return 76; } static assert(!is(typeof(compiles!(zfs(2))))); static assert(!is(typeof(compiles!(zfs(3))))); static assert(!is(typeof(compiles!(zfs(4))))); static assert( is(typeof(compiles!(zfs(1))))); static assert( is(typeof(compiles!(zfs(5))))); /************************************************** .dup must protect string literals **************************************************/ string mutateTheImmutable(immutable string _s) { char[] s = _s.dup; foreach (ref c; s) c = 'x'; return s.idup; } string doharm(immutable string _name) { return mutateTheImmutable(_name[2 .. $].idup); } enum victimLiteral = "CL_INVALID_CONTEXT"; enum thug = doharm(victimLiteral); static assert(victimLiteral == "CL_INVALID_CONTEXT"); /************************************************** Use $ in a slice of a dotvar slice **************************************************/ int sliceDollar() { Xarg z; z.s = new char[20]; z.s[] = 'b'; z.s = z.s[2 .. $ - 2]; z.s[$ - 2] = 'c'; return z.s[$ - 2]; } static assert(sliceDollar() == 'c'); /************************************************** Variation of 5972 which caused segfault **************************************************/ int bug5972crash() { char[] z = "abc".dup; char[][] a = [null, null]; a[0] = z[0 .. 2]; a[0][1] = 'q'; return 56; } static assert(bug5972crash() == 56); /************************************************** String slice assignment through ref parameter **************************************************/ void popft(A)(ref A a) { a = a[1 .. $]; } int sdfgasf() { auto scp = "abc".dup; popft(scp); return 1; } static assert(sdfgasf() == 1); /************************************************** 8830 slice of slice.ptr **************************************************/ string bug8830(string s) { auto ss = s[1 .. $]; return ss.ptr[0 .. 2]; } static assert(bug8830("hello") == "el"); /************************************************** 8608 ICE **************************************************/ void bug8608(ref int m) {} void test8608() { int z; int foo(bool b) { if (b) bug8608(z); return 1; } static assert( is(typeof(compiles!(foo(false))))); static assert(!is(typeof(compiles!(foo(true) )))); } /************************************************** Bug 7770 **************************************************/ immutable char[] foo7770 = "abcde"; int bug7770a(string a) { return 1; } bool bug7770b(char c) { return true; } static assert(bug7770a(foo7770[0 .. $])); static assert(bug7770b(foo7770[$ - 2])); void baz7770() { static assert(bug7770a(foo7770[0 .. $])); static assert(bug7770b(foo7770[$ - 2])); } /************************************************** 8601 ICE **************************************************/ dchar bug8601(dstring s) { dstring w = s[1 .. $]; return w[0]; } enum dstring e8601 = [cast(dchar)'o', 'n']; static assert(bug8601(e8601) == 'n'); /************************************************** Bug 6015 **************************************************/ struct Foo6015 { string field; } bool func6015(string input) { Foo6015 foo; foo.field = input[0 .. $]; assert(foo.field == "test"); foo.field = "test2"; assert(foo.field != "test"); assert(foo.field == "test2"); return true; } static assert(func6015("test")); /************************************************** Bug 6001 **************************************************/ void bug6001e(ref int[] s) { int[] r = s; s ~= 0; } bool bug6001f() { int[] s; bug6001e(s); return true; } static assert(bug6001f()); // Assignment to AAs void blah(int[char] as) { auto k = [6: as]; as = k[6]; } int blaz() { int[char] q; blah(q); return 67; } static assert(blaz() == 67); void bug6001g(ref int[] w) { w = [88]; bug6001e(w); w[0] = 23; } bool bug6001h() { int[] s; bug6001g(s); assert(s.length == 2); assert(s[1] == 0); assert(s[0] == 23); return true; } static assert(bug6001h()); /************************************************** 10243 wrong code *&arr as ref parameter 10551 wrong code (&arr)[0] as ref parameter **************************************************/ void bug10243(ref int n) { n = 3; } void bug10551(int* p) { bug10243(p[0]); } bool test10243() { int[1] arr; bug10243(*arr.ptr); assert(arr[0] == 3); int[1] arr2; bug10551(arr2.ptr); assert(arr2[0] == 3); int v; bug10551(&v); assert(v == 3); return true; } static assert(test10243()); /************************************************** Bug 4910 **************************************************/ int bug4910(int a) { return a; } static int var4910; static assert(!is(typeof(Compiles!(bug4910(var4910))))); static assert(bug4910(123)); /************************************************** Bug 5845 - Regression(2.041) **************************************************/ void test5845(ulong cols) {} uint solve(bool niv, ref ulong cols) { if (niv) solve(false, cols); else test5845(cols); return 65; } ulong nqueen(int n) { ulong cols = 0; return solve(true, cols); } static assert(nqueen(2) == 65); /************************************************** Bug 5258 **************************************************/ struct Foo5258 { int x; } void bar5258(int n, ref Foo5258 fong) { if (n) bar5258(n - 1, fong); else fong.x++; } int bug5258() { Foo5258 foo5258 = Foo5258(); bar5258(1, foo5258); return 45; } static assert(bug5258() == 45); struct Foo5258b { int[2] r; } void baqopY(int n, ref int[2] fongo) { if (n) baqopY(n - 1, fongo); else fongo[0]++; } int bug5258b() { Foo5258b qq; baqopY(1, qq.r); return 618; } static assert(bug5258b() == 618); // Notice that this case involving reassigning the dynamic array struct Foo5258c { int[] r; } void baqop(int n, ref int[] fongo) { if (n) baqop(n - 1, fongo); else { fongo = new int[20]; fongo[0]++; } } size_t bug5258c() { Foo5258c qq; qq.r = new int[30]; baqop(1, qq.r); return qq.r.length; } static assert(bug5258c() == 20); /************************************************** Bug 6049 **************************************************/ struct Bug6049 { int m; this(int x) { m = x; } invariant() { } } const Bug6049[] foo6049 = [Bug6049(6), Bug6049(17)]; static assert(foo6049[0].m == 6); /************************************************** Bug 6052 **************************************************/ struct Bug6052 { int a; } bool bug6052() { Bug6052[2] arr; for (int i = 0; i < 2; ++ i) { Bug6052 el = {i}; Bug6052 ek = el; arr[i] = el; el.a = i + 2; assert(ek.a == i); // ok assert(arr[i].a == i); // fail } assert(arr[1].a == 1); // ok assert(arr[0].a == 0); // fail return true; } static assert(bug6052()); bool bug6052b() { int[][1] arr; int[1] z = [7]; arr[0] = z; assert(arr[0][0] == 7); arr[0] = z; z[0] = 3; assert(arr[0][0] == 3); return true; } static assert(bug6052b()); struct Bug6052c { int x; this(int a) { x = a; } } int bug6052c() { Bug6052c[] pieces = []; for (int c = 0; c < 2; ++ c) pieces ~= Bug6052c(c); assert(pieces[1].x == 1); assert(pieces[0].x == 0); return 1; } static assert(bug6052c() == 1); static assert(bug6052c() == 1); static assert({ Bug6052c[] pieces = []; pieces.length = 2; int c = 0; pieces[0] = Bug6052c(c); ++c; pieces[1] = Bug6052c(c); assert(pieces[0].x == 0); return true; }()); static assert({ int[1][] pieces = []; pieces.length = 2; for (int c = 0; c < 2; ++ c) pieces[c][0] = c; assert(pieces[1][0] == 1); assert(pieces[0][0] == 0); return true; }()); static assert({ Bug6052c[] pieces = []; for (int c = 0; c < 2; ++ c) pieces ~= Bug6052c(c); assert(pieces[1].x == 1); assert(pieces[0].x == 0); return true; }()); static assert({ int[1] z = 7; int[1][] pieces = [z,z]; pieces[1][0]=3; assert(pieces[0][0] == 7); pieces = pieces ~ [z,z]; pieces[3][0] = 16; assert(pieces[2][0] == 7); pieces = [z,z] ~ pieces; pieces[5][0] = 16; assert(pieces[4][0] == 7); return true; }()); /************************************************** Bug 6749 **************************************************/ struct CtState { string code; } CtState bug6749() { CtState[] pieces; CtState r = CtState("correct"); pieces ~= r; r = CtState("clobbered"); return pieces[0]; } static assert(bug6749().code == "correct"); /************************************************** Index + slice assign to function returns **************************************************/ int[] funcRetArr(int[] a) { return a; } int testFuncRetAssign() { int[] x = new int[20]; funcRetArr(x)[2] = 4; assert(x[2] == 4); funcRetArr(x)[] = 27; assert(x[15] == 27); return 5; } static assert(testFuncRetAssign() == 5); int keyAssign() { int[int] pieces; pieces[3] = 1; pieces.keys[0] = 4; pieces.values[0] = 27; assert(pieces[3] == 1); return 5; } static assert(keyAssign() == 5); /************************************************** Bug 6054 -- AA literals **************************************************/ enum x6054 = { auto p = { int[string] pieces; pieces[['a'].idup] = 1; return pieces; }(); return p; }(); /************************************************** Bug 6077 **************************************************/ enum bug6077 = { string s; string t; return s ~ t; }(); /************************************************** Bug 6078 -- Pass null array by ref **************************************************/ struct Foo6078 { int[] bar; } static assert({ Foo6078 f; int i; foreach (ref e; f.bar) { i += e; } return i; }() == 0); int bug6078(ref int[] z) { int[] q = z; return 2; } static assert({ Foo6078 f; return bug6078(f.bar); }() == 2); /************************************************** Bug 6079 -- Array bounds checking **************************************************/ static assert(!is(typeof(compiles!({ int[] x = [1, 2, 3, 4]; x[4] = 1; return true; }() )))); /************************************************** Bug 6100 **************************************************/ struct S6100 { int a; } S6100 init6100(int x) { S6100 s = S6100(x); return s; } static const S6100[2] s6100a = [init6100(1), init6100(2)]; static assert(s6100a[0].a == 1); /************************************************** Bug 4825 -- failed with -inline **************************************************/ int a4825() { int r; return r; } int b4825() { return a4825(); } void c4825() { void d() { auto e = b4825(); } static const int f = b4825(); } /************************************************** Bug 5708 -- failed with -inline **************************************************/ string b5708(string s) { return s; } string a5708(string s) { return b5708(s); } void bug5708() { void m() { a5708("lit"); } static assert(a5708("foo") == "foo"); static assert(a5708("bar") == "bar"); } /************************************************** Bug 6120 -- failed with -inline **************************************************/ struct Bug6120(T) { this(int x) { } } static assert({ auto s = Bug6120!int(0); return true; }()); /************************************************** Bug 6123 -- failed with -inline **************************************************/ struct Bug6123(T) { void f() {} // can also trigger if the struct is normal but f is template } static assert({ auto piece = Bug6123!int(); piece.f(); return true; }()); /************************************************** Bug 6053 -- ICE involving pointers **************************************************/ static assert({ int* a = null; assert(a is null); assert(a == null); return true; }()); static assert({ int b; int* a = &b; assert(a !is null); *a = 7; assert(b == 7); assert(*a == 7); return true; }()); int dontbreak6053() { auto q = &dontbreak6053; void caz() {} auto tr = &caz; return 5; } static assert(dontbreak6053()); static assert({ int a; *(&a) = 15; assert(a == 15); assert(*(&a) == 15); return true; }()); static assert({ int a = 5, b = 6, c = 2; assert(*(c ? &a : &b) == 5); assert(*(!c ? &a : &b) == 6); return true; }()); static assert({ int a, b, c; (c ? a : b) = 1; return true; }()); static assert({ int a, b, c = 1; int* p = &a; (c ? *p : b) = 51; assert(a == 51); return true; }()); /************************************************** Pointer arithmetic, dereference, and comparison **************************************************/ // dereference null pointer static assert(!is(typeof(compiles!({ int a, b, c = 1; int* p; (c ? *p : b) = 51; return 6; }() )))); static assert(!is(typeof(compiles!({ int* a = null; assert(*a != 6); return 72; }() )))); // cannot <, > compare pointers to different arrays static assert(!is(typeof(compiles!({ int[5] a, b; bool c = (&a[0] > &b[0]); return 72; }() )))); // can ==, is, !is, != compare pointers for different arrays static assert({ int[5] a; int[5] b; assert(!(&a[0] == &b[0])); assert(&a[0] != &b[0]); assert(!(&a[0] is &b[0])); assert(&a[0] !is &b[0]); return 72; }()); static assert({ int[5] a; a[0] = 25; a[1] = 5; int* b = &a[1]; assert(*b == 5); *b = 34; int c = *b; *b += 6; assert(b == &a[1]); assert(b != &a[0]); assert(&a[0] < &a[1]); assert(&a[0] <= &a[1]); assert(!(&a[0] >= &a[1])); assert(&a[4] > &a[0]); assert(c == 34); assert(*b == 40); assert(a[1] == 40); return true; }()); static assert({ int[12] x; int* p = &x[10]; int* q = &x[4]; return p - q; }() == 6); static assert({ int[12] x; int* p = &x[10]; int* q = &x[4]; q = p; assert(p == q); q = &x[4]; assert(p != q); q = q + 6; assert(q is p); return 6; }() == 6); static assert({ int[12] x; int[] y = x[2 .. 8]; int* p = &y[4]; int* q = &x[6]; assert(p == q); p = &y[5]; assert(p > q); p = p + 5; // OK, as long as we don't dereference assert(p > q); return 6; }() == 6); static assert({ char[12] x; const(char)* p = "abcdef"; const (char)* q = p; q = q + 2; assert(*q == 'c'); assert(q > p); assert(q - p == 2); assert(p - q == -2); q = &x[7]; p = &x[1]; assert(q>p); return 6; }() == 6); // Relations involving null pointers bool nullptrcmp() { // null tests void* null1 = null, null2 = null; int x = 2; void* p = &x; assert(null1 == null2); assert(null1 is null2); assert(null1 <= null2); assert(null1 >= null2); assert(!(null1 > null2)); assert(!(null2 > null1)); assert(null1 != p); assert(null1 !is p); assert(p != null1); assert(p !is null1); assert(null1 <= p); assert(p >= null2); assert(p > null1); assert(!(null1 > p)); return true; } static assert(nullptrcmp()); /************************************************** 10840 null pointer in dotvar **************************************************/ struct Data10840 { bool xxx; } struct Bug10840 { Data10840* _data; } bool bug10840(int n) { Bug10840 stack; if (n == 1) { // detect deref through null pointer return stack._data.xxx; } // Wrong-code for ?: return stack._data ? false : true; } static assert(bug10840(0)); static assert(!is(typeof(Compileable!(bug10840(1))))); /************************************************** 8216 ptr inside a pointer range **************************************************/ // Four-pointer relations. Return true if [p1 .. p2] points inside [q1 .. q2] // (where the end points dont coincide). bool ptr4cmp(void* p1, void* p2, void* q1, void* q2) { // Each compare can be written with <, <=, >, or >=. // Either && or || can be used, giving 32 permutations. // Additionally each compare can be negated with !, yielding 128 in total. bool b1 = (p1 > q1 && p2 <= q2); bool b2 = (p1 > q1 && p2 < q2); bool b3 = (p1 >= q1 && p2 <= q2); bool b4 = (p1 >= q1 && p2 < q2); bool b5 = (q1 <= p1 && q2 > p2); bool b6 = (q1 <= p1 && q2 >= p2); bool b7 = (p2 <= q2 && p1 > q1); bool b8 = (!(p1 <= q1) && p2 <= q2); bool b9 = (!(p1 <= q1) && !(p2 > q2)); bool b10 = (!!!(p1 <= q1) && !(p2 > q2)); assert(b1 == b2 && b1 == b3 && b1 == b4 && b1 == b5 && b1 == b6); assert(b1 == b7 && b1 == b8 && b1 == b9 && b1 == b10); bool c1 = (p1 <= q1 || p2 > q2); assert(c1 == !b1); bool c2 = (p1 < q1 || p2 >= q2); bool c3 = (!(q1 <= p1) || !(q2 >= p2)); assert(c1 == c2 && c1 == c3); return b1; } bool bug8216() { int[4] a; int[13] b; int v; int* p = &v; assert(!ptr4cmp(&a[0], &a[3], p, p)); assert(!ptr4cmp(&b[2], &b[9], &a[1], &a[2])); assert(!ptr4cmp(&b[1], &b[9], &b[2], &b[8])); assert( ptr4cmp(&b[2], &b[8], &b[1], &b[9])); return 1; } static assert(bug8216()); /************************************************** 6517 ptr++, ptr-- **************************************************/ int bug6517() { int[] arr = [1, 2, 3]; auto startp = arr.ptr; auto endp = arr.ptr + arr.length; for (; startp < endp; startp++) {} startp = arr.ptr; assert(startp++ == arr.ptr); assert(startp != arr.ptr); assert(startp-- != arr.ptr); assert(startp == arr.ptr); return 84; } static assert(bug6517() == 84); /************************************************** Out-of-bounds pointer assignment and deference **************************************************/ int ptrDeref(int ofs, bool wantDeref) { int[5] a; int* b = &a[0]; b = b + ofs; // OK if (wantDeref) return *b; // out of bounds return 72; } static assert(!is(typeof(compiles!(ptrDeref(-1, true))))); static assert( is(typeof(compiles!(ptrDeref(4, true))))); static assert( is(typeof(compiles!(ptrDeref(5, false))))); static assert(!is(typeof(compiles!(ptrDeref(5, true))))); static assert(!is(typeof(compiles!(ptrDeref(6, false))))); static assert(!is(typeof(compiles!(ptrDeref(6, true))))); /************************************************** Pointer += **************************************************/ static assert({ int[12] x; int zzz; assert(&zzz); int* p = &x[10]; int* q = &x[4]; q = p; assert(p == q); q = &x[4]; assert(p != q); q += 4; assert(q == &x[8]); q = q - 2; q = q + 4; assert(q is p); return 6; }() == 6); /************************************************** Reduced version of bug 5615 **************************************************/ const(char)[] passthrough(const(char)[] x) { return x; } sizediff_t checkPass(Char1)(const(Char1)[] s) { const(Char1)[] balance = s[1 .. $]; return passthrough(balance).ptr - s.ptr; } static assert(checkPass("foobar") == 1); /************************************************** Pointers must not escape from CTFE **************************************************/ struct Toq { const(char)* m; } Toq ptrRet(bool b) { string x = "abc"; return Toq(b ? x[0 .. 1].ptr : null); } static assert(is(typeof(compiles!({ enum Toq boz = ptrRet(false); // OK - ptr is null Toq z = ptrRet(true); // OK -- ptr doesn't escape return 4; }() )))); static assert(!is(typeof(compiles!({ enum Toq boz = ptrRet(true); // fail - ptr escapes return 4; }() )))); /************************************************** Pointers to struct members **************************************************/ struct Qoz { int w; int[3] yof; } static assert({ int[3] gaz; gaz[2] = 3156; Toq z = ptrRet(true); auto p = z.m; assert(*z.m == 'a'); assert(*p == 'a'); auto q = &z.m; assert(*q == p); assert(**q == 'a'); Qoz g = Qoz(2, [5, 6, 7]); auto r = &g.w; assert(*r == 2); r = &g.yof[1]; assert(*r == 6); g.yof[0] = 15; ++r; assert(*r == 7); r -= 2; assert(*r == 15); r = &gaz[0]; r += 2; assert(*r == 3156); return *p; }() == 'a'); struct AList { AList* next; int value; static AList* newList() { AList[] z = new AList[1]; return &z[0]; } static AList* make(int i, int j) { auto r = newList(); r.next = (new AList[1]).ptr; r.value = 1; AList* z = r.next; (*z).value = 2; r.next.value = j; assert(r.value == 1); assert(r.next.value == 2); r.next.next = &(new AList[1])[0]; assert(r.next.next != null); assert(r.next.next); r.next.next.value = 3; assert(r.next.next.value == 3); r.next.next = newList(); r.next.next.value = 9; return r; } static int checkList() { auto r = make(1,2); assert(r.value == 1); assert(r.next.value == 2); assert(r.next.next.value == 9); return 2; } } static assert(AList.checkList() == 2); /************************************************** 7194 pointers as struct members **************************************************/ struct S7194 { int* p, p2; } int f7194() { assert(S7194().p == null); assert(!S7194().p); assert(S7194().p == S7194().p2); S7194 s = S7194(); assert(!s.p); assert(s.p == null); assert(s.p == s.p2); int x; s.p = &x; s.p2 = s.p; assert(s.p == &x); return 0; } int g7194() { auto s = S7194(); assert(s.p); // should fail return 0; } static assert(f7194() == 0); static assert(!is(typeof(compiles!(g7194())))); /************************************************** 7248 recursive struct pointers in array **************************************************/ struct S7248 { S7248* ptr; } bool bug7248() { S7248[2] sarr; sarr[0].ptr = &sarr[1]; sarr[0].ptr = null; S7248* t = sarr[0].ptr; return true; } static assert(bug7248()); /************************************************** 7216 calling a struct pointer member **************************************************/ struct S7216 { S7216* p; int t; void f() { } void g() { ++t; } } bool bug7216() { S7216 s0, s1; s1.t = 6; s0.p = &s1; s0.p.f(); s0.p.g(); assert(s1.t == 7); return true; } static assert(bug7216()); /************************************************** 10858 Wrong code with array of pointers **************************************************/ bool bug10858() { int*[4] x; x[0] = null; assert(x[0] == null); return true; } static assert(bug10858()); /************************************************** 12528 - painting inout type for value type literals **************************************************/ inout(T)[] dup12528(T)(inout(T)[] a) { inout(T)[] res; foreach (ref e; a) res ~= e; return res; } enum arr12528V1 = dup12528([0]); enum arr12528V2 = dup12528([0, 1]); static assert(arr12528V1 == [0]); static assert(arr12528V2 == [0, 1]); enum arr12528C1 = dup12528([new immutable Object]); enum arr12528C2 = dup12528([new immutable Object, new immutable Object]); static assert(arr12528C1.length == 1); static assert(arr12528C2.length == 2 && arr12528C2[0] !is arr12528C2[1]); /************************************************** 9745 Allow pointers to static variables **************************************************/ shared int x9745; shared int[5] y9745; shared(int)* bug9745(int m) { auto k = &x9745; auto j = &x9745; auto p = &y9745[0]; auto q = &y9745[3]; assert(j - k == 0); assert(j == k); assert(q - p == 3); --q; int a = 0; assert(p + 2 == q); if (m == 7) { auto z1 = y9745[0 .. 2]; // slice global pointer } if (m == 8) p[1] = 7; // modify through a pointer if (m == 9) a = p[1]; // read from a pointer if (m == 0) return &x9745; return &y9745[1]; } int test9745(int m) { bug9745(m); // type painting shared int* w = bug9745(0); return 1; } shared int* w9745a = bug9745(0); shared int* w9745b = bug9745(1); static assert( is(typeof(compiles!(test9745(6))))); static assert(!is(typeof(compiles!(test9745(7))))); static assert(!is(typeof(compiles!(test9745(8))))); static assert(!is(typeof(compiles!(test9745(9))))); // pointers cast from an absolute address // (mostly applies to fake pointers, eg Windows HANDLES) bool test9745b() { void* b6 = cast(void*)0xFEFEFEFE; void* b7 = cast(void*)0xFEFEFEFF; assert(b6 is b6); assert(b7 != b6); return true; } static assert(test9745b()); /************************************************** 9364 ICE with pointer to local struct **************************************************/ struct S9364 { int i; } bool bug9364() { S9364 s; auto k = (&s).i; return 1; } static assert(bug9364()); /************************************************** 10251 Pointers to const globals **************************************************/ static const int glob10251 = 7; const(int)* bug10251() { return &glob10251; } static a10251 = &glob10251; // OK static b10251 = bug10251(); /************************************************** 4065 [CTFE] AA "in" operator doesn't work **************************************************/ bool bug4065(string s) { enum int[string] aa = ["aa":14, "bb":2]; int* p = s in aa; if (s == "aa") assert(*p == 14); else if (s == "bb") assert(*p == 2); else assert(!p); int[string] zz; assert(!("xx" in zz)); bool c = !p; return cast(bool)(s in aa); } static assert(!bug4065("xx")); static assert( bug4065("aa")); static assert( bug4065("bb")); /************************************************** 12689 - assigning via pointer from 'in' expression **************************************************/ int g12689() { int[int] aa; aa[1] = 13; assert(*(1 in aa) == 13); *(1 in aa) = 42; return aa[1]; } static assert(g12689() == 42); /************************************************** Pointers in ? : **************************************************/ static assert({ int[2] x; int* p = &x[1]; return p ? true: false; }()); /************************************************** Pointer slicing **************************************************/ int ptrSlice() { auto arr = new int[5]; int* x = &arr[0]; int[] y = x[0 .. 5]; x[1 .. 3] = 6; ++x; x[1 .. 3] = 14; assert(arr[1] == 6); assert(arr[2] == 14); //x[-1 .. 4] = 5; // problematic because negative lower boundary will throw RangeError in runtime (x - 1)[0 .. 3] = 5; int[] z = arr[1 .. 2]; z.length = 4; z[$ - 1] = 17; assert(arr.length == 5); return 2; } static assert(ptrSlice() == 2); /************************************************** 6344 - create empty slice from null pointer **************************************************/ static assert({ char* c = null; auto m = c[0 .. 0]; return true; }()); /************************************************** 8365 - block assignment of enum arrays **************************************************/ enum E8365 { first = 7, second, third, fourth } static assert({ E8365[2] x; return x[0]; }() == E8365.first); static assert({ E8365[2][2] x; return x[0][0]; }() == E8365.first); static assert({ E8365[2][2][2] x; return x[0][0][0]; }() == E8365.first); /************************************************** 4448 - labelled break + continue **************************************************/ int bug4448() { int n = 2; L1: do { switch(n) { case 5: return 7; default: n = 5; break L1; } int w = 7; } while (0); return 3; } static assert(bug4448() == 3); int bug4448b() { int n = 2; L1: for (n = 2; n < 5; ++n) { for (int m = 1; m < 6; ++m) { if (n < 3) { assert(m == 1); continue L1; } } break; } return 3; } static assert(bug4448b() == 3); /************************************************** 6985 - non-constant case **************************************************/ int bug6985(int z) { int q = z * 2 - 6; switch(z) { case q: q = 87; break; default: } return q; } static assert(bug6985(6) == 87); /************************************************** 6281 - [CTFE] A null pointer '!is null' returns 'true' **************************************************/ static assert(!{ auto p = null; return p !is null; }()); static assert(!{ auto p = null; return p != null; }()); /************************************************** 6331 - evaluate SliceExp on if condition **************************************************/ bool bug6331(string s) { if (s[0 .. 1]) return true; return false; } static assert(bug6331("str")); /************************************************** 6283 - assign to AA with slice as index **************************************************/ static assert({ immutable p = "pp"; int[string] pieces = [p: 0]; pieces["qq"] = 1; return true; }()); static assert({ immutable renames = [0: "pp"]; int[string] pieces; pieces[true ? renames[0] : "qq"] = 1; pieces["anything"] = 1; return true; }()); static assert({ immutable qq = "qq"; string q = qq; int[string] pieces = ["a":1]; pieces[q] = 0; string w = "ab"; int z = pieces[w[0 .. 1]]; assert(z == 1); return true; }()); /************************************************** 6282 - dereference 'in' of an AA **************************************************/ static assert({ int[] w = new int[4]; w[2] = 6; auto c = [5: w]; auto kk = (*(5 in c))[2]; (*(5 in c))[2] = 8; (*(5 in c))[1 .. $ - 2] = 4; auto a = [4:"1"]; auto n = *(4 in a); return n; }() == "1"); /************************************************** 6337 - member function call on struct literal **************************************************/ struct Bug6337 { int k; void six() { k = 6; } int ctfe() { six(); return k; } } static assert(Bug6337().ctfe() == 6); /************************************************** 6603 call manifest function pointer **************************************************/ int f6603(int a) { return a + 5; } enum bug6603 = &f6603; static assert(bug6603(6) == 11); /************************************************** 6375 **************************************************/ struct D6375 { int[] arr; } A6375 a6375(int[] array) { return A6375(array); } struct A6375 { D6375* _data; this(int[] arr) { _data = new D6375; _data.arr = arr; } int[] data() { return _data.arr; } } static assert({ int[] a = [1, 2]; auto app2 = a6375(a); auto data = app2.data(); return true; }()); /************************************************** 6280 Converting pointers to bool **************************************************/ static assert({ if ((0 in [0:0])) {} if ((0 in [0:0]) && (0 in [0:0])) {} return true; }()); /************************************************** 6276 ~= **************************************************/ struct Bug6276 { int[] i; } static assert({ Bug6276 foo; foo.i ~= 1; foo.i ~= 2; return true; }()); /************************************************** 6374 ptr[n] = x, x = ptr[n] **************************************************/ static assert({ int[] arr = [1]; arr.ptr[0] = 2; auto k = arr.ptr[0]; assert(k == 2); return arr[0]; }() == 2); /************************************************** 6306 recursion and local variables **************************************************/ void recurse6306() { bug6306(false); } bool bug6306(bool b) { int x = 0; if (b) recurse6306(); assert(x == 0); x = 1; return true; } static assert(bug6306(true)); /************************************************** 6386 ICE on unsafe pointer cast **************************************************/ static assert(!is(typeof(compiles!({ int x = 123; int* p = &x; float z; float* q = cast(float*)p; return true; }() )))); static assert({ int[] x = [123, 456]; int* p = &x[0]; auto m = cast(const(int)*)p; auto q = p; return *q; }()); /************************************************** 6420 ICE on dereference of invalid pointer **************************************************/ static assert({ // Should compile, but pointer can't be dereferenced int x = 123; int* p = cast(int*)x; auto q = cast(char*)x; auto r = cast(char*)323; // Valid const-changing cast const float *m = cast(immutable float*)[1.2f,2.4f,3f]; return true; }() ); static assert(!is(typeof(compiles!({ int x = 123; int* p = cast(int*)x; int a = *p; return true; }() )))); static assert(!is(typeof(compiles!({ int* p = cast(int*)123; int a = *p; return true; }() )))); static assert(!is(typeof(compiles!({ auto k = cast(int*)45; *k = 1; return true; }() )))); static assert(!is(typeof(compiles!({ *cast(float*)"a" = 4.0; return true; }() )))); static assert(!is(typeof(compiles!({ float f = 2.8; long *p = &f; return true; }() )))); static assert(!is(typeof(compiles!({ long *p = cast(long*)[1.2f, 2.4f, 3f]; return true; }() )))); /************************************************** 6250 deref pointers to array **************************************************/ int[]* simple6250(int[]* x) { return x; } void swap6250(int[]* lhs, int[]* rhs) { int[] kk = *lhs; assert(simple6250(lhs) == lhs); lhs = simple6250(lhs); assert(kk[0] == 18); assert((*lhs)[0] == 18); assert((*rhs)[0] == 19); *lhs = *rhs; assert((*lhs)[0] == 19); *rhs = kk; assert(*rhs == kk); assert(kk[0] == 18); assert((*rhs)[0] == 18); } int ctfeSort6250() { int[][2] x; int[3] a = [17, 18, 19]; x[0] = a[1 .. 2]; x[1] = a[2 .. $]; assert(x[0][0] == 18); assert(x[0][1] == 19); swap6250(&x[0], &x[1]); assert(x[0][0] == 19); assert(x[1][0] == 18); a[1] = 57; assert(x[0][0] == 19); return x[1][0]; } static assert(ctfeSort6250() == 57); /************************************************** 6672 circular references in array **************************************************/ void bug6672(ref string lhs, ref string rhs) { auto tmp = lhs; lhs = rhs; rhs = tmp; } static assert({ auto kw = ["a"]; bug6672(kw[0], kw[0]); return true; }()); void slice6672(ref string[2] agg, ref string lhs) { agg[0 .. $] = lhs; } static assert({ string[2] kw = ["a", "b"]; slice6672(kw, kw[0]); assert(kw[0] == "a"); assert(kw[1] == "a"); return true; }()); // an unrelated rejects-valid bug static assert({ string[2] kw = ["a", "b"]; kw[0 .. 2] = "x"; return true; }()); void bug6672b(ref string lhs, ref string rhs) { auto tmp = lhs; assert(tmp == "a"); lhs = rhs; assert(tmp == "a"); rhs = tmp; } static assert({ auto kw=["a", "b"]; bug6672b(kw[0], kw[1]); assert(kw[0] == "b"); assert(kw[1] == "a"); return true; }()); /************************************************** 6399 (*p).length = n **************************************************/ struct A6399 { int[] arr; int subLen() { arr = [1, 2, 3, 4, 5]; arr.length -= 1; return cast(int)arr.length; } } static assert({ A6399 a; return a.subLen(); }() == 4); /************************************************** 7789 (*p).length++ where *p is null **************************************************/ struct S7789 { size_t foo() { _ary.length += 1; return _ary.length; } int[] _ary; } static assert(S7789().foo()); /************************************************** 6418 member named 'length' **************************************************/ struct Bug6418 { size_t length() { return 189; } } static assert(Bug6418.init.length == 189); /************************************************** 4021 rehash **************************************************/ bool bug4021() { int[int] aa = [1: 1]; aa.rehash; return true; } static assert(bug4021()); /************************************************** 11629 crash on AA.rehash **************************************************/ struct Base11629 { alias T = ubyte, Char = char; alias String = immutable(Char)[]; const Char[T] toChar; this(int _dummy) { Char[T] toCharTmp = [0:'A']; toChar = toCharTmp.rehash; } } enum ct11629 = Base11629(4); /************************************************** 3512 foreach (dchar; string) 6558 foreach (int, dchar; string) **************************************************/ bool test3512() { string s = "öhai"; int q = 0; foreach (wchar c; s) { if (q == 2) assert(c == 'a'); ++q; } assert(q == 4); // _aApplycd1 foreach (dchar c; s) { ++q; if (c == 'h') break; } assert(q == 6); // _aApplycw2 foreach (int i, wchar c; s) { assert(i >= 0 && i < s.length); } // _aApplycd2 foreach (int i, dchar c; s) { assert(i >= 0 && i < s.length); } wstring w = "xüm"; // _aApplywc1 foreach (char c; w) { ++q; } assert(q == 10); // _aApplywd1 foreach (dchar c; w) { ++q; } assert(q == 13); // _aApplywc2 foreach (int i, char c; w) { assert(i >= 0 && i < w.length); } // _aApplywd2 foreach (int i, dchar c; w) { assert(i >= 0 && i < w.length); } dstring d = "yäq"; // _aApplydc1 q = 0; foreach (char c; d) { ++q; } assert(q == 4); // _aApplydw1 q = 0; foreach (wchar c; d) { ++q; } assert(q == 3); // _aApplydc2 foreach (int i, char c; d) { assert(i >= 0 && i < d.length); } // _aApplydw2 foreach (int i, wchar c; d) { assert(i >= 0 && i < d.length); } dchar[] dr = "squop"d.dup; foreach (int n, char c; dr) { if (n == 2) break; assert(c != 'o'); } // _aApplyRdc1 foreach_reverse (char c; dr) {} // _aApplyRdw1 foreach_reverse (wchar c; dr) {} // _aApplyRdc2 foreach_reverse (int n, char c; dr) { if (n == 4) break; assert(c != 'o'); } // _aApplyRdw2 foreach_reverse (int i, wchar c; dr) { assert(i >= 0 && i < dr.length); } q = 0; wstring w2 = ['x', 'ü', 'm']; // foreach over array literals foreach_reverse (int n, char c; w2) { ++q; if (c == 'm') assert(n == 2 && q == 1); if (c == 'x') assert(n == 0 && q == 4); } return true; } static assert(test3512()); /************************************************** 6510 ICE only with -inline **************************************************/ struct Stack6510 { struct Proxy { void shrink() {} } Proxy stack; void pop() { stack.shrink(); } } int bug6510() { static int used() { Stack6510 junk; junk.pop(); return 3; } return used(); } void test6510() { static assert(bug6510() == 3); } /************************************************** 6511 arr[] shouldn't make a copy **************************************************/ T bug6511(T)() { T[1] a = [1]; a[] += a[]; return a[0]; } static assert(bug6511!ulong() == 2); static assert(bug6511!long() == 2); /************************************************** 6512 new T[][] **************************************************/ bool bug6512(int m) { auto x = new int[2][][](m, 5); assert(x.length == m); assert(x[0].length == 5); assert(x[0][0].length == 2); foreach (i; 0.. m) foreach (j; 0 .. 5) foreach (k; 0 .. 2) x[i][j][k] = k + j*10 + i*100; foreach (i; 0.. m) foreach (j; 0 .. 5) foreach (k; 0 .. 2) assert(x[i][j][k] == k + j*10 + i*100); return true; } static assert(bug6512(3)); /************************************************** 6516 ICE(constfold.c) **************************************************/ dstring bug6516() { return cast(dstring)new dchar[](0); } static assert(bug6516() == ""d); /************************************************** 6727 ICE(interpret.c) **************************************************/ const(char)* ice6727(const(char)* z) { return z; } static assert({ auto q = ice6727("a".dup.ptr); return true; }()); /************************************************** 6721 Cannot get pointer to start of char[] **************************************************/ static assert({ char[] c1 = "".dup; auto p = c1.ptr; string c2 = ""; auto p2 = c2.ptr; return 6; }() == 6); /************************************************** 6693 Assign to null AA **************************************************/ struct S6693 { int[int] m; } static assert({ int[int][int] aaa; aaa[3][1] = 4; int[int][3] aab; aab[2][1] = 4; S6693 s; s.m[2] = 4; return 6693; }() == 6693); /************************************************** 7602 Segfault AA.keys on null AA **************************************************/ string[] test7602() { int[string] array; return array.keys; } enum bug7602 = test7602(); /************************************************** 6739 Nested AA assignment **************************************************/ static assert({ int[int][int][int] aaa; aaa[3][1][6] = 14; return aaa[3][1][6]; }() == 14); static assert({ int[int][int] aaa; aaa[3][1] = 4; aaa[3][3] = 3; aaa[1][5] = 9; auto kk = aaa[1][5]; return kk; }() == 9); /************************************************** 6751 ref AA assignment **************************************************/ void bug6751(ref int[int] aa) { aa[1] = 2; } static assert({ int[int] aa; bug6751(aa); assert(aa[1] == 2); return true; }()); void bug6751b(ref int[int][int] aa) { aa[1][17] = 2; } struct S6751 { int[int][int] aa; int[int] bb; } static assert({ S6751 s; bug6751b(s.aa); assert(s.aa[1][17] == 2); return true; }()); static assert({ S6751 s; s.aa[7][56] = 57; bug6751b(s.aa); assert(s.aa[1][17] == 2); assert(s.aa[7][56] == 57); bug6751c(s.aa); assert(s.aa.keys.length == 1); assert(s.aa.values.length == 1); return true; }()); static assert({ S6751 s; s.bb[19] = 97; bug6751(s.bb); assert(s.bb[1] == 2); assert(s.bb[19] == 97); return true; }()); void bug6751c(ref int[int][int] aa) { aa = [38: [56 : 77]]; } /************************************************** 7790 AA foreach ref **************************************************/ struct S7790 { size_t id; } size_t bug7790(S7790[string] tree) { foreach (k, ref v; tree) v.id = 1; return tree["a"].id; } static assert(bug7790(["a":S7790(0)]) == 1); /************************************************** 6765 null AA.length **************************************************/ static assert({ int[int] w; return w.length; }() == 0); /************************************************** 6769 AA.keys, AA.values with -inline **************************************************/ static assert({ double[char[3]] w = ["abc" : 2.3]; double[] z = w.values; return w.keys.length; }() == 1); /************************************************** 4022 AA.get **************************************************/ static assert({ int[int] aa = [58: 13]; int r = aa.get(58, 1000); assert(r == 13); r = aa.get(59, 1000); return r; }() == 1000); /************************************************** 6775 AA.opApply **************************************************/ static assert({ int[int] aa = [58: 17, 45:6]; int valsum = 0; int keysum = 0; foreach (m; aa) // aaApply { valsum += m; } assert(valsum == 17 + 6); valsum = 0; foreach (n, m; aa) // aaApply2 { valsum += m; keysum += n; } assert(valsum == 17 + 6); assert(keysum == 58 + 45); // Check empty AA valsum = 0; int[int] bb; foreach (m; bb) { ++valsum; } assert(valsum == 0); return true; }()); /************************************************** 7890 segfault struct with AA field **************************************************/ struct S7890 { int[int] tab; } S7890 bug7890() { S7890 foo; foo.tab[0] = 0; return foo; } enum e7890 = bug7890(); /************************************************** AA.remove **************************************************/ static assert({ int[int] aa = [58: 17, 45:6]; aa.remove(45); assert(aa.length == 1); aa.remove(7); assert(aa.length == 1); aa.remove(58); assert(aa.length == 0); return true; }()); /************************************************** try, finally **************************************************/ static assert({ int n = 0; try { n = 1; } catch (Exception e) {} assert(n == 1); try { n = 2; } catch (Exception e) {} finally { assert(n == 2); n = 3; } assert(n == 3); return true; }()); /************************************************** 6800 bad pointer casts **************************************************/ bool badpointer(int k) { int m = 6; int* w = &m; assert(*w == 6); int[3] a = [17, 2, 21]; int* w2 = &a[2]; assert(*w2 == 21); // cast int* to uint* is OK uint* u1 = cast(uint*)w; assert(*u1 == 6); uint* u2 = cast(uint*)w2; assert(*u2 == 21); uint* u3 = cast(uint*)&m; assert(*u3 == 6); // cast int* to void* is OK void* v1 = cast(void*)w; void* v3 = &m; void* v4 = &a[0]; // cast from void* back to int* is OK int* t3 = cast(int*)v3; assert(*t3 == 6); int* t4 = cast(int*)v4; assert(*t4 == 17); // cast from void* to uint* is OK uint* t1 = cast(uint*)v1; assert(*t1 == 6); // and check that they're real pointers m = 18; assert(*t1 == 18); assert(*u3 == 18); int** p = &w; if (k == 1) // bad reinterpret double *d1 = cast(double*)w; if (k == 3) // bad reinterpret char* d3 = cast(char*)w2; if (k == 4) { void* q1 = cast(void*)p; // OK-void is int* void* *q = cast(void**)p; // OK-void is int } if (k == 5) void*** q = cast(void***)p; // bad: too many * if (k == 6) // bad reinterpret through void* double* d1 = cast(double*)v1; if (k == 7) double* d7 = cast(double*)v4; if (k == 8) ++v4; // can't do pointer arithmetic on void* return true; } static assert(badpointer(4)); static assert(!is(typeof(compiles!(badpointer(1))))); static assert( is(typeof(compiles!(badpointer(2))))); static assert(!is(typeof(compiles!(badpointer(3))))); static assert( is(typeof(compiles!(badpointer(4))))); static assert(!is(typeof(compiles!(badpointer(5))))); static assert(!is(typeof(compiles!(badpointer(6))))); static assert(!is(typeof(compiles!(badpointer(7))))); static assert(!is(typeof(compiles!(badpointer(8))))); /************************************************** 10211 Allow casts S**->D**, when S*->D* is OK **************************************************/ int bug10211() { int m = 7; int* x = &m; int** y = &x; assert(**y == 7); uint* p = cast(uint*)x; uint** q = cast(uint**)y; return 1; } static assert(bug10211()); /************************************************** 10568 CTFE rejects function pointer safety casts **************************************************/ @safe void safetyDance() {} int isItSafeToDance() { void function() @trusted yourfriends = &safetyDance; void function() @safe nofriendsOfMine = yourfriends; return 1; } static assert(isItSafeToDance()); /************************************************** 12296 CTFE rejects const compatible AA pointer cast **************************************************/ int test12296() { immutable x = [5 : 4]; auto aa = &x; const(int[int])* y = aa; return 1; } static assert(test12296()); /************************************************** 9170 Allow reinterpret casts float<->int **************************************************/ int f9170(float x) { return *(cast(int*)&x); } float i9170(int x) { return *(cast(float*)&x); } float u9170(uint x) { return *(cast(float*)&x); } int f9170arr(float[] x) { return *(cast(int*)&(x[1])); } long d9170(double x) { return *(cast(long*)&x); } int fref9170(ref float x) { return *(cast(int*)&x); } long dref9170(ref double x) { return *(cast(long*)&x); } bool bug9170() { float f = 1.25; double d = 1.25; assert(f9170(f) == 0x3FA0_0000); assert(fref9170(f) == 0x3FA0_0000); assert(d9170(d) == 0x3FF4_0000_0000_0000L); assert(dref9170(d) == 0x3FF4_0000_0000_0000L); float [3] farr = [0, 1.25, 0]; assert(f9170arr(farr) == 0x3FA0_0000); int i = 0x3FA0_0000; assert(i9170(i) == 1.25); uint u = 0x3FA0_0000; assert(u9170(u) == 1.25); return true; } static assert(bug9170()); /************************************************** 6792 ICE with pointer cast of indexed array **************************************************/ struct S6792 { int i; } static assert({ { void* p; p = [S6792(1)].ptr; S6792 s = *(cast(S6792*)p); assert(s.i == 1); } { void*[] ary; ary ~= [S6792(2)].ptr; S6792 s = *(cast(S6792*)ary[0]); assert(s.i == 2); } { void*[7] ary; ary[6]= [S6792(2)].ptr; S6792 s = *(cast(S6792*)ary[6]); assert(s.i == 2); } { void* p; p = [S6792(1)].ptr; void*[7] ary; ary[5]= p; S6792 s = *(cast(S6792*)ary[5]); assert(s.i == 1); } { S6792*[string] aa; aa["key"] = [S6792(3)].ptr; const(S6792) s = *(cast(const(S6792)*)aa["key"]); assert(s.i == 3); } { S6792[string] blah; blah["abc"] = S6792(6); S6792*[string] aa; aa["kuy"] = &blah["abc"]; const(S6792) s = *(cast(const(S6792)*)aa["kuy"]); assert(s.i == 6); void*[7] ary; ary[5]= &blah["abc"]; S6792 t = *(cast(S6792*)ary[5]); assert(t.i == 6); int q = 6; ary[3]= &q; int gg = *(cast(int*)(ary[3])); } return true; }()); /************************************************** 7780 array cast **************************************************/ int bug7780(int testnum) { int[] y = new int[2]; y[0] = 2000000; if (testnum == 1) { void[] x = y; return (cast(byte[])x)[1]; } if (testnum == 2) { int[] x = y[0 .. 1]; return (cast(byte[])x)[1]; } return 1; } static assert( is(typeof(compiles!(bug7780(0))))); static assert(!is(typeof(compiles!(bug7780(1))))); static assert(!is(typeof(compiles!(bug7780(2))))); /************************************************** 14028 - static array pointer that refers existing array elements. **************************************************/ int test14028a(size_t ofs)(bool ct) { int[4] a; int[2]* p; int num = ofs; if (ct) p = cast(int[2]*)&a[ofs]; // SymOffExp else p = cast(int[2]*)&a[num]; // CastExp + AddrExp // pointers comparison assert(cast(void*)a.ptr <= cast(void*)p); assert(cast(void*)a.ptr <= cast(void*)&(*p)[0]); assert(cast(void*)&a[0] <= cast(void*)p); return 1; } static assert(test14028a!0(true)); static assert(test14028a!0(false)); static assert(test14028a!3(true)); static assert(test14028a!3(false)); static assert(!is(typeof(compiles!(test14028a!4(true))))); static assert(!is(typeof(compiles!(test14028a!4(false))))); int test14028b(int num) { int[4] a; int[2]* p; if (num == 1) { p = cast(int[2]*)&a[0]; // &a[0..2]; (*p)[0] = 1; // a[0] = 1 (*p)[1] = 2; // a[1] = 2 assert(a == [1,2,0,0]); p = p + 1; // &a[0] -> &a[2] (*p)[0] = 3; // a[2] = 3 (*p)[1] = 4; // a[3] = 4 assert(a == [1,2,3,4]); } if (num == 2) { p = cast(int[2]*)&a[1]; // &a[1..3]; (*p)[0] = 1; // a[1] = 1 p = p + 1; // &a[1..3] -> &a[3..5] (*p)[0] = 2; // a[3] = 2 assert(a == [0,1,0,2]); } if (num == 3) { p = cast(int[2]*)&a[1]; // &a[1..3]; (*p)[0] = 1; // a[1] = 1 p = p + 1; // &a[1..3] -> &a[3..5] (*p)[0] = 2; // a[3] = 2 (*p)[1] = 3; // a[4] = 3 (CTFE error) } if (num == 4) { p = cast(int[2]*)&a[0]; // &a[0..2]; p = p + 1; // &a[0..2] -> &a[2..4] p = p + 1; // &a[2..4] -> &a[4..6] (ok) } if (num == 5) { p = cast(int[2]*)&a[1]; // &a[1..3]; p = p + 2; // &a[1..3] -> &a[5..7] (CTFE error) } return 1; } static assert(test14028b(1)); static assert(test14028b(2)); static assert(!is(typeof(compiles!(test14028b(3))))); static assert(test14028b(4)); static assert(!is(typeof(compiles!(test14028b(5))))); /************************************************** 10275 cast struct literals to immutable **************************************************/ struct Bug10275 { uint[] ivals; } Bug10275 bug10275() { return Bug10275([1, 2, 3]); } int test10275() { immutable(Bug10275) xxx = cast(immutable(Bug10275))bug10275(); return 1; } static assert(test10275()); /************************************************** 6851 passing pointer by argument **************************************************/ void set6851(int* pn) { *pn = 20; } void bug6851() { int n = 0; auto pn = &n; *pn = 10; assert(n == 10); set6851(&n); } static assert({ bug6851(); return true; }()); /************************************************** 7876 **************************************************/ int* bug7876(int n) { int x; auto ptr = &x; if (n == 2) ptr = null; return ptr; } struct S7876 { int* p; } S7876 bug7876b(int n) { int x; S7876 s; s.p = &x; if (n == 11) s.p = null; return s; } int test7876(int n) { if (n >= 10) { S7876 m = bug7876b(n); return 1; } int* p = bug7876(n); return 1; } static assert( is(typeof(compiles!(test7876(2))))); static assert(!is(typeof(compiles!(test7876(0))))); static assert( is(typeof(compiles!(test7876(11))))); static assert(!is(typeof(compiles!(test7876(10))))); /************************************************** 11824 **************************************************/ int f11824(T)() { T[] arr = new T[](1); T* getAddr(ref T a) { return &a; } getAddr(arr[0]); return 1; } static assert(f11824!int()); // OK static assert(f11824!(int[])()); // OK <- NG /************************************************** 6817 if converted to &&, only with -inline **************************************************/ static assert({ void toggle() { bool b; if (b) b = false; } toggle(); return true; }()); /************************************************** cast to void **************************************************/ static assert({ cast(void)(71); return true; }()); /************************************************** 6816 nested function can't access this **************************************************/ struct S6816 { size_t foo() { return (){ return value +1 ; }(); } size_t value; } enum s6816 = S6816().foo(); /************************************************** 7277 ICE nestedstruct.init.tupleof **************************************************/ struct Foo7277 { int a; int func() { int b; void nested() { b = 7; a = 10; } nested(); return a+b; } } static assert(Foo7277().func() == 17); /************************************************** 10217 ICE. CTFE version of 9315 **************************************************/ bool bug10217() { struct S { int i; void bar() {} } auto yyy = S.init.tupleof[$ - 1]; assert(!yyy); return 1; } static assert(bug10217()); /************************************************** 8276 ICE **************************************************/ void bug8676(int n) { const int X1 = 4 + n; const int X2 = 4; int X3 = 4; int bar1() { return X1; } int bar2() { return X2; } int bar3() { return X3; } static assert(!is(typeof(compiles!(bar1())))); static assert( is(typeof(compiles!(bar2())))); static assert(!is(typeof(compiles!(bar3())))); } /************************************************** classes and interfaces **************************************************/ interface SomeInterface { int daz(); float bar(char); int baz(); } interface SomeOtherInterface { int xxx(); } class TheBase : SomeInterface, SomeOtherInterface { int q = 88; int rad = 61; int a = 14; int somebaseclassfunc() { return 28; } int daz() { return 0; } int baz() { return 0; } int xxx() { return 762; } int foo() { return q; } float bar(char c) { return 3.6; } } class SomeClass : TheBase, SomeInterface { int gab = 9; int fab; int a = 17; int b = 23; override int foo() { return gab + a; } override float bar(char c) { return 2.6; } int something() { return 0; } override int daz() { return 0; } override int baz() { return 0; } } class Unrelated : TheBase { this(int x) { a = x; } } auto classtest1(int n) { SomeClass c = new SomeClass; assert(c.a == 17); assert(c.q == 88); TheBase d = c; assert(d.a == 14); assert(d.q == 88); if (n == 7) { // bad cast -- should fail Unrelated u = cast(Unrelated)d; assert(u is null); } SomeClass e = cast(SomeClass)d; d.q = 35; assert(c.q == 35); assert(c.foo() == 9 + 17); ++c.a; assert(c.foo() == 9 + 18); assert(d.foo() == 9 + 18); d = new TheBase; SomeInterface fc = c; SomeOtherInterface ot = c; assert(fc.bar('x') == 2.6); assert(ot.xxx() == 762); fc = d; ot = d; assert(fc.bar('x') == 3.6); assert(ot.xxx() == 762); Unrelated u2 = new Unrelated(7); assert(u2.a == 7); return 6; } static assert(classtest1(1)); static assert(classtest1(2)); static assert(classtest1(7)); // bug 7154 // can't initialize enum with not null class SomeClass classtest2(int n) { return n == 5 ? (new SomeClass) : null; } static assert( is(typeof((){ enum const(SomeClass) xx = classtest2(2);}()))); static assert(!is(typeof((){ enum const(SomeClass) xx = classtest2(5);}()))); class RecursiveClass { int x; this(int n) { x = n; } RecursiveClass b; void doit() { b = new RecursiveClass(7); b.x = 2;} } int classtest3() { RecursiveClass x = new RecursiveClass(17); x.doit(); RecursiveClass y = x.b; assert(y.x == 2); assert(x.x == 17); return 1; } static assert(classtest3()); /************************************************** 12016 class cast and qualifier reinterpret **************************************************/ class B12016 { } class C12016 : B12016 { } bool f12016(immutable B12016 b) { assert(b); return true; } static assert(f12016(new immutable C12016)); /************************************************** 10610 ice immutable implicit conversion **************************************************/ class Bug10610(T) { int baz() immutable { return 1; } static immutable(Bug10610!T) min = new Bug10610!T(); } void ice10610() { alias T10610 = Bug10610!(int); static assert (T10610.min.baz()); } /************************************************** 13141 regression fix caused by 10610 **************************************************/ struct MapResult13141(alias pred) { int[] range; @property empty() { return range.length == 0; } @property front() { return pred(range[0]); } void popFront() { range = range[1 .. $]; } } string[] array13141(R)(R r) { typeof(return) result; foreach (e; r) result ~= e; return result; } //immutable string[] splitterNames = [4].map!(e => "4").array(); immutable string[] splitterNames13141 = MapResult13141!(e => "4")([4]).array13141(); /************************************************** 11587 AA compare **************************************************/ static assert([1:2, 3:4] == [3:4, 1:2]); /************************************************** 14325 more AA comparisons **************************************************/ static assert([1:1] != [1:2, 2:1]); // OK static assert([1:1] != [1:2]); // OK static assert([1:1] != [2:1]); // OK <- Error static assert([1:1, 2:2] != [3:3, 4:4]); // OK <- Error /************************************************** 7147 typeid() **************************************************/ static assert({ TypeInfo xxx = typeid(Object); TypeInfo yyy = typeid(new Error("xxx")); return true; }()); int bug7147(int n) { Error err = n ? new Error("xxx") : null; TypeInfo qqq = typeid(err); return 1; } // Must not segfault if class is null static assert(!is(typeof(compiles!(bug7147(0))))); static assert( is(typeof(compiles!(bug7147(1))))); /************************************************** 14123 - identity TypeInfo objects **************************************************/ static assert({ bool eq(TypeInfo t1, TypeInfo t2) { return t1 is t2; } class C {} struct S {} assert( eq(typeid(C), typeid(C))); assert(!eq(typeid(C), typeid(Object))); assert( eq(typeid(S), typeid(S))); assert(!eq(typeid(S), typeid(int))); assert( eq(typeid(int), typeid(int))); assert(!eq(typeid(int), typeid(long))); Object o = new Object; Object c = new C; assert( eq(typeid(o), typeid(o))); assert(!eq(typeid(c), typeid(o))); assert(!eq(typeid(o), typeid(S))); return 1; }()); /************************************************** 6885 wrong code with new array **************************************************/ struct S6885 { int p; } int bug6885() { auto array = new double[1][2]; array[1][0] = 6; array[0][0] = 1; assert(array[1][0] == 6); auto barray = new S6885[2]; barray[1].p = 5; barray[0].p = 2; assert(barray[1].p == 5); return 1; } static assert(bug6885()); /************************************************** 6886 ICE with new array of dynamic arrays **************************************************/ int bug6886() { auto carray = new int[][2]; carray[1] = [6]; carray[0] = [4]; assert(carray[1][0] == 6); return 1; } static assert(bug6886()); /************************************************** 10198 Multidimensional struct block initializer **************************************************/ struct Block10198 { int val[3][4]; } int bug10198() { Block10198 pp = Block10198(67); assert(pp.val[2][3] == 67); assert(pp.val[1][3] == 67); return 1; } static assert(bug10198()); /************************************************** 14440 Multidimensional block initialization should create distinct arrays for each elements **************************************************/ struct Matrix14440(E, size_t row, size_t col) { E[col][row] array2D; @safe pure nothrow this(E[row * col] numbers...) { foreach (r; 0 .. row) { foreach (c; 0 .. col) { array2D[r][c] = numbers[r * col + c]; } } } } void test14440() { // Replace 'enum' with 'auto' here and it will work fine. enum matrix = Matrix14440!(int, 3, 3)( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); static assert(matrix.array2D[0][0] == 1); static assert(matrix.array2D[0][1] == 2); static assert(matrix.array2D[0][2] == 3); static assert(matrix.array2D[1][0] == 4); static assert(matrix.array2D[1][1] == 5); static assert(matrix.array2D[1][2] == 6); static assert(matrix.array2D[2][0] == 7); static assert(matrix.array2D[2][1] == 8); static assert(matrix.array2D[2][2] == 9); } /**************************************************** * Exception chaining tests from xtest46.d ****************************************************/ class A75 { pure static void raise(string s) { throw new Exception(s); } } int test75() { int x = 0; try { A75.raise("a"); } catch (Exception e) { x = 1; } assert(x == 1); return 1; } static assert(test75()); /**************************************************** * Exception chaining tests from test4.d ****************************************************/ int test4_test54() { int status = 0; try { try { status++; assert(status == 1); throw new Exception("first"); } finally { status++; assert(status == 2); status++; throw new Exception("second"); } } catch (Exception e) { assert(e.msg == "first"); assert(e.next.msg == "second"); } return true; } static assert(test4_test54()); void foo55() { try { Exception x = new Exception("second"); throw x; } catch (Exception e) { assert(e.msg == "second"); } } int test4_test55() { int status = 0; try { try { status++; assert(status == 1); Exception x = new Exception("first"); throw x; } finally { status++; assert(status == 2); status++; foo55(); } } catch (Exception e) { assert(e.msg == "first"); assert(status == 3); } return 1; } static assert(test4_test55()); /**************************************************** * Exception chaining tests from eh.d ****************************************************/ void bug1513outer() { int result1513; void bug1513a() { throw new Exception("d"); } void bug1513b() { try { try { bug1513a(); } finally { result1513 |= 4; throw new Exception("f"); } } catch (Exception e) { assert(e.msg == "d"); assert(e.next.msg == "f"); assert(!e.next.next); } } void bug1513c() { try { try { throw new Exception("a"); } finally { result1513 |= 1; throw new Exception("b"); } } finally { bug1513b(); result1513 |= 2; throw new Exception("c"); } } void bug1513() { result1513 = 0; try { bug1513c(); } catch (Exception e) { assert(result1513 == 7); assert(e.msg == "a"); assert(e.next.msg == "b"); assert(e.next.next.msg == "c"); } } bug1513(); } void collideone() { try { throw new Exception("x"); } finally { throw new Exception("y"); } } void doublecollide() { try { try { try { throw new Exception("p"); } finally { throw new Exception("q"); } } finally { collideone(); } } catch (Exception e) { assert(e.msg == "p"); assert(e.next.msg == "q"); assert(e.next.next.msg == "x"); assert(e.next.next.next.msg == "y"); assert(!e.next.next.next.next); } } void collidetwo() { try { try { throw new Exception("p2"); } finally { throw new Exception("q2"); } } finally { collideone(); } } void collideMixed() { int works = 6; try { try { try { throw new Exception("e"); } finally { throw new Error("t"); } } catch (Exception f) { // Doesn't catch, because Error is chained to it. works += 2; } } catch (Error z) { works += 4; assert(z.msg == "t"); // Error comes first assert(z.next is null); assert(z.bypassedException.msg == "e"); } assert(works == 10); } class AnotherException : Exception { this(string s) { super(s); } } void multicollide() { try { try { try { try { throw new Exception("m2"); } finally { throw new AnotherException("n2"); } } catch (AnotherException s) { // Not caught -- we needed to catch the root cause "m2", not // just the collateral "n2" (which would leave m2 uncaught). assert(0); } } finally { collidetwo(); } } catch (Exception f) { assert(f.msg == "m2"); assert(f.next.msg == "n2"); Throwable e = f.next.next; assert(e.msg == "p2"); assert(e.next.msg == "q2"); assert(e.next.next.msg == "x"); assert(e.next.next.next.msg == "y"); assert(!e.next.next.next.next); } } int testsFromEH() { bug1513outer(); doublecollide(); collideMixed(); multicollide(); return 1; } static assert(testsFromEH()); /************************************************** With + synchronized statements + bug 6901 **************************************************/ struct With1 { int a; int b; } class Foo6 { } class Foo32 { struct Bar { int x; } } class Base56 { private string myfoo; private string mybar; // Get/set properties that will be overridden. void foo(string s) { myfoo = s; } string foo() { return myfoo; } // Get/set properties that will not be overridden. void bar(string s) { mybar = s; } string bar() { return mybar; } } class Derived56 : Base56 { alias Base56.foo foo; // Bring in Base56's foo getter. override void foo(string s) { super.foo = s; } // Override foo setter. } int testwith() { With1 x = With1(7); with (x) { a = 2; } assert(x.a == 2); // from test11.d Foo6 foo6 = new Foo6(); with (foo6) { int xx; xx = 4; } with (new Foo32) { Bar z; z.x = 5; } Derived56 d = new Derived56; with (d) { foo = "hi"; d.foo = "hi"; bar = "hi"; assert(foo == "hi"); assert(d.foo == "hi"); assert(bar == "hi"); } int w = 7; synchronized { ++w; } assert(w == 8); return 1; } static assert(testwith()); /************************************************** 9236 ICE switch with(EnumType) **************************************************/ enum Command9236 { Char, Any, }; bool bug9236(Command9236 cmd) { int n = 0; with (Command9236) switch (cmd) { case Any: n = 1; break; default: n = 2; } assert(n == 1); switch (cmd) with (Command9236) { case Any: return true; default: return false; } } static assert(bug9236(Command9236.Any)); /************************************************** 6416 static struct declaration **************************************************/ static assert({ static struct S { int y = 7; } S a; a.y += 6; assert(a.y == 13); return true; }()); /************************************************** 10499 static template struct declaration **************************************************/ static assert({ static struct Result() {} return true; }()); /************************************************** 13757 extern(C) alias declaration **************************************************/ static assert({ alias FP1 = extern(C) int function(); alias extern(C) int function() FP2; return true; }()); /************************************************** 6522 opAssign + foreach ref **************************************************/ struct Foo6522 { bool b = false; void opAssign(int x) { this.b = true; } } bool foo6522() { Foo6522[1] array; foreach (ref item; array) item = 1; return true; } static assert(foo6522()); /************************************************** 7245 pointers + foreach ref **************************************************/ int bug7245(int testnum) { int[3] arr; arr[0] = 4; arr[1] = 6; arr[2] = 8; int* ptr; foreach (i, ref p; arr) { if (i == 1) ptr = &p; if (testnum == 1) p = 5; } return *ptr; } static assert(bug7245(0) == 6); static assert(bug7245(1) == 5); /************************************************** 8498 modifying foreach 7658 foreach ref 8539 nested funcs, ref param, -inline **************************************************/ int bug8498() { foreach (ref i; 0 .. 5) { assert(i == 0); i = 100; } return 1; } static assert(bug8498()); string bug7658() { string[] children = ["0"]; foreach (ref child; children) child = "1"; return children[0]; } static assert(bug7658() == "1"); int bug8539() { static void one(ref int x) { x = 1; } static void go() { int y; one(y); assert(y == 1); // fails with -inline } go(); return 1; } static assert(bug8539()); /************************************************** 7874, 13297, 13740 - better lvalue handling **************************************************/ int bug7874(int x){ return ++x = 1; } static assert(bug7874(0) == 1); // ---- struct S13297 { int* p; } void f13297(ref int* p) { p = cast(int*) 1; assert(p); // passes } static assert( { S13297 s; f13297(s.p); return s.p != null; // false }()); // ---- class R13740 { int e; bool empty = false; @property ref front() { return e; } void popFront() { empty = true; } } static assert({ auto r = new R13740(); foreach (ref e; r) e = 42; assert(r.e == 42); /* fails in CTFE */ return true; }()); /************************************************** 6919 **************************************************/ void bug6919(int* val) { *val = 1; } void test6919() { int n; bug6919(&n); assert(n == 1); } static assert({ test6919(); return true; }()); void bug6919b(string* val) { *val = "1"; } void test6919b() { string val; bug6919b(&val); assert(val == "1"); } static assert({ test6919b(); return true; }()); /************************************************** 6995 **************************************************/ struct Foo6995 { static size_t index(size_t v)() { return v; } } static assert(Foo6995.index!(27)() == 27); /************************************************** 7043 ref with -inline **************************************************/ int bug7043(S)(ref int x) { return x; } static assert({ int i = 416; return bug7043!(char)(i); }() == 416); /************************************************** 6037 recursive ref **************************************************/ void bug6037(ref int x, bool b) { int w = 3; if (b) { bug6037(w, false); assert(w == 6); } else { x = 6; assert(w == 3); // fails } } int bug6037outer() { int q; bug6037(q, true); return 401; } static assert(bug6037outer() == 401); /************************************************** 14299 - [REG2.067a], more than one depth of recursive call with ref **************************************************/ string gen14299(int max, int idx, ref string name) { string ret; name = [cast(char)(idx + '0')]; ret ~= name; if (idx < max) { string subname; ret ~= gen14299(max, idx + 1, subname); } ret ~= name; return ret; } string test14299(int max) { string n; return gen14299(max, 0, n); } static assert(test14299(1) == "0110"); // OK <- fail static assert(test14299(2) == "012210"); // OK <- ICE static assert(test14299(3) == "01233210"); static assert(test14299(4) == "0123443210"); static assert(test14299(5) == "012345543210"); /************************************************** 7940 wrong code for complicated assign **************************************************/ struct Bug7940 { int m; } struct App7940 { Bug7940[] x; } int bug7940() { Bug7940[2] y; App7940 app; app.x = y[0 .. 1]; app.x[0].m = 12; assert(y[0].m == 12); assert(app.x[0].m == 12); return 1; } static assert(bug7940()); /************************************************** 10298 wrong code for struct array literal init **************************************************/ struct Bug10298 { int m; } int bug10298() { Bug10298[1] y = [Bug10298(78)]; y[0].m = 6; assert(y[0].m == 6); // Root cause Bug10298[1] x; x[] = [cast(const Bug10298)(Bug10298(78))]; assert(x[0].m == 78); return 1; } static assert(bug10298()); /************************************************** 7266 dotvar ref parameters **************************************************/ struct S7266 { int a; } bool bug7266() { S7266 s; s.a = 4; bar7266(s.a); assert(s.a == 5); out7266(s.a); assert(s.a == 7); return true; } void bar7266(ref int b) { b = 5; assert(b == 5); } void out7266(out int b) { b = 7; assert(b == 7); } static assert(bug7266()); /************************************************** 9982 dotvar assign through pointer **************************************************/ struct Bug9982 { int a; } int test9982() { Bug9982 x; int*q = &x.a; *q = 99; assert(x.a == 99); return 1; } static assert(test9982()); // 9982, rejects-valid case struct SS9982 { Bug9982 s2; this(Bug9982 s1) { s2.a = 6; emplace9982(&s2, s1); assert(s2.a == 3); } } void emplace9982(Bug9982* chunk, Bug9982 arg) { *chunk = arg; } enum s9982 = Bug9982(3); enum p9982 = SS9982(s9982); /************************************************** 11618 dotvar assign through casted pointer **************************************************/ struct Tuple11618(T...) { T field; alias field this; } static assert({ Tuple11618!(immutable dchar) result = void; auto addr = cast(dchar*)&result[0]; *addr = dchar.init; return (result[0] == dchar.init); }()); /************************************************** 7143 'is' for classes **************************************************/ class C7143 { int x; } int bug7143(int test) { C7143 c = new C7143; C7143 d = new C7143; if (test == 1) { if (c) return c.x + 8; return -1; } if (test == 2) { if (c is null) return -1; return c.x + 45; } if (test == 3) { if (c is c) return 58; } if (test == 4) { if (c !is c) return -1; else return 48; } if (test == 6) d = c; if (test == 5 || test == 6) { if (c is d) return 188; else return 48; } return -1; } static assert(bug7143(1) == 8); static assert(bug7143(2) == 45); static assert(bug7143(3) == 58); static assert(bug7143(4) == 48); static assert(bug7143(5) == 48); static assert(bug7143(6) == 188); /************************************************** 7147 virtual function calls from base class **************************************************/ class A7147 { int foo() { return 0; } int callfoo() { return foo(); } } class B7147 : A7147 { override int foo() { return 1; } } int test7147() { A7147 a = new B7147; return a.callfoo(); } static assert(test7147() == 1); /************************************************** 7158 **************************************************/ class C7158 { bool b() { return true; } } struct S7158 { C7158 c; } bool test7158() { S7158 s = S7158(new C7158); return s.c.b; } static assert(test7158()); /************************************************** 8484 **************************************************/ class C8484 { int n; int b() { return n + 3; } } struct S { C8484 c; } int t8484(ref C8484 c) { return c.b(); } int test8484() { auto s = S(new C8484); s.c.n = 4; return t8484(s.c); } static assert(test8484() == 7); /************************************************** 7419 **************************************************/ struct X7419 { double x; this(double x) { this.x = x; } } void bug7419() { enum x = { auto p = X7419(3); return p.x; }(); static assert(x == 3); } /************************************************** 9445 ice **************************************************/ template c9445(T...) { } void ice9445(void delegate() expr, void function() f2) { static assert(!is(typeof(c9445!(f2())))); static assert(!is(typeof(c9445!(expr())))); } /************************************************** 10452 delegate == **************************************************/ struct S10452 { bool func() { return true; } } struct Outer10452 { S10452 inner; } class C10452 { bool func() { return true; } } bool delegate() ref10452(ref S10452 s) { return &s.func; } bool test10452() { bool delegate() bar = () { return true; }; assert(bar !is null); assert(bar is bar); S10452 bag; S10452[6] bad; Outer10452 outer; C10452 tag = new C10452; auto rat = &outer.inner.func; assert(rat == rat); auto tat = &tag.func; assert(tat == tat); auto bat = &outer.inner.func; auto mat = &bad[2].func; assert(mat is mat); assert(rat == bat); auto zat = &bag.func; auto cat = &bag.func; assert(zat == zat); assert(zat == cat); auto drat = ref10452(bag); assert(cat == drat); assert(drat == drat); drat = ref10452(bad[2]); assert( drat == mat); assert(tat != rat); assert(zat != rat); assert(rat != cat); assert(zat != bar); assert(tat != cat); cat = bar; assert(cat == bar); return true; } static assert(test10452()); /************************************************** 7162 and 4711 **************************************************/ void f7162() { } bool ice7162() { false && f7162(); false || f7162(); false && f7162(); // bug 4711 true && f7162(); return true; } static assert(ice7162()); /************************************************** 8857, only with -inline (creates an &&) **************************************************/ struct Result8857 { char[] next; } void bug8857()() { Result8857 r; r.next = null; if (true) { auto next = r.next; } } static assert({ bug8857(); return true; }()); /************************************************** 7527 **************************************************/ struct Bug7527 { char[] data; } int bug7527() { auto app = Bug7527(); app.data.ptr[0 .. 1] = "x"; return 1; } static assert(!is(typeof(compiles!(bug7527())))); /************************************************** 7527 **************************************************/ int bug7380; static assert(!is(typeof( compiles!( (){ return &bug7380; }() )))); /************************************************** 7165 **************************************************/ struct S7165 { int* ptr; bool f() const { return !!ptr; } } static assert(!S7165().f()); /************************************************** 7187 **************************************************/ int[] f7187() { return [0]; } int[] f7187b(int n) { return [0]; } int g7187(int[] r) { auto t = r[0 .. 0]; return 1; } static assert(g7187(f7187())); static assert(g7187(f7187b(7))); struct S7187 { const(int)[] field; } const(int)[] f7187c() { auto s = S7187([0]); return s.field; } bool g7187c(const(int)[] r) { auto t = r[0 .. 0]; return true; } static assert(g7187c(f7187c())); /************************************************** 6933 struct destructors **************************************************/ struct Bug6933 { int x = 3; ~this() { } } int test6933() { Bug6933 q; assert(q.x == 3); return 3; } static assert(test6933()); /************************************************** 7197 **************************************************/ int foo7197(int[] x...) { return 1; } template bar7197(y...) { enum int bar7197 = foo7197(y); } enum int bug7197 = 7; static assert(bar7197!(bug7197)); /************************************************** Enum string compare **************************************************/ enum EScmp : string { a = "aaa" } bool testEScmp() { EScmp x = EScmp.a; assert(x < "abc"); return true; } static assert(testEScmp()); /************************************************** 7667 **************************************************/ bool baz7667(int[] vars...) { return true; } struct S7667 { static void his(int n) { static assert(baz7667(2)); } } bool bug7667() { S7667 unused; unused.his(7); return true; } enum e7667 = bug7667(); /************************************************** 7536 **************************************************/ bool bug7536(string expr) { return true; } void vop() { const string x7536 = "x"; static assert(bug7536(x7536)); } /************************************************** 6681 unions **************************************************/ struct S6681 { this(int a, int b) { this.a = b; this.b = a; } union { ulong g; struct { int a, b; }; } } static immutable S6681 s6681 = S6681(0, 1); bool bug6681(int test) { S6681 x = S6681(0, 1); x.g = 5; auto u = &x.g; auto v = &x.a; long w = *u; int z; assert(w == 5); if (test == 4) z = *v; // error x.a = 2; // invalidate g, and hence u. if (test == 1) w = *u; // error z = *v; assert(z == 2); x.g = 6; w = *u; assert(w == 6); if (test == 3) z = *v; return true; } static assert(bug6681(2)); static assert(!is(typeof(compiles!(bug6681(1))))); static assert(!is(typeof(compiles!(bug6681(3))))); static assert(!is(typeof(compiles!(bug6681(4))))); /************************************************** 9113 ICE with struct in union **************************************************/ union U9113 { struct M { int y; } int xx; } int bug9113(T)() { U9113 x; x.M.y = 10; // error, need 'this' return 1; } static assert(!is(typeof(compiles!(bug9113!(int)())))); /************************************************** Creation of unions **************************************************/ union UnionTest1 { int x; float y; } int uniontest1() { UnionTest1 u = UnionTest1(1); return 1; } static assert(uniontest1()); /************************************************** 6438 void **************************************************/ struct S6438 { int a; int b = void; } void fill6438(int[] arr, int testnum) { if (testnum == 2) { auto u = arr[0]; } foreach (ref x; arr) x = 7; auto r = arr[0]; S6438[2] s; auto p = &s[0].b; if (testnum == 3) { auto v = *p; } } bool bug6438(int testnum) { int[4] stackSpace = void; fill6438(stackSpace[], testnum); assert(stackSpace == [7, 7, 7, 7]); return true; } static assert( is(typeof(compiles!(bug6438(1))))); static assert(!is(typeof(compiles!(bug6438(2))))); static assert(!is(typeof(compiles!(bug6438(3))))); /************************************************** 10994 void static array members **************************************************/ struct Bug10994 { ubyte[2] buf = void; } static bug10994 = Bug10994.init; /************************************************** 10937 struct inside union **************************************************/ struct S10937 { union { ubyte[1] a; struct { ubyte b; } } this(ubyte B) { if (B > 6) this.b = B; else this.a[0] = B; } } enum test10937 = S10937(7); enum west10937 = S10937(2); /************************************************** 13831 **************************************************/ struct Vector13831() { } struct Coord13831 { union { struct { short x; } Vector13831!() vector; } } struct Chunk13831 { this(Coord13831) { coord = coord; } Coord13831 coord; static const Chunk13831* unknownChunk = new Chunk13831(Coord13831()); } /************************************************** 7732 **************************************************/ struct AssociativeArray { int* impl; int f() { if (impl !is null) auto x = *impl; return 1; } } int test7732() { AssociativeArray aa; return aa.f; } static assert(test7732()); /************************************************** 7784 **************************************************/ struct Foo7784 { void bug() { tab["A"] = Bar7784(&this); auto pbar = "A" in tab; auto bar = *pbar; } Bar7784[string] tab; } struct Bar7784 { Foo7784* foo; int val; } bool ctfe7784() { auto foo = Foo7784(); foo.bug(); return true; } static assert(ctfe7784()); /************************************************** 7781 **************************************************/ static assert(({ return; }(), true)); /************************************************** 7785 **************************************************/ bool bug7785(int n) { int val = 7; auto p = &val; if (n == 2) { auto ary = p[0 .. 1]; } auto x = p[0]; val = 6; assert(x == 7); if (n == 3) p[0 .. 1] = 1; return true; } static assert(bug7785(1)); static assert(!is(typeof(compiles!(bug7785(2))))); static assert(!is(typeof(compiles!(bug7785(3))))); /************************************************** 7987 **************************************************/ class C7987 { int m; } struct S7987 { int* p; C7987 c; } bool bug7987() { int[7] q; int[][2] b = q[0 .. 5]; assert(b == b); assert(b is b); C7987 c1 = new C7987; C7987 c2 = new C7987; S7987 s, t; s.p = &q[0]; t.p = &q[1]; assert(s != t); s.p = &q[1]; /*assert(s == t);*/ assert(s.p == t.p); s.c = c1; t.c = c2; /*assert(s != t);*/ assert(s.c !is t.c); assert(s !is t); s.c = c2; /*assert(s == t);*/ assert(s.p == t.p && s.c is t.c); assert(s is t); return true; } static assert(bug7987()); /************************************************** 10579 typeinfo.func() must not segfault **************************************************/ static assert(!is(typeof(compiles!(typeid(int).toString.length)))); class Bug10579 { int foo() { return 1; } } Bug10579 uninitialized10579; static assert(!is(typeof(compiles!(uninitialized10579.foo())))); /************************************************** 10804 mixin ArrayLiteralExp typed string **************************************************/ void test10804() { String identity(String)(String a) { return a; } string cfun() { char[] s; s.length = 8 + 2 + (2) + 1 + 2; s[] = "identity(`Ω`c)"c[]; return cast(string)s; // Return ArrayLiteralExp as the CTFE result } { enum a1 = "identity(`Ω`c)"c; enum a2 = cfun(); static assert(cast(ubyte[])mixin(a1) == [0xCE, 0xA9]); static assert(cast(ubyte[])mixin(a2) == [0xCE, 0xA9]); // should pass } wstring wfun() { wchar[] s; s.length = 8 + 2 + (2) + 1 + 2; s[] = "identity(`\U0002083A`w)"w[]; return cast(wstring)s; // Return ArrayLiteralExp as the CTFE result } { enum a1 = "identity(`\U0002083A`w)"w; enum a2 = wfun(); static assert(cast(ushort[])mixin(a1) == [0xD842, 0xDC3A]); static assert(cast(ushort[])mixin(a2) == [0xD842, 0xDC3A]); } dstring dfun() { dchar[] s; s.length = 8 + 2 + (1) + 1 + 2; s[] = "identity(`\U00101000`d)"d[]; return cast(dstring)s; // Return ArrayLiteralExp as the CTFE result } { enum a1 = "identity(`\U00101000`d)"d; enum a2 = dfun(); static assert(cast(uint[])mixin(a1) == [0x00101000]); static assert(cast(uint[])mixin(a2) == [0x00101000]); } } /******************************************************/ struct B73 {} struct C73 { B73 b; } C73 func73() { C73 b = void; b.b = B73(); return b; } C73 test73 = func73(); /******************************************************/ struct S74 { int n[1]; static S74 test(){ S74 ret = void; ret.n[0] = 0; return ret; } } enum Test74 = S74.test(); /******************************************************/ static bool bug8865() in { int x = 0; label: foreach (i; (++x) .. 3) { if (i == 1) continue label; // doesn't work. else break label; // doesn't work. } } out { int x = 0; label: foreach (i; (++x) .. 3) { if (i == 1) continue label; // doesn't work. else break label; // doesn't work. } } body { int x = 0; label: foreach (i; (++x) .. 3) { if (i == 1) continue label; // works. else break label; // works. } return true; } static assert(bug8865()); /******************************************************/ struct Test75 { this(int) pure {} } static assert( __traits(compiles, { static shared(Test75*) t75 = new shared(Test75)(0); return t75; })); static assert( __traits(compiles, { static shared(Test75)* t75 = new shared(Test75)(0); return t75; })); static assert( __traits(compiles, { static __gshared Test75* t75 = new Test75(0); return t75; })); static assert( __traits(compiles, { static const(Test75*) t75 = new const(Test75)(0); return t75; })); static assert( __traits(compiles, { static immutable Test75* t75 = new immutable(Test75)(0); return t75; })); static assert(!__traits(compiles, { static Test75* t75 = new Test75(0); return t75; })); /+ static assert(!__traits(compiles, { enum t75 = new shared(Test75)(0); return t75; })); static assert(!__traits(compiles, { enum t75 = new Test75(0); return t75; })); static assert(!__traits(compiles, { enum shared(Test75)* t75 = new shared(Test75)(0); return t75; })); static assert(!__traits(compiles, { enum Test75* t75 = new Test75(0); return t75; })); static assert( __traits(compiles, { enum t75 = new const(Test75)(0); return t75;})); static assert( __traits(compiles, { enum t75 = new immutable(Test75)(0); return t75;})); static assert( __traits(compiles, { enum const(Test75)* t75 = new const(Test75)(0); return t75;})); static assert( __traits(compiles, { enum immutable(Test75)* t75 = new immutable(Test75)(0); return t75;})); +/ /******************************************************/ class Test76 { this(int) pure {} } /+ static assert(!__traits(compiles, { enum t76 = new shared(Test76)(0); return t76;})); static assert(!__traits(compiles, { enum t76 = new Test76(0); return t76;})); static assert(!__traits(compiles, { enum shared(Test76) t76 = new shared(Test76)(0); return t76;})); static assert(!__traits(compiles, { enum Test76 t76 = new Test76(0); return t76;})); static assert( __traits(compiles, { enum t76 = new const(Test76)(0); return t76;})); static assert( __traits(compiles, { enum t76 = new immutable(Test76)(0); return t76;})); static assert( __traits(compiles, { enum const(Test76) t76 = new const(Test76)(0); return t76;})); static assert( __traits(compiles, { enum immutable(Test76) t76 = new immutable(Test76)(0); return t76;})); +/ /******************************************************/ static assert( __traits(compiles, { static shared Test76 t76 = new shared(Test76)(0); return t76; })); static assert( __traits(compiles, { static shared(Test76) t76 = new shared(Test76)(0); return t76; })); static assert( __traits(compiles, { static __gshared Test76 t76 = new Test76(0); return t76; })); static assert( __traits(compiles, { static const Test76 t76 = new const(Test76)(0); return t76; })); static assert( __traits(compiles, { static immutable Test76 t76 = new immutable Test76(0); return t76; })); static assert(!__traits(compiles, { static Test76 t76 = new Test76(0); return t76; })); /***** Bug 5678 *********************************/ struct Bug5678 { this(int) {} } static assert(!__traits(compiles, { enum const(Bug5678)* b5678 = new const(Bug5678)(0); return b5678; })); /************************************************** 10782 run semantic2 for class field **************************************************/ enum e10782 = 0; class C10782 { int x = e10782; } string f10782() { auto c = new C10782(); return ""; } mixin(f10782()); /************************************************** 10929 NRVO support in CTFE **************************************************/ struct S10929 { this(this) { postblitCount++; } ~this() { dtorCount++; } int payload; int dtorCount; int postblitCount; } auto makeS10929() { auto s = S10929(42, 0, 0); return s; } bool test10929() { auto s = makeS10929(); assert(s.postblitCount == 0); assert(s.dtorCount == 0); return true; }; static assert(test10929()); /************************************************** 9245 - support postblit call on array assignments **************************************************/ bool test9245() { int postblits = 0; struct S { this(this) { ++postblits; } } S s; S[2] a; assert(postblits == 0); { S[2] arr = s; assert(postblits == 2); arr[] = s; assert(postblits == 4); postblits = 0; S[2] arr2 = arr; assert(postblits == 2); arr2 = arr; assert(postblits == 4); postblits = 0; const S[2] constArr = s; assert(postblits == 2); postblits = 0; const S[2] constArr2 = arr; assert(postblits == 2); postblits = 0; } { S[2][2] arr = s; assert(postblits == 4); arr[] = a; assert(postblits == 8); postblits = 0; S[2][2] arr2 = arr; assert(postblits == 4); arr2 = arr; assert(postblits == 8); postblits = 0; const S[2][2] constArr = s; assert(postblits == 4); postblits = 0; const S[2][2] constArr2 = arr; assert(postblits == 4); postblits = 0; } return true; } static assert(test9245()); /************************************************** 12906 don't call postblit on blit initializing **************************************************/ struct S12906 { this(this) { assert(0); } } static assert({ S12906[1] arr; return true; }()); /************************************************** 11510 support overlapped field access in CTFE **************************************************/ struct S11510 { union { size_t x; int* y; // pointer field } } bool test11510() { S11510 s; s.y = [1,2,3].ptr; // writing overlapped pointer field is OK assert(s.y[0 .. 3] == [1,2,3]); // reading valid field is OK s.x = 10; assert(s.x == 10); // There's no reinterpretation between S.x and S.y return true; } static assert(test11510()); /************************************************** 11534 - subtitude inout **************************************************/ struct MultiArray11534 { this(size_t[] sizes...) { storage = new size_t[5]; } @property auto raw_ptr() inout { return storage.ptr + 1; } size_t[] storage; } enum test11534 = () { auto m = MultiArray11534(3,2,1); auto start = m.raw_ptr; //this trigger the bug //auto start = m.storage.ptr + 1; //this obviously works return 0; }(); /************************************************** 11941 - Regression of 11534 fix **************************************************/ void takeConst11941(const string[]) {} string[] identity11941(string[] x) { return x; } bool test11941a() { struct S { string[] a; } S s; takeConst11941(identity11941(s.a)); s.a ~= []; return true; } static assert(test11941a()); bool test11941b() { struct S { string[] a; } S s; takeConst11941(identity11941(s.a)); s.a ~= "foo"; /* Error refers to this line (15), */ string[] b = s.a[]; /* but only when this is here. */ return true; } static assert(test11941b()); /************************************************** 11535 - element-wise assignment from string to ubyte array literal **************************************************/ struct Hash11535 { ubyte[6] _buffer; void put(scope const(ubyte)[] data...) { uint i = 0, index = 0; auto inputLen = data.length; (&_buffer[index])[0 .. inputLen - i] = (&data[i])[0 .. inputLen - i]; } } auto md5_digest11535(T...)(scope const T data) { Hash11535 hash; hash.put(cast(const(ubyte[]))data[0]); return hash._buffer; } static assert(md5_digest11535(`TEST`) == [84, 69, 83, 84, 0, 0]); /************************************************** 11540 - goto label + try-catch-finally / with statement **************************************************/ static assert(() { // enter to TryCatchStatement.body { bool c = false; try { if (c) // need to bypass front-end optimization throw new Exception(""); else { goto Lx; L1: c = true; } } catch (Exception e) {} Lx: if (!c) goto L1; } // jump inside TryCatchStatement.body { bool c = false; try { if (c) // need to bypass front-end optimization throw new Exception(""); else goto L2; L2: ; } catch (Exception e) {} } // exit from TryCatchStatement.body { bool c = false; try { if (c) // need to bypass front-end optimization throw new Exception(""); else goto L3; } catch (Exception e) {} c = true; L3: assert(!c); } return 1; }()); static assert(() { // enter to TryCatchStatement.catches which has no exception variable { bool c = false; goto L1; try { c = true; } catch (Exception/* e*/) { L1: ; } assert(c == false); } // jump inside TryCatchStatement.catches { bool c = false; try { throw new Exception(""); } catch (Exception e) { goto L2; c = true; L2: ; } assert(c == false); } // exit from TryCatchStatement.catches { bool c = false; try { throw new Exception(""); } catch (Exception e) { goto L3; c = true; } L3: assert(c == false); } return 1; }()); static assert(() { // enter forward to TryFinallyStatement.body { bool c = false; goto L0; c = true; try { L0: ; } finally {} assert(!c); } // enter back to TryFinallyStatement.body { bool c = false; try { goto Lx; L1: c = true; } finally { } Lx: if (!c) goto L1; } // jump inside TryFinallyStatement.body { try { goto L2; L2: ; } finally {} } // exit from TryFinallyStatement.body { bool c = false; try { goto L3; } finally {} c = true; L3: assert(!c); } // enter in / exit out from finally block is rejected in semantic analysis // jump inside TryFinallyStatement.finalbody { bool c = false; try { } finally { goto L4; c = true; L4: assert(c == false); } } return 1; }()); static assert(() { { bool c = false; with (Object.init) { goto L2; c = true; L2: ; } assert(c == false); } { bool c = false; with (Object.init) { goto L3; c = true; } L3: assert(c == false); } return 1; }()); /************************************************** 11627 - cast dchar to char at compile time on AA assignment **************************************************/ bool test11627() { char[ubyte] toCharTmp; dchar letter = 'A'; //char c = cast(char)letter; // OK toCharTmp[0] = cast(char)letter; // NG return true; } static assert(test11627()); /************************************************** 11664 - ignore function local static variables **************************************************/ bool test11664() { static int x; static int y = 1; return true; } static assert(test11664()); /************************************************** 12110 - operand of dereferencing does not need to be an lvalue **************************************************/ struct SliceOverIndexed12110 { Uint24Array12110* arr; @property front(uint val) { arr.dupThisReference(); } } struct Uint24Array12110 { ubyte[] data; this(ubyte[] range) { data = range; SliceOverIndexed12110(&this).front = 0; assert(data.length == range.length * 2); } void dupThisReference() { auto new_data = new ubyte[data.length * 2]; data = new_data; } } static m12110 = Uint24Array12110([0x80]); /************************************************** 12310 - heap allocation for built-in sclar types **************************************************/ bool test12310() { auto p1 = new int, p2 = p1; assert(*p1 == 0); assert(*p2 == 0); *p1 = 10; assert(*p1 == 10); assert(*p2 == 10); auto q1 = new int(3), q2 = q1; assert(*q1 == 3); assert(*q2 == 3); *q1 = 20; assert(*q1 == 20); assert(*q2 == 20); return true; } static assert(test12310()); /************************************************** 12499 - initialize TupleDeclaraion in CTFE **************************************************/ auto f12499() { //Initialize 3 ints to 5. TypeTuple!(int, int, int) a = 5; return a[0]; //Error: variable _a_field_0 cannot be read at compile time } static assert(f12499() == 5); /************************************************** 12602 - slice in struct literal members **************************************************/ struct Result12602 { uint[] source; } auto wrap12602a(uint[] r) { return Result12602(r); } auto wrap12602b(uint[] r) { Result12602 x; x.source = r; return x; } auto testWrap12602a() { uint[] dest = [1, 2, 3, 4]; auto ra = wrap12602a(dest[0 .. 2]); auto rb = wrap12602a(dest[2 .. 4]); foreach (i; 0 .. 2) rb.source[i] = ra.source[i]; assert(ra.source == [1,2]); assert(rb.source == [1,2]); assert(&ra.source[0] == &dest[0]); assert(&rb.source[0] == &dest[2]); assert(dest == [1,2,1,2]); return dest; } auto testWrap12602b() { uint[] dest = [1, 2, 3, 4]; auto ra = wrap12602b(dest[0 .. 2]); auto rb = wrap12602b(dest[2 .. 4]); foreach (i; 0 .. 2) rb.source[i] = ra.source[i]; assert(ra.source == [1,2]); assert(rb.source == [1,2]); assert(&ra.source[0] == &dest[0]); assert(&rb.source[0] == &dest[2]); assert(dest == [1,2,1,2]); return dest; } auto testWrap12602c() { uint[] dest = [1, 2, 3, 4]; auto ra = Result12602(dest[0 .. 2]); auto rb = Result12602(dest[2 .. 4]); foreach (i; 0 .. 2) rb.source[i] = ra.source[i]; assert(ra.source == [1,2]); assert(rb.source == [1,2]); assert(&ra.source[0] == &dest[0]); assert(&rb.source[0] == &dest[2]); assert(dest == [1,2,1,2]); return dest; } auto testWrap12602d() { uint[] dest = [1, 2, 3, 4]; Result12602 ra; ra.source = dest[0 .. 2]; Result12602 rb; rb.source = dest[2 .. 4]; foreach (i; 0 .. 2) rb.source[i] = ra.source[i]; assert(ra.source == [1,2]); assert(rb.source == [1,2]); assert(&ra.source[0] == &dest[0]); assert(&rb.source[0] == &dest[2]); assert(dest == [1,2,1,2]); return dest; } static assert(testWrap12602a() == [1,2,1,2]); static assert(testWrap12602b() == [1,2,1,2]); static assert(testWrap12602c() == [1,2,1,2]); static assert(testWrap12602d() == [1,2,1,2]); /************************************************** 12677 - class type initializing from DotVarExp **************************************************/ final class C12677 { TypeTuple!(Object, int[]) _test; this() { auto t0 = _test[0]; // auto t1 = _test[1]; // assert(t0 is null); assert(t1 is null); } } struct S12677 { auto f = new C12677(); } /************************************************** 12851 - interpret function local const static array **************************************************/ void test12851() { const int[5] arr; alias staticZip = TypeTuple!(arr[0]); } /************************************************** 13630 - indexing and setting array element via pointer **************************************************/ struct S13630(T) { T[3] arr; this(A...)(auto ref in A args) { auto p = arr.ptr; foreach (ref v; args) { *p = 0; } } } enum s13630 = S13630!float(1); /************************************************** 13827 **************************************************/ struct Matrix13827(T, uint N) { private static defaultMatrix() { T arr[N]; return arr; } union { T[N] A = defaultMatrix; T[N] flat; } this(A...)(auto ref in A args) { uint k; foreach (ref v; args) flat[k++] = cast(T)v; } } enum m13827 = Matrix13827!(int, 3)(1, 2, 3); /************************************************** 13847 - support DotTypeExp **************************************************/ class B13847 { int foo() { return 1; } } class C13847 : B13847 { override int foo() { return 2; } final void test(int n) { assert(foo() == n); assert(B13847.foo() == 1); assert(C13847.foo() == 2); assert(this.B13847.foo() == 1); assert(this.C13847.foo() == 2); } } class D13847 : C13847 { override int foo() { return 3; } } static assert({ C13847 c = new C13847(); c.test(2); assert(c.B13847.foo() == 1); assert(c.C13847.foo() == 2); D13847 d = new D13847(); d.test(3); assert(d.B13847.foo() == 1); assert(d.C13847.foo() == 2); assert(d.D13847.foo() == 3); c = d; c.test(3); assert(c.B13847.foo() == 1); assert(c.C13847.foo() == 2); return true; }()); /************************************************** 12495 - cast from string to immutable(ubyte)[] **************************************************/ string getStr12495() { char[1] buf = void; // dummy starting point. string s = cast(string)buf[0..0]; // empty slice, .ptr points mutable. assert(buf.ptr == s.ptr); s ~= 'a'; // this should allocate. assert(buf.ptr != s.ptr); return s.idup; // this should allocate again, and // definitly point immutable memory. } auto indexOf12495(string s) { auto p1 = s.ptr; auto p2 = (cast(immutable(ubyte)[])s).ptr; assert(cast(void*)p1 == cast(void*)p2); // OK <- fails return cast(void*)p2 - cast(void*)p1; // OK <- "cannot subtract pointers ..." } static assert(indexOf12495(getStr12495()) == 0); /************************************************** 13992 - Repainting pointer arithmetic result **************************************************/ enum hash13992 = hashOf13992("abcd".ptr); @trusted hashOf13992(const void* buf) { auto data = cast(const(ubyte)*) buf; size_t hash; data += 2; // problematic pointer arithmetic hash += *data; // CTFE internal issue was shown by the dereference return hash; } /************************************************** 13739 - Precise copy for ArrayLiteralExp elements **************************************************/ static assert( { int[] a1 = [13]; int[][] a2 = [a1]; assert(a2[0] is a1); // OK assert(a2[0].ptr is a1.ptr); // OK <- NG a1[0] = 1; assert(a2[0][0] == 1); // OK <- NG a2[0][0] = 2; assert(a1[0] == 2); // OK <- NG return 1; }()); /************************************************** 14463 - ICE on slice assignment without postblit **************************************************/ struct Boo14463 { private int[1] c; this(int[] x) { c = x; } } immutable Boo14463 a14463 = Boo14463([1]); /************************************************** 13295 - Don't copy struct literal in VarExp::interpret() **************************************************/ struct S13295 { int n; } void f13295(ref const S13295 s) { *cast(int*) &s.n = 1; assert(s.n == 1); // OK <- fail } static assert( { S13295 s; f13295(s); return s.n == 1; // true <- false }()); int foo14061(int[] a) { foreach (immutable x; a) { auto b = a ~ x; return b == [1, 1]; } return 0; } static assert(foo14061([1])); /************************************************** 14024 - CTFE version **************************************************/ bool test14024() { string op; struct S { char x = 'x'; this(this) { op ~= x-0x20; } // upper case ~this() { op ~= x; } // lower case } S[4] mem; ref S[2] slice(int a, int b) { return mem[a .. b][0 .. 2]; } op = null; mem[0].x = 'a'; mem[1].x = 'b'; mem[2].x = 'x'; mem[3].x = 'y'; slice(0, 2) = slice(2, 4); // [ab] = [xy] assert(op == "XaYb", op); op = null; mem[0].x = 'x'; mem[1].x = 'y'; mem[2].x = 'a'; mem[3].x = 'b'; slice(2, 4) = slice(0, 2); // [ab] = [xy] assert(op == "XaYb", op); op = null; mem[0].x = 'a'; mem[1].x = 'b'; mem[2].x = 'c'; slice(0, 2) = slice(1, 3); // [ab] = [bc] assert(op == "BaCb", op); op = null; mem[0].x = 'x'; mem[1].x = 'y'; mem[2].x = 'z'; slice(1, 3) = slice(0, 2); // [yz] = [xy] assert(op == "YzXy", op); return true; } static assert(test14024()); /************************************************** 14304 - cache of static immutable value **************************************************/ immutable struct Bug14304 { string s_name; alias s_name this; string fun()() { return "fun"; } } class Buggy14304 { static string fun(string str)() { return str; } static immutable val = immutable Bug14304("val"); } void test14304() { enum kt = Buggy14304.fun!(Buggy14304.val); static assert(kt == "val"); enum bt = Buggy14304.val.fun(); static assert(bt == "fun"); } /************************************************** 14371 - evaluate BinAssignExp as lvalue **************************************************/ int test14371() { int x; ++(x += 1); return x; } static assert(test14371() == 2); /************************************************** 7151 - [CTFE] cannot compare classes with == **************************************************/ bool test7151() { auto a = new Object; return a == a && a != new Object; } static assert(test7151()); /************************************************** 12603 - [CTFE] goto does not correctly call dtors **************************************************/ struct S12603 { this(uint* dtorCalled) { *dtorCalled = 0; this.dtorCalled = dtorCalled; } @disable this(); ~this() { ++*dtorCalled; } uint* dtorCalled; } auto numDtorCallsByGotoWithinScope() { uint dtorCalled; { S12603 s = S12603(&dtorCalled); assert(dtorCalled == 0); goto L_abc; L_abc: assert(dtorCalled == 0); } assert(dtorCalled == 1); return dtorCalled; } static assert(numDtorCallsByGotoWithinScope() == 1); auto numDtorCallsByGotoOutOfScope() { uint dtorCalled; { S12603 s = S12603(&dtorCalled); assert(dtorCalled == 0); goto L_abc; } L_abc: assert(dtorCalled == 1); return dtorCalled; } static assert(numDtorCallsByGotoOutOfScope() == 1); uint numDtorCallsByGotoDifferentScopeAfter() { uint dtorCalled; { S12603 s = S12603(&dtorCalled); assert(dtorCalled == 0); } assert(dtorCalled == 1); goto L_abc; L_abc: assert(dtorCalled == 1); return dtorCalled; } static assert(numDtorCallsByGotoDifferentScopeAfter() == 1); auto numDtorCallsByGotoDifferentScopeBefore() { uint dtorCalled; assert(dtorCalled == 0); goto L_abc; L_abc: assert(dtorCalled == 0); { S12603 s = S12603(&dtorCalled); assert(dtorCalled == 0); } assert(dtorCalled == 1); return dtorCalled; } static assert(numDtorCallsByGotoDifferentScopeBefore() == 1); struct S12603_2 { ~this() { dtorCalled = true; } bool dtorCalled = false; } auto structInCaseScope() { auto charsets = S12603_2(); switch(1) { case 0: auto set = charsets; break; default: break; } return charsets.dtorCalled; } static assert(!structInCaseScope());
D
module antlr.v4.runtime.InterpreterRuleContext; import antlr.v4.runtime.ParserRuleContext; import std.conv; /** * This class extends {@link ParserRuleContext} by allowing the value of * {@link #getRuleIndex} to be explicitly set for the context. * * <p> * {@link ParserRuleContext} does not include field storage for the rule index * since the context classes created by the code generator override the * {@link #getRuleIndex} method to return the correct value for that context. * Since the parser interpreter does not use the context classes generated for a * parser, this class (with slightly more memory overhead per node) is used to * provide equivalent functionality.</p> */ class InterpreterRuleContext : ParserRuleContext { protected size_t ruleIndex; public this() { } public this(ParserRuleContext parent, int invokingStateNumber, size_t ruleIndex) { super(parent, invokingStateNumber); this.ruleIndex = ruleIndex; } /** * @uml * @override */ public override size_t getRuleIndex() { return ruleIndex; } }
D
/Users/markheijnekamp/mandelbrot/target/debug/deps/mandelbrot-3e5fa0df9b6f04c1.rmeta: src/main.rs /Users/markheijnekamp/mandelbrot/target/debug/deps/mandelbrot-3e5fa0df9b6f04c1.d: src/main.rs src/main.rs:
D
import std.json; import tests.types; import jsonizer.fromjson; import jsonizer.tojson; // assert that an object can be serialized to JSON and then reconstructed void runTest(T, Params ...)(Params params) { T obj = T(params); // check JSONValue serialization assert(obj.toJSON.fromJSON!T == obj); // check JSON string serialization assert(obj.toJSONString.fromJSONString!T == obj); } // helper to make an empty instance of an array type T template emptyArray(T) { enum emptyArray = cast(T) []; } auto staticArray(T, Params ...)(Params params) { return cast(T[Params.length]) [params]; } /++ unittest { runTest!PrimitiveStruct(1, 2UL, true, 0.4f, 0.8, "wat?"); // general case runTest!PrimitiveStruct(0, 40, false, 0.4f, 22.8, ""); // empty string runTest!PrimitiveStruct(0, 40, false, 0.4f, 22.8, null); // null string // NaN and Inf are currently not handled by std.json //runTest!PrimitiveStruct(0, 40, false, float.nan, 22.8, null); } unittest { runTest!PrivateFieldsStruct(1, 2UL, true, 0.4f, 0.8, "wat?"); } unittest { runTest!PropertyStruct(4, false, -2.7f, "asdf"); } unittest { runTest!ArrayStruct([1, 2, 3], ["a", "b", "c"]); // populated arrays runTest!ArrayStruct([1, 2, 3], ["a", null, "c"]); // null in array runTest!ArrayStruct(emptyArray!(int[]), emptyArray!(string[])); // empty arrays runTest!ArrayStruct(null, null); // null arrays } unittest { runTest!NestedArrayStruct([[1, 2], [3, 4]], [["a", "b"], ["c", "d"]]); // nested arrays runTest!NestedArrayStruct([null, [3, 4]], cast(string[][]) [null]); // null entries runTest!NestedArrayStruct(emptyArray!(int[][]), emptyArray!(string[][])); // empty arrays runTest!NestedArrayStruct(null, null); // null arrays } unittest { runTest!StaticArrayStruct(staticArray!int(1, 2, 3), staticArray!string("a", "b")); } unittest { runTest!NestedStruct(5, "ra", 4.2, [2, 3]); } unittest { auto json = q{{ "inner": { "i": 1 } }}; auto nested = json.fromJSONString!Nested2; assert(nested.inner.i == 1); } unittest { runTest!AliasedTypeStruct([2, 3]); } unittest { runTest!CustomCtorStruct(1, 4.2f); } unittest { runTest!(GenericStruct!int)(5); runTest!(GenericStruct!string)("s"); runTest!(GenericStruct!PrimitiveStruct)(PrimitiveStruct(1, 2UL, true, 0.4f, 0.8, "wat?")); } unittest { auto jstr = "5"; assert(jstr.fromJSONString!IntStruct == IntStruct(5)); } unittest { assert(`{"i": 5, "j": 7}`.fromJSONString!JSONValueStruct == JSONValueStruct(5, JSONValue(7))); assert(`{"i": 5, "j": "hi"}`.fromJSONString!JSONValueStruct == JSONValueStruct(5, JSONValue("hi"))); } ++/
D
/* DIrrlicht - D Bindings for Irrlicht Engine Copyright (C) 2014- Danyal Zia ([email protected]) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ module dirrlicht.scene.animatedmeshmd2; import dirrlicht.scene.scenemanager; import dirrlicht.scene.mesh; import dirrlicht.scene.animatedmesh; import std.conv; import std.string; /// Types of standard md2 animations enum AnimationTypeMD2 { Stand = 0, Run, Attack, PainA, PainB, PainC, Jump, Flip, Salute, Fallback, Wave, Point, CrouchStand, CrouchWalk, CrouchAttack, CrouchPain, CrouchDeath, DeathFallBack, DeathFallForward, DeathFallBackSlow, Boom, /// Not an animation, but amount of animation types. Count } interface AnimatedMeshMD2 { /*** * Get frame loop data for a default MD2 animation type. * * Params: * l = The EMD2_ANIMATION_TYPE to get the frames for. * outBegin = The returned beginning frame for animation type specified. * outEnd = The returned ending frame for the animation type specified. * outFPS = The number of frames per second, this animation should be played at. */ void getFrameLoop(AnimationTypeMD2 l, ref int outBegin, ref int outEnd, ref int outFPS); /*** * Get frame loop data for a special MD2 animation type, identified by name. * * Params: * name = Name of the animation. * outBegin = The returned beginning frame for animation type specified. * outEnd = The returned ending frame for the animation type specified. * outFPS = The number of frames per second, this animation should be played at. */ bool getFrameLoop(string name, ref int outBegin, ref int outEnd, ref int outFPS); /*** * Get amount of md2 animations in this file. */ int getAnimationCount(); /*** * Get name of md2 animation. * * Params: * nr: Zero based index of animation. */ string getAnimationName(int nr); @property void* c_ptr(); @property void c_ptr(void* ptr); } /+++ + Stub for AnimatedMeshMD2 +/ mixin template DefaultAnimatedMeshMD2() { mixin DefaultMesh; void getFrameLoop(AnimationTypeMD2 l, ref int outBegin, ref int outEnd, ref int outFPS) { irr_IAnimatedMeshMD2_getFrameLoop(ptr, l, outBegin, outEnd, outFPS); } bool getFrameLoop(string name, ref int outBegin, ref int outEnd, ref int outFPS) { return irr_IAnimatedMeshMD2_getFrameLoopByName(ptr, toStringz(name), outBegin, outEnd, outFPS); } int getAnimationCount() { return irr_IAnimatedMeshMD2_getAnimationCount(ptr); } string getAnimationName(int nr) { auto str = irr_IAnimatedMeshMD2_getAnimationName(ptr, nr); return to!string(str); } } /+++ + Implementation for AnimatedMeshMD2 +/ class CAnimatedMeshMD2 : AnimatedMeshMD2 { mixin DefaultAnimatedMeshMD2; this(irr_IAnimatedMeshMD2* ptr) in { assert(ptr != null); } body { this.ptr = ptr; } @property void* c_ptr() { return ptr; } @property void c_ptr(void* ptr) { this.ptr = cast(typeof(this.ptr))(ptr); } private: irr_IAnimatedMeshMD2* ptr; } extern (C): struct irr_IAnimatedMeshMD2; void irr_IAnimatedMeshMD2_getFrameLoop(irr_IAnimatedMeshMD2* mesh, AnimationTypeMD2 l, ref int outBegin, ref int outEnd, ref int outFPS); bool irr_IAnimatedMeshMD2_getFrameLoopByName(irr_IAnimatedMeshMD2* mesh, const char* name, ref int outBegin, ref int outEnd, ref int outFPS); int irr_IAnimatedMeshMD2_getAnimationCount(irr_IAnimatedMeshMD2* mesh); const(char*) irr_IAnimatedMeshMD2_getAnimationName(irr_IAnimatedMeshMD2* mesh, int nr);
D
/Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/Objects-normal/x86_64/WebSocket.o : /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/Compression.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/WebSocket.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/SSLSecurity.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/bootcamp/Documents/collab2/Pods/Target\ Support\ Files/Starscream/Starscream-umbrella.h /Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/unextended-module.modulemap /Users/bootcamp/Documents/collab2/Pods/Starscream/zlib/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/Objects-normal/x86_64/WebSocket~partial.swiftmodule : /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/Compression.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/WebSocket.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/SSLSecurity.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/bootcamp/Documents/collab2/Pods/Target\ Support\ Files/Starscream/Starscream-umbrella.h /Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/unextended-module.modulemap /Users/bootcamp/Documents/collab2/Pods/Starscream/zlib/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/Objects-normal/x86_64/WebSocket~partial.swiftdoc : /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/Compression.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/WebSocket.swift /Users/bootcamp/Documents/collab2/Pods/Starscream/Sources/SSLSecurity.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/bootcamp/Documents/collab2/Pods/Target\ Support\ Files/Starscream/Starscream-umbrella.h /Users/bootcamp/Documents/collab2/DerivedData/goOSC/Build/Intermediates.noindex/IBDesignables/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Starscream.build/unextended-module.modulemap /Users/bootcamp/Documents/collab2/Pods/Starscream/zlib/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.4.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
/Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ScatterChartData.o : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Legend.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Description.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ScatterChartData~partial.swiftmodule : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Legend.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Description.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/ScatterChartData~partial.swiftdoc : /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Legend.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/Description.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Charts/Source/Charts/Components/LegendEntry.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/Jaskeerat/Desktop/CryptoLive/CryptoLive/DerivedData/CryptoLive/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap
D
#as: --64 -mrelax-relocations=yes #ld: -melf_x86_64 #objdump: -dw .*: +file format .* Disassembly of section .text: [a-f0-9]+ <_start>: +[a-f0-9]+: 66 13 05 ([0-9a-f]{2} ){4} * adc 0x[a-f0-9]+\(%rip\),%ax # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 03 1d ([0-9a-f]{2} ){4} * add 0x[a-f0-9]+\(%rip\),%bx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 23 0d ([0-9a-f]{2} ){4} * and 0x[a-f0-9]+\(%rip\),%cx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 3b 15 ([0-9a-f]{2} ){4} * cmp 0x[a-f0-9]+\(%rip\),%dx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 0b 3d ([0-9a-f]{2} ){4} * or 0x[a-f0-9]+\(%rip\),%di # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 1b 35 ([0-9a-f]{2} ){4} * sbb 0x[a-f0-9]+\(%rip\),%si # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 2b 2d ([0-9a-f]{2} ){4} * sub 0x[a-f0-9]+\(%rip\),%bp # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 44 33 05 ([0-9a-f]{2} ){4} * xor 0x[a-f0-9]+\(%rip\),%r8w # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 85 0d ([0-9a-f]{2} ){4} * test %cx,0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 13 05 ([0-9a-f]{2} ){4} * adc 0x[a-f0-9]+\(%rip\),%ax # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 03 1d ([0-9a-f]{2} ){4} * add 0x[a-f0-9]+\(%rip\),%bx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 23 0d ([0-9a-f]{2} ){4} * and 0x[a-f0-9]+\(%rip\),%cx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 3b 15 ([0-9a-f]{2} ){4} * cmp 0x[a-f0-9]+\(%rip\),%dx # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 0b 3d ([0-9a-f]{2} ){4} * or 0x[a-f0-9]+\(%rip\),%di # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 1b 35 ([0-9a-f]{2} ){4} * sbb 0x[a-f0-9]+\(%rip\),%si # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 2b 2d ([0-9a-f]{2} ){4} * sub 0x[a-f0-9]+\(%rip\),%bp # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 44 33 05 ([0-9a-f]{2} ){4} * xor 0x[a-f0-9]+\(%rip\),%r8w # [a-f0-9]+ <_start\+0x[a-f0-9]+> +[a-f0-9]+: 66 85 0d ([0-9a-f]{2} ){4} * test %cx,0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_start\+0x[a-f0-9]+> #pass
D
PLONG PLAT ED95 KD LOMAGAGE HIMAGAGE SLAT SLONG RESULTNO DP DM WT ROCKTYPE 273 54 4 0 46 48 -33.5 151.300003 1769 6 6 0.923116346 intrusives, basalt 264.399994 75 15.6000004 0 2 65 -8.80000019 126.699997 1206 10.3999996 18 0.296176398 extrusives, intrusives 346 61 9 41.2000008 35 100 -31.3999996 138.600006 1170 13 15 0.666976811 sediments 333 45 9 16.5 35 100 -30.3999996 139.399994 1161 17 18 0.666976811 sediments, tillite 317 57 5 200 35 100 -30.5 139.300003 1165 9 10 0.882496903 sediments, redbeds 329 58 25 4.0999999 35 100 -30.2000008 139 1166 41.5999985 45.5999985 0.0439369336 sediments, sandstone, tillite 223 26 13 14.8000002 35 100 -30.2999992 139.5 1157 26 26 0.429557358 extrusives 320 63 9 15.5 34 65 -38 145.5 1854 16 16 0.666976811 extrusives 317 63 14 16 23 56 -32.5 151 1840 20 20 0.375311099 extrusives, basalts 302.700012 66.8000031 6.80000019 35 34 65 -38 145.5 1819 10.8000002 12.1000004 0.793580724 extrusives 305 73 17 29 23 56 -42 147 1821 25 29 0.235746077 extrusives, basalts 274 66 27.6000004 8.60000038 25 65 -41.2999992 145.899994 1873 39.7999992 46.9000015 0.0221747703 intrusives, granite 321 64 6 27.5 25 65 -35.5999985 137.5 1874 10 11 0.835270211 sediments 294 75 11 7 25 65 -41.0999985 146.100006 1871 16.2999992 18.8999996 0.546074427 sediments, sandstone 315 66 10.5 18 25 65 -41 145.5 1872 18.2000008 19.6000004 0.576229074 extrusives, sediments 298 58.7999992 2.4000001 0 35 65 -27 141.5 1972 3.79999995 3.79999995 0.971610765 sediments, weathered 310.899994 68.5 5.19999981 0 40 60 -35 150 1927 5.19999981 5.19999981 0.873541195 extrusives, basalts
D
a disease of infants and young children the part of an animal that corresponds to the human buttocks
D
module java.io.Reader; import java.lang.util; class Reader { protected Object lock; protected this() { implMissing(__FILE__, __LINE__); } protected this(Object lock) { implMissing(__FILE__, __LINE__); } abstract void close(); void mark(int readAheadLimit) { implMissing(__FILE__, __LINE__); } bool markSupported() { implMissing(__FILE__, __LINE__); return false; } int read() { implMissing(__FILE__, __LINE__); return 0; } int read(char[] cbuf) { implMissing(__FILE__, __LINE__); return 0; } abstract int read(char[] cbuf, int off, int len); bool ready() { implMissing(__FILE__, __LINE__); return false; } void reset() { implMissing(__FILE__, __LINE__); } long skip(long n) { implMissing(__FILE__, __LINE__); return 0; } }
D
/** * Low Level MPI Types * * Copyright: * (C) 1999-2007 Jack Lloyd * (C) 2014-2015 Etienne Cimon * * License: * Botan is released under the Simplified BSD License (see LICENSE.md) */ module botan.math.mp.mp_types; public import botan_math.mp_types;
D
func void B_Bartok_ShitAnOrc() { AI_Output(self,other,"DIA_Bartok_Angekommen_04_02"); //(to himself) An orc right outside the city - holy shit ... };
D
//https://issues.dlang.org/show_bug.cgi?id=23607 /* TEST_OUTPUT: --- fail_compilation/test23607.d(15): Error: template `to(T)()` does not have property `bad` fail_compilation/test23607.d(16): Error: template `to(T)()` does not have property `bad` --- */ template to(T) { void to(T)(){} } alias comb = to!int.bad!0; auto combe = to!int.bad!0;
D
import gfm.math:vec2i; import map_site_calculator, height_map_settings; interface IMapCell { @property int rank(); @property vec2i site(); @property int siteIndex(); }
D
/Users/aligame/work/rust_repository/rutils/target/release/build/proc-macro2-73d6b9ccbc0fb72f/build_script_build-73d6b9ccbc0fb72f: /Users/aligame/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-0.4.30/build.rs /Users/aligame/work/rust_repository/rutils/target/release/build/proc-macro2-73d6b9ccbc0fb72f/build_script_build-73d6b9ccbc0fb72f.d: /Users/aligame/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-0.4.30/build.rs /Users/aligame/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-0.4.30/build.rs:
D
/* * Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. * Use of this file is governed by the BSD 3-clause license that * can be found in the LICENSE.txt file in the project root. */ module antlr.v4.runtime.Lexer; import std.stdio; import std.typecons; import std.array; import std.conv; import std.variant; import antlr.v4.runtime.ANTLRErrorListener; import antlr.v4.runtime.Recognizer; import antlr.v4.runtime.RecognitionException; import antlr.v4.runtime.atn.LexerATNSimulator; import antlr.v4.runtime.Token; import antlr.v4.runtime.TokenConstantDefinition; import antlr.v4.runtime.TokenSource; import antlr.v4.runtime.InterfaceLexer; import antlr.v4.runtime.TokenFactory; import antlr.v4.runtime.CharStream; import antlr.v4.runtime.IntStream; import antlr.v4.runtime.IntStreamConstant; import antlr.v4.runtime.CommonToken; import antlr.v4.runtime.CommonTokenFactory; import antlr.v4.runtime.IllegalStateException; import antlr.v4.runtime.LexerNoViableAltException; import antlr.v4.runtime.misc; import antlr.v4.runtime.InterfaceRuleContext; alias TokenFactorySourcePair = Tuple!(TokenSource, "a", CharStream, "b"); /** * A lexer is recognizer that draws input symbols from a character stream. * lexer grammars result in a subclass of this object. A Lexer object * uses simplified match() and error recovery mechanisms in the interest * of speed. */ abstract class Lexer : Recognizer!(int, LexerATNSimulator), TokenSource, InterfaceLexer { enum int DEFAULT_MODE = 0; enum int MORE = -2; enum int SKIP = -3; enum int DEFAULT_TOKEN_CHANNEL = TokenConstantDefinition.DEFAULT_CHANNEL; enum int HIDDEN = TokenConstantDefinition.HIDDEN_CHANNEL; enum int MIN_CHAR_VALUE = 0; enum int MAX_CHAR_VALUE = 0x10FFFF; public CharStream _input; protected TokenFactorySourcePair _tokenFactorySourcePair; /** * How to create token objects * @uml * @read * @write * @override */ public TokenFactory!CommonToken tokenFactory_; /** * The goal of all lexer rules/methods is to create a token object. * This is an instance variable as multiple rules may collaborate to * create a single token. nextToken will return this object after * matching lexer rule(s). If you subclass to allow multiple token * emissions, then set this to the last token to be matched or * something nonnull so that the auto token emit mechanism will not * emit another token. */ public Token _token; public IntegerStack _modeStack; /** * What character index in the stream did the current token start at? * Needed, for example, to get the text for current token. Set at * the start of nextToken. */ public size_t _tokenStartCharIndex; /** * The line on which the first character of the token resides */ public int _tokenStartLine; /** * The character position of first character within the line */ public int _tokenStartCharPositionInLine; public bool _hitEOF; /** * The channel number for the current token */ public int _channel; /** * The token type for the current token */ public int _type; public int _mode; /** * You can set the text for the current token to override what is in * the input char buffer. Use setText() or can set this instance var. */ public Variant _text; public this() { } public this(CharStream input) { tokenFactory_ = CommonTokenFactory.DEFAULT; this._input = input; this._tokenFactorySourcePair = tuple(this, input); _modeStack = new IntegerStack(); } public void reset() { // wack Lexer state variables if (_input !is null) { _input.seek(0); // rewind the input } _token = null; _type = TokenConstantDefinition.INVALID_TYPE; _channel = TokenConstantDefinition.DEFAULT_CHANNEL; _tokenStartCharIndex = -1; _tokenStartCharPositionInLine = -1; _tokenStartLine = -1; _text.init; _hitEOF = false; _mode = Lexer.DEFAULT_MODE; _modeStack.clear(); getInterpreter().reset(); } /** * Return a token from this source; i.e., match a token on the char * stream. */ public Token nextToken() { if (_input is null) { throw new IllegalStateException("nextToken requires a non-null input stream."); } // Mark start location in char stream so unbuffered streams are // guaranteed at least have text of current token int tokenStartMarker = _input.mark(); try{ outer: while (true) { if (_hitEOF) { emitEOF(); return _token; } _token = null; _channel = TokenConstantDefinition.DEFAULT_CHANNEL; _tokenStartCharIndex = _input.index; _tokenStartCharPositionInLine = getInterpreter.getCharPositionInLine(); _tokenStartLine = getInterpreter.getLine; _text.init; do { _type = TokenConstantDefinition.INVALID_TYPE; debug(Lexer) { import std.stdio; writefln("nextToken line = %s at %s: %s in mode %s at index %s", _tokenStartLine, _tokenStartCharPositionInLine, _input.LA(1), _mode, _input.index); } int ttype; try { ttype = getInterpreter.match(_input, _mode); } catch (LexerNoViableAltException e) { notifyListeners(e); // report error recover(e); ttype = SKIP; } if (_input.LA(1) == IntStreamConstant.EOF) { _hitEOF = true; } if (_type == TokenConstantDefinition.INVALID_TYPE) _type = ttype; if (_type == SKIP) { continue outer; } } while (_type == MORE); if (_token is null) { emit(); } return _token; } } finally { // make sure we release marker after match or // unbuffered char stream will keep buffering _input.release(tokenStartMarker); } assert(0); } /** * Instruct the lexer to skip creating a token for current lexer rule * and look for another token. nextToken() knows to keep looking when * a lexer rule finishes with token set to SKIP_TOKEN. Recall that * if token==null at end of any token rule, it creates one for you * and emits it. */ public void skip() { _type = SKIP; } public void more() { _type = MORE; } public void mode(int m) { _mode = m; } public void pushMode(int m) { debug(LexerATNSimulator) writefln("pushMode %s %s", m, _modeStack); _modeStack.push(_mode); mode(m); } public int popMode() { assert (!_modeStack.isEmpty, "Empty stack"); debug(LexerATNSimulator) writefln("popMode back to %s", _modeStack.peek); mode(_modeStack.pop); return _mode; } /** * Set the char stream and reset the lexer * @uml * @override */ public override void setInputStream(IntStream input) { this._input = null; this._tokenFactorySourcePair = tuple(this, _input); reset(); this._input = cast(CharStream)input; this._tokenFactorySourcePair = tuple(this, _input); } public string getSourceName() { return _input.getSourceName(); } /** * @uml * @override */ public override CharStream getInputStream() { return _input; } /** * By default does not support multiple emits per nextToken invocation * for efficiency reasons. Subclass and override this method, nextToken, * and getToken (to push tokens into a list and pull from that list * rather than a single variable as this implementation does). */ public void emit(Token token) { this._token = token; } /** * The standard method called to automatically emit a token at the * outermost lexical rule. The token object should point into the * char buffer start..stop. If there is a text override in 'text', * use that to set the token's text. Override this method to emit * custom Token objects or provide a new factory. */ public Token emit() { Variant v = _text; Token t = tokenFactory_.create(_tokenFactorySourcePair, _type, v, _channel, _tokenStartCharIndex, getCharIndex()-1, _tokenStartLine, _tokenStartCharPositionInLine); emit(t); return t; } public Token emitEOF() { int cpos = getCharPositionInLine(); int line = getLine(); Variant Null; Token eof = tokenFactory_.create(_tokenFactorySourcePair, TokenConstantDefinition.EOF, Null, TokenConstantDefinition.DEFAULT_CHANNEL, _input.index(), _input.index()-1, line, cpos); emit(eof); return eof; } public int getLine() { return getInterpreter().getLine(); } public int getCharPositionInLine() { return getInterpreter().getCharPositionInLine(); } public void setLine(int line) { getInterpreter().setLine(line); } public void setCharPositionInLine(int charPositionInLine) { getInterpreter().setCharPositionInLine(charPositionInLine); } /** * What is the index of the current character of lookahead? */ public size_t getCharIndex() { return _input.index(); } /** * Return the text matched so far for the current token or any * text override. */ public Variant getText() { Variant Null; if (_text !is Null) { return _text; } Variant v = getInterpreter().getText(_input); return v; } /** * Set the complete text of this token; it wipes any previous * changes to the text. */ public void setText(Variant text) { this._text = text; } /** * Override if emitting multiple tokens. */ public Token getToken() { return _token; } public void setToken(Token token) { this._token = token; } public void setType(int ttype) { _type = ttype; } public int getType() { return _type; } public void setChannel(int channel) { _channel = channel; } public int getChannel() { return _channel; } public string[] getChannelNames() { return null; } public string[] getModeNames() { return null; } /** * Used to print out token names like ID during debugging and * error reporting. The generated parsers implement a method * that overrides this to point to their String[] tokenNames * @uml * @override */ public override string[] getTokenNames() { return null; } /** * Return a list of all Token objects in input char stream. * Forces load of all tokens. Does not include EOF token. */ public Token[] getAllTokens() { Token[] tokens; Token t = nextToken(); while (t.getType() != TokenConstantDefinition.EOF) { tokens ~= t; t = nextToken(); } return tokens; } public void recover(LexerNoViableAltException e) { if (_input.LA(1) != IntStreamConstant.EOF) { // skip a char and try again getInterpreter().consume(_input); } } public void notifyListeners(LexerNoViableAltException e) { auto text = _input.getText(Interval.of(to!int(_tokenStartCharIndex), to!int(_input.index))); auto msg = "token recognition error at: '" ~ getErrorDisplay(text) ~ "'"; ANTLRErrorListener listener = getErrorListenerDispatch(); listener.syntaxError(this, null, _tokenStartLine, _tokenStartCharPositionInLine, msg, e); } public string getErrorDisplay(string s) { auto buf = appender!string; foreach (dchar c; s) { buf.put(getErrorDisplay(c)); } return buf.data; } public string getErrorDisplay(dchar c) { string s; switch ( c ) { case TokenConstantDefinition.EOF : s = "<EOF>"; break; case '\n' : s = "\\n"; break; case '\t' : s = "\\t"; break; case '\r' : s = "\\r"; break; default: s ~= c; break; } return s; } public string getCharErrorDisplay(dchar c) { string s = getErrorDisplay(c); return "'" ~ s ~ "'"; } /** * Lexers can normally match any char in it's vocabulary after matching * a token, so do the easy thing and just kill a character and hope * it all works out. You can instead use the rule invocation stack * to do sophisticated error recovery if you are in a fragment rule. */ public void recover(RecognitionException re) { //System.out.println("consuming char "+(char)input.LA(1)+" during recovery"); //re.printStackTrace(); // TODO: Do we lose character or line position information? _input.consume(); } /** * @uml * @override */ public override void action(InterfaceRuleContext interfaceRuleContext, int ruleIndex, int actionIndex) { } public override final TokenFactory!CommonToken tokenFactory() { return this.tokenFactory_; } public override final void tokenFactory(TokenFactory!CommonToken tokenFactory) { this.tokenFactory_ = tokenFactory; } }
D
// Compiler implementation of the D programming language // Copyright (c) 1999-2015 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt module ddmd.delegatize; import ddmd.apply; import ddmd.declaration; import ddmd.dscope; import ddmd.expression; import ddmd.func; import ddmd.globals; import ddmd.mtype; import ddmd.statement; import ddmd.tokens; import ddmd.visitor; extern (C++) Expression toDelegate(Expression e, Type t, Scope* sc) { //printf("Expression::toDelegate(t = %s) %s\n", t->toChars(), e->toChars()); Loc loc = e.loc; auto tf = new TypeFunction(null, t, 0, LINKd); if (t.hasWild()) tf.mod = MODwild; auto fld = new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, null); sc = sc.push(); sc.parent = fld; // set current function to be the delegate lambdaSetParent(e, sc); bool r = lambdaCheckForNestedRef(e, sc); sc = sc.pop(); if (r) return new ErrorExp(); Statement s; if (t.ty == Tvoid) s = new ExpStatement(loc, e); else s = new ReturnStatement(loc, e); fld.fbody = s; e = new FuncExp(loc, fld); e = e.semantic(sc); return e; } /****************************************** * Patch the parent of declarations to be the new function literal. */ extern (C++) void lambdaSetParent(Expression e, Scope* sc) { extern (C++) final class LambdaSetParent : StoppableVisitor { alias visit = super.visit; Scope* sc; public: extern (D) this(Scope* sc) { this.sc = sc; } override void visit(Expression) { } override void visit(DeclarationExp e) { e.declaration.parent = sc.parent; } override void visit(IndexExp e) { if (e.lengthVar) { //printf("lengthVar\n"); e.lengthVar.parent = sc.parent; } } override void visit(SliceExp e) { if (e.lengthVar) { //printf("lengthVar\n"); e.lengthVar.parent = sc.parent; } } } scope LambdaSetParent lsp = new LambdaSetParent(sc); walkPostorder(e, lsp); } /******************************************* * Look for references to variables in a scope enclosing the new function literal. * Returns true if error occurs. */ extern (C++) bool lambdaCheckForNestedRef(Expression e, Scope* sc) { extern (C++) final class LambdaCheckForNestedRef : StoppableVisitor { alias visit = super.visit; public: Scope* sc; bool result; extern (D) this(Scope* sc) { this.sc = sc; } override void visit(Expression) { } override void visit(SymOffExp e) { VarDeclaration v = e.var.isVarDeclaration(); if (v) result = v.checkNestedReference(sc, Loc()); } override void visit(VarExp e) { VarDeclaration v = e.var.isVarDeclaration(); if (v) result = v.checkNestedReference(sc, Loc()); } override void visit(ThisExp e) { VarDeclaration v = e.var.isVarDeclaration(); if (v) result = v.checkNestedReference(sc, Loc()); } override void visit(DeclarationExp e) { VarDeclaration v = e.declaration.isVarDeclaration(); if (v) { result = v.checkNestedReference(sc, Loc()); if (result) return; /* Some expressions cause the frontend to create a temporary. * For example, structs with cpctors replace the original * expression e with: * __cpcttmp = __cpcttmp.cpctor(e); * * In this instance, we need to ensure that the original * expression e does not have any nested references by * checking the declaration initializer too. */ if (v._init && v._init.isExpInitializer()) { Expression ie = v._init.toExpression(); result = lambdaCheckForNestedRef(ie, sc); } } } } scope LambdaCheckForNestedRef v = new LambdaCheckForNestedRef(sc); walkPostorder(e, v); return v.result; }
D
import vfs; import std.intrinsic; // ISO 9660 align(1) struct IsoDate { ubyte info[17]; // 8.4.26.1 } static ulong s733(uint v) { return cast(ulong)v | ((cast(ulong)bswap(v)) << 32); } align(1) struct uint733 { union { struct { uint l; uint h; } ulong v; } void opAssign(uint v) { l = v; h = bswap(v); } int opCmp(uint733 z) { if (v < z.v) return -1; else if (v > z.v) return +1; return 0; } static uint733 opCall(uint v) { uint733 r; r.l = v; r.h = bswap(v); return r; } uint opCast() { return l; } } align(1) struct IsoDirectoryRecord { ubyte Length; ubyte ExtAttrLength; uint733 Extent; uint733 Size; ubyte Date[7]; ubyte Flags; ubyte FileUnitSize; ubyte Interleave; uint VolumeSequenceNumber; ubyte NameLength; //ubyte _Unused; //char Name[0x100]; } struct IsoVolumeDescriptor { ubyte Type; char Id[5]; ubyte Version; ubyte Data[2041]; }; // 0x800 bytes (1 sector) align(1) struct IsoPrimaryDescriptor { ubyte Type; char Id[5]; ubyte Version; ubyte _Unused1; char SystemId[0x20]; char VolumeId[0x20]; ulong _Unused2; ulong VolumeSpaceSize; ulong _Unused3[4]; uint VolumeSetSize; uint VolumeSequenceNumber; uint LogicalBlockSize; ulong PathTableSize; uint Type1PathTable; uint OptType1PathTable; uint TypeMPathTable; uint OptTypeMPathTable; IsoDirectoryRecord RootDirectoryRecord; ubyte _Unused3b; char VolumeSetId[128]; char PublisherId[128]; char PreparerId[128]; char ApplicationId[128]; char CopyrightFileId[37]; char AbstractFileId[37]; char BibliographicFileId[37]; IsoDate CreationDate; IsoDate ModificationDate; IsoDate ExpirationDate; IsoDate EffectiveDate; ubyte FileStructureVersion; ubyte _Unused4; ubyte ApplicationData[512]; ubyte _Unused5[653]; }; void Dump(IsoDirectoryRecord idr) { writefln("IsoDirectoryRecord {"); writefln(" Length: %02X", idr.Length); writefln(" ExtAttrLength: %02X", idr.ExtAttrLength); writefln(" Extent: %08X", cast(uint)idr.Extent); writefln(" Size: %08X", cast(uint)idr.Size); writefln(" Date: [...]"); writefln(" Flags: %02X", idr.Flags); writefln(" FileUnitSize: %02X", idr.FileUnitSize); writefln(" Interleave: %02X", idr.Interleave); writefln(" VolumeSequenceNumber: %08X", idr.VolumeSequenceNumber); writefln(" NameLength: %08X", idr.NameLength); writefln("}"); writefln(); } void Dump(IsoPrimaryDescriptor ipd) { writefln("IsoPrimaryDescriptor {"); writefln(" Type: %02X", ipd.Type); writefln(" ID: '%s'", ipd.Id); writefln(" Version: %02X", ipd.Version); writefln(" SystemId: '%s'", ipd.SystemId); writefln(" VolumeId: '%s'", ipd.VolumeId); writefln(" VolumeSpaceSize: %016X", ipd.VolumeSpaceSize); writefln(" VolumeSetSize: %08X", ipd.VolumeSetSize); writefln(" VolumeSequenceNumber: %08X", ipd.VolumeSequenceNumber); writefln(" LogicalBlockSize: %08X", ipd.LogicalBlockSize); writefln(" PathTableSize: %016X", ipd.PathTableSize); writefln(" Type1PathTable: %08X", ipd.Type1PathTable); writefln(" OptType1PathTable: %08X", ipd.OptType1PathTable); writefln(" TypeMPathTable: %08X", ipd.TypeMPathTable); writefln(" OptTypeMPathTable: %08X", ipd.OptTypeMPathTable); writefln(" RootDirectoryRecord: [...]"); Dump(ipd.RootDirectoryRecord); writefln(" VolumeSetId: '%s'", ipd.VolumeSetId); writefln(" PublisherId: '%s'", ipd.PublisherId); writefln(" PreparerId: '%s'", ipd.PreparerId); writefln(" ApplicationId: '%s'", ipd.ApplicationId); writefln(" CopyrightFileId: '%s'", ipd.CopyrightFileId); writefln(" AbstractFileId: '%s'", ipd.AbstractFileId); writefln(" BibliographicFileId: '%s'", ipd.BibliographicFileId); writefln(" CreationDate: [...]"); writefln(" ModificationDate: [...]"); writefln(" ExpirationDate: [...]"); writefln(" EffectiveDate: [...]"); writefln(" FileStructureVersion: %02X", ipd.FileStructureVersion); writefln("}"); writefln(); } class IsoEntry : FileContainer { Stream drstream; IsoDirectoryRecord dr; Iso iso; int udf_extent; char[] fullname; override void print() { writefln(this.toString); Dump(dr); } // Escribimos el DirectoryRecord void writedr() { drstream.position = 0; drstream.write(TA(dr)); // Actualizamos tambien el udf if (udf_extent) { //writefln("UDF: %08X", udf_extent); Stream udfs = new SliceStream(iso.stream, 0x800 * udf_extent, 0x800 * (udf_extent + 1)); udfs.position = 0x38; udfs.write(cast(uint)dr.Size); udfs.position = 0x134; udfs.write(cast(uint)dr.Size); udfs.write(cast(uint)((cast(uint)dr.Extent) - 262)); //writefln("patching udf"); } } // Cantidad de sectores necesarios para almacenar uint Sectors() { return iso.sectors(dr.Size); } override int replace(Stream from, bool limited = true) { Stream op = iso.openDirectoryRecord(dr, limited); ulong start = op.position; //writefln("%d->%d", from.size, op.size); try { copy2From(op, from); //copyStream(from, op); uint length = op.position - start; op.close(); dr.Size = s733(length); writedr(); return length; } catch (Exception e) { throw(new Exception(std.string.format("'%s': Can't write (%d -> %d) without removing limits (%d)", name, from.size, op.size, from.size - op.size))); } } override int replaceAt(Stream from, int skip = 0) { Stream op = iso.openDirectoryRecord(dr, false); ulong start = op.position; op.position = start + skip; copy2From(op, from); //copyStream(from, op); uint length = op.position - start; op.close(); dr.Size = s733(length); writedr(); return length; } void swap(IsoEntry ie) { if (ie.iso != this.iso) throw(new Exception("Only can swap entries in same iso file")); uint733 TempExtent, TempSize; TempExtent = ie.dr.Extent; TempSize = ie.dr.Size; ie.dr.Extent = this.dr.Extent; ie.dr.Size = this.dr.Size; this.dr.Extent = TempExtent; this.dr.Size = TempSize; this.writedr(); ie.writedr(); } void use(IsoEntry ie) { if (ie.iso != this.iso) throw(new Exception("Only can swap entries in same iso file")); this.dr.Extent = ie.dr.Extent; this.dr.Size = ie.dr.Size; this.writedr(); } /*override protected Stream realopen(bool limited = true) { throw(new Exception("")); }*/ } class IsoDirectory : IsoEntry { Stream open() { throw(new Exception("")); } void clearFiles() { foreach (ce; this) { IsoEntry ie = cast(IsoEntry)ce; if (ie.classinfo.name == IsoFile.classinfo.name) { ie.dr.Extent = 0; ie.dr.Size = 0; ie.writedr(); } else if (ie.classinfo.name == IsoDirectory.classinfo.name) { if (ie != this) (cast(IsoDirectory)ie).clearFiles(); } } } } class IsoFile : IsoEntry { uint size; override bool isFile() { return true; } //override protected Stream realopen(bool limited = true) { override Stream realopen(FileMode mode, bool limited = true) { //writefln("%s", name); //writefln("%08X", (dr.Size >> 32) & 0x_FFFFFFFF); return iso.openDirectoryRecord(dr); } override void makePPF(Stream to, long offset) { Stream s; ubyte[0xFF] temp; char[50] info; foreach (k, c; info) info[k] = ' '; to.writeString("PPF30"); to.write(cast(ubyte)2); to.writeString(info); to.write(cast(ubyte)0); to.write(cast(ubyte)0); to.write(cast(ubyte)0); to.write(cast(ubyte)0); long pos = (cast(long)cast(uint)dr.Extent) * 0x800; int size = cast(uint)dr.Size; //writefln("%08X ", pos); s = new SliceStream(iso.stream, pos); while (size) { int csize = 0xFF; if (csize > size) csize = size; to.write(cast(long)pos); to.write(cast(ubyte)csize); s.read(temp[0..csize]); to.write(temp[0..csize]); pos += csize; size -= csize; } }} class Iso : IsoDirectory { IsoPrimaryDescriptor ipd; uint position = 0; uint datastart = 0xFFFFFFFF; uint firstDatasector = 0xFFFFFFFF; uint lastDatasector = 0x00000000; uint writeDatasector = 0x00000000; Iso copyIsoStructure(Stream s) { Iso iso; //writefln(firstDatasector); if (firstDatasector > 3000) throw(new Exception("ERROR!")); copy2From(s, new SliceStream(stream, 0, (cast(ulong)firstDatasector) * 0x800)); //writefln(firstDatasector); //copyStream(new SliceStream(stream, 0, (cast(ulong)firstDatasector) * 0x800), s); s.position = 0; iso = new Iso(s); iso.writeDatasector = iso.firstDatasector; iso.clearFiles(); return iso; } void copyUnrecreatedFiles(Iso iso, bool show = true) { //writefln("copyUnrecreatedFiles()"); foreach (ce; this) { IsoEntry ie = cast(IsoEntry)ce; if (cast(uint)ie.dr.Extent) continue; if (show) printf("%s...", toStringz(ce.name)); recreateFile(ie, iso[ie.name].open, 5); iso[ie.name].close(); if (show) printf("Ok\n"); } stream.flush(); } void recreateFile(FileContainer ce) { IsoEntry e = cast(IsoEntry)ce; e.dr.Extent = 1; e.dr.Size = 0; e.writedr(); } void recreateFile(FileContainer ce, char[] n, int addVoidSectors = 0) { Stream s = new File(n, FileMode.In); recreateFile(ce, s, addVoidSectors); s.close(); } void recreateFile(FileContainer ce, Stream s, int addVoidSectors = 0) { s.position = 0; //printf("Available: %d\n", cast(int)(s.available & 0xFFFFFFFF)); Stream w = startFileCreate(ce); uint pos = w.position; uint available = s.available; //copyStream(s, w); copy2From(w, s); w.position = pos + available; //printf("Z: %d | (%d)\n", cast(int)(w.position - pos), s.available); endFileCreate(addVoidSectors); } FileContainer oce; // OpenedFileContainer Stream writing; Stream startFileCreate(FileContainer ce) { oce = ce; if ((cast(IsoEntry)ce).iso != this) throw(new Exception("Only can update entries in same iso file")); //printf("{START: %08X}\n", writeDatasector); uint spos = (cast(ulong)writeDatasector) * 0x800; { stream.seek(0, SeekPos.End); ubyte[] temp; temp.length = 0x800 * 0x100; while (stream.position < spos) { if (spos - stream.position > temp.length) { stream.write(temp); } else { stream.write(temp[0..spos - stream.position]); //stream.position - spos } } } writing = new SliceStream(stream, spos); return writing; } void endFileCreate(int addVoidSectors = 0) { writing.position = 0; uint length = writing.available; IsoEntry e = cast(IsoEntry)oce; e.dr.Extent = writeDatasector; e.dr.Size = length; e.writedr(); writeDatasector += sectors(length) + addVoidSectors; //printf("| {END: %08X}\n", writeDatasector); if (length % 0x800) { stream.position = (cast(ulong)writeDatasector) * 0x800 - 1; stream.write(cast(ubyte)0); } } override void print() { Dump(ipd); } static uint sectors(ulong size) { uint sect = (size / 0x800); if ((size % 0x800) != 0) sect++; return sect; } static uint sectors(uint733 size) { return sectors(cast(ulong)cast(uint)size); } void processFileDR(IsoDirectoryRecord dr) { uint ssect = cast(uint)dr.Extent; uint size = cast(uint)dr.Size; uint sectl = sectors(size); uint esect = ssect + sectl; //writefln("%08X", ssect); if (ssect < firstDatasector) firstDatasector = ssect; if (esect > lastDatasector ) lastDatasector = esect; } Stream openDirectoryRecord(IsoDirectoryRecord dr, bool limited = true) { ulong from = getSectorPos(dr.Extent); uint size = cast(uint)dr.Size; return limited ? (new SliceStreamNoClose(stream, from, from + size)) : (new SliceStreamNoClose(stream, from)); } ubyte[] readSector(uint sector) { ubyte[] ret; ret.length = 0x800; stream.position = getSectorPos(sector); stream.read(ret); return ret; } private ulong getSectorPos(uint sector) { return (cast(ulong)sector) * 0x800; } private ulong getSectorPos(uint733 sector) { return getSectorPos(cast(uint)sector); } private void processDirectory(IsoDirectory id) { IsoDirectoryRecord dr; IsoDirectoryRecord bdr = id.dr; int cp; stream.position = getSectorPos(bdr.Extent); uint maxPos = stream.position + cast(uint)bdr.Size; //Dump(bdr); while (true) { char[] name; Stream drstream; uint bposition = stream.position; drstream = new SliceStream(stream, stream.position, stream.position + dr.sizeof); stream.read(TA(dr)); //writefln("%08X", bposition); //Dump(dr); //writefln("%08X", dr.Length); if (!dr.Length) { stream.position = getSectorPos(bposition / 0x800 + 1); drstream = new SliceStream(stream, stream.position, stream.position + dr.sizeof); stream.read(TA(dr)); } if (stream.position >= maxPos) break; name.length = dr.Length - dr.sizeof; stream.read(cast(ubyte[])name); name.length = dr.NameLength; //writefln(":'%s'", name); Dump(dr); //processDR(dr); if (dr.NameLength && name[0] != 0 && name[0] != 1) { //writefln("DIRECTORY: '%s'", name); // Directorio if (dr.Flags & 2) { IsoDirectory cid = new IsoDirectory(); cid.drstream = drstream; cid.iso = this; cid.dr = dr; id.add(cid); cid.name = name[0..name.length - 2]; uint bp = stream.position; { processDirectory(cid); } stream.position = bp; } // Fichero else { processFileDR(dr); if (cast(uint)dr.Extent < datastart) datastart = cast(uint)dr.Extent; IsoFile cif = new IsoFile(); cif.drstream = drstream; cif.iso = this; cif.dr = dr; cif.size = cast(uint)dr.Size; cif.name = name[0..name.length - 2]; id.add(cif); //writefln("%08X - %s", cast(uint)dr.Size, cif.name); } } else { IsoEntry ie = new IsoEntry(); ie.iso = this; ie.dr = dr; id.add(ie); //Dump(dr); } } } this(Stream s) { ubyte magic[4]; //stream = new PatchedStream(s); stream = s; stream.position = 0; stream.read(magic); if (cast(char[])magic == "CVMH") { stream.position = 0; stream = new SliceStream(stream, 0x1800); } stream.position = getSectorPos(0x10); stream.read(TA(ipd)); this.dr = ipd.RootDirectoryRecord; this.name = "/"; processDirectory(this); writeDatasector = lastDatasector; //try { _udf_check(); } catch (Exception e) { } } this(char[] s, bool readonly = false) { Stream f; //try { if (readonly) { f = new BufferedFile(s, FileMode.In ); } else { try { f = new File(s, FileMode.In | FileMode.Out); } catch (Exception e) { throw(new Exception(e.toString ~ " (for write)")); } } /* } catch (Exception e) { f = new File(s, FileMode.In); }*/ this(f); } private this() { } void copyIsoInfo(Iso from) { ubyte[0x800 * 0x10] data; int fromposition = from.stream.position; scope(exit) { from.stream.position = fromposition; } from.stream.position = 0; from.stream.read(data); this.stream.write(data); this.ipd = from.ipd; this.position = 0x800 * 0x11; this.datastart = from.datastart; } static Iso create(Stream s) { Iso iso = new Iso; iso.stream = s; return iso; } void swap(char[] a, char[] b) { (cast(IsoEntry)this[a]).swap(cast(IsoEntry)this[b]); } void use(char[] a, char[] b) { (cast(IsoEntry)this[a]).use(cast(IsoEntry)this[b]); } //void _udf_test() { void _udf_check() { char[] decodeDstringUDF(ubyte[] s) { char[] r; if (s.length) { ubyte bits = s[0]; switch (bits) { case 8: for (int n = 1; n < s.length; n++) r ~= s[n]; break; case 16: for (int n = 2; n < s.length; n += 2) r ~= s[n]; break; } } return r; } stream.position = 0x800 * 264; int count = 0; while (true) { uint ICB_length, ICB_extent; ubyte FileCharacteristics, LengthofFileIdentifier; ushort FileVersionNumber, LengthofImplementationUse; // Padding while (stream.position % 4) stream.position = stream.position + 1; // Escapamos el tag stream.seek(0x10, SeekPos.Current); stream.read(FileVersionNumber); if (FileVersionNumber != 0x01) { //writefln("%08X : %04X", stream.position - 2, FileVersionNumber); break; } //writefln("%08X", stream.position - 2); stream.read(FileCharacteristics); stream.read(LengthofFileIdentifier); stream.read(ICB_length); stream.read(ICB_extent); stream.seek(8, SeekPos.Current); // Escapamos la implementacion stream.read(LengthofImplementationUse); stream.seek(LengthofImplementationUse, SeekPos.Current); ubyte[] name; name.length = LengthofFileIdentifier; stream.read(name); if (name.length) { //writefln("%s : %d", decodeDstringUDF(name), ICB_length); (cast(IsoEntry)this[decodeDstringUDF(name)]).udf_extent = ICB_extent + 262; //writefln("%s", decodeDstringUDF(name)); //writefln(this[decodeDstringUDF(name)]); } } } override void regen(FileContainer fc, int delegate(char[], int, int, long, long, bool) callback = null) { uint min = 0xFFFFFFFF; foreach (_e; this) { IsoEntry e = cast(IsoEntry)_e; if (!e) continue; if (!e.name.length) continue; uint cpos = cast(uint)e.dr.Extent; if (min > cpos) min = cpos; //writefln("%s: %08X", e.name, cpos); } //writefln("regen ", min); uint cpos = min; auto cchilds = childs; foreach (ccp, _e; cchilds) { IsoEntry e = cast(IsoEntry)_e; if (!e) continue; if (!e.name.length) continue; //if (e.name == "AJI_D03.PKB") continue; if (callback && callback(e.name, ccp, cchilds.length, cast(long)stream.position, cast(long)stream.size, false)) break; if (!fc[e.name].exists) continue; try { Stream s = fc[e.name].open(FileMode.In); //scope(exit) { s.close(); } uint s_size = s.size; e.dr.Size = s_size; e.dr.Extent = cpos; stream.position = getSectorPos(cpos); copy2From(stream, s); cpos += sectors(s_size); } catch (Exception ex) { e.dr.Size = 0; if (callback && callback(e.name, ccp, cchilds.length, cast(long)stream.position, cast(long)stream.size, true)) break; } e.writedr(); } //writefln(); } } /*int main(char[][] args) { ubyte[0x100] temp; Iso iso = new Iso(new File("f:\\isos\\ps2\\Tales of Abyss.iso", FileMode.In)); Iso niso = Iso.create(new File("temp.iso", FileMode.OutNew)); niso.copyIsoInfo(iso); //iso.list; //Stream s = iso.childs[0].open(); //s.read(temp); //writefln("%s", cast(char[])temp); //Iso iso = new Iso(new File("f:\\isos\\ps2\\Final Fantasy XII.iso", FileMode.In)); //writefln("%d", IsoDirectoryRecord.sizeof); //writefln("%d", IsoPrimaryDescriptor.sizeof); return 0; }*/ /*static this() { uint733 t1 = 1000; uint733 t2 = 1001; writefln(t1.sizeof); if (t1 <= t2) { writefln("right"); } writefln(cast(uint)t1); //writefln("%16X", t.v); }*/
D
/Users/hdcui/blind_sig_project/bld_sig/target/release/deps/smallvec-b51284b3258de9af.rmeta: /Users/hdcui/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.13/lib.rs /Users/hdcui/blind_sig_project/bld_sig/target/release/deps/libsmallvec-b51284b3258de9af.rlib: /Users/hdcui/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.13/lib.rs /Users/hdcui/blind_sig_project/bld_sig/target/release/deps/smallvec-b51284b3258de9af.d: /Users/hdcui/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.13/lib.rs /Users/hdcui/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.13/lib.rs:
D
/Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Bytes.swift.o : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Bytes~partial.swiftmodule : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Bits.build/Data+Bytes~partial.swiftdoc : /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Deprecated.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+require.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+string.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+peek.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Control.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/BitsError.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Bytes.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Data+Strings.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/ByteBuffer+binaryFloatingPointOperations.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Alphabet.swift /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/core.git-9210800844849382486/Sources/Bits/Byte+Digit.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/cpp_magic.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIODarwin/include/c_nio_darwin.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOAtomics/include/c-atomics.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio.git-3108475404973543938/Sources/CNIOLinux/include/c_nio_linux.h /Users/user/Documents/RiseTimeAssets/server/.build/checkouts/swift-nio-zlib-support.git--1071467962839356487/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/user/Documents/RiseTimeAssets/server/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
D
<?xml version="1.0" encoding="ASCII" standalone="no"?> <di:SashWindowsMngr xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmi:version="2.0"> <pageList> <availablePage> <emfPageIdentifier href="VAR_1_BeT-1991791641.notation#_copSALmGEeKQQp7P9cQvNQ"/> </availablePage> </pageList> <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> <windows> <children xsi:type="di:TabFolder"> <children> <emfPageIdentifier href="VAR_1_BeT-1991791641.notation#_copSALmGEeKQQp7P9cQvNQ"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>
D
/** * D header file for NetBSD * * Authors: Martin Nowak * * http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/mman.h */ module core.sys.netbsd.sys.mman; version (NetBSD): extern (C): nothrow: public import core.sys.posix.sys.mman; import core.sys.posix.sys.types; enum __BSD_VISIBLE = true; static if (__BSD_VISIBLE) { enum INHERIT_SHARE = 0; enum INHERIT_COPY = 1; enum INHERIT_NONE = 2; enum INHERIT_DONATE_COPY = 3; enum INHERIT_ZERO = 4; } // already in core.sys.posix.sys.mman // enum PROT_NONE = 0x00; // enum PROT_READ = 0x01; // enum PROT_WRITE = 0x02; // enum PROT_EXEC = 0x04; // enum MAP_SHARED = 0x0001; // enum MAP_PRIVATE = 0x0002; static if (__BSD_VISIBLE) enum MAP_COPY = 0x0002; // enum MAP_FIXED = 0x0010; static if (__BSD_VISIBLE) { enum MAP_RENAME = 0x0020; enum MAP_NORESERVE = 0x0040; enum MAP_HASSEMAPHORE = 0x0200; enum MAP_STACK = 0x2000; enum MAP_WIRED = 0x0800; enum MAP_FILE = 0x0000; // already in core.sys.posix.sys.mman // enum MAP_ANON = 0x1000; //#ifndef _KERNEL alias MAP_ANONYMOUS = MAP_ANON; //#endif /* !_KERNEL */ extern(D) int MAP_ALIGNED(int n) { return n << MAP_ALIGNMENT_SHIFT; } enum MAP_ALIGNMENT_SHIFT = 24; enum MAP_ALIGNMENT_MASK = MAP_ALIGNED(0xff); } //static if (__POSIX_VISIBLE >= 199309) //{ // already in core.sys.posix.sys.mman // enum MCL_CURRENT = 0x0001; // enum MCL_FUTURE = 0x0002; //} // already in core.sys.posix.sys.mman enum MAP_FAILED = cast(void*)-1; // already in core.sys.posix.sys.mman // enum MS_SYNC = 0x0000; // enum MS_ASYNC = 0x0001; // enum MS_INVALIDATE = 0x0002; enum _MADV_NORMAL = 0; enum _MADV_RANDOM = 1; enum _MADV_SEQUENTIAL = 2; enum _MADV_WILLNEED = 3; enum _MADV_DONTNEED = 4; static if (__BSD_VISIBLE) { alias MADV_NORMAL = _MADV_NORMAL; alias MADV_RANDOM = _MADV_RANDOM; alias MADV_SEQUENTIAL = _MADV_SEQUENTIAL; alias MADV_WILLNEED = _MADV_WILLNEED; alias MADV_DONTNEED = _MADV_DONTNEED; enum MADV_SPACEAVAIL = 5; enum MADV_FREE = 6; } //static if (__POSIX_VISIBLE >= 200112) //{ // already in core.sys.posix.sys.mman // alias POSIX_MADV_NORMAL = _MADV_NORMAL; // alias POSIX_MADV_RANDOM = _MADV_RANDOM; // alias POSIX_MADV_SEQUENTIAL = _MADV_SEQUENTIAL; // alias POSIX_MADV_WILLNEED = _MADV_WILLNEED; // alias POSIX_MADV_DONTNEED = _MADV_DONTNEED; //} static if (__BSD_VISIBLE) { //int getpagesizes(size_t *, int); int madvise(void *, size_t, int); int mincore(const(void) *, size_t, char *); int minherit(void *, size_t, int); } // already in core.sys.posix.sys.mman // int mlock(const void *, size_t); // void * mmap(void *, size_t, int, int, int, off_t); // int mprotect(const void *, size_t, int); // int msync(void *, size_t, int); // int munlock(const void *, size_t); // int munmap(void *, size_t); //static if (__POSIX_VISIBLE >= 200112) // int posix_madvise(void *, size_t, int); //static if (__POSIX_VISIBLE >= 199309) //{ // int mlockall(int); // int munlockall(); // int shm_open(const(char) *, int, mode_t); // int shm_unlink(const(char) *); //}
D
# FIXED drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/examples/boards/dk-tm4c129x/drivers/pinout.c drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/stdbool.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/stdint.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/stdint.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/cdefs.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/_types.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/machine/_types.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/machine/_stdint.h drivers/pinout.obj: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/_stdint.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_gpio.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_memmap.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_types.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/gpio.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/pin_map.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/rom.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/sysctl.h drivers/pinout.obj: C:/ti/TivaWare_C_Series-2.1.4.178/examples/boards/dk-tm4c129x/drivers/pinout.h C:/ti/TivaWare_C_Series-2.1.4.178/examples/boards/dk-tm4c129x/drivers/pinout.c: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/stdbool.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/stdint.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/stdint.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/cdefs.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/_types.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/machine/_types.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/machine/_stdint.h: C:/ti/ccsv8/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include/sys/_stdint.h: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_gpio.h: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_memmap.h: C:/ti/TivaWare_C_Series-2.1.4.178/inc/hw_types.h: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/gpio.h: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/pin_map.h: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/rom.h: C:/ti/TivaWare_C_Series-2.1.4.178/driverlib/sysctl.h: C:/ti/TivaWare_C_Series-2.1.4.178/examples/boards/dk-tm4c129x/drivers/pinout.h:
D
instance DIA_SEK_8048_FORTUNO_EXIT(C_Info) { npc = sek_8048_fortuno; nr = 999; condition = dia_sek_8048_fortuno_exit_condition; information = dia_sek_8048_fortuno_exit_info; permanent = TRUE; description = Dialog_Ende; }; func int dia_sek_8048_fortuno_exit_condition() { return TRUE; }; func void dia_sek_8048_fortuno_exit_info() { AI_StopProcessInfos(self); }; instance DIA_SEK_8048_FORTUNO_PICKPOCKET(C_Info) { npc = sek_8048_fortuno; nr = 900; condition = dia_sek_8048_fortuno_pickpocket_condition; information = dia_sek_8048_fortuno_pickpocket_info; permanent = TRUE; description = PICKPOCKET_COMM; }; func int dia_sek_8048_fortuno_pickpocket_condition() { return C_Beklauen(10,25); }; func void dia_sek_8048_fortuno_pickpocket_info() { Info_ClearChoices(dia_sek_8048_fortuno_pickpocket); Info_AddChoice(dia_sek_8048_fortuno_pickpocket,Dialog_Back,dia_sek_8048_fortuno_pickpocket_back); Info_AddChoice(dia_sek_8048_fortuno_pickpocket,DIALOG_PICKPOCKET,dia_sek_8048_fortuno_pickpocket_doit); }; func void dia_sek_8048_fortuno_pickpocket_doit() { B_Beklauen(); Info_ClearChoices(dia_sek_8048_fortuno_pickpocket); }; func void dia_sek_8048_fortuno_pickpocket_back() { Info_ClearChoices(dia_sek_8048_fortuno_pickpocket); }; instance DIA_SEK_8048_FORTUNO_HI(C_Info) { npc = sek_8048_fortuno; nr = 2; condition = dia_sek_8048_fortuno_hi_condition; information = dia_sek_8048_fortuno_hi_info; permanent = FALSE; description = "Ну и как тебе здесь?"; }; func int dia_sek_8048_fortuno_hi_condition() { if((FORTUNOBACK == TRUE) && ((other.guild == GIL_SEK) || (other.guild == GIL_TPL) || (other.guild == GIL_GUR))) { return TRUE; }; }; func void dia_sek_8048_fortuno_hi_info() { B_GivePlayerXP(100); AI_Output(other,self,"DIA_SEK_8048_Fortuno_Hi_13_00"); //Ну и как тебе здесь? AI_Output(self,other,"DIA_SEK_8048_Fortuno_Hi_13_01"); //Намного лучше, чем там - в лагере Ворона! AI_Output(self,other,"DIA_SEK_8048_Fortuno_Hi_13_02"); //Я даже и мечтать не мог о таком месте. AI_Output(self,other,"DIA_SEK_8048_Fortuno_Hi_13_03"); //Но благодаря тебе... Эх, теперь я твой вечный должник! }; instance DIA_FORTUNO_SEKTEHEILEN(C_Info) { npc = sek_8048_fortuno; nr = 1; condition = dia_fortuno_sekteheilen_condition; information = dia_fortuno_sekteheilen_info; permanent = FALSE; description = "Выпей напиток! Он помогает от головной боли."; }; func int dia_fortuno_sekteheilen_condition() { if((Npc_HasItems(other,ItPo_HealObsession_MIS) > 0) && (MIS_SEKTEHEILEN == LOG_Running) && Npc_KnowsInfo(hero,dia_baalorun_sekteheilengot)) { return TRUE; }; }; func void dia_fortuno_sekteheilen_info() { B_GivePlayerXP(50); AI_Output(other,self,"DIA_Fortuno_SekteHeilen_01_00"); //Выпей напиток! Он помогает от головной боли. B_GiveInvItems(other,self,ItPo_HealObsession_MIS,1); B_UseItem(self,ItPo_HealObsession_MIS); SEKTEHEILENCOUNT = SEKTEHEILENCOUNT + 1; AI_Output(self,other,"DIA_Fortuno_SekteHeilen_01_01"); //М-моя голова п-прошла! AI_Output(self,other,"DIA_Fortuno_SekteHeilen_01_02"); //О, как я тебе б-благодарен! };
D
module pairhist; import std.typecons, std.conv; import gsl.histogram; // Make an MPI-supported version version(MPI) { import mpi.mpi; } class Histogram2D { this(int nx, double xmin, double xmax, int ny, double ymin, double ymax) { hist = gsl_histogram2d_alloc(nx, ny); gsl_histogram2d_set_ranges_uniform(hist, xmin, xmax, ymin, ymax); this.nx = nx; this.ny = ny; } this(double[] xbins, double[] ybins) { this.nx = xbins.length-1; this.ny = ybins.length-1; hist = gsl_histogram2d_alloc(this.nx, this.ny); gsl_histogram2d_set_ranges(hist, &xbins[0], this.nx+1, &ybins[0],this.ny+1); } this(Histogram2D h1, bool reset=true) { hist = gsl_histogram2d_clone(h1.hist); if (reset) gsl_histogram2d_reset(hist); this.nx = h1.nx; this.ny = h1.ny; } ~this() { gsl_histogram2d_free(hist); } // Accumulate void accumulate(double x, double y, double val=1) { gsl_histogram2d_accumulate(hist,x,y,val); } // Overload index double opIndex(int i, int j) { return gsl_histogram2d_get(hist, i, j); } // Overload += ref Histogram2D opOpAssign(string op) (Histogram2D rhs) if (op=="+") { gsl_histogram2d_add(hist, rhs.hist); return this; } // Overload += for double ref Histogram2D opOpAssign(string op) (double rhs) if (op=="+") { gsl_histogram2d_shift(hist, rhs); return this; } // Overload -= ref Histogram2D opOpAssign(string op) (Histogram2D rhs) if (op=="-") { gsl_histogram2d_sub(hist, rhs.hist); return this; } // Overload *= ref Histogram2D opOpAssign(string op) (Histogram2D rhs) if (op=="*") { gsl_histogram2d_mul(hist, rhs.hist); return this; } // Overload /= ref Histogram2D opOpAssign(string op) (Histogram2D rhs) if (op=="/") { gsl_histogram2d_div(hist, rhs.hist); return this; } // Get the maximum value of the histogram @property double max() { return gsl_histogram2d_max_val(hist); } // Get the minimum value of the histogram @property double min() { return gsl_histogram2d_min_val(hist); } // Reset the histogram void reset() { gsl_histogram2d_reset(hist); } // Return the x and y ranges as tuples Tuple!(double, double) xrange(int i) { double lo, hi; gsl_histogram2d_get_xrange(hist, i, &lo, &hi); return tuple(lo, hi); } Tuple!(double, double) yrange(int i) { double lo, hi; gsl_histogram2d_get_yrange(hist, i, &lo, &hi); return tuple(lo, hi); } // Return a copy of the full array double[] getHist() { auto arr = new double[nx*ny]; arr[] = hist.bin[0..nx*ny]; return arr; } version(MPI) { void mpiReduce(int root, MPI_Comm comm) { int rank; MPI_Comm_rank(comm, &rank); if (rank == root) { auto arr = new double[nx*ny]; arr[] = hist.bin[0..nx*ny]; MPI_Reduce(cast(void*)&arr[0],cast(void*)hist.bin, to!int(nx*ny), MPI_DOUBLE, MPI_SUM, root, comm); } else { MPI_Reduce(cast(void*)hist.bin, null, to!int(nx*ny), MPI_DOUBLE, MPI_SUM, root, comm); } } } //private double[] hist; private gsl_histogram2d* hist; private ulong nx, ny; } class Histogram { this(int nx, double xmin, double xmax) { hist = gsl_histogram_alloc(nx); gsl_histogram_set_ranges_uniform(hist, xmin, xmax); this.nx = nx; } this(double[] bins) { this.nx=bins.length-1; hist = gsl_histogram_alloc(this.nx); gsl_histogram_set_ranges(hist, &bins[0], this.nx+1); } this(Histogram h1, bool reset=true) { hist = gsl_histogram_clone(h1.hist); if (reset) gsl_histogram_reset(hist); this.nx = h1.nx; } ~this() { gsl_histogram_free(hist); } // Accumulate void accumulate(double x, double val=1) { gsl_histogram_accumulate(hist,x,val); } // Overload index double opIndex(int i) { return gsl_histogram_get(hist, i); } // Overload += ref Histogram opOpAssign(string op) (Histogram rhs) if (op=="+") { gsl_histogram_add(hist, rhs.hist); return this; } // Overload += for double ref Histogram opOpAssign(string op) (double rhs) if (op=="+") { gsl_histogram_shift(hist, rhs); return this; } // Overload -= ref Histogram opOpAssign(string op) (Histogram rhs) if (op=="-") { gsl_histogram_sub(hist, rhs.hist); return this; } // Overload *= ref Histogram opOpAssign(string op) (Histogram rhs) if (op=="*") { gsl_histogram_mul(hist, rhs.hist); return this; } // Overload /= ref Histogram opOpAssign(string op) (Histogram rhs) if (op=="/") { gsl_histogram_div(hist, rhs.hist); return this; } // Get the maximum value of the histogram @property double max() { return gsl_histogram_max_val(hist); } // Get the minimum value of the histogram @property double min() { return gsl_histogram_min_val(hist); } // Reset the histogram void reset() { gsl_histogram_reset(hist); } // Return the ranges as tuples Tuple!(double, double) xrange(int i) { double lo, hi; gsl_histogram_get_range(hist, i, &lo, &hi); return tuple(lo, hi); } // Return a copy of the full array double[] getHist() { auto arr = new double[nx]; arr[] = hist.bin[0..nx]; return arr; } version(MPI) { void mpiReduce(int root, MPI_Comm comm) { int rank; MPI_Comm_rank(comm, &rank); if (rank == root) { auto arr = new double[nx]; arr[] = hist.bin[0..nx]; MPI_Reduce(cast(void*)&arr[0],cast(void*)hist.bin, to!int(nx), MPI_DOUBLE, MPI_SUM, root, comm); } else { MPI_Reduce(cast(void*)hist.bin, null, to!int(nx), MPI_DOUBLE, MPI_SUM, root, comm); } } } //private double[] hist; private gsl_histogram* hist; private ulong nx; } // Arrays of histograms --- useful if you want to simultaneously histogram // multiple quantities // This is a convenience wrapper around a public array of Histogram2D // HT : type of histogram class HistArr(HT, ulong Nhist) { alias typeof(this) MyType; HT[Nhist] hists; this(T:MyType, U:bool) (T hin, U reset=true) { foreach (ref h1; hists) { h1 = new HT(hin[0], reset); } } this(T:MyType) (T hin) { foreach (ref h1; hists) { h1 = new HT(hin[0], true); } } // Simple wrapper for all other constructors this(T...) (T args) { foreach (ref h1; hists) { h1 = new HT(args); } } // We do use this in the paircounting code ref MyType opOpAssign(string op) (MyType rhs) if (op=="+") { foreach (i, ref h1; hists) { h1 += rhs[i]; } return this; } // Overload index ref HT opIndex(ulong i) { return hists[i]; } void reset() { foreach (ref h1; hists) h1.reset(); } // MPI reduce version(MPI) { void mpiReduce(int root, MPI_Comm comm) { foreach (ref h1; hists) h1.mpiReduce(root, comm); } } } // NOTE : Dynamic version of above // Arrays of histograms --- useful if you want to simultaneously histogram // multiple quantities // This is a convenience wrapper around a public array of Histogram2D // HT : type of histogram class HistArrDyn(HT) { alias typeof(this) MyType; HT[] hists; ulong Nhist; this(T:MyType, U:bool) (T hin, U reset=true) { hists = new HT[hin.Nhist]; foreach (ref h1; hists) { h1 = new HT(hin[0], reset); } } this(T:MyType) (T hin) { hists = new HT[hin.Nhist]; foreach (ref h1; hists) { h1 = new HT(hin[0], true); } } // Simple wrapper for all other constructors this(T...) (ulong N, T args) { Nhist = N; hists = new HT[Nhist]; foreach (ref h1; hists) { h1 = new HT(args); } } // We do use this in the paircounting code ref MyType opOpAssign(string op) (MyType rhs) if (op=="+") { foreach (i, ref h1; hists) { h1 += rhs[i]; } return this; } // Overload index ref HT opIndex(ulong i) { return hists[i]; } void reset() { foreach (ref h1; hists) h1.reset(); } // MPI reduce version(MPI) { void mpiReduce(int root, MPI_Comm comm) { foreach (ref h1; hists) h1.mpiReduce(root, comm); } } }
D
/** * D header file for POSIX. * * Copyright: Copyright Sean Kelly 2005 - 2009. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Sean Kelly, Alex Rønne Petersen * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition */ /* Copyright Sean Kelly 2005 - 2009. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * http://www.boost.org/LICENSE_1_0.txt) */ module core.sys.posix.sys.uio; private import core.sys.posix.config; public import core.sys.posix.sys.types; // for ssize_t version (OSX) version = Darwin; else version (iOS) version = Darwin; else version (TVOS) version = Darwin; else version (WatchOS) version = Darwin; version (Posix): extern (C) nothrow @nogc: // // Required // /* struct iovec { void* iov_base; size_t iov_len; } ssize_t // from core.sys.posix.sys.types size_t // from core.sys.posix.sys.types ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); */ version (CRuntime_Glibc) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (Darwin) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (FreeBSD) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (NetBSD) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (OpenBSD) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (DragonFlyBSD) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (Solaris) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (CRuntime_Bionic) { struct iovec { void* iov_base; size_t iov_len; } int readv(int, const scope iovec*, int); int writev(int, const scope iovec*, int); } else version (CRuntime_Musl) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else version (CRuntime_UClibc) { struct iovec { void* iov_base; size_t iov_len; } ssize_t readv(int, const scope iovec*, int); ssize_t writev(int, const scope iovec*, int); } else { static assert(false, "Unsupported platform"); }
D
/Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Routing.build/RouteBuilder.swift.o : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Branch.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/ParametersContainer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/libc.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Routing.build/RouteBuilder~partial.swiftmodule : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Branch.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/ParametersContainer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/libc.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Routing.build/RouteBuilder~partial.swiftdoc : /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Branch.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/ParametersContainer.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder+RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteCollection.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup+RouteBuilder.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/RouteGroup.swift /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/Packages/Routing-1.0.1/Sources/Routing/Router.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Core.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/libc.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Node.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/PathIndexable.swiftmodule /Users/mohammadazam/Documents/Projects/StoryTellersAPICode/StoryTellersAPI/.build/debug/Polymorphic.swiftmodule
D
/// Copyright: Copyright (c) 2018-2020 Penechko. /// License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). /// Authors: Andrey Penechko. /// Linear scan register allocation pass /// /// Notes: /// Non-split current interval does not intersect with inactive intervals because of SSA form /// /// Splits need to be at the odd position. This gives: /// a) no intervals of form: [x; x) /// b) no problems with two operand form mov instruction before two operand instruction /// two operand form can insert mov from first operand into result register /// and in case first operand's interval was split it would start at the instruction and not include the mov /// as result register allocator may allocate arg0 register to reloaded argument, /// but reload will precede the mov, thus overwriting the value /// 100 | v0 = add v1, v2 | eax(v0) = add ecx(v1), ecx(v2) /// v0 [100; 200) eax /// v1 [50; 100) ecx /// v2 [40; 99) s0 [100; 109) ecx /// becomes /// 99| ecx = load i32* s3 // split move overwrites ecx that is used in the next instruction /// 99| eax = mov ecx // fix two operand form /// 100| eax = add eax, ecx /// /// As result of splits being on odd positions another invariant becomes available: /// All ranges have distinct `from` and `to` positions. Zero length ranges become impossible. /// range.from < range.to module be.reg_alloc.linear_scan; import std.array : empty; import std.string : format; import std.stdio : writeln, write, writef, writefln, stdout; import std.format : formattedWrite, FormatSpec; import std.range : repeat; import std.range : chain; import std.algorithm : min, max, sort, swap; import all; //version = RAPrint; //version = RAPrint_resolve; /// Does linear scan register allocation. /// Uses live intervals produced by pass_live_intervals void pass_linear_scan(LinearScan* linearScan) { CompilationContext* c = linearScan.context; assert(!linearScan.fun.isExternal); linearScan.scanFun(); if (c.printLirRA && c.printDumpOf(linearScan.fun)) { IrFunction* lirData = c.getAst!IrFunction(linearScan.fun.backendData.lirData); dumpFunction(c, lirData, "RA"); linearScan.livePtr.dump(c, lirData); } } struct RegisterState { IrIndex index; IntervalIndex activeInterval; bool isAllocatable; bool isUsed; bool isCalleeSaved; uint blockPos; uint usePos; void setUsePos(uint pos) { usePos = min(usePos, pos); } void setBlockPos(uint pos) { blockPos = min(blockPos, pos); usePos = min(usePos, pos); } } struct PhysRegisters { RegisterState[] gpr; const(IrIndex)[] allocatableRegs; ref RegisterState opIndex(IrIndex reg) { assert(reg.isPhysReg, format("%s", reg)); return gpr[reg.physRegIndex]; } void setup(CompilationContext* c, IrFunction* lir, MachineInfo* machineInfo) { CallConv* callConv = lir.getCallConv(c); allocatableRegs = callConv.allocatableRegs; if (c.debugRegAlloc) allocatableRegs = allocatableRegs[0..5]; // only 5 regs are available for tests gpr.length = machineInfo.registers.length; foreach(i, ref RegisterState reg; gpr) { reg = RegisterState(machineInfo.registers[i].index); } foreach(i, reg; allocatableRegs) { opIndex(reg).isAllocatable = true; } foreach(i, reg; callConv.calleeSaved) { opIndex(reg).isCalleeSaved = true; } } void resetBlockPos() { foreach (ref reg; gpr) { if (reg.isAllocatable) { reg.usePos = MAX_USE_POS; reg.blockPos = MAX_USE_POS; } else { reg.usePos = 0; reg.blockPos = 0; // prevent allocation } } } void resetUsePos() { foreach (ref reg; gpr) { if (reg.isAllocatable) reg.usePos = MAX_USE_POS; else reg.usePos = 0; // prevent allocation } } void markAsUsed(IrIndex reg) { assert(gpr[reg.physRegIndex].isAllocatable); gpr[reg.physRegIndex].isUsed = true; } } // data shared between all split children of interval // identified by vreg index struct VregState { IrIndex spillSlot; } /// Implementation of: /// "Optimized Interval Splitting in a Linear Scan Register Allocator" /// "Linear Scan Register Allocation on SSA Form" struct LinearScan { IntervalIndex[] unhandledStorage; // TODO: remove GC storage here VregState[] vregState; Array!IntervalIndex activeVirtual; Array!IntervalIndex activeFixed; Array!IntervalIndex inactiveVirtual; Array!IntervalIndex inactiveFixed; // unhandled = list of intervals sorted by increasing start positions IntervalPriorityQueue unhandled; // List of handled split intervals that begin in the middle of basic block // Intervals are with increasing start position Array!IntervalIndex pendingMoveSplits; PhysRegisters physRegs; CompilationContext* context; IrBuilder* builder; FunctionDeclNode* fun; LivenessInfo* livePtr; ref LivenessInfo live() { return *livePtr; } IrFunction* lir; IrIndex scratchSpillSlot; void freeMem() { activeVirtual.free(context.arrayArena); activeFixed.free(context.arrayArena); inactiveVirtual.free(context.arrayArena); inactiveFixed.free(context.arrayArena); pendingMoveSplits.free(context.arrayArena); unhandled.free(context.arrayArena); } void checkActiveImpl(uint position, ref Array!IntervalIndex active, ref Array!IntervalIndex inactive) { size_t index; // // check for intervals in active that are handled or inactive // for each interval it in active do while (index < active.length) { IntervalIndex activeId = active[index]; LiveInterval* activeInt = &live.intervals[activeId]; // already spilled if (activeInt.reg.isStackSlot) { version(RAPrint) writefln(" move %s active -> handled, spilled to %s", activeId, activeInt.reg); active.removeInPlace(index); continue; } LiveRangeIndex rangeId = activeInt.getRightRange(position); // if it ends before position then if (rangeId.isNull) { // move it from active to handled version(RAPrint) writefln(" move %s active -> handled", activeId); active.removeInPlace(index); } // else if it does not cover position then else if(!activeInt.ranges[rangeId].contains(position)) { // move it from active to inactive version(RAPrint) writefln(" move %s active -> inactive", activeId); active.removeInPlace(index); inactive.put(context.arrayArena, activeId); } else { ++index; } } } void checkActive(uint position) { checkActiveImpl(position, activeFixed, inactiveFixed); checkActiveImpl(position, activeVirtual, inactiveVirtual); } void checkInactiveImpl(uint position, ref Array!IntervalIndex active, ref Array!IntervalIndex inactive) { size_t index = 0; // check for intervals in inactive that are handled or active // for each interval it in inactive do while (index < inactive.length) { IntervalIndex inactiveId = inactive[index]; LiveInterval* inactiveInt = &live.intervals[inactiveId]; LiveRangeIndex rangeId = inactiveInt.getRightRange(position); // if it ends before position then if (rangeId.isNull) { // move it from inactive to handled version(RAPrint) writefln(" move %s inactive -> handled", inactiveId); inactive.removeInPlace(index); } // else if it covers position then else if(inactiveInt.ranges[rangeId].contains(position)) { // move it from inactive to active version(RAPrint) writefln(" move %s inactive -> active", inactiveId); active.put(context.arrayArena, inactiveId); inactive.removeInPlace(index); } else ++index; } } void checkInactive(uint position) { checkInactiveImpl(position, activeFixed, inactiveFixed); checkInactiveImpl(position, activeVirtual, inactiveVirtual); } /* LinearScan unhandled = list of intervals sorted by increasing start positions active = { }; inactive = { }; handled = { } while unhandled != { } do current = pick and remove first interval from unhandled position = start position of current // check for intervals in active that are handled or inactive for each interval it in active do if it ends before position then move it from active to handled else if it does not cover position then move it from active to inactive // check for intervals in inactive that are handled or active for each interval it in inactive do if it ends before position then move it from inactive to handled else if it covers position then move it from inactive to active // find a register for current TryAllocateFreeReg if allocation failed then AllocateBlockedReg if current has a register assigned then add current to active */ void scanFun() { import std.container.binaryheap; lir = context.getAst!IrFunction(fun.backendData.lirData); physRegs.setup(context, lir, context.machineInfo); vregState = context.allocateTempArray!VregState(lir.numVirtualRegisters); //writefln("\nstart scan of %s", context.idString(lir.backendData.name)); scope(exit) { lir = null; } // active = { }; inactive = { }; handled = { } activeVirtual.clear; activeFixed.clear; inactiveVirtual.clear; inactiveFixed.clear; pendingMoveSplits.clear; unhandled.clear; size_t i = 0; foreach (ref LiveInterval it; live.virtualIntervals) { if (!it.ranges.empty) unhandled.insert(context.arrayArena, live.vindex(i), it.from); ++i; } i = 0; foreach (ref LiveInterval it; live.physicalIntervals) { if (!it.ranges.empty) inactiveFixed.put(context.arrayArena, live.pindex(i)); ++i; } IrIndex currentBlock = lir.entryBasicBlock; // while unhandled != { } do while (!unhandled.empty) { // current = pick and remove first interval from unhandled IntervalIndex currentIndex = unhandled.removeFront; LiveInterval* currentInterval = &live.intervals[currentIndex]; // position = start position of current uint position = currentInterval.from; version(RAPrint) writefln("current %s %s pos %s firstUse %s", currentIndex, *currentInterval, position, currentInterval.firstUse); checkActive(position); checkInactive(position); if (currentInterval.isSplitChild) { version(RAPrint) writefln(" current is split child"); if (!live.isBlockStartAt(lir, position, currentBlock)) { version(RAPrint) writefln(" current is in the middle of the block %s", currentBlock); pendingMoveSplits.put(context.arrayArena, currentIndex); } // skip allocation if this interval has spill slot assigned if (currentInterval.reg.isStackSlot) { version(RAPrint) writefln(" current is spilled to %s. skip allocation", currentInterval.reg); continue; } } // find a register for current bool success = tryAllocateFreeReg(currentIndex); // if allocation failed then AllocateBlockedReg if (!success) { allocateBlockedReg(fun, currentIndex, position); } currentInterval = &live.intervals[currentIndex]; // intervals may have reallocated version(RAPrint) writefln(" alloc current %s %s %s to %s", currentIndex, currentInterval, *currentInterval, IrIndexDump(currentInterval.reg, context, lir)); // if current has a register assigned then add current to active if (currentInterval.reg.isPhysReg) { // don't add stack slot assigned interval to active version(RAPrint) writefln(" move current %s %s -> active", currentIndex, *currentInterval); activeVirtual.put(context.arrayArena, currentIndex); } version(RAPrint) writeln; } //live.dump(context, lir); MoveSolver moveSolver = MoveSolver(context); moveSolver.setup(fun); fixInstructionArgs(fun); // this pass inserts moves for spills and loads resolveInsertSplitMoves(moveSolver); // this pass inserts moves to resolve two-operand form, // so it needs to be after `resolveInsertSplitMoves` fixInstructionResults(fun); resolveControlFlow(moveSolver); genSaveCalleeSavedRegs(fun.backendData.stackLayout); moveSolver.release(); lir.removeAllPhis; if (context.validateIr) validateIrFunction(context, lir); //writefln("finished scan of %s\n", context.idString(lir.backendData.name)); } /* TRYALLOCATEFREEREG set freeUntilPos of all physical registers to maxInt for each interval it in active do freeUntilPos[it.reg] = 0 for each interval it in inactive intersecting with current do freeUntilPos[it.reg] = next intersection of it with current // clarification: if current intersects active and inactive, freeUntilPos is 0 reg = register with highest freeUntilPos if freeUntilPos[reg] = 0 then // no register available without spilling allocation failed else if current ends before freeUntilPos[reg] then // register available for the whole interval current.reg = reg else // register available for the first part of the interval current.reg = reg split current before freeUntilPos[reg] */ bool tryAllocateFreeReg(IntervalIndex currentId) { // set usePos of all physical registers to maxInt physRegs.resetUsePos; LiveInterval* currentIt = &live.intervals[currentId]; uint currentEnd = currentIt.to; static struct FreeUntilPos { uint num; void toString(scope void delegate(const(char)[]) sink) { if (num == MAX_USE_POS) formattedWrite(sink, "max"); else formattedWrite(sink, "%s", num); } } // for each interval it in active do // usePos[it.reg] = 0 version(RAPrint) writeln(" active:"); foreach (IntervalIndex activeId; activeFixed) { LiveInterval* it = &live.intervals[activeId]; physRegs[it.reg].usePos = 0; version(RAPrint) writefln(" intp %s %s reg %s (next use 0)", activeId, IrIndexDump(it.definition, context, lir), IrIndexDump(it.reg, context, lir)); } foreach (IntervalIndex activeId; activeVirtual) { LiveInterval* it = &live.intervals[activeId]; physRegs[it.reg].usePos = 0; version(RAPrint) writefln(" intv %s %s reg %s (next use 0)", activeId, *it, IrIndexDump(it.reg, context, lir)); } // for each interval it in inactive intersecting with current do // usePos[it.reg] = next intersection of it with current version(RAPrint) writeln(" inactive:"); foreach (IntervalIndex inactiveId; inactiveFixed) { LiveInterval* it = &live.intervals[inactiveId]; version(RAPrint) writef(" intp %s %s (next use %s)", IrIndexDump(it.reg, context, lir), IrIndexDump(it.definition, context, lir), FreeUntilPos(physRegs[it.reg].usePos)); // if current intersects both active and inactive, usePos stays 0 if (physRegs[it.reg].usePos == 0) { version(RAPrint) writeln; continue; } // in case there is no intersection will return MAX_USE_POS (noop) uint inactiveIntersection = firstIntersection(currentIt, it); // Register may be already occupied by active or inactive interval, so preserve it's use pos physRegs[it.reg].usePos = min(physRegs[it.reg].usePos, inactiveIntersection); version(RAPrint) writefln(":=%s", FreeUntilPos(inactiveIntersection)); } // We only need to check inactive intervals when current interval was split // because otherwise SSA form is intact, and there may not be intersections with inactive intervals if (currentIt.isSplitChild) { foreach (IntervalIndex inactiveId; inactiveVirtual) { LiveInterval* it = &live.intervals[inactiveId]; assert(it.reg.isPhysReg, "not a reg"); version(RAPrint) writef(" intv %s %s (next use %s)", IrIndexDump(it.reg, context, lir), it.definition, FreeUntilPos(physRegs[it.reg].usePos)); // if current intersects both active and inactive, usePos stays 0 if (physRegs[it.reg].usePos == 0) { version(RAPrint) writeln; continue; } // in case there is no intersection will return MAX_USE_POS (noop) uint inactiveIntersection = firstIntersection(currentIt, it); // Register may be already occupied by active or inactive interval, so preserve it's use pos physRegs[it.reg].usePos = min(physRegs[it.reg].usePos, inactiveIntersection); version(RAPrint) writefln(":=%s", FreeUntilPos(inactiveIntersection)); } } version(RAPrint) writefln(" Try alloc free reg for %s %s", *currentIt, currentId); // reg = register with highest usePos uint maxPos = 0; IrIndex reg; const IrIndex[] candidates = physRegs.allocatableRegs; version(RAPrint) write(" candidates:"); foreach (i, IrIndex r; candidates) { version(RAPrint) writef(" %s:%s", IrIndexDump(r, context, lir), FreeUntilPos(physRegs[r].usePos)); if (physRegs[r].usePos > maxPos) { maxPos = physRegs[r].usePos; reg = r; } } version(RAPrint) writeln; // reg stored in hint IrIndex hintReg = currentIt.storageHint; if (maxPos == 0) { // no register available without spilling version(RAPrint) writeln(" no register available without spilling"); // special case // if current is interval without uses we can just spill the whole interval // this happens when interval is used at the beginning of the loop, then split in the middle // the tail part then contains no uses if (currentIt.uses.empty) { assignSpillSlot(fun.backendData.stackLayout, currentIt); version(RAPrint) writeln(" spill whole interval because of no uses"); return true; } return false; } else { version(RAPrint) writefln(" hint is %s", IrIndexDump(hintReg, context, lir)); if (hintReg.isDefined) { if (currentEnd < physRegs[hintReg].usePos) { // register available for the whole interval currentIt.reg = hintReg; currentIt.reg.physRegSize = typeToRegSize(lir.getValueType(context, currentIt.definition), context); physRegs.markAsUsed(hintReg); version(RAPrint) writefln(" alloc hint %s", IrIndexDump(hintReg, context, lir)); return true; } else { version(RAPrint) writefln(" hint %s is not available for the whole interval", IrIndexDump(hintReg, context, lir)); // use hint reg with spill if it is one of max use regs if (physRegs[hintReg].usePos == maxPos) reg = hintReg; } } if (currentEnd < maxPos) { // register available for the whole interval currentIt.reg = reg; currentIt.reg.physRegSize = typeToRegSize(lir.getValueType(context, currentIt.definition), context); physRegs.markAsUsed(reg); version(RAPrint) writefln(" alloc %s", IrIndexDump(reg, context, lir)); return true; } else { // split version(RAPrint) writefln(" alloc %s + split at %s", IrIndexDump(reg, context, lir), maxPos); // prevent split at even x when interval starts at x-1 if (currentIt.from + 1 == maxPos) return false; splitBefore(currentId, maxPos); currentIt = &live.intervals[currentId]; // intervals may have reallocated currentIt.reg = reg; currentIt.reg.physRegSize = typeToRegSize(lir.getValueType(context, currentIt.definition), context); physRegs.markAsUsed(reg); return true; } } } /* ALLOCATEBLOCKEDREG set nextUsePos of all physical registers to maxInt for each interval it in active do nextUsePos[it.reg] = next use of it after start of current for each interval it in inactive intersecting with current do nextUsePos[it.reg] = next use of it after start of current reg = register with highest nextUsePos if first usage of current is after nextUsePos[reg] then // all other intervals are used before current, // so it is best to spill current itself assign spill slot to current split current before its first use position that requires a register else // spill intervals that currently block reg current.reg = reg split active interval for reg at position split any inactive interval for reg at the end of its lifetime hole // make sure that current does not intersect with // the fixed interval for reg if current intersects with the fixed interval for reg then split current before this intersection */ // Returns new interval void allocateBlockedReg(FunctionDeclNode* fun, IntervalIndex currentId, uint currentStart) { physRegs.resetBlockPos; LiveInterval* currentIt = &live.intervals[currentId]; assert(currentIt.ranges.length); version(RAPrint) writefln("allocateBlockedReg of int %s start %s", currentId, currentStart); foreach (IntervalIndex activeId; activeVirtual) { LiveInterval* it = &live.intervals[activeId]; physRegs[it.reg].setUsePos = it.nextUseAfter(currentStart); physRegs[it.reg].activeInterval = activeId; version(RAPrint) writefln("active virt usePos of %s %s use %s block %s", activeId, *it, physRegs[it.reg].usePos, physRegs[it.reg].blockPos); } // We only need to check inactive intervals when current interval was split // because otherwise SSA form is intact, and there may not be intersections with inactive intervals if (currentIt.isSplitChild) { foreach (inactiveId; inactiveVirtual) { LiveInterval* it = &live.intervals[inactiveId]; physRegs[it.reg].setUsePos = it.nextUseAfter(currentStart); version(RAPrint) writefln("inactive virt usePos of %s %s use %s block %s", inactiveId, *it, physRegs[it.reg].usePos, physRegs[it.reg].blockPos); } } foreach (IntervalIndex activeId; activeFixed) { LiveInterval* it = &live.intervals[activeId]; physRegs[it.reg].setBlockPos = 0; physRegs[it.reg].activeInterval = IntervalIndex.NULL; version(RAPrint) writefln("active fixed usePos of %s %s use %s block %s", activeId, *it, physRegs[it.reg].usePos, physRegs[it.reg].blockPos); } foreach (inactiveId; inactiveFixed) { LiveInterval* it = &live.intervals[inactiveId]; uint intersection = firstIntersection(currentIt, it); if (intersection != MAX_USE_POS) { physRegs[it.reg].setBlockPos = intersection; } version(RAPrint) writefln("inactive fixed usePos of %s %s use %s block %s", inactiveId, *it, physRegs[it.reg].usePos, physRegs[it.reg].blockPos); } // reg = register with highest usePos uint maxPos = 0; IrIndex reg; foreach (i, IrIndex r; physRegs.allocatableRegs) { if (physRegs[r].usePos > maxPos) { // if register was only available for the start of interval // then all uses may have moved into split child maxPos = physRegs[r].usePos; reg = r; } } version(RAPrint) writefln(" candidate %s usePos %s", IrIndexDump(reg, context, lir), maxPos); uint firstUse = currentIt.firstUse; if (maxPos < firstUse) { version(RAPrint) writefln(" spill current maxUse %s firstUse %s", maxPos, firstUse); // all other intervals are used before current, so it is best to spill current itself assignSpillSlot(fun.backendData.stackLayout, currentIt); // split current before its first use position that requires a register splitBefore(currentId, firstUse); currentIt = &live.intervals[currentId]; // intervals may have reallocated version(RAPrint) writefln(" spill current %s", currentId); } else { // spill intervals that currently block reg currentIt.reg = reg; currentIt.reg.physRegSize = typeToRegSize(lir.getValueType(context, currentIt.definition), context); physRegs.markAsUsed(reg); // split active interval for reg at position void splitActiveOrInactive(IntervalIndex index) { LiveInterval* activeIt = &live.intervals[index]; // split before current start. Add to unhandled so we get split move registered version(RAPrint) writefln(" split before current start %s", currentStart); IntervalIndex newInterval = splitBefore(index, currentStart); LiveInterval* splitActiveIt = &live.intervals[newInterval]; assignSpillSlot(fun.backendData.stackLayout, splitActiveIt); // if there is a use position in spilled interval, split before use uint nextActiveUse = splitActiveIt.nextUseAfter(currentStart); if (nextActiveUse != MAX_USE_POS) { version(RAPrint) writefln(" split before use %s", newInterval); splitBefore(newInterval, nextActiveUse); } } IntervalIndex activeIndex = physRegs[reg].activeInterval; context.assertf(!activeIndex.isNull, "%s", IrIndexDump(reg, context, lir)); // null means that it is fixed interval. But we filter out fixed interval above version(RAPrint) writefln(" split active interval %s", activeIndex); splitActiveOrInactive(activeIndex); // split any inactive interval for reg at the end of its lifetime hole foreach (inactiveId; inactiveVirtual) { LiveInterval* it = &live.intervals[inactiveId]; if (sameIndexOrPhysReg(it.reg, reg)) { version(RAPrint) writefln(" split inactive interval %s", inactiveId); splitActiveOrInactive(inactiveId); } } // if current intersects with the fixed interval for reg then if (currentIt.exclusivePosition(physRegs[reg].blockPos)) { // split current before this intersection splitBefore(currentId, physRegs[reg].blockPos); } version(RAPrint) writefln(" spill currently active interval %s before %s for %s", activeIndex, currentStart, IrIndexDump(reg, context, lir)); } } // auto adds new interval to unhandled IntervalIndex splitBefore(IntervalIndex it, uint before) { IntervalIndex newInterval = live.splitBefore(context, lir, it, before); if (newInterval != it) { unhandled.insert(context.arrayArena, newInterval, live.intervals[newInterval].from); } return newInterval; } IntervalIndex splitBefore(IntervalIndex it, uint before, LiveRangeIndex rangeIndex) { IntervalIndex newInterval = live.splitBefore(context, it, before, rangeIndex); if (newInterval != it) { unhandled.insert(context.arrayArena, newInterval, live.intervals[newInterval].from); } return newInterval; } void assignSpillSlot(ref StackLayout stackLayout, LiveInterval* it) { assert(it.definition.isVirtReg); VregState* state = &vregState[it.definition.storageUintIndex]; if (state.spillSlot.isDefined) { // use cached slot it.reg = state.spillSlot; version(RAPrint) writefln("assignSpillSlot %s use cached %s", it.definition, state.spillSlot); } else { IrIndex type = lir.getValueType(context, it.definition); IrIndex slot = stackLayout.addStackItem(context, type, StackSlotKind.local, 0); state.spillSlot = slot; // cache slot version(RAPrint) writefln("assignSpillSlot %s new slot %s", it.definition, slot); it.reg = slot; } // TODO: need to fix instructions to use stack slots after RA // Not relevant yet // We always provide register for all uses // simple way would be to allow src arguments be stack slots } // Replaces all uses of virtual registers with physical registers or stack slots void fixInstructionArgs(FunctionDeclNode* fun) { // fix uses first, because we may copy arg to definition below foreach (IrIndex vregIndex, ref IrVirtualRegister vreg; lir.virtualRegisters) { foreach (size_t i, IrIndex userIndex; vreg.users.range(lir)) { final switch (userIndex.kind) with(IrValueKind) { case none, array, virtualRegister, physicalRegister, constant, constantAggregate, constantZero, global, basicBlock, stackSlot, type, func: assert(false); case instruction: uint pos = live.linearIndicies.instr(userIndex); IrIndex reg = live.getRegFor(vregIndex, pos); foreach (ref IrIndex arg; lir.getInstr(userIndex).args(lir)) if (arg == vregIndex) { arg = reg; } break; case phi: IrPhi* phi = lir.getPhi(userIndex); IrIndex[] preds = lir.getBlock(phi.blockIndex).predecessors.data(lir); foreach (size_t i, ref IrIndex phiArg; phi.args(lir)) if (phiArg == vregIndex) { IrIndex lastInstr = lir.getBlock(preds[i]).lastInstr; uint pos = live.linearIndicies.instr(lastInstr); IrIndex reg = live.getRegFor(vregIndex, pos); //writefln("set %s arg reg %s -> %s at %s", userIndex, phiArg, reg, pos); phiArg = reg; } break; case variable: assert(false); } } } } void fixInstructionResults(FunctionDeclNode* fun) { // fix definitions // args are already fixed foreach (IrIndex vregIndex, ref IrVirtualRegister vreg; lir.virtualRegisters) { switch(vreg.definition.kind) with(IrValueKind) { case instruction: uint pos = live.linearIndicies.instr(vreg.definition); IrIndex resultReg = live.getRegFor(vregIndex, pos); IrIndex instrIndex = vreg.definition; IrInstrHeader* instrHeader = lir.getInstr(instrIndex); instrHeader.result(lir) = resultReg; InstrInfo instrInfo = context.machineInfo.instrInfo[instrHeader.op]; // requires two operant form if (instrInfo.isResultInDst) { fixTwoOperandForm(instrInfo, instrIndex, instrHeader); } // optimization that can be safely disabled else { if (instrInfo.isMov) { IrIndex src = instrHeader.arg(lir, 0); if (resultReg == src) { // redundant mov //writefln("%s mov %s", resultReg, src); lir.removeInstruction(instrIndex); } } } break; case phi: IrPhi* irPhi = lir.getPhi(vreg.definition); uint pos = live.linearIndicies.basicBlock(irPhi.blockIndex); IrIndex reg = live.getRegFor(vregIndex, pos); irPhi.result = reg; break; default: assert(false); } } } void fixTwoOperandForm(InstrInfo instrInfo, IrIndex instrIndex, IrInstrHeader* instrHeader) { void makeMov(IrIndex to, IrIndex from) { IrArgSize sizeFrom; switch(from.kind) with(IrValueKind) { case stackSlot, global, func, constant, constantZero: sizeFrom = IrArgSize.size64; // use regular mov break; case physicalRegister: sizeFrom = cast(IrArgSize)from.physRegSize; // movzx for 8/16bit regs break; default: context.internal_error("fixTwoOperandForm %s", from); } IrIndex instr; ExtraInstrArgs extra = {addUsers : false, result : to}; // zero extend 8 and 16 bit args to 32bit final switch(sizeFrom) with(IrArgSize) { case size8: instr = builder.emitInstr!(Amd64Opcode.movzx_btod)(extra, from).instruction; break; case size16: instr = builder.emitInstr!(Amd64Opcode.movzx_wtod)(extra, from).instruction; break; case size32, size64: instr = builder.emitInstr!(Amd64Opcode.mov)(extra, from).instruction; break; } builder.insertBeforeInstr(instrIndex, instr); } // Insert mov for instructions requiring two-operand form (like x86 xor) if (instrHeader.numArgs == 2) { // Rewrite // input: r1 = r2 op r3 // as // output: r1 = r2 // output: r1 = r1 op r3 // // if r2 != r3 // { // if r1 == r2 { // input: r1 = r1 op r3 // output: r1 = r1 op r3 // } else if r1 == r3 { // input: "r1 = r2 op r1" // if (op.isCommutative) { // input: "r1 = r3 op r2" // output: "r1 = r1 op r2" // } else { // input: "r1 = r2 op r1" // // error, we cannot swap r2 with r1 here to get r2 = r1 op r2 // // because r2 may be used later // // this case is handled inside liveness analysis pass // } // } else { // input: "r1 = r2 op r3" // output: "mov r1 r2" // output: "r1 = op r1 r3" // } // } // else // input: "r1 = op r2 r2" // { // output: "mov r1 r2" if r1 != r2 // output: "r1 = op r1 r1" // } IrIndex r1 = instrHeader.result(lir); IrIndex r2 = instrHeader.arg(lir, 0); IrIndex r3 = instrHeader.arg(lir, 1); if ( !sameIndexOrPhysReg(r2, r3) ) // r2 != r3 { if ( sameIndexOrPhysReg(r1, r2) ) // r1 == r2 { // "r1 = op r1 r3", noop } else if ( sameIndexOrPhysReg(r1, r3) ) // r1 = op r2 r1 { if (instrInfo.isCommutative) // r1 = op r1 r2 { instrHeader.arg(lir, 0) = r1; instrHeader.arg(lir, 1) = r2; } else { //InstrInfo instrInfo2 = context.machineInfo.instrInfo[instrHeader.op]; writefln("%s %s %s %s %s", cast(Amd64Opcode)instrHeader.op, r1, r2, r3, instrInfo.isCommutative); context.internal_error("Unhandled non-commutative instruction in RA, %s %s", context.idString(fun.backendData.name), instrIndex); } } else // r1 = op r2 r3; all different { // mov r1 r2 makeMov(r1, r2); // r1 = op r1 r3 instrHeader.arg(lir, 0) = r1; } } else // r2 == r3 { if ( !sameIndexOrPhysReg(r1, r2) ) { // mov r1 r2 makeMov(r1, r2); } // r1 = op r1 r1 instrHeader.arg(lir, 0) = r1; } // validation context.assertf(sameIndexOrPhysReg(instrHeader.result(lir), instrHeader.arg(lir, 0)), "two-operand form not ensured res(%s) != arg0(%s)", IrIndexDump(instrHeader.result(lir), context, lir), IrIndexDump(instrHeader.arg(lir, 0), context, lir)); } else if (instrHeader.numArgs == 1) { // Rewrite // input: r1 = op r2 // as // output: r1 = r2 // output: r1 = op r1 // IrIndex r1 = instrHeader.result(lir); IrIndex r2 = instrHeader.arg(lir, 0); if ( !sameIndexOrPhysReg(r1, r2) ) { makeMov(r1, r2); } instrHeader.arg(lir, 0) = r1; } } /* // Resolve for each control flow edge from predecessor to successor do for each interval it live at begin of successor do if it starts at begin of successor then phi = phi function defining it opd = phi.inputOf(predecessor) if opd is a constant then moveFrom = opd else moveFrom = location of intervals[opd] at end of predecessor else moveFrom = location of it at end of predecessor moveTo = location of it at begin of successor if moveFrom ≠ moveTo then mapping.add(moveFrom, moveTo) mapping.orderAndInsertMoves() */ // Insert moves between sub-intervals on control flow edges where different sub-intervals meet void resolveControlFlow(ref MoveSolver moveSolver) { version(RAPrint_resolve) writefln("resolve"); foreach (IrIndex succIndex, ref IrBasicBlock succBlock; lir.blocks) { foreach (IrIndex predIndex; succBlock.predecessors.range(lir)) { IrBasicBlock* predBlock = lir.getBlock(predIndex); resolveEdge(moveSolver, predIndex, *predBlock, succIndex, succBlock); } } } IrArgSize getMoveArgSize(IrIndex value) { if (value.isPhysReg) return cast(IrArgSize)value.physRegSize; IrIndex type = getValueType(value, lir, context); if (value.isStackSlot) type = context.types.getPointerBaseType(type); return sizeToIrArgSize(context.types.typeSize(type), context); } void resolveEdge( ref MoveSolver moveSolver, IrIndex predIndex, ref IrBasicBlock predBlock, IrIndex succIndex, ref IrBasicBlock succBlock) { // those are already handled at split site // we have no linearIndicies for new blocks if (predBlock.replacesCriticalEdge || succBlock.replacesCriticalEdge) return; uint succPos = live.linearIndicies.basicBlock(succIndex); uint predPos = live.linearIndicies.instr(predBlock.lastInstr); moveSolver.reset(); size_t[] succLiveIn = live.bitmap.blockLiveInBuckets(succIndex); // version(RAPrint_resolve) writefln(" edge %s -> %s", predIndex, succIndex); foreach(size_t index; succLiveIn.bitsSet) { LiveInterval* interval = live.vint(index); // always returns first part of split intervals if (!interval.isSplit) continue; // skip intervals that weren't split IrIndex vreg = interval.definition; version(RAPrint_resolve) writefln(" %s %s -> %s", vreg, succPos, predPos); IrIndex succLoc = live.getRegFor(vreg, succPos); IrIndex predLoc = live.getRegFor(vreg, predPos); if (!predLoc.isDefined) continue; // inteval doesn't exist in pred if (succLoc != predLoc) { IrArgSize argSize = getMoveArgSize(vreg); version(RAPrint_resolve) writefln(" vreg %s, pred %s succ %s size %s", vreg, IrIndexDump(predLoc, context, lir), IrIndexDump(succLoc, context, lir), argSize); moveSolver.addMove(predLoc, succLoc, argSize); } } foreach (IrIndex phiIndex, ref IrPhi phi; succBlock.phis(lir)) { version(RAPrint_resolve) writef(" phi %s res %s", phiIndex, IrIndexDump(phi.result, context, lir)); IrIndex[] preds = lir.getBlock(phi.blockIndex).predecessors.data(lir); foreach (size_t arg_i, ref IrIndex arg; phi.args(lir)) { IrIndex argBlock = preds[arg_i]; if (argBlock == predIndex) { IrIndex moveFrom = arg; IrIndex moveTo = phi.result; IrArgSize argSize = getMoveArgSize(phi.result); version(RAPrint_resolve) writefln(" arg %s %s size %s", argBlock, IrIndexDump(arg, context, lir), argSize); moveSolver.addMove(moveFrom, moveTo, argSize); } } } if (moveSolver.numWrittenNodes == 0) return; if (isCriticalEdge(predBlock, succBlock)) { IrIndex movesTarget = splitCriticalEdge(predIndex, predBlock, succIndex, succBlock); // add to the back moveSolver.placeMovesBeforeInstr(builder, lir.getBlock(movesTarget).lastInstr, &getScratchSpillSlot); } else if (predBlock.successors.length > 1) { IrIndex movesTarget = succIndex; // add to the front moveSolver.placeMovesBeforeInstr(builder, lir.getBlock(movesTarget).firstInstr, &getScratchSpillSlot); } else { context.assertf(predBlock.successors.length == 1, "predBlock.successors.length %s", predBlock.successors.length); IrIndex movesTarget = predIndex; // add to the back moveSolver.placeMovesBeforeInstr(builder, lir.getBlock(movesTarget).lastInstr, &getScratchSpillSlot); } } /// Critical edge is edge between predecessor and successor /// where predecessor has more that 1 successor and /// successor has more than 1 predecessor /// Splitting of this edge is done by inserting new basic block on the edge /// This new block is then returned /// successor list of predecessor is updated as well as predecessor list of successor /// Phi functions are not updated IrIndex splitCriticalEdge( IrIndex predIndex, ref IrBasicBlock predBlock, IrIndex succIndex, ref IrBasicBlock succBlock) { // place block right after precessor to get better codegen // TODO: may need to invert branch conditions for that IrIndex newBlock = builder.appendBasicBlockSlot; moveBlockAfter(lir, newBlock, predIndex); version(RAPrint_resolve) writefln("Split critical edge %s -> %s with %s", predIndex, succIndex, newBlock); predBlock.successors.replaceFirst(lir, succIndex, newBlock); succBlock.predecessors.replaceFirst(lir, predIndex, newBlock); lir.getBlock(newBlock).predecessors.append(builder, predIndex); lir.getBlock(newBlock).successors.append(builder, succIndex); lir.getBlock(newBlock).isSealed = true; builder.emitInstr!(Amd64Opcode.jmp)(newBlock); lir.getBlock(newBlock).isFinished = true; lir.getBlock(newBlock).replacesCriticalEdge = true; return newBlock; } // Insert moves between sub-intervals in the middle of basic blocks void resolveInsertSplitMoves(ref MoveSolver moveSolver) { moveSolver.reset(); uint prevPos = 0; version(RAPrint_resolve) writefln("Fix splits"); void insertPrevMoves() { if (prevPos == 0) return; if (moveSolver.numWrittenNodes == 0) return; IrIndex insertBeforeInstr = live.evenIndexToIrIndex[prevPos/2]; context.assertf(insertBeforeInstr.isInstruction, "%s %s", prevPos, insertBeforeInstr); version(RAPrint_resolve) writefln(" insert %s moves before %s at %s", moveSolver.numWrittenNodes, insertBeforeInstr, prevPos); moveSolver.placeMovesBeforeInstr(builder, insertBeforeInstr, &getScratchSpillSlot); moveSolver.reset(); } //IrIndex movesTarget = predIndex; foreach (IntervalIndex id; pendingMoveSplits) { LiveInterval* it = &live.intervals[id]; // always returns first part of split intervals uint splitPos = it.from+1; assert((splitPos & 1) == 0, "Must be even pos"); // insert all moves on prev position if (prevPos != splitPos) insertPrevMoves; LiveInterval* parentIt = &live.intervals[it.parent]; version(RAPrint_resolve) writefln(" %s:%s split at %s, parent %s at %s", id, it.definition, it.from, it.parent, parentIt.to); context.assertf(prevPos <= splitPos, "Wrong order %s < %s", prevPos, splitPos); IrIndex moveFrom = parentIt.reg; IrIndex moveTo = it.reg; version(RAPrint_resolve) writefln(" from %s to %s", IrIndexDump(moveFrom, context, lir), IrIndexDump(moveTo, context, lir)); if (moveFrom != moveTo) { IrIndex vreg = it.definition; IrArgSize argSize = getMoveArgSize(vreg); moveSolver.addMove(moveFrom, moveTo, argSize); prevPos = splitPos; } } insertPrevMoves; } void genSaveCalleeSavedRegs(ref StackLayout stackLayout) { IrIndex entryBlock = lir.entryBasicBlock; IrIndex exitBlock = lir.exitBasicBlock; foreach(reg; physRegs.gpr) { if (reg.isCalleeSaved && reg.isUsed) { IrIndex slot = stackLayout.addStackItem(context, makeBasicTypeIndex(IrValueType.i64), StackSlotKind.local, 0); // save register ExtraInstrArgs extra1 = { argSize : IrArgSize.size64 }; IrIndex instrStore = builder.emitInstr!(Amd64Opcode.store)(extra1, slot, reg.index); builder.prependBlockInstr(entryBlock, instrStore); // restore register ExtraInstrArgs extra = { result : reg.index, argSize : IrArgSize.size64 }; InstrWithResult instrLoad = builder.emitInstr!(Amd64Opcode.load)(extra, slot); builder.insertBeforeLastInstr(exitBlock, instrLoad.instruction); } } } IrIndex getScratchSpillSlot() { if (scratchSpillSlot.isUndefined) { scratchSpillSlot = fun.backendData.stackLayout.addStackItem(context, makeBasicTypeIndex(IrValueType.i64), StackSlotKind.local, 0); } return scratchSpillSlot; } } struct IntervalPriority { uint from; IntervalIndex interval; } // Tweaked to prefer sequential inserts struct IntervalPriorityQueue { Array!IntervalPriority queue; uint maxFrom = 0; uint numRemoved = 0; void clear() { queue.clear; maxFrom = 0; numRemoved = 0; } void free(ref ArrayArena arrayArena) { queue.free(arrayArena); } void insert(ref ArrayArena arrayArena, IntervalIndex interval, uint from) { if (from >= maxFrom) { // fast path for append (happens most of the time) queue.put(arrayArena, IntervalPriority(from, interval)); maxFrom = from; } else { for(size_t i = numRemoved; i < queue.length; ++i) { if (queue[i].from > from) { // insert before i if (numRemoved > 0) { // shift to the left using one of removed slots for(size_t j = numRemoved; j < i; ++j) queue[j-1] = queue[j]; --numRemoved; queue[i-1] = IntervalPriority(from, interval); } else { // shift to the right queue.putAt(arrayArena, i, IntervalPriority(from, interval)); } break; } } } } IntervalIndex removeFront() { auto res = queue[numRemoved].interval; ++numRemoved; return res; } bool empty() { return numRemoved == queue.length; } uint length() { return queue.length - numRemoved; } }
D
module libos.console; private import user.syscall; import user.console; import libos.ramfs; struct Console { static: // The default color. const ubyte DEFAULTCOLORS = Color.LightGray; // The width of a tab const auto TABSTOP = 4; void initialize() { video = RamFS.open("/devices/video", 0); videoBuffer = video.ptr; // Get video info videoInfo = cast(MetaData*)videoBuffer; // Go to actual video buffer videoBuffer += videoInfo.videoBufferOffset; } void putChar(char c) { if (c == '\t') { videoInfo.xpos += TABSTOP; } else if (c != '\n' && c != '\r') { ubyte* ptr = cast(ubyte*)videoBuffer; ptr += (videoInfo.xpos + (videoInfo.ypos * videoInfo.width)) * 2; // Set the current piece of video memory to the character *(ptr) = c & 0xff; *(ptr + 1) = videoInfo.colorAttribute; // Increment videoInfo.xpos++; } // check for end of line, or newline if (c == '\n' || c == '\r' || videoInfo.xpos >= videoInfo.width) { videoInfo.xpos = 0; videoInfo.ypos++; while (videoInfo.ypos >= videoInfo.height) { scroll(1); } } } void putString(char[] string) { foreach(c; string) { putChar(c); } } void getPosition(out uint x, out uint y) { x = videoInfo.xpos; y = videoInfo.ypos; } void setPosition(uint x, uint y) { videoInfo.xpos = x; videoInfo.ypos = y; if (videoInfo.xpos >= videoInfo.width) { videoInfo.xpos = videoInfo.width - 1; } if (videoInfo.ypos >= videoInfo.height) { videoInfo.ypos = videoInfo.height - 1; } } void clear() { ubyte* ptr = cast(ubyte*)videoBuffer; for (int i; i < videoInfo.width * videoInfo.height * 2; i += 2) { *(ptr + i) = 0x00; *(ptr + i + 1) = videoInfo.colorAttribute; } videoInfo.xpos = 0; videoInfo.ypos = 0; } void scroll(uint numLines) { ubyte* ptr = cast(ubyte*)videoBuffer; if (numLines >= videoInfo.height) { clear(); return; } int cury = 0; int offset1 = 0; int offset2 = numLines * videoInfo.width; // Go through and shift the correct amount for ( ; cury <= videoInfo.height - numLines; cury++) { for (int curx = 0; curx < videoInfo.width; curx++) { *(ptr + (curx + offset1) * 2) = *(ptr + (curx + offset1 + offset2) * 2); *(ptr + (curx + offset1) * 2 + 1) = *(ptr + (curx + offset1 + offset2) * 2 + 1); } offset1 += videoInfo.width; } // clear remaining lines for ( ; cury <= videoInfo.height; cury++) { for (int curx = 0; curx < videoInfo.width; curx++) { *(ptr + (curx + offset1) * 2) = 0x00; *(ptr + (curx + offset1) * 2 + 1) = 0x00; } } videoInfo.ypos -= numLines; if (videoInfo.ypos < 0) { videoInfo.ypos = 0; } } void resetColor() { videoInfo.colorAttribute = DEFAULTCOLORS; } void forecolor(Color clr) { videoInfo.colorAttribute = (videoInfo.colorAttribute & 0xf0) | clr; } Color forecolor() { ubyte clr = videoInfo.colorAttribute & 0xf; return cast(Color)clr; } void backcolor(Color clr) { videoInfo.colorAttribute = (videoInfo.colorAttribute & 0x0f) | (clr << 4); } Color backcolor() { ubyte clr = videoInfo.colorAttribute & 0xf0; clr >>= 4; return cast(Color)clr; } uint width() { return videoInfo.width; } uint height() { return videoInfo.height; } private: MetaData* videoInfo; Gib video; ubyte* videoBuffer; }
D
import unit_threaded; //these must all be imported in order to be used as a symbol import tests.pass.normal; import tests.pass.delayed; import tests.pass.attributes; import tests.pass.io; import tests.pass.mock; int main(string[] args) { return args.runTests!( tests.pass.normal, tests.pass.delayed, tests.pass.attributes, tests.pass.io, tests.pass.property, tests.pass.mock, ); }
D
module std.string; pragma(lib, "DinrusStd.lib"); private import stdrus; const char[16] hexdigits = "0123456789ABCDEF"; /// 0..9A..F const char[10] digits = "0123456789"; /// 0..9 const char[8] octdigits = "01234567"; /// 0..7 const char[92] lowercase = "abcdefghijklmnopqrstuvwxyzабвгдеёжзийклмнопрстуфхцчшщъыьэюя"; /// a..z а..я const char[92] uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; /// A..Z А..Я const char[184] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"; /// A..Za..z const char[6] whitespace = " \t\v\r\n\f"; /// ASCII whitespace const dchar LS = '\u2028'; /// UTF line separator const dchar PS = '\u2029'; /// UTF paragraph separator /// Newline sequence for this system version (Windows) const char[2] newline = "\r\n"; else version (Posix) const char[1] newline = "\n"; alias stdrus.пробел_ли iswhite; alias stdrus.ткствцел atoi; alias stdrus.ткствдробь atof; alias stdrus.сравни cmp; alias stdrus.сравнлюб icmp; alias stdrus.вТкст0 toStringz; alias stdrus.найди find; alias stdrus.найдлюб ifind; alias stdrus.найдрек rfind; alias stdrus.найдлюбрек irfind; alias stdrus.впроп tolower; alias stdrus.взаг toupper; alias stdrus.озаг capitalize; alias stdrus.озагслова capwords; alias stdrus.повтори repeat; alias stdrus.объедини join; alias stdrus.разбей split; alias stdrus.разбейдоп split; alias stdrus.разбейнастр splitlines; alias stdrus.уберислева stripl; alias stdrus.уберисправа stripr; alias stdrus.убери strip; alias stdrus.убериразгр chomp; alias stdrus.уберигран chop; alias stdrus.полев ljustify; alias stdrus.поправ rjustify; alias stdrus.вцентр center; alias stdrus.занули zfill; alias stdrus.замени replace; alias stdrus.заменисрез replaceSlice; alias stdrus.вставь insert; alias stdrus.счесть count; alias stdrus.заменитабнапбел expandtabs; alias stdrus.заменипбелнатаб entab; alias stdrus.постройтранстаб maketrans; alias stdrus.транслируй translate; alias stdrus.посчитайсимв countchars; alias stdrus.удалисимв removechars; alias stdrus.сквиз squeeze; alias stdrus.следщ succ; alias stdrus.тз tr; alias stdrus.чис_ли isNumeric; alias stdrus.колном column; alias stdrus.параграф wrap; alias stdrus.эладр_ли isEmail; alias stdrus.урл_ли isURL; alias stdrus.целВЮ8 intToUtf8; alias stdrus.бдолВЮ8 ulongToUtf8; alias stdrus.фм format; /+ struct Ткст { } +/ /+ public import std.uni : icmp, toLower, toLowerInPlace, toUpper, toUpperInPlace; public import std.format : format, sformat; import std.typecons : Flag; import std.range.primitives; import std.traits; import std.typetuple; //public imports for backward compatibility public import std.algorithm : startsWith, endsWith, cmp, count; public import std.array : join, replace, replaceInPlace, split; /* ************* Exceptions *************** */ /++ Exception thrown on errors in std.string functions. +/ class ТкстИск : Exception { /++ Params: msg = The message for the exception. file = The file where the exception occurred. line = The line number where the exception occurred. next = The previous exception in the chain of exceptions, if any. +/ this(string msg, string file = __FILE__, size_t line = __LINE__, Exception next = null) { super(msg, file, line, next); } } /++ Params: cString = A null-terminated c-style string. Returns: A D-style array of $(D char) referencing the same string. The returned array will retain the same type qualifiers as the input. $(RED Important Note:) The returned array is a slice of the original buffer. The original data is not changed and not copied. +/ inout(char)[] fromStringz(inout(char)* cString) @nogc @system pure nothrow { import core.stdc.string : strlen; return cString ? cString[0 .. strlen(cString)] : null; } /// @system pure unittest { assert(fromStringz(null) == null); assert(fromStringz("foo") == "foo"); } /++ Params: s = A D-style string. Returns: A C-style null-terminated string equivalent to $(D s). $(D s) must not contain embedded $(D '\0')'s as any C function will treat the first $(D '\0') that it sees as the end of the string. If $(D s.empty) is $(D true), then a string containing only $(D '\0') is returned. $(RED Important Note:) When passing a $(D char*) to a C function, and the C function keeps it around for any reason, make sure that you keep a reference to it in your D code. Otherwise, it may become invalid during a garbage collection cycle and cause a nasty bug when the C code tries to use it. +/ immutable(char)* toStringz(const(char)[] s) @trusted pure nothrow in { // The assert below contradicts the unittests! //assert(memchr(s.ptr, 0, s.length) == null, //text(s.length, ": `", s, "'")); } out (result) { import core.stdc.string : strlen, memcmp; if (result) { auto slen = s.length; while (slen > 0 && s[slen-1] == 0) --slen; assert(strlen(result) == slen); assert(memcmp(result, s.ptr, slen) == 0); } } body { import std.exception : assumeUnique; /+ Unfortunately, this isn't reliable. We could make this work if string literals are put in read-only memory and we test if s[] is pointing into that. /* Peek past end of s[], if it's 0, no conversion necessary. * Note that the compiler will put a 0 past the end of static * strings, and the storage allocator will put a 0 past the end * of newly allocated char[]'s. */ char* p = &s[0] + s.length; if (*p == 0) return s; +/ // Need to make a copy auto copy = new char[s.length + 1]; copy[0..s.length] = s[]; copy[s.length] = 0; return assumeUnique(copy).ptr; } /++ Ditto +/ immutable(char)* toStringz(in string s) @trusted pure nothrow { if (s.empty) return "".ptr; /* Peek past end of s[], if it's 0, no conversion necessary. * Note that the compiler will put a 0 past the end of static * strings, and the storage allocator will put a 0 past the end * of newly allocated char[]'s. */ immutable p = s.ptr + s.length; // Is p dereferenceable? A simple test: if the p points to an // address multiple of 4, then conservatively assume the pointer // might be pointing to a new block of memory, which might be // unreadable. Otherwise, it's definitely pointing to valid // memory. if ((cast(size_t) p & 3) && *p == 0) return s.ptr; return toStringz(cast(const char[]) s); } pure nothrow unittest { import core.stdc.string : strlen; import std.conv : to; debug(string) эхо("string.toStringz.unittest\n"); // TODO: CTFEable toStringz is really necessary? //assertCTFEable!( //{ auto p = toStringz("foo"); assert(strlen(p) == 3); const(char)[] foo = "abbzxyzzy"; p = toStringz(foo[3..5]); assert(strlen(p) == 2); string test = ""; p = toStringz(test); assert(*p == 0); test = "\0"; p = toStringz(test); assert(*p == 0); test = "foo\0"; p = toStringz(test); assert(p[0] == 'f' && p[1] == 'o' && p[2] == 'o' && p[3] == 0); const string test2 = ""; p = toStringz(test2); assert(*p == 0); //}); } /** Flag indicating whether a search is case-sensitive. */ alias CaseSensitive = Flag!"caseSensitive"; /++ Searches for character in range. Params: s = string or InputRange of characters to search in correct UTF format c = character to search for cs = CaseSensitive.yes or CaseSensitive.no Returns: the index of the first occurrence of $(D c) in $(D s). If $(D c) is not found, then $(D -1) is returned. If the parameters are not valid UTF, the result will still be in the range [-1 .. s.length], but will not be reliable otherwise. +/ ptrdiff_t indexOf(Range)(Range s, in dchar c, in CaseSensitive cs = CaseSensitive.yes) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { import std.ascii : toLower, isASCII; import std.uni : toLower; import std.utf : byDchar, byCodeUnit, UTFException, codeLength; alias Char = Unqual!(ElementEncodingType!Range); if (cs == CaseSensitive.yes) { static if (Char.sizeof == 1 && isSomeString!Range) { import core.stdc.string : memchr; if (std.ascii.isASCII(c) && !__ctfe) { // Plain old ASCII auto trustedmemchr() @trusted { return cast(Char*)memchr(s.ptr, c, s.length); } const p = trustedmemchr(); if (p) return p - s.ptr; else return -1; } } static if (Char.sizeof == 1) { if (c <= 0x7F) { ptrdiff_t i; foreach (const c2; s) { if (c == c2) return i; ++i; } } else { ptrdiff_t i; foreach (const c2; s.byDchar()) { if (c == c2) return i; i += codeLength!Char(c2); } } } else static if (Char.sizeof == 2) { if (c <= 0xFFFF) { ptrdiff_t i; foreach (const c2; s) { if (c == c2) return i; ++i; } } else if (c <= 0x10FFFF) { // Encode UTF-16 surrogate pair const wchar c1 = cast(wchar)((((c - 0x10000) >> 10) & 0x3FF) + 0xD800); const wchar c2 = cast(wchar)(((c - 0x10000) & 0x3FF) + 0xDC00); ptrdiff_t i; for (auto r = s.byCodeUnit(); !r.empty; r.popFront()) { if (c1 == r.front) { r.popFront(); if (r.empty) // invalid UTF - missing second of pair break; if (c2 == r.front) return i; ++i; } ++i; } } } else static if (Char.sizeof == 4) { ptrdiff_t i; foreach (const c2; s) { if (c == c2) return i; ++i; } } else static assert(0); return -1; } else { if (std.ascii.isASCII(c)) { // Plain old ASCII auto c1 = cast(char) std.ascii.toLower(c); ptrdiff_t i; foreach (const c2; s.byCodeUnit()) { if (c1 == std.ascii.toLower(c2)) return i; ++i; } } else { // c is a universal character auto c1 = std.uni.toLower(c); ptrdiff_t i; foreach (const c2; s.byDchar()) { if (c1 == std.uni.toLower(c2)) return i; i += codeLength!Char(c2); } } } return -1; } ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in CaseSensitive cs = CaseSensitive.yes) if (isConvertibleToString!Range) { return indexOf!(StringTypeOf!Range)(s, c, cs); } unittest { assert(testAliasedString!indexOf("std/string.d", '/')); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOf.unittest\n"); import std.exception; import std.utf : byChar, byWchar, byDchar; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { assert(indexOf(cast(S)null, cast(dchar)'a') == -1); assert(indexOf(to!S("def"), cast(dchar)'a') == -1); assert(indexOf(to!S("abba"), cast(dchar)'a') == 0); assert(indexOf(to!S("def"), cast(dchar)'f') == 2); assert(indexOf(to!S("def"), cast(dchar)'a', CaseSensitive.no) == -1); assert(indexOf(to!S("def"), cast(dchar)'a', CaseSensitive.no) == -1); assert(indexOf(to!S("Abba"), cast(dchar)'a', CaseSensitive.no) == 0); assert(indexOf(to!S("def"), cast(dchar)'F', CaseSensitive.no) == 2); assert(indexOf(to!S("ödef"), 'ö', CaseSensitive.no) == 0); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; assert(indexOf("def", cast(char)'f', CaseSensitive.no) == 2); assert(indexOf(sPlts, cast(char)'P', CaseSensitive.no) == 23); assert(indexOf(sPlts, cast(char)'R', CaseSensitive.no) == 2); } foreach (cs; EnumMembers!CaseSensitive) { assert(indexOf("hello\U00010143\u0100\U00010143", '\u0100', cs) == 9); assert(indexOf("hello\U00010143\u0100\U00010143"w, '\u0100', cs) == 7); assert(indexOf("hello\U00010143\u0100\U00010143"d, '\u0100', cs) == 6); assert(indexOf("hello\U00010143\u0100\U00010143".byChar, '\u0100', cs) == 9); assert(indexOf("hello\U00010143\u0100\U00010143".byWchar, '\u0100', cs) == 7); assert(indexOf("hello\U00010143\u0100\U00010143".byDchar, '\u0100', cs) == 6); assert(indexOf("hello\U000007FF\u0100\U00010143".byChar, 'l', cs) == 2); assert(indexOf("hello\U000007FF\u0100\U00010143".byChar, '\u0100', cs) == 7); assert(indexOf("hello\U0000EFFF\u0100\U00010143".byChar, '\u0100', cs) == 8); assert(indexOf("hello\U00010100".byWchar, '\U00010100', cs) == 5); assert(indexOf("hello\U00010100".byWchar, '\U00010101', cs) == -1); } char[10] fixedSizeArray = "0123456789"; assert(indexOf(fixedSizeArray, '2') == 2); }); } /++ Searches for character in range starting at index startIdx. Params: s = string or InputRange of characters to search in correct UTF format c = character to search for startIdx = starting index to a well-formed code point cs = CaseSensitive.yes or CaseSensitive.no Returns: the index of the first occurrence of $(D c) in $(D s). If $(D c) is not found, then $(D -1) is returned. If the parameters are not valid UTF, the result will still be in the range [-1 .. s.length], but will not be reliable otherwise. +/ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { static if (isSomeString!(typeof(s)) || (hasSlicing!(typeof(s)) && hasLength!(typeof(s)))) { if (startIdx < s.length) { ptrdiff_t foundIdx = indexOf(s[startIdx .. $], c, cs); if (foundIdx != -1) { return foundIdx + cast(ptrdiff_t)startIdx; } } } else { foreach (i; 0 .. startIdx) { if (s.empty) return -1; s.popFront(); } ptrdiff_t foundIdx = indexOf(s, c, cs); if (foundIdx != -1) { return foundIdx + cast(ptrdiff_t)startIdx; } } return -1; } ptrdiff_t indexOf(Range)(auto ref Range s, in dchar c, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) if (isConvertibleToString!Range) { return indexOf!(StringTypeOf!Range)(s, c, startIdx, cs); } unittest { assert(testAliasedString!indexOf("std/string.d", '/', 3)); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOf(startIdx).unittest\n"); import std.utf : byCodeUnit, byChar, byWchar; assert("hello".byCodeUnit.indexOf(cast(dchar)'l', 1) == 2); assert("hello".byWchar.indexOf(cast(dchar)'l', 1) == 2); assert("hello".byWchar.indexOf(cast(dchar)'l', 6) == -1); foreach (S; TypeTuple!(string, wstring, dstring)) { assert(indexOf(cast(S)null, cast(dchar)'a', 1) == -1); assert(indexOf(to!S("def"), cast(dchar)'a', 1) == -1); assert(indexOf(to!S("abba"), cast(dchar)'a', 1) == 3); assert(indexOf(to!S("def"), cast(dchar)'f', 1) == 2); assert((to!S("def")).indexOf(cast(dchar)'a', 1, CaseSensitive.no) == -1); assert(indexOf(to!S("def"), cast(dchar)'a', 1, CaseSensitive.no) == -1); assert(indexOf(to!S("def"), cast(dchar)'a', 12, CaseSensitive.no) == -1); assert(indexOf(to!S("AbbA"), cast(dchar)'a', 2, CaseSensitive.no) == 3); assert(indexOf(to!S("def"), cast(dchar)'F', 2, CaseSensitive.no) == 2); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; assert(indexOf("def", cast(char)'f', cast(uint)2, CaseSensitive.no) == 2); assert(indexOf(sPlts, cast(char)'P', 12, CaseSensitive.no) == 23); assert(indexOf(sPlts, cast(char)'R', cast(ulong)1, CaseSensitive.no) == 2); } foreach(cs; EnumMembers!CaseSensitive) { assert(indexOf("hello\U00010143\u0100\U00010143", '\u0100', 2, cs) == 9); assert(indexOf("hello\U00010143\u0100\U00010143"w, '\u0100', 3, cs) == 7); assert(indexOf("hello\U00010143\u0100\U00010143"d, '\u0100', 6, cs) == 6); } } /++ Searches for substring in $(D s). Params: s = string or ForwardRange of characters to search in correct UTF format sub = substring to search for cs = CaseSensitive.yes or CaseSensitive.no Returns: the index of the first occurrence of $(D sub) in $(D s). If $(D sub) is not found, then $(D -1) is returned. If the arguments are not valid UTF, the result will still be in the range [-1 .. s.length], but will not be reliable otherwise. Bugs: Does not work with case insensitive strings where the mapping of tolower and toupper is not 1:1. +/ ptrdiff_t indexOf(Range, Char)(Range s, const(Char)[] sub, in CaseSensitive cs = CaseSensitive.yes) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && isSomeChar!Char) { import std.uni : toLower; alias Char1 = Unqual!(ElementEncodingType!Range); static if (isSomeString!Range) { import std.algorithm : find; const(Char1)[] balance; if (cs == CaseSensitive.yes) { balance = std.algorithm.find(s, sub); } else { balance = std.algorithm.find! ((a, b) => std.uni.toLower(a) == std.uni.toLower(b)) (s, sub); } return balance.empty ? -1 : balance.ptr - s.ptr; } else { if (s.empty) return -1; if (sub.empty) return 0; // degenerate case import std.utf : byDchar, codeLength; auto subr = sub.byDchar; // decode sub[] by dchar's dchar sub0 = subr.front; // cache first character of sub[] subr.popFront(); // Special case for single character search if (subr.empty) return indexOf(s, sub0, cs); if (cs == CaseSensitive.no) sub0 = toLower(sub0); /* Classic double nested loop search algorithm */ ptrdiff_t index = 0; // count code unit index into s for (auto sbydchar = s.byDchar(); !sbydchar.empty; sbydchar.popFront()) { dchar c2 = sbydchar.front; if (cs == CaseSensitive.no) c2 = toLower(c2); if (c2 == sub0) { auto s2 = sbydchar.save; // why s must be a forward range foreach (c; subr.save) { s2.popFront(); if (s2.empty) return -1; if (cs == CaseSensitive.yes ? c != s2.front : toLower(c) != toLower(s2.front) ) goto Lnext; } return index; } Lnext: index += codeLength!Char1(c2); } return -1; } } ptrdiff_t indexOf(Range, Char)(auto ref Range s, const(Char)[] sub, in CaseSensitive cs = CaseSensitive.yes) if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && isSomeChar!Char) && is(StringTypeOf!Range)) { return indexOf!(StringTypeOf!Range)(s, sub, cs); } unittest { assert(testAliasedString!indexOf("std/string.d", "string")); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOf.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOf(cast(S)null, to!T("a")) == -1); assert(indexOf(to!S("def"), to!T("a")) == -1); assert(indexOf(to!S("abba"), to!T("a")) == 0); assert(indexOf(to!S("def"), to!T("f")) == 2); assert(indexOf(to!S("dfefffg"), to!T("fff")) == 3); assert(indexOf(to!S("dfeffgfff"), to!T("fff")) == 6); assert(indexOf(to!S("dfeffgfff"), to!T("a"), CaseSensitive.no) == -1); assert(indexOf(to!S("def"), to!T("a"), CaseSensitive.no) == -1); assert(indexOf(to!S("abba"), to!T("a"), CaseSensitive.no) == 0); assert(indexOf(to!S("def"), to!T("f"), CaseSensitive.no) == 2); assert(indexOf(to!S("dfefffg"), to!T("fff"), CaseSensitive.no) == 3); assert(indexOf(to!S("dfeffgfff"), to!T("fff"), CaseSensitive.no) == 6); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; S sMars = "Who\'s \'My Favorite Maritian?\'"; assert(indexOf(sMars, to!T("MY fAVe"), CaseSensitive.no) == -1); assert(indexOf(sMars, to!T("mY fAVOriTe"), CaseSensitive.no) == 7); assert(indexOf(sPlts, to!T("mArS:"), CaseSensitive.no) == 0); assert(indexOf(sPlts, to!T("rOcK"), CaseSensitive.no) == 17); assert(indexOf(sPlts, to!T("Un."), CaseSensitive.no) == 41); assert(indexOf(sPlts, to!T(sPlts), CaseSensitive.no) == 0); assert(indexOf("\u0100", to!T("\u0100"), CaseSensitive.no) == 0); // Thanks to Carlos Santander B. and zwang assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y", to!T("page-break-before"), CaseSensitive.no) == -1); }(); foreach (cs; EnumMembers!CaseSensitive) { assert(indexOf("hello\U00010143\u0100\U00010143", to!S("\u0100"), cs) == 9); assert(indexOf("hello\U00010143\u0100\U00010143"w, to!S("\u0100"), cs) == 7); assert(indexOf("hello\U00010143\u0100\U00010143"d, to!S("\u0100"), cs) == 6); } } }); } @safe pure @nogc nothrow unittest { import std.utf : byWchar; foreach (cs; EnumMembers!CaseSensitive) { assert(indexOf("".byWchar, "", cs) == -1); assert(indexOf("hello".byWchar, "", cs) == 0); assert(indexOf("hello".byWchar, "l", cs) == 2); assert(indexOf("heLLo".byWchar, "LL", cs) == 2); assert(indexOf("hello".byWchar, "lox", cs) == -1); assert(indexOf("hello".byWchar, "betty", cs) == -1); assert(indexOf("hello\U00010143\u0100*\U00010143".byWchar, "\u0100*", cs) == 7); } } /++ Params: s = string to search sub = substring to search for startIdx = the index into s to start searching from cs = CaseSensitive.yes or CaseSensitive.no Returns: The index of the first occurrence of $(D sub) in $(D s) with respect to the start index $(D startIdx). If $(D sub) is not found, then $(D -1) is returned. If $(D sub) is found the value of the returned index is at least $(D startIdx). $(D startIdx) represents a codeunit index in $(D s). If the sequence starting at $(D startIdx) does not represent a well formed codepoint, then a $(XREF utf,UTFException) may be thrown. $(D cs) indicates whether the comparisons are case sensitive. +/ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe if (isSomeChar!Char1 && isSomeChar!Char2) { if (startIdx < s.length) { ptrdiff_t foundIdx = indexOf(s[startIdx .. $], sub, cs); if (foundIdx != -1) { return foundIdx + cast(ptrdiff_t)startIdx; } } return -1; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOf(startIdx).unittest\n"); foreach(S; TypeTuple!(string, wstring, dstring)) { foreach(T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOf(cast(S)null, to!T("a"), 1337) == -1); assert(indexOf(to!S("def"), to!T("a"), 0) == -1); assert(indexOf(to!S("abba"), to!T("a"), 2) == 3); assert(indexOf(to!S("def"), to!T("f"), 1) == 2); assert(indexOf(to!S("dfefffg"), to!T("fff"), 1) == 3); assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 5) == 6); assert(indexOf(to!S("dfeffgfff"), to!T("a"), 1, CaseSensitive.no) == -1); assert(indexOf(to!S("def"), to!T("a"), 2, CaseSensitive.no) == -1); assert(indexOf(to!S("abba"), to!T("a"), 3, CaseSensitive.no) == 3); assert(indexOf(to!S("def"), to!T("f"), 1, CaseSensitive.no) == 2); assert(indexOf(to!S("dfefffg"), to!T("fff"), 2, CaseSensitive.no) == 3); assert(indexOf(to!S("dfeffgfff"), to!T("fff"), 4, CaseSensitive.no) == 6); assert(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, CaseSensitive.no) == 9, to!string(indexOf(to!S("dfeffgffföä"), to!T("öä"), 9, CaseSensitive.no)) ~ " " ~ S.stringof ~ " " ~ T.stringof); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; S sMars = "Who\'s \'My Favorite Maritian?\'"; assert(indexOf(sMars, to!T("MY fAVe"), 10, CaseSensitive.no) == -1); assert(indexOf(sMars, to!T("mY fAVOriTe"), 4, CaseSensitive.no) == 7); assert(indexOf(sPlts, to!T("mArS:"), 0, CaseSensitive.no) == 0); assert(indexOf(sPlts, to!T("rOcK"), 12, CaseSensitive.no) == 17); assert(indexOf(sPlts, to!T("Un."), 32, CaseSensitive.no) == 41); assert(indexOf(sPlts, to!T(sPlts), 0, CaseSensitive.no) == 0); assert(indexOf("\u0100", to!T("\u0100"), 0, CaseSensitive.no) == 0); // Thanks to Carlos Santander B. and zwang assert(indexOf("sus mejores cortesanos. Se embarcaron en el puerto de Dubai y", to!T("page-break-before"), 10, CaseSensitive.no) == -1); // In order for indexOf with and without index to be consistent assert(indexOf(to!S(""), to!T("")) == indexOf(to!S(""), to!T(""), 0)); }(); foreach(cs; EnumMembers!CaseSensitive) { assert(indexOf("hello\U00010143\u0100\U00010143", to!S("\u0100"), 3, cs) == 9); assert(indexOf("hello\U00010143\u0100\U00010143"w, to!S("\u0100"), 3, cs) == 7); assert(indexOf("hello\U00010143\u0100\U00010143"d, to!S("\u0100"), 3, cs) == 6); } } } /++ Params: s = string to search c = character to search for cs = CaseSensitive.yes or CaseSensitive.no Returns: The index of the last occurrence of $(D c) in $(D s). If $(D c) is not found, then $(D -1) is returned. $(D cs) indicates whether the comparisons are case sensitive. +/ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char) { import std.ascii : isASCII, toLower; import std.utf : canSearchInCodeUnits; if (cs == CaseSensitive.yes) { if (canSearchInCodeUnits!Char(c)) { foreach_reverse (i, it; s) { if (it == c) { return i; } } } else { foreach_reverse (i, dchar it; s) { if (it == c) { return i; } } } } else { if (std.ascii.isASCII(c)) { immutable c1 = std.ascii.toLower(c); foreach_reverse (i, it; s) { immutable c2 = std.ascii.toLower(it); if (c1 == c2) { return i; } } } else { immutable c1 = std.uni.toLower(c); foreach_reverse (i, dchar it; s) { immutable c2 = std.uni.toLower(it); if (c1 == c2) { return i; } } } } return -1; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOf.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { assert(lastIndexOf(cast(S) null, 'a') == -1); assert(lastIndexOf(to!S("def"), 'a') == -1); assert(lastIndexOf(to!S("abba"), 'a') == 3); assert(lastIndexOf(to!S("def"), 'f') == 2); assert(lastIndexOf(to!S("ödef"), 'ö') == 0); assert(lastIndexOf(cast(S) null, 'a', CaseSensitive.no) == -1); assert(lastIndexOf(to!S("def"), 'a', CaseSensitive.no) == -1); assert(lastIndexOf(to!S("AbbA"), 'a', CaseSensitive.no) == 3); assert(lastIndexOf(to!S("def"), 'F', CaseSensitive.no) == 2); assert(lastIndexOf(to!S("ödef"), 'ö', CaseSensitive.no) == 0); assert(lastIndexOf(to!S("i\u0100def"), to!dchar("\u0100"), CaseSensitive.no) == 1); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; assert(lastIndexOf(to!S("def"), 'f', CaseSensitive.no) == 2); assert(lastIndexOf(sPlts, 'M', CaseSensitive.no) == 34); assert(lastIndexOf(sPlts, 'S', CaseSensitive.no) == 40); } foreach (cs; EnumMembers!CaseSensitive) { assert(lastIndexOf("\U00010143\u0100\U00010143hello", '\u0100', cs) == 4); assert(lastIndexOf("\U00010143\u0100\U00010143hello"w, '\u0100', cs) == 2); assert(lastIndexOf("\U00010143\u0100\U00010143hello"d, '\u0100', cs) == 1); } }); } /++ Params: s = string to search c = character to search for startIdx = the index into s to start searching from cs = CaseSensitive.yes or CaseSensitive.no Returns: The index of the last occurrence of $(D c) in $(D s). If $(D c) is not found, then $(D -1) is returned. The $(D startIdx) slices $(D s) in the following way $(D s[0 .. startIdx]). $(D startIdx) represents a codeunit index in $(D s). If the sequence ending at $(D startIdx) does not represent a well formed codepoint, then a $(XREF utf,UTFException) may be thrown. $(D cs) indicates whether the comparisons are case sensitive. +/ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char) { if (startIdx <= s.length) { return lastIndexOf(s[0u .. startIdx], c, cs); } return -1; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOf.unittest\n"); foreach(S; TypeTuple!(string, wstring, dstring)) { assert(lastIndexOf(cast(S) null, 'a') == -1); assert(lastIndexOf(to!S("def"), 'a') == -1); assert(lastIndexOf(to!S("abba"), 'a', 3) == 0); assert(lastIndexOf(to!S("deff"), 'f', 3) == 2); assert(lastIndexOf(cast(S) null, 'a', CaseSensitive.no) == -1); assert(lastIndexOf(to!S("def"), 'a', CaseSensitive.no) == -1); assert(lastIndexOf(to!S("AbbAa"), 'a', to!ushort(4), CaseSensitive.no) == 3, to!string(lastIndexOf(to!S("AbbAa"), 'a', 4, CaseSensitive.no))); assert(lastIndexOf(to!S("def"), 'F', 3, CaseSensitive.no) == 2); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; assert(lastIndexOf(to!S("def"), 'f', 4, CaseSensitive.no) == -1); assert(lastIndexOf(sPlts, 'M', sPlts.length -2, CaseSensitive.no) == 34); assert(lastIndexOf(sPlts, 'S', sPlts.length -2, CaseSensitive.no) == 40); } foreach(cs; EnumMembers!CaseSensitive) { assert(lastIndexOf("\U00010143\u0100\U00010143hello", '\u0100', cs) == 4); assert(lastIndexOf("\U00010143\u0100\U00010143hello"w, '\u0100', cs) == 2); assert(lastIndexOf("\U00010143\u0100\U00010143hello"d, '\u0100', cs) == 1); } } /++ Params: s = string to search sub = substring to search for cs = CaseSensitive.yes or CaseSensitive.no Returns: the index of the last occurrence of $(D sub) in $(D s). If $(D sub) is not found, then $(D -1) is returned. $(D cs) indicates whether the comparisons are case sensitive. +/ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char1 && isSomeChar!Char2) { import std.utf : strideBack; import std.conv : to; import std.algorithm : endsWith; if (sub.empty) return s.length; if (walkLength(sub) == 1) return lastIndexOf(s, sub.front, cs); if (cs == CaseSensitive.yes) { static if (is(Unqual!Char1 == Unqual!Char2)) { import core.stdc.string : memcmp; immutable c = sub[0]; for (ptrdiff_t i = s.length - sub.length; i >= 0; --i) { if (s[i] == c) { if (__ctfe) { foreach (j; 1 .. sub.length) { if (s[i + j] != sub[j]) continue; } return i; } else { auto trustedMemcmp(in void* s1, in void* s2, size_t n) @trusted { return memcmp(s1, s2, n); } if (trustedMemcmp(&s[i + 1], &sub[1], (sub.length - 1) * Char1.sizeof) == 0) return i; } } } } else { for (size_t i = s.length; !s.empty;) { if (s.endsWith(sub)) return cast(ptrdiff_t)i - to!(const(Char1)[])(sub).length; i -= strideBack(s, i); s = s[0 .. i]; } } } else { for (size_t i = s.length; !s.empty;) { if (endsWith!((a, b) => std.uni.toLower(a) == std.uni.toLower(b)) (s, sub)) { return cast(ptrdiff_t)i - to!(const(Char1)[])(sub).length; } i -= strideBack(s, i); s = s[0 .. i]; } } return -1; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOf.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 enum typeStr = S.stringof ~ " " ~ T.stringof; assert(lastIndexOf(cast(S)null, to!T("a")) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("c")) == 6, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd")) == 6, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("ef")) == 8, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("c")) == 2, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("cd")) == 2, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("x")) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("xy")) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("")) == 10, typeStr); assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö")) == 0, typeStr); assert(lastIndexOf(cast(S)null, to!T("a"), CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), CaseSensitive.no) == 6, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), CaseSensitive.no) == 6, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"), CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("xy"), CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), CaseSensitive.no) == 10, typeStr); assert(lastIndexOf(to!S("öabcdefcdef"), to!T("ö"), CaseSensitive.no) == 0, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), CaseSensitive.no) == 6, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), CaseSensitive.no) == 6, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), CaseSensitive.no) == 7, typeStr); assert(lastIndexOf(to!S("ödfeffgfff"), to!T("ö"), CaseSensitive.yes) == 0); S sPlts = "Mars: the fourth Rock (Planet) from the Sun."; S sMars = "Who\'s \'My Favorite Maritian?\'"; assert(lastIndexOf(sMars, to!T("RiTE maR"), CaseSensitive.no) == 14, typeStr); assert(lastIndexOf(sPlts, to!T("FOuRTh"), CaseSensitive.no) == 10, typeStr); assert(lastIndexOf(sMars, to!T("whO\'s \'MY"), CaseSensitive.no) == 0, typeStr); assert(lastIndexOf(sMars, to!T(sMars), CaseSensitive.no) == 0, typeStr); }(); foreach (cs; EnumMembers!CaseSensitive) { enum csString = to!string(cs); assert(lastIndexOf("\U00010143\u0100\U00010143hello", to!S("\u0100"), cs) == 4, csString); assert(lastIndexOf("\U00010143\u0100\U00010143hello"w, to!S("\u0100"), cs) == 2, csString); assert(lastIndexOf("\U00010143\u0100\U00010143hello"d, to!S("\u0100"), cs) == 1, csString); } } }); } @safe pure unittest // issue13529 { import std.conv : to; foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) { enum typeStr = S.stringof ~ " " ~ T.stringof; auto idx = lastIndexOf(to!T("Hällö Wörldö ö"),to!S("ö ö")); assert(idx != -1, to!string(idx) ~ " " ~ typeStr); idx = lastIndexOf(to!T("Hällö Wörldö ö"),to!S("ö öd")); assert(idx == -1, to!string(idx) ~ " " ~ typeStr); } } } /++ Params: s = string to search sub = substring to search for startIdx = the index into s to start searching from cs = CaseSensitive.yes or CaseSensitive.no Returns: the index of the last occurrence of $(D sub) in $(D s). If $(D sub) is not found, then $(D -1) is returned. The $(D startIdx) slices $(D s) in the following way $(D s[0 .. startIdx]). $(D startIdx) represents a codeunit index in $(D s). If the sequence ending at $(D startIdx) does not represent a well formed codepoint, then a $(XREF utf,UTFException) may be thrown. $(D cs) indicates whether the comparisons are case sensitive. +/ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char1 && isSomeChar!Char2) { if (startIdx <= s.length) { return lastIndexOf(s[0u .. startIdx], sub, cs); } return -1; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOf.unittest\n"); foreach(S; TypeTuple!(string, wstring, dstring)) { foreach(T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 enum typeStr = S.stringof ~ " " ~ T.stringof; assert(lastIndexOf(cast(S)null, to!T("a")) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), 5) == 2, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), 3) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("ef"), 6) == 4, typeStr ~ format(" %u", lastIndexOf(to!S("abcdefcdef"), to!T("ef"), 6))); assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), 5) == 2, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("cd"), 3) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdefx"), to!T("x"), 1) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdefxy"), to!T("xy"), 6) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), 8) == 8, typeStr); assert(lastIndexOf(to!S("öafö"), to!T("ö"), 3) == 0, typeStr ~ to!string(lastIndexOf(to!S("öafö"), to!T("ö"), 3))); //BUG 10472 assert(lastIndexOf(cast(S)null, to!T("a"), 1, CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("c"), 5, CaseSensitive.no) == 2, typeStr); assert(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 4, CaseSensitive.no) == 2, typeStr ~ " " ~ to!string(lastIndexOf(to!S("abcdefCdef"), to!T("cD"), 3, CaseSensitive.no))); assert(lastIndexOf(to!S("abcdefcdef"), to!T("x"),3 , CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdefXY"), to!T("xy"), 4, CaseSensitive.no) == -1, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T(""), 7, CaseSensitive.no) == 7, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("c"), 4, CaseSensitive.no) == 2, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("cd"), 4, CaseSensitive.no) == 2, typeStr); assert(lastIndexOf(to!S("abcdefcdef"), to!T("def"), 6, CaseSensitive.no) == 3, typeStr); assert(lastIndexOf(to!S(""), to!T(""), 0) == lastIndexOf(to!S(""), to!T("")), typeStr); }(); foreach(cs; EnumMembers!CaseSensitive) { enum csString = to!string(cs); assert(lastIndexOf("\U00010143\u0100\U00010143hello", to!S("\u0100"), 6, cs) == 4, csString); assert(lastIndexOf("\U00010143\u0100\U00010143hello"w, to!S("\u0100"), 6, cs) == 2, csString); assert(lastIndexOf("\U00010143\u0100\U00010143hello"d, to!S("\u0100"), 3, cs) == 1, csString); } } } private ptrdiff_t indexOfAnyNeitherImpl(bool forward, bool any, Char, Char2)( const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { import std.algorithm : canFind; if (cs == CaseSensitive.yes) { static if (forward) { static if (any) { import std.algorithm : findAmong; size_t n = haystack.findAmong(needles).length; return n ? haystack.length - n : -1; } else { foreach (idx, dchar hay; haystack) { if (!canFind(needles, hay)) { return idx; } } } } else { static if (any) { import std.utf : strideBack; import std.algorithm : findAmong; import std.range : retro; size_t n = haystack.retro.findAmong(needles).source.length; if (n) { return n - haystack.strideBack(n); } } else { foreach_reverse (idx, dchar hay; haystack) { if(!canFind(needles, hay)) { return idx; } } } } } else { if (needles.length <= 16 && needles.walkLength(17)) { size_t si = 0; dchar[16] scratch = void; foreach ( dchar c; needles) { scratch[si++] = std.uni.toLower(c); } static if (forward) { foreach (i, dchar c; haystack) { if (canFind(scratch[0 .. si], std.uni.toLower(c)) == any) { return i; } } } else { foreach_reverse (i, dchar c; haystack) { if (canFind(scratch[0 .. si], std.uni.toLower(c)) == any) { return i; } } } } else { static bool f(dchar a, dchar b) { return std.uni.toLower(a) == b; } static if (forward) { foreach (i, dchar c; haystack) { if (canFind!f(needles, std.uni.toLower(c)) == any) { return i; } } } else { foreach_reverse (i, dchar c; haystack) { if (canFind!f(needles, std.uni.toLower(c)) == any) { return i; } } } } } return -1; } /** Returns the index of the first occurence of any of the elements in $(D needles) in $(D haystack). If no element of $(D needles) is found, then $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(true, true)(haystack, needles, cs); } /// @safe pure unittest { import std.conv : to; ptrdiff_t i = "helloWorld".indexOfAny("Wr"); assert(i == 5); i = "öällo world".indexOfAny("lo "); assert(i == 4, to!string(i)); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOfAny.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOfAny(cast(S)null, to!T("a")) == -1); assert(indexOfAny(to!S("def"), to!T("rsa")) == -1); assert(indexOfAny(to!S("abba"), to!T("a")) == 0); assert(indexOfAny(to!S("def"), to!T("f")) == 2); assert(indexOfAny(to!S("dfefffg"), to!T("fgh")) == 1); assert(indexOfAny(to!S("dfeffgfff"), to!T("feg")) == 1); assert(indexOfAny(to!S("zfeffgfff"), to!T("ACDC"), CaseSensitive.no) == -1); assert(indexOfAny(to!S("def"), to!T("MI6"), CaseSensitive.no) == -1); assert(indexOfAny(to!S("abba"), to!T("DEA"), CaseSensitive.no) == 0); assert(indexOfAny(to!S("def"), to!T("FBI"), CaseSensitive.no) == 2); assert(indexOfAny(to!S("dfefffg"), to!T("NSA"), CaseSensitive.no) == -1); assert(indexOfAny(to!S("dfeffgfff"), to!T("BND"), CaseSensitive.no) == 0); assert(indexOfAny(to!S("dfeffgfff"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"), CaseSensitive.no) == 0); assert(indexOfAny("\u0100", to!T("\u0100"), CaseSensitive.no) == 0); }(); } } ); } /** Returns the index of the first occurence of any of the elements in $(D needles) in $(D haystack). If no element of $(D needles) is found, then $(D -1) is returned. The $(D startIdx) slices $(D s) in the following way $(D haystack[startIdx .. $]). $(D startIdx) represents a codeunit index in $(D haystack). If the sequence ending at $(D startIdx) does not represent a well formed codepoint, then a $(XREF utf,UTFException) may be thrown. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. startIdx = slices haystack like this $(D haystack[startIdx .. $]). If the startIdx is greater equal the length of haystack the functions returns $(D -1). cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t indexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { if (startIdx < haystack.length) { ptrdiff_t foundIdx = indexOfAny(haystack[startIdx .. $], needles, cs); if (foundIdx != -1) { return foundIdx + cast(ptrdiff_t)startIdx; } } return -1; } /// @safe pure unittest { import std.conv : to; ptrdiff_t i = "helloWorld".indexOfAny("Wr", 4); assert(i == 5); i = "Foo öällo world".indexOfAny("lh", 3); assert(i == 8, to!string(i)); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOfAny(startIdx).unittest\n"); foreach(S; TypeTuple!(string, wstring, dstring)) { foreach(T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOfAny(cast(S)null, to!T("a"), 1337) == -1); assert(indexOfAny(to!S("def"), to!T("AaF"), 0) == -1); assert(indexOfAny(to!S("abba"), to!T("NSa"), 2) == 3); assert(indexOfAny(to!S("def"), to!T("fbi"), 1) == 2); assert(indexOfAny(to!S("dfefffg"), to!T("foo"), 2) == 3); assert(indexOfAny(to!S("dfeffgfff"), to!T("fsb"), 5) == 6); assert(indexOfAny(to!S("dfeffgfff"), to!T("NDS"), 1, CaseSensitive.no) == -1); assert(indexOfAny(to!S("def"), to!T("DRS"), 2, CaseSensitive.no) == -1); assert(indexOfAny(to!S("abba"), to!T("SI"), 3, CaseSensitive.no) == -1); assert(indexOfAny(to!S("deO"), to!T("ASIO"), 1, CaseSensitive.no) == 2); assert(indexOfAny(to!S("dfefffg"), to!T("fbh"), 2, CaseSensitive.no) == 3); assert(indexOfAny(to!S("dfeffgfff"), to!T("fEe"), 4, CaseSensitive.no) == 4); assert(indexOfAny(to!S("dfeffgffföä"), to!T("föä"), 9, CaseSensitive.no) == 9); assert(indexOfAny("\u0100", to!T("\u0100"), 0, CaseSensitive.no) == 0); }(); foreach(cs; EnumMembers!CaseSensitive) { assert(indexOfAny("hello\U00010143\u0100\U00010143", to!S("e\u0100"), 3, cs) == 9); assert(indexOfAny("hello\U00010143\u0100\U00010143"w, to!S("h\u0100"), 3, cs) == 7); assert(indexOfAny("hello\U00010143\u0100\U00010143"d, to!S("l\u0100"), 5, cs) == 6); } } } /** Returns the index of the last occurence of any of the elements in $(D needles) in $(D haystack). If no element of $(D needles) is found, then $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(false, true)(haystack, needles, cs); } /// @safe pure unittest { ptrdiff_t i = "helloWorld".lastIndexOfAny("Wlo"); assert(i == 8); i = "Foo öäöllo world".lastIndexOfAny("öF"); assert(i == 8); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOfAny.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(lastIndexOfAny(cast(S)null, to!T("a")) == -1); assert(lastIndexOfAny(to!S("def"), to!T("rsa")) == -1); assert(lastIndexOfAny(to!S("abba"), to!T("a")) == 3); assert(lastIndexOfAny(to!S("def"), to!T("f")) == 2); assert(lastIndexOfAny(to!S("dfefffg"), to!T("fgh")) == 6); ptrdiff_t oeIdx = 9; if (is(S == wstring) || is(S == dstring)) { oeIdx = 8; } auto foundOeIdx = lastIndexOfAny(to!S("dfeffgföf"), to!T("feg")); assert(foundOeIdx == oeIdx, to!string(foundOeIdx)); assert(lastIndexOfAny(to!S("zfeffgfff"), to!T("ACDC"), CaseSensitive.no) == -1); assert(lastIndexOfAny(to!S("def"), to!T("MI6"), CaseSensitive.no) == -1); assert(lastIndexOfAny(to!S("abba"), to!T("DEA"), CaseSensitive.no) == 3); assert(lastIndexOfAny(to!S("def"), to!T("FBI"), CaseSensitive.no) == 2); assert(lastIndexOfAny(to!S("dfefffg"), to!T("NSA"), CaseSensitive.no) == -1); oeIdx = 2; if (is(S == wstring) || is(S == dstring)) { oeIdx = 1; } assert(lastIndexOfAny(to!S("ödfeffgfff"), to!T("BND"), CaseSensitive.no) == oeIdx); assert(lastIndexOfAny("\u0100", to!T("\u0100"), CaseSensitive.no) == 0); }(); } } ); } /** Returns the index of the last occurence of any of the elements in $(D needles) in $(D haystack). If no element of $(D needles) is found, then $(D -1) is returned. The $(D stopIdx) slices $(D s) in the following way $(D s[0 .. stopIdx]). $(D stopIdx) represents a codeunit index in $(D s). If the sequence ending at $(D startIdx) does not represent a well formed codepoint, then a $(XREF utf,UTFException) may be thrown. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. stopIdx = slices haystack like this $(D haystack[0 .. stopIdx]). If the stopIdx is greater equal the length of haystack the functions returns $(D -1). cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t lastIndexOfAny(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t stopIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { if (stopIdx <= haystack.length) { return lastIndexOfAny(haystack[0u .. stopIdx], needles, cs); } return -1; } /// @safe pure unittest { import std.conv : to; ptrdiff_t i = "helloWorld".lastIndexOfAny("Wlo", 4); assert(i == 3); i = "Foo öäöllo world".lastIndexOfAny("öF", 3); assert(i == 0); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOfAny(index).unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 enum typeStr = S.stringof ~ " " ~ T.stringof; assert(lastIndexOfAny(cast(S)null, to!T("a"), 1337) == -1, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("c"), 7) == 6, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("cd"), 5) == 3, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("ef"), 6) == 5, typeStr); assert(lastIndexOfAny(to!S("abcdefCdef"), to!T("c"), 8) == 2, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("x"), 7) == -1, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("xy"), 4) == -1, typeStr); assert(lastIndexOfAny(to!S("öabcdefcdef"), to!T("ö"), 2) == 0, typeStr); assert(lastIndexOfAny(cast(S)null, to!T("a"), 1337, CaseSensitive.no) == -1, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("C"), 7, CaseSensitive.no) == 6, typeStr); assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("cd"), 5, CaseSensitive.no) == 3, typeStr); assert(lastIndexOfAny(to!S("abcdefcdef"), to!T("EF"), 6, CaseSensitive.no) == 5, typeStr); assert(lastIndexOfAny(to!S("ABCDEFcDEF"), to!T("C"), 8, CaseSensitive.no) == 6, typeStr); assert(lastIndexOfAny(to!S("ABCDEFCDEF"), to!T("x"), 7, CaseSensitive.no) == -1, typeStr); assert(lastIndexOfAny(to!S("abCdefcdef"), to!T("XY"), 4, CaseSensitive.no) == -1, typeStr); assert(lastIndexOfAny(to!S("ÖABCDEFCDEF"), to!T("ö"), 2, CaseSensitive.no) == 0, typeStr); }(); } } ); } /** Returns the index of the first occurence of any character not an elements in $(D needles) in $(D haystack). If all element of $(D haystack) are element of $(D needles) $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(true, false)(haystack, needles, cs); } /// @safe pure unittest { assert(indexOfNeither("def", "a") == 0); assert(indexOfNeither("def", "de") == 2); assert(indexOfNeither("dfefffg", "dfe") == 6); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOf.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOfNeither(cast(S)null, to!T("a")) == -1); assert(indexOfNeither("abba", "a") == 1); assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"), CaseSensitive.no) == 0); assert(indexOfNeither(to!S("def"), to!T("D"), CaseSensitive.no) == 1); assert(indexOfNeither(to!S("ABca"), to!T("a"), CaseSensitive.no) == 1); assert(indexOfNeither(to!S("def"), to!T("f"), CaseSensitive.no) == 0); assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"), CaseSensitive.no) == 6); if (is(S == string)) { assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"), CaseSensitive.no) == 8, to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"), CaseSensitive.no))); } else { assert(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"), CaseSensitive.no) == 7, to!string(indexOfNeither(to!S("äDfEfffg"), to!T("ädFe"), CaseSensitive.no))); } }(); } } ); } /** Returns the index of the first occurence of any character not an elements in $(D needles) in $(D haystack). If all element of $(D haystack) are element of $(D needles) $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. startIdx = slices haystack like this $(D haystack[startIdx .. $]). If the startIdx is greater equal the length of haystack the functions returns $(D -1). cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t indexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t startIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { if (startIdx < haystack.length) { ptrdiff_t foundIdx = indexOfAnyNeitherImpl!(true, false)( haystack[startIdx .. $], needles, cs); if (foundIdx != -1) { return foundIdx + cast(ptrdiff_t)startIdx; } } return -1; } /// @safe pure unittest { assert(indexOfNeither("abba", "a", 2) == 2); assert(indexOfNeither("def", "de", 1) == 2); assert(indexOfNeither("dfefffg", "dfe", 4) == 6); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.indexOfNeither(index).unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(indexOfNeither(cast(S)null, to!T("a"), 1) == -1); assert(indexOfNeither(to!S("def"), to!T("a"), 1) == 1, to!string(indexOfNeither(to!S("def"), to!T("a"), 1))); assert(indexOfNeither(to!S("dfeffgfff"), to!T("a"), 4, CaseSensitive.no) == 4); assert(indexOfNeither(to!S("def"), to!T("D"), 2, CaseSensitive.no) == 2); assert(indexOfNeither(to!S("ABca"), to!T("a"), 3, CaseSensitive.no) == -1); assert(indexOfNeither(to!S("def"), to!T("tzf"), 2, CaseSensitive.no) == -1); assert(indexOfNeither(to!S("DfEfffg"), to!T("dFe"), 5, CaseSensitive.no) == 6); if (is(S == string)) { assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no) == 3, to!string(indexOfNeither( to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no))); } else { assert(indexOfNeither(to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no) == 2, to!string(indexOfNeither( to!S("öDfEfffg"), to!T("äDi"), 2, CaseSensitive.no))); } }(); } } ); } /** Returns the last index of the first occurence of any character that is not an elements in $(D needles) in $(D haystack). If all element of $(D haystack) are element of $(D needles) $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { return indexOfAnyNeitherImpl!(false, false)(haystack, needles, cs); } /// @safe pure unittest { assert(lastIndexOfNeither("abba", "a") == 2); assert(lastIndexOfNeither("def", "f") == 1); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOfNeither.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(lastIndexOfNeither(cast(S)null, to!T("a")) == -1); assert(lastIndexOfNeither(to!S("def"), to!T("rsa")) == 2); assert(lastIndexOfNeither(to!S("dfefffg"), to!T("fgh")) == 2); ptrdiff_t oeIdx = 8; if (is(S == string)) { oeIdx = 9; } auto foundOeIdx = lastIndexOfNeither(to!S("ödfefegff"), to!T("zeg")); assert(foundOeIdx == oeIdx, to!string(foundOeIdx)); assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"), CaseSensitive.no) == 5); assert(lastIndexOfNeither(to!S("def"), to!T("MI6"), CaseSensitive.no) == 2, to!string(lastIndexOfNeither(to!S("def"), to!T("MI6"), CaseSensitive.no))); assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"), CaseSensitive.no) == 6, to!string(lastIndexOfNeither( to!S("abbadeafsb"), to!T("fSb"), CaseSensitive.no))); assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"), CaseSensitive.no) == 1); assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"), CaseSensitive.no) == 6); assert(lastIndexOfNeither(to!S("dfeffgfffö"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"), CaseSensitive.no) == 8, to!string(lastIndexOfNeither(to!S("dfeffgfffö"), to!T("BNDabCHIJKQEPÖÖSYXÄ??ß"), CaseSensitive.no))); }(); } } ); } /** Returns the last index of the first occurence of any character that is not an elements in $(D needles) in $(D haystack). If all element of $(D haystack) are element of $(D needles) $(D -1) is returned. Params: haystack = String to search for needles in. needles = Strings to search for in haystack. stopIdx = slices haystack like this $(D haystack[0 .. stopIdx]) If the stopIdx is greater equal the length of haystack the functions returns $(D -1). cs = Indicates whether the comparisons are case sensitive. */ ptrdiff_t lastIndexOfNeither(Char,Char2)(const(Char)[] haystack, const(Char2)[] needles, in size_t stopIdx, in CaseSensitive cs = CaseSensitive.yes) @safe pure if (isSomeChar!Char && isSomeChar!Char2) { if (stopIdx < haystack.length) { return indexOfAnyNeitherImpl!(false, false)(haystack[0 .. stopIdx], needles, cs); } return -1; } /// @safe pure unittest { assert(lastIndexOfNeither("def", "rsa", 3) == -1); assert(lastIndexOfNeither("abba", "a", 2) == 1); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.lastIndexOfNeither(index).unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { foreach (T; TypeTuple!(string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(lastIndexOfNeither(cast(S)null, to!T("a"), 1337) == -1); assert(lastIndexOfNeither(to!S("def"), to!T("f")) == 1); assert(lastIndexOfNeither(to!S("dfefffg"), to!T("fgh")) == 2); ptrdiff_t oeIdx = 4; if (is(S == string)) { oeIdx = 5; } auto foundOeIdx = lastIndexOfNeither(to!S("ödfefegff"), to!T("zeg"), 7); assert(foundOeIdx == oeIdx, to!string(foundOeIdx)); assert(lastIndexOfNeither(to!S("zfeffgfsb"), to!T("FSB"), 6, CaseSensitive.no) == 5); assert(lastIndexOfNeither(to!S("def"), to!T("MI6"), 2, CaseSensitive.no) == 1, to!string(lastIndexOfNeither(to!S("def"), to!T("MI6"), 2, CaseSensitive.no))); assert(lastIndexOfNeither(to!S("abbadeafsb"), to!T("fSb"), 6, CaseSensitive.no) == 5, to!string(lastIndexOfNeither( to!S("abbadeafsb"), to!T("fSb"), 6, CaseSensitive.no))); assert(lastIndexOfNeither(to!S("defbi"), to!T("FBI"), 3, CaseSensitive.no) == 1); assert(lastIndexOfNeither(to!S("dfefffg"), to!T("NSA"), 2, CaseSensitive.no) == 1, to!string(lastIndexOfNeither( to!S("dfefffg"), to!T("NSA"), 2, CaseSensitive.no))); }(); } } ); } /** * Returns the _representation of a string, which has the same type * as the string except the character type is replaced by $(D ubyte), * $(D ushort), or $(D uint) depending on the character width. * * Params: * s = The string to return the _representation of. * * Returns: * The _representation of the passed string. */ auto representation(Char)(Char[] s) @safe pure nothrow @nogc if (isSomeChar!Char) { alias ToRepType(T) = TypeTuple!(ubyte, ushort, uint)[T.sizeof / 2]; return cast(ModifyTypePreservingTQ!(ToRepType, Char)[])s; } /// @safe pure unittest { string s = "hello"; static assert(is(typeof(representation(s)) == immutable(ubyte)[])); assert(representation(s) is cast(immutable(ubyte)[]) s); assert(representation(s) == [0x68, 0x65, 0x6c, 0x6c, 0x6f]); } @trusted pure unittest { import std.exception; import std.typecons; assertCTFEable!( { void test(Char, T)(Char[] str) { static assert(is(typeof(representation(str)) == T[])); assert(representation(str) is cast(T[]) str); } foreach (Type; TypeTuple!(Tuple!(char , ubyte ), Tuple!(wchar, ushort), Tuple!(dchar, uint ))) { alias Char = FieldTypeTuple!Type[0]; alias Int = FieldTypeTuple!Type[1]; enum immutable(Char)[] hello = "hello"; test!( immutable Char, immutable Int)(hello); test!( const Char, const Int)(hello); test!( Char, Int)(hello.dup); test!( shared Char, shared Int)(cast(shared) hello.dup); test!(const shared Char, const shared Int)(hello); } }); } /** * Capitalize the first character of $(D s) and convert the rest of $(D s) to * lowercase. * * Params: * input = The string to _capitalize. * * Returns: * The capitalized string. * * See_Also: * $(XREF uni, toCapitalized) for a lazy range version that doesn't allocate memory */ S capitalize(S)(S s) @trusted pure if (isSomeString!S) { import std.utf : encode; Unqual!(typeof(s[0]))[] retval; bool changed = false; foreach (i, dchar c; s) { dchar c2; if (i == 0) { c2 = std.uni.toUpper(c); if (c != c2) changed = true; } else { c2 = std.uni.toLower(c); if (c != c2) { if (!changed) { changed = true; retval = s[0 .. i].dup; } } } if (changed) std.utf.encode(retval, c2); } return changed ? cast(S)retval : s; } auto capitalize(S)(auto ref S s) if (!isSomeString!S && is(StringTypeOf!S)) { return capitalize!(StringTypeOf!S)(s); } unittest { assert(testAliasedString!capitalize("hello")); } @trusted pure unittest { import std.conv : to; import std.algorithm : cmp; import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring, char[], wchar[], dchar[])) { S s1 = to!S("FoL"); S s2; s2 = capitalize(s1); assert(cmp(s2, "Fol") == 0); assert(s2 !is s1); s2 = capitalize(s1[0 .. 2]); assert(cmp(s2, "Fo") == 0); assert(s2.ptr == s1.ptr); s1 = to!S("fOl"); s2 = capitalize(s1); assert(cmp(s2, "Fol") == 0); assert(s2 !is s1); s1 = to!S("\u0131 \u0130"); s2 = capitalize(s1); assert(cmp(s2, "\u0049 \u0069") == 0); assert(s2 !is s1); s1 = to!S("\u017F \u0049"); s2 = capitalize(s1); assert(cmp(s2, "\u0053 \u0069") == 0); assert(s2 !is s1); } }); } /++ Split $(D s) into an array of lines according to the unicode standard using $(D '\r'), $(D '\n'), $(D "\r\n"), $(XREF uni, lineSep), $(XREF uni, paraSep), $(D U+0085) (NEL), $(D '\v') and $(D '\f') as delimiters. If $(D keepTerm) is set to $(D KeepTerminator.yes), then the delimiter is included in the strings returned. Does not throw on invalid UTF; such is simply passed unchanged to the output. Allocates memory; use $(LREF lineSplitter) for an alternative that does not. Adheres to $(WEB http://www.unicode.org/versions/Unicode7.0.0/ch05.pdf, Unicode 7.0). Params: s = a string of $(D chars), $(D wchars), or $(D dchars), or any custom type that casts to a $(D string) type keepTerm = whether delimiter is included or not in the results Returns: array of strings, each element is a line that is a slice of $(D s) See_Also: $(LREF lineSplitter) $(XREF algorithm, splitter) $(XREF regex, splitter) +/ alias KeepTerminator = Flag!"keepTerminator"; /// ditto S[] splitLines(S)(S s, in KeepTerminator keepTerm = KeepTerminator.no) @safe pure if (isSomeString!S) { import std.uni : lineSep, paraSep; import std.array : appender; size_t iStart = 0; auto retval = appender!(S[])(); for (size_t i; i < s.length; ++i) { switch (s[i]) { case '\v', '\f', '\n': retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes)]); iStart = i + 1; break; case '\r': if (i + 1 < s.length && s[i + 1] == '\n') { retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 2]); iStart = i + 2; ++i; } else { goto case '\n'; } break; static if (s[i].sizeof == 1) { /* Manually decode: * lineSep is E2 80 A8 * paraSep is E2 80 A9 */ case 0xE2: if (i + 2 < s.length && s[i + 1] == 0x80 && (s[i + 2] == 0xA8 || s[i + 2] == 0xA9) ) { retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 3]); iStart = i + 3; i += 2; } else goto default; break; /* Manually decode: * NEL is C2 85 */ case 0xC2: if(i + 1 < s.length && s[i + 1] == 0x85) { retval.put(s[iStart .. i + (keepTerm == KeepTerminator.yes) * 2]); iStart = i + 2; i += 1; } else goto default; break; } else { case lineSep: case paraSep: case '\u0085': goto case '\n'; } default: break; } } if (iStart != s.length) retval.put(s[iStart .. $]); return retval.data; } auto splitLines(S)(auto ref S s, in KeepTerminator keepTerm = KeepTerminator.no) if (!isSomeString!S && is(StringTypeOf!S)) { return splitLines!(StringTypeOf!S)(s, keepTerm); } unittest { assert(testAliasedString!splitLines("hello\nworld")); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.splitLines.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { auto s = to!S( "\rpeter\n\rpaul\r\njerry\u2028ice\u2029cream\n\nsunday\n" ~ "mon\u2030day\nschadenfreude\vkindergarten\f\vcookies\u0085" ); auto lines = splitLines(s); assert(lines.length == 14); assert(lines[0] == ""); assert(lines[1] == "peter"); assert(lines[2] == ""); assert(lines[3] == "paul"); assert(lines[4] == "jerry"); assert(lines[5] == "ice"); assert(lines[6] == "cream"); assert(lines[7] == ""); assert(lines[8] == "sunday"); assert(lines[9] == "mon\u2030day"); assert(lines[10] == "schadenfreude"); assert(lines[11] == "kindergarten"); assert(lines[12] == ""); assert(lines[13] == "cookies"); ubyte[] u = ['a', 0xFF, 0x12, 'b']; // invalid UTF auto ulines = splitLines(cast(char[])u); assert(cast(ubyte[])(ulines[0]) == u); lines = splitLines(s, KeepTerminator.yes); assert(lines.length == 14); assert(lines[0] == "\r"); assert(lines[1] == "peter\n"); assert(lines[2] == "\r"); assert(lines[3] == "paul\r\n"); assert(lines[4] == "jerry\u2028"); assert(lines[5] == "ice\u2029"); assert(lines[6] == "cream\n"); assert(lines[7] == "\n"); assert(lines[8] == "sunday\n"); assert(lines[9] == "mon\u2030day\n"); assert(lines[10] == "schadenfreude\v"); assert(lines[11] == "kindergarten\f"); assert(lines[12] == "\v"); assert(lines[13] == "cookies\u0085"); s.popBack(); // Lop-off trailing \n lines = splitLines(s); assert(lines.length == 14); assert(lines[9] == "mon\u2030day"); lines = splitLines(s, KeepTerminator.yes); assert(lines.length == 14); assert(lines[13] == "cookies"); } }); } private struct LineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range) { import std.uni : lineSep, paraSep; import std.conv : unsigned; private: Range _input; alias IndexType = typeof(unsigned(_input.length)); enum IndexType _unComputed = IndexType.max; IndexType iStart = _unComputed; IndexType iEnd = 0; IndexType iNext = 0; public: this(Range input) { _input = input; } static if (isInfinite!Range) { enum bool empty = false; } else { @property bool empty() { return iStart == _unComputed && iNext == _input.length; } } @property typeof(_input) front() { if (iStart == _unComputed) { iStart = iNext; Loop: for (IndexType i = iNext; ; ++i) { if (i == _input.length) { iEnd = i; iNext = i; break Loop; } switch (_input[i]) { case '\v', '\f', '\n': iEnd = i + (keepTerm == KeepTerminator.yes); iNext = i + 1; break Loop; case '\r': if (i + 1 < _input.length && _input[i + 1] == '\n') { iEnd = i + (keepTerm == KeepTerminator.yes) * 2; iNext = i + 2; break Loop; } else { goto case '\n'; } static if (_input[i].sizeof == 1) { /* Manually decode: * lineSep is E2 80 A8 * paraSep is E2 80 A9 */ case 0xE2: if (i + 2 < _input.length && _input[i + 1] == 0x80 && (_input[i + 2] == 0xA8 || _input[i + 2] == 0xA9) ) { iEnd = i + (keepTerm == KeepTerminator.yes) * 3; iNext = i + 3; break Loop; } else goto default; /* Manually decode: * NEL is C2 85 */ case 0xC2: if(i + 1 < _input.length && _input[i + 1] == 0x85) { iEnd = i + (keepTerm == KeepTerminator.yes) * 2; iNext = i + 2; break Loop; } else goto default; } else { case '\u0085': case lineSep: case paraSep: goto case '\n'; } default: break; } } } return _input[iStart .. iEnd]; } void popFront() { if (iStart == _unComputed) { assert(!empty); front(); } iStart = _unComputed; } static if (isForwardRange!Range) { @property typeof(this) save() { auto ret = this; ret._input = _input.save; return ret; } } } /*********************************** * Split an array or slicable range of characters into a range of lines using $(D '\r'), $(D '\n'), $(D '\v'), $(D '\f'), $(D "\r\n"), $(XREF uni, lineSep), $(XREF uni, paraSep) and $(D '\u0085') (NEL) as delimiters. If $(D keepTerm) is set to $(D KeepTerminator.yes), then the delimiter is included in the slices returned. Does not throw on invalid UTF; such is simply passed unchanged to the output. Adheres to $(WEB http://www.unicode.org/versions/Unicode7.0.0/ch05.pdf, Unicode 7.0). Does not allocate memory. Params: r = array of $(D chars), $(D wchars), or $(D dchars) or a slicable range keepTerm = whether delimiter is included or not in the results Returns: range of slices of the input range $(D r) See_Also: $(LREF splitLines) $(XREF algorithm, splitter) $(XREF regex, splitter) */ auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(Range r) if ((hasSlicing!Range && hasLength!Range && isSomeChar!(ElementType!Range) || isSomeString!Range) && !isConvertibleToString!Range) { return LineSplitter!(keepTerm, Range)(r); } auto lineSplitter(KeepTerminator keepTerm = KeepTerminator.no, Range)(auto ref Range r) if (isConvertibleToString!Range) { return LineSplitter!(keepTerm, StringTypeOf!Range)(r); } @safe pure unittest { import std.conv : to; import std.array : array; debug(string) эхо("string.lineSplitter.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { auto s = to!S( "\rpeter\n\rpaul\r\njerry\u2028ice\u2029cream\n\n" ~ "sunday\nmon\u2030day\nschadenfreude\vkindergarten\f\vcookies\u0085" ); auto lines = lineSplitter(s).array; assert(lines.length == 14); assert(lines[0] == ""); assert(lines[1] == "peter"); assert(lines[2] == ""); assert(lines[3] == "paul"); assert(lines[4] == "jerry"); assert(lines[5] == "ice"); assert(lines[6] == "cream"); assert(lines[7] == ""); assert(lines[8] == "sunday"); assert(lines[9] == "mon\u2030day"); assert(lines[10] == "schadenfreude"); assert(lines[11] == "kindergarten"); assert(lines[12] == ""); assert(lines[13] == "cookies"); ubyte[] u = ['a', 0xFF, 0x12, 'b']; // invalid UTF auto ulines = lineSplitter(cast(char[])u).array; assert(cast(ubyte[])(ulines[0]) == u); lines = lineSplitter!(KeepTerminator.yes)(s).array; assert(lines.length == 14); assert(lines[0] == "\r"); assert(lines[1] == "peter\n"); assert(lines[2] == "\r"); assert(lines[3] == "paul\r\n"); assert(lines[4] == "jerry\u2028"); assert(lines[5] == "ice\u2029"); assert(lines[6] == "cream\n"); assert(lines[7] == "\n"); assert(lines[8] == "sunday\n"); assert(lines[9] == "mon\u2030day\n"); assert(lines[10] == "schadenfreude\v"); assert(lines[11] == "kindergarten\f"); assert(lines[12] == "\v"); assert(lines[13] == "cookies\u0085"); s.popBack(); // Lop-off trailing \n lines = lineSplitter(s).array; assert(lines.length == 14); assert(lines[9] == "mon\u2030day"); lines = lineSplitter!(KeepTerminator.yes)(s).array; assert(lines.length == 14); assert(lines[13] == "cookies"); } }); } /// @nogc @safe pure unittest { auto s = "\rpeter\n\rpaul\r\njerry\u2028ice\u2029cream\n\nsunday\nmon\u2030day\n"; auto lines = s.lineSplitter(); static immutable witness = ["", "peter", "", "paul", "jerry", "ice", "cream", "", "sunday", "mon\u2030day"]; uint i; foreach (line; lines) { assert(line == witness[i++]); } assert(i == witness.length); } unittest { import std.file : DirEntry; import std.algorithm.comparison : equal; auto s = "std/string.d"; auto de = DirEntry(s); auto i = de.lineSplitter(); auto j = s.lineSplitter(); assert(equal(i, j)); } /++ Strips leading whitespace (as defined by $(XREF uni, isWhite)). Params: input = string or ForwardRange of characters Returns: $(D str) stripped of leading whitespace. Postconditions: $(D str) and the returned value will share the same tail (see $(XREF array, sameTail)). +/ auto stripLeft(Range)(Range str) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { import std.ascii : isASCII, isWhite; import std.uni : isWhite; import std.utf : decodeFront; while (!str.empty) { auto c = str.front; if (std.ascii.isASCII(c)) { if (!std.ascii.isWhite(c)) break; str.popFront(); } else { auto save = str.save; auto dc = decodeFront(str); if (!std.uni.isWhite(dc)) return save; } } return str; } /// @safe pure unittest { import std.uni : lineSep, paraSep; assert(stripLeft(" hello world ") == "hello world "); assert(stripLeft("\n\t\v\rhello world\n\t\v\r") == "hello world\n\t\v\r"); assert(stripLeft("hello world") == "hello world"); assert(stripLeft([lineSep] ~ "hello world" ~ lineSep) == "hello world" ~ [lineSep]); assert(stripLeft([paraSep] ~ "hello world" ~ paraSep) == "hello world" ~ [paraSep]); import std.utf : byChar; import std.array; assert(stripLeft(" hello world "w.byChar).array == "hello world "); } auto stripLeft(Range)(auto ref Range str) if (isConvertibleToString!Range) { return stripLeft!(StringTypeOf!Range)(str); } unittest { assert(testAliasedString!stripLeft(" hello")); } /++ Strips trailing whitespace (as defined by $(XREF uni, isWhite)). Params: str = string or random access range of characters Returns: slice of $(D str) stripped of trailing whitespace. +/ auto stripRight(Range)(Range str) if (isSomeString!Range || isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && !isConvertibleToString!Range && isSomeChar!(ElementEncodingType!Range)) { alias C = Unqual!(ElementEncodingType!(typeof(str))); static if (isSomeString!(typeof(str))) { import std.utf : codeLength; foreach_reverse (i, dchar c; str) { if (!std.uni.isWhite(c)) return str[0 .. i + codeLength!C(c)]; } return str[0 .. 0]; } else { size_t i = str.length; while (i--) { static if (C.sizeof == 4) { if (std.uni.isWhite(str[i])) continue; break; } else static if (C.sizeof == 2) { auto c2 = str[i]; if (c2 < 0xD800 || c2 >= 0xE000) { if (std.uni.isWhite(c2)) continue; } else if (c2 >= 0xDC00) { if (i) { auto c1 = str[i - 1]; if (c1 >= 0xD800 && c1 < 0xDC00) { dchar c = ((c1 - 0xD7C0) << 10) + (c2 - 0xDC00); if (std.uni.isWhite(c)) { --i; continue; } } } } break; } else static if (C.sizeof == 1) { import std.utf : byDchar; char cx = str[i]; if (cx <= 0x7F) { if (std.uni.isWhite(cx)) continue; break; } else { size_t stride = 0; while (1) { ++stride; if (!i || (cx & 0xC0) == 0xC0 || stride == 4) break; cx = str[i - 1]; if (!(cx & 0x80)) break; --i; } if (!std.uni.isWhite(str[i .. i + stride].byDchar.front)) return str[0 .. i + stride]; } } else static assert(0); } return str[0 .. i + 1]; } } /// @safe pure unittest { import std.uni : lineSep, paraSep; assert(stripRight(" hello world ") == " hello world"); assert(stripRight("\n\t\v\rhello world\n\t\v\r") == "\n\t\v\rhello world"); assert(stripRight("hello world") == "hello world"); assert(stripRight([lineSep] ~ "hello world" ~ lineSep) == [lineSep] ~ "hello world"); assert(stripRight([paraSep] ~ "hello world" ~ paraSep) == [paraSep] ~ "hello world"); } auto stripRight(Range)(auto ref Range str) if (isConvertibleToString!Range) { return stripRight!(StringTypeOf!Range)(str); } unittest { assert(testAliasedString!stripRight("hello ")); } unittest { import std.utf; import std.array; import std.uni : lineSep, paraSep; assert(stripRight(" hello world ".byChar).array == " hello world"); assert(stripRight("\n\t\v\rhello world\n\t\v\r"w.byWchar).array == "\n\t\v\rhello world"w); assert(stripRight("hello world"d.byDchar).array == "hello world"d); assert(stripRight("\u2028hello world\u2020\u2028".byChar).array == "\u2028hello world\u2020"); assert(stripRight("hello world\U00010001"w.byWchar).array == "hello world\U00010001"w); foreach (C; TypeTuple!(char, wchar, dchar)) { foreach (s; invalidUTFstrings!C()) { cast(void)stripRight(s.byUTF!C).array; } } cast(void)stripRight("a\x80".byUTF!char).array; wstring ws = ['a', cast(wchar)0xDC00]; cast(void)stripRight(ws.byUTF!wchar).array; } /++ Strips both leading and trailing whitespace (as defined by $(XREF uni, isWhite)). Params: str = string or random access range of characters Returns: slice of $(D str) stripped of leading and trailing whitespace. +/ auto strip(Range)(Range str) if (isSomeString!Range || isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && !isConvertibleToString!Range && isSomeChar!(ElementEncodingType!Range)) { return stripRight(stripLeft(str)); } /// @safe pure unittest { import std.uni : lineSep, paraSep; assert(strip(" hello world ") == "hello world"); assert(strip("\n\t\v\rhello world\n\t\v\r") == "hello world"); assert(strip("hello world") == "hello world"); assert(strip([lineSep] ~ "hello world" ~ [lineSep]) == "hello world"); assert(strip([paraSep] ~ "hello world" ~ [paraSep]) == "hello world"); } auto strip(Range)(auto ref Range str) if (isConvertibleToString!Range) { return strip!(StringTypeOf!Range)(str); } @safe pure unittest { assert(testAliasedString!strip(" hello world ")); } @safe pure unittest { import std.conv : to; import std.algorithm : equal; debug(string) эхо("string.strip.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!( char[], const char[], string, wchar[], const wchar[], wstring, dchar[], const dchar[], dstring)) { assert(equal(stripLeft(to!S(" foo\t ")), "foo\t ")); assert(equal(stripLeft(to!S("\u2008 foo\t \u2007")), "foo\t \u2007")); assert(equal(stripLeft(to!S("\u0085 μ \u0085 \u00BB \r")), "μ \u0085 \u00BB \r")); assert(equal(stripLeft(to!S("1")), "1")); assert(equal(stripLeft(to!S("\U0010FFFE")), "\U0010FFFE")); assert(equal(stripLeft(to!S("")), "")); assert(equal(stripRight(to!S(" foo\t ")), " foo")); assert(equal(stripRight(to!S("\u2008 foo\t \u2007")), "\u2008 foo")); assert(equal(stripRight(to!S("\u0085 μ \u0085 \u00BB \r")), "\u0085 μ \u0085 \u00BB")); assert(equal(stripRight(to!S("1")), "1")); assert(equal(stripRight(to!S("\U0010FFFE")), "\U0010FFFE")); assert(equal(stripRight(to!S("")), "")); assert(equal(strip(to!S(" foo\t ")), "foo")); assert(equal(strip(to!S("\u2008 foo\t \u2007")), "foo")); assert(equal(strip(to!S("\u0085 μ \u0085 \u00BB \r")), "μ \u0085 \u00BB")); assert(equal(strip(to!S("\U0010FFFE")), "\U0010FFFE")); assert(equal(strip(to!S("")), "")); } }); } @safe pure unittest { import std.exception; import std.range; assertCTFEable!( { wstring s = " "; assert(s.sameTail(s.stripLeft())); assert(s.sameHead(s.stripRight())); }); } /++ If $(D str) ends with $(D delimiter), then $(D str) is returned without $(D delimiter) on its end. If it $(D str) does $(I not) end with $(D delimiter), then it is returned unchanged. If no $(D delimiter) is given, then one trailing $(D '\r'), $(D '\n'), $(D "\r\n"), $(D '\f'), $(D '\v'), $(XREF uni, lineSep), $(XREF uni, paraSep), or $(XREF uni, nelSep) is removed from the end of $(D str). If $(D str) does not end with any of those characters, then it is returned unchanged. Params: str = string or indexable range of characters delimiter = string of characters to be sliced off end of str[] Returns: slice of str +/ Range chomp(Range)(Range str) if ((isRandomAccessRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; if (str.empty) return str; alias C = ElementEncodingType!Range; switch (str[$ - 1]) { case '\n': { if (str.length > 1 && str[$ - 2] == '\r') return str[0 .. $ - 2]; goto case; } case '\r', '\v', '\f': return str[0 .. $ - 1]; // Pop off the last character if lineSep, paraSep, or nelSep static if (is(C : const char)) { /* Manually decode: * lineSep is E2 80 A8 * paraSep is E2 80 A9 */ case 0xA8: // Last byte of lineSep case 0xA9: // Last byte of paraSep if (str.length > 2 && str[$ - 2] == 0x80 && str[$ - 3] == 0xE2) return str [0 .. $ - 3]; goto default; /* Manually decode: * NEL is C2 85 */ case 0x85: if (str.length > 1 && str[$ - 2] == 0xC2) return str [0 .. $ - 2]; goto default; } else { case lineSep: case paraSep: case nelSep: return str[0 .. $ - 1]; } default: return str; } } /// Ditto Range chomp(Range, C2)(Range str, const(C2)[] delimiter) if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range && isSomeChar!C2) { if (delimiter.empty) return chomp(str); alias C1 = ElementEncodingType!Range; static if (is(Unqual!C1 == Unqual!C2) && (isSomeString!Range || (hasSlicing!Range && C2.sizeof == 4))) { import std.algorithm : endsWith; if (str.endsWith(delimiter)) return str[0 .. $ - delimiter.length]; return str; } else { auto orig = str.save; static if (isSomeString!Range) alias C = dchar; // because strings auto-decode else alias C = C1; // and ranges do not foreach_reverse (C c; delimiter) { if (str.empty || str.back != c) return orig; str.popBack(); } return str; } } /// @safe pure unittest { import std.utf : decode; import std.uni : lineSep, paraSep, nelSep; assert(chomp(" hello world \n\r") == " hello world \n"); assert(chomp(" hello world \r\n") == " hello world "); assert(chomp(" hello world \f") == " hello world "); assert(chomp(" hello world \v") == " hello world "); assert(chomp(" hello world \n\n") == " hello world \n"); assert(chomp(" hello world \n\n ") == " hello world \n\n "); assert(chomp(" hello world \n\n" ~ [lineSep]) == " hello world \n\n"); assert(chomp(" hello world \n\n" ~ [paraSep]) == " hello world \n\n"); assert(chomp(" hello world \n\n" ~ [ nelSep]) == " hello world \n\n"); assert(chomp(" hello world") == " hello world"); assert(chomp("") == ""); assert(chomp(" hello world", "orld") == " hello w"); assert(chomp(" hello world", " he") == " hello world"); assert(chomp("", "hello") == ""); // Don't decode pointlessly assert(chomp("hello\xFE", "\r") == "hello\xFE"); } StringTypeOf!Range chomp(Range)(auto ref Range str) if (isConvertibleToString!Range) { return chomp!(StringTypeOf!Range)(str); } StringTypeOf!Range chomp(Range, C2)(auto ref Range str, const(C2)[] delimiter) if (isConvertibleToString!Range) { return chomp!(StringTypeOf!Range, C2)(str, delimiter); } unittest { assert(testAliasedString!chomp(" hello world \n\r")); assert(testAliasedString!chomp(" hello world", "orld")); } unittest { import std.conv : to; debug(string) эхо("string.chomp.unittest\n"); string s; import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { // @@@ BUG IN COMPILER, MUST INSERT CAST assert(chomp(cast(S)null) is null); assert(chomp(to!S("hello")) == "hello"); assert(chomp(to!S("hello\n")) == "hello"); assert(chomp(to!S("hello\r")) == "hello"); assert(chomp(to!S("hello\r\n")) == "hello"); assert(chomp(to!S("hello\n\r")) == "hello\n"); assert(chomp(to!S("hello\n\n")) == "hello\n"); assert(chomp(to!S("hello\r\r")) == "hello\r"); assert(chomp(to!S("hello\nxxx\n")) == "hello\nxxx"); assert(chomp(to!S("hello\u2028")) == "hello"); assert(chomp(to!S("hello\u2029")) == "hello"); assert(chomp(to!S("hello\u0085")) == "hello"); assert(chomp(to!S("hello\u2028\u2028")) == "hello\u2028"); assert(chomp(to!S("hello\u2029\u2029")) == "hello\u2029"); assert(chomp(to!S("hello\u2029\u2129")) == "hello\u2029\u2129"); assert(chomp(to!S("hello\u2029\u0185")) == "hello\u2029\u0185"); foreach (T; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 // @@@ BUG IN COMPILER, MUST INSERT CAST assert(chomp(cast(S)null, cast(T)null) is null); assert(chomp(to!S("hello\n"), cast(T)null) == "hello"); assert(chomp(to!S("hello"), to!T("o")) == "hell"); assert(chomp(to!S("hello"), to!T("p")) == "hello"); // @@@ BUG IN COMPILER, MUST INSERT CAST assert(chomp(to!S("hello"), cast(T) null) == "hello"); assert(chomp(to!S("hello"), to!T("llo")) == "he"); assert(chomp(to!S("\uFF28ello"), to!T("llo")) == "\uFF28e"); assert(chomp(to!S("\uFF28el\uFF4co"), to!T("l\uFF4co")) == "\uFF28e"); }(); } }); // Ranges import std.utf : byChar, byWchar, byDchar; import std.array; assert(chomp("hello world\r\n" .byChar ).array == "hello world"); assert(chomp("hello world\r\n"w.byWchar).array == "hello world"w); assert(chomp("hello world\r\n"d.byDchar).array == "hello world"d); assert(chomp("hello world"d.byDchar, "ld").array == "hello wor"d); assert(chomp("hello\u2020" .byChar , "\u2020").array == "hello"); assert(chomp("hello\u2020"d.byDchar, "\u2020"d).array == "hello"d); } /++ If $(D str) starts with $(D delimiter), then the part of $(D str) following $(D delimiter) is returned. If $(D str) does $(I not) start with $(D delimiter), then it is returned unchanged. Params: str = string or forward range of characters delimiter = string of characters to be sliced off front of str[] Returns: slice of str +/ Range chompPrefix(Range, C2)(Range str, const(C2)[] delimiter) if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range && isSomeChar!C2) { alias C1 = ElementEncodingType!Range; static if (is(Unqual!C1 == Unqual!C2) && (isSomeString!Range || (hasSlicing!Range && C2.sizeof == 4))) { import std.algorithm : startsWith; if (str.startsWith(delimiter)) return str[delimiter.length .. $]; return str; } else { auto orig = str.save; static if (isSomeString!Range) alias C = dchar; // because strings auto-decode else alias C = C1; // and ranges do not foreach (C c; delimiter) { if (str.empty || str.front != c) return orig; str.popFront(); } return str; } } /// @safe pure unittest { assert(chompPrefix("hello world", "he") == "llo world"); assert(chompPrefix("hello world", "hello w") == "orld"); assert(chompPrefix("hello world", " world") == "hello world"); assert(chompPrefix("", "hello") == ""); } StringTypeOf!Range chompPrefix(Range, C2)(auto ref Range str, const(C2)[] delimiter) if (isConvertibleToString!Range) { return chompPrefix!(StringTypeOf!Range, C2)(str, delimiter); } @safe pure unittest { import std.conv : to; import std.algorithm : equal; import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { foreach (T; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(equal(chompPrefix(to!S("abcdefgh"), to!T("abcde")), "fgh")); assert(equal(chompPrefix(to!S("abcde"), to!T("abcdefgh")), "abcde")); assert(equal(chompPrefix(to!S("\uFF28el\uFF4co"), to!T("\uFF28el\uFF4co")), "")); assert(equal(chompPrefix(to!S("\uFF28el\uFF4co"), to!T("\uFF28el")), "\uFF4co")); assert(equal(chompPrefix(to!S("\uFF28el"), to!T("\uFF28el\uFF4co")), "\uFF28el")); }(); } }); // Ranges import std.utf : byChar, byWchar, byDchar; import std.array; assert(chompPrefix("hello world" .byChar , "hello"d).array == " world"); assert(chompPrefix("hello world"w.byWchar, "hello" ).array == " world"w); assert(chompPrefix("hello world"d.byDchar, "hello"w).array == " world"d); assert(chompPrefix("hello world"c.byDchar, "hello"w).array == " world"d); assert(chompPrefix("hello world"d.byDchar, "lx").array == "hello world"d); assert(chompPrefix("hello world"d.byDchar, "hello world xx").array == "hello world"d); assert(chompPrefix("\u2020world" .byChar , "\u2020").array == "world"); assert(chompPrefix("\u2020world"d.byDchar, "\u2020"d).array == "world"d); } unittest { assert(testAliasedString!chompPrefix("hello world", "hello")); } /++ Returns $(D str) without its last character, if there is one. If $(D str) ends with $(D "\r\n"), then both are removed. If $(D str) is empty, then then it is returned unchanged. Params: str = string (must be valid UTF) Returns: slice of str +/ Range chop(Range)(Range str) if ((isBidirectionalRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range) { if (str.empty) return str; static if (isSomeString!Range) { if (str.length >= 2 && str[$ - 1] == '\n' && str[$ - 2] == '\r') return str[0 .. $ - 2]; str.popBack(); return str; } else { alias C = Unqual!(ElementEncodingType!Range); C c = str.back; str.popBack(); if (c == '\n') { if (!str.empty && str.back == '\r') str.popBack(); return str; } // Pop back a dchar, not just a code unit static if (C.sizeof == 1) { int cnt = 1; while ((c & 0xC0) == 0x80) { if (str.empty) break; c = str.back; str.popBack(); if (++cnt > 4) break; } } else static if (C.sizeof == 2) { if (c >= 0xD800 && c <= 0xDBFF) { if (!str.empty) str.popBack(); } } else static if (C.sizeof == 4) { } else static assert(0); return str; } } /// @safe pure unittest { assert(chop("hello world") == "hello worl"); assert(chop("hello world\n") == "hello world"); assert(chop("hello world\r") == "hello world"); assert(chop("hello world\n\r") == "hello world\n"); assert(chop("hello world\r\n") == "hello world"); assert(chop("Walter Bright") == "Walter Brigh"); assert(chop("") == ""); } StringTypeOf!Range chop(Range)(auto ref Range str) if (isConvertibleToString!Range) { return chop!(StringTypeOf!Range)(str); } unittest { assert(testAliasedString!chop("hello world")); } @safe pure unittest { import std.utf : byChar, byWchar, byDchar, byCodeUnit, invalidUTFstrings; import std.array; assert(chop("hello world".byChar).array == "hello worl"); assert(chop("hello world\n"w.byWchar).array == "hello world"w); assert(chop("hello world\r"d.byDchar).array == "hello world"d); assert(chop("hello world\n\r".byChar).array == "hello world\n"); assert(chop("hello world\r\n"w.byWchar).array == "hello world"w); assert(chop("Walter Bright"d.byDchar).array == "Walter Brigh"d); assert(chop("".byChar).array == ""); assert(chop(`ミツバチと科学者` .byCodeUnit).array == "ミツバチと科学"); assert(chop(`ミツバチと科学者`w.byCodeUnit).array == "ミツバチと科学"w); assert(chop(`ミツバチと科学者`d.byCodeUnit).array == "ミツバチと科学"d); auto ca = invalidUTFstrings!char(); foreach (s; ca) { foreach (c; chop(s.byCodeUnit)) { } } auto wa = invalidUTFstrings!wchar(); foreach (s; wa) { foreach (c; chop(s.byCodeUnit)) { } } } unittest { import std.conv : to; import std.algorithm : equal; debug(string) эхо("string.chop.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { assert(chop(cast(S) null) is null); assert(equal(chop(to!S("hello")), "hell")); assert(equal(chop(to!S("hello\r\n")), "hello")); assert(equal(chop(to!S("hello\n\r")), "hello\n")); assert(equal(chop(to!S("Verité")), "Verit")); assert(equal(chop(to!S(`さいごの果実`)), "さいごの果")); assert(equal(chop(to!S(`ミツバチと科学者`)), "ミツバチと科学")); } }); } /++ Left justify $(D s) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D s) doesn't fill. Params: s = string width = minimum field width fillChar = used to pad end up to $(D width) characters Returns: GC allocated string See_Also: $(LREF leftJustifier), which does not allocate +/ S leftJustify(S)(S s, size_t width, dchar fillChar = ' ') if (isSomeString!S) { import std.array; return leftJustifier(s, width, fillChar).array; } /++ Left justify $(D s) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D s) doesn't fill. Params: r = string or range of characters width = minimum field width fillChar = used to pad end up to $(D width) characters Returns: a lazy range of the left justified result See_Also: $(LREF rightJustifier) +/ auto leftJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); static if (C.sizeof == 1) { import std.utf : byDchar, byChar; return leftJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) { import std.utf : byDchar, byWchar; return leftJustifier(r.byDchar, width, fillChar).byWchar; } else static if (C.sizeof == 4) { static struct Result { private: Range _input; size_t _width; dchar _fillChar; size_t len; public: this(Range input, size_t width, dchar fillChar) { _input = input; _width = width; _fillChar = fillChar; } @property bool empty() { return len >= _width && _input.empty; } @property C front() { return _input.empty ? _fillChar : _input.front; } void popFront() { ++len; if (!_input.empty) _input.popFront(); } static if (isForwardRange!Range) { @property typeof(this) save() { auto ret = this; ret._input = _input.save; return ret; } } } return Result(r, width, fillChar); } else static assert(0); } /// @safe pure @nogc nothrow unittest { import std.algorithm : equal; import std.utf : byChar; assert(leftJustifier("hello", 2).equal("hello".byChar)); assert(leftJustifier("hello", 7).equal("hello ".byChar)); assert(leftJustifier("hello", 7, 'x').equal("helloxx".byChar)); } auto leftJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') if (isConvertibleToString!Range) { return leftJustifier!(StringTypeOf!Range)(r, width, fillChar); } unittest { auto r = "hello".leftJustifier(8); r.popFront(); auto save = r.save; r.popFront(); assert(r.front == 'l'); assert(save.front == 'e'); } unittest { assert(testAliasedString!leftJustifier("hello", 2)); } /++ Right justify $(D s) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D s) doesn't fill. Params: s = string width = minimum field width fillChar = used to pad end up to $(D width) characters Returns: GC allocated string See_Also: $(LREF rightJustifier), which does not allocate +/ S rightJustify(S)(S s, size_t width, dchar fillChar = ' ') if (isSomeString!S) { import std.array; return rightJustifier(s, width, fillChar).array; } /++ Right justify $(D s) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D s) doesn't fill. Params: r = string or forward range of characters width = minimum field width fillChar = used to pad end up to $(D width) characters Returns: a lazy range of the right justified result See_Also: $(LREF leftJustifier) +/ auto rightJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); static if (C.sizeof == 1) { import std.utf : byDchar, byChar; return rightJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) { import std.utf : byDchar, byWchar; return rightJustifier(r.byDchar, width, fillChar).byWchar; } else static if (C.sizeof == 4) { static struct Result { private: Range _input; size_t _width; alias nfill = _width; // number of fill characters to prepend dchar _fillChar; bool inited; // Lazy initialization so constructor is trivial and cannot fail void initialize() { // Replace _width with nfill // (use alias instead of union because CTFE cannot deal with unions) assert(_width); static if (hasLength!Range) { auto len = _input.length; nfill = (_width > len) ? _width - len : 0; } else { // Lookahead to see now many fill characters are needed import std.range : walkLength, take; nfill = _width - walkLength(_input.save.take(_width), _width); } inited = true; } public: this(Range input, size_t width, dchar fillChar) pure nothrow { _input = input; _fillChar = fillChar; _width = width; } @property bool empty() { return !nfill && _input.empty; } @property C front() { if (!nfill) return _input.front; // fast path if (!inited) initialize(); return nfill ? _fillChar : _input.front; } void popFront() { if (!nfill) _input.popFront(); // fast path else { if (!inited) initialize(); if (nfill) --nfill; else _input.popFront(); } } @property typeof(this) save() { auto ret = this; ret._input = _input.save; return ret; } } return Result(r, width, fillChar); } else static assert(0); } /// @safe pure @nogc nothrow unittest { import std.algorithm : equal; import std.utf : byChar; assert(rightJustifier("hello", 2).equal("hello".byChar)); assert(rightJustifier("hello", 7).equal(" hello".byChar)); assert(rightJustifier("hello", 7, 'x').equal("xxhello".byChar)); } auto rightJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') if (isConvertibleToString!Range) { return rightJustifier!(StringTypeOf!Range)(r, width, fillChar); } unittest { assert(testAliasedString!rightJustifier("hello", 2)); } unittest { auto r = "hello"d.rightJustifier(6); r.popFront(); auto save = r.save; r.popFront(); assert(r.front == 'e'); assert(save.front == 'h'); auto t = "hello".rightJustifier(7); t.popFront(); assert(t.front == ' '); t.popFront(); assert(t.front == 'h'); auto u = "hello"d.rightJustifier(5); u.popFront(); u.popFront(); u.popFront(); } /++ Center $(D s) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D s) doesn't fill. Params: s = The string to center width = Width of the field to center `s` in fillChar = The character to use for filling excess space in the field Returns: The resulting _center-justified string. The returned string is GC-allocated. To avoid GC allocation, use $(LREF centerJustifier) instead. +/ S center(S)(S s, size_t width, dchar fillChar = ' ') if (isSomeString!S) { import std.array; return centerJustifier(s, width, fillChar).array; } @trusted pure unittest { import std.conv : to; debug(string) эхо("string.justify.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { S s = to!S("hello"); assert(leftJustify(s, 2) == "hello"); assert(rightJustify(s, 2) == "hello"); assert(center(s, 2) == "hello"); assert(leftJustify(s, 7) == "hello "); assert(rightJustify(s, 7) == " hello"); assert(center(s, 7) == " hello "); assert(leftJustify(s, 8) == "hello "); assert(rightJustify(s, 8) == " hello"); assert(center(s, 8) == " hello "); assert(leftJustify(s, 8, '\u0100') == "hello\u0100\u0100\u0100"); assert(rightJustify(s, 8, '\u0100') == "\u0100\u0100\u0100hello"); assert(center(s, 8, '\u0100') == "\u0100hello\u0100\u0100"); assert(leftJustify(s, 8, 'ö') == "helloööö"); assert(rightJustify(s, 8, 'ö') == "öööhello"); assert(center(s, 8, 'ö') == "öhelloöö"); } }); } /++ Center justify $(D r) in a field $(D width) characters wide. $(D fillChar) is the character that will be used to fill up the space in the field that $(D r) doesn't fill. Params: r = string or forward range of characters width = minimum field width fillChar = used to pad end up to $(D width) characters Returns: a lazy range of the center justified result See_Also: $(LREF leftJustifier) $(LREF rightJustifier) +/ auto centerJustifier(Range)(Range r, size_t width, dchar fillChar = ' ') if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); static if (C.sizeof == 1) { import std.utf : byDchar, byChar; return centerJustifier(r.byDchar, width, fillChar).byChar; } else static if (C.sizeof == 2) { import std.utf : byDchar, byWchar; return centerJustifier(r.byDchar, width, fillChar).byWchar; } else static if (C.sizeof == 4) { import std.range : chain, repeat, walkLength; auto len = walkLength(r.save, width); if (len > width) len = width; const nleft = (width - len) / 2; const nright = width - len - nleft; return chain(repeat(fillChar, nleft), r, repeat(fillChar, nright)); } else static assert(0); } /// @safe pure @nogc nothrow unittest { import std.algorithm : equal; import std.utf : byChar; assert(centerJustifier("hello", 2).equal("hello".byChar)); assert(centerJustifier("hello", 8).equal(" hello ".byChar)); assert(centerJustifier("hello", 7, 'x').equal("xhellox".byChar)); } auto centerJustifier(Range)(auto ref Range r, size_t width, dchar fillChar = ' ') if (isConvertibleToString!Range) { return centerJustifier!(StringTypeOf!Range)(r, width, fillChar); } unittest { assert(testAliasedString!centerJustifier("hello", 8)); } unittest { static auto byFwdRange(dstring s) { static struct FRange { dstring str; this(dstring s) { str = s; } @property bool empty() { return str.length == 0; } @property dchar front() { return str[0]; } void popFront() { str = str[1 .. $]; } @property FRange save() { return this; } } return FRange(s); } auto r = centerJustifier(byFwdRange("hello"d), 6); r.popFront(); auto save = r.save; r.popFront(); assert(r.front == 'l'); assert(save.front == 'e'); auto t = "hello".centerJustifier(7); t.popFront(); assert(t.front == 'h'); t.popFront(); assert(t.front == 'e'); auto u = byFwdRange("hello"d).centerJustifier(6); u.popFront(); u.popFront(); u.popFront(); u.popFront(); u.popFront(); u.popFront(); } /++ Replace each tab character in $(D s) with the number of spaces necessary to align the following character at the next tab stop. Params: s = string tabSize = distance between tab stops Returns: GC allocated string with tabs replaced with spaces +/ S detab(S)(S s, size_t tabSize = 8) pure if (isSomeString!S) { import std.array; return detabber(s, tabSize).array; } /++ Replace each tab character in $(D r) with the number of spaces necessary to align the following character at the next tab stop. Params: r = string or forward range tabSize = distance between tab stops Returns: lazy forward range with tabs replaced with spaces +/ auto detabber(Range)(Range r, size_t tabSize = 8) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; import std.utf : codeUnitLimit, decodeFront; assert(tabSize > 0); alias C = Unqual!(ElementEncodingType!Range); static struct Result { private: Range _input; size_t _tabSize; size_t nspaces; int column; size_t index; public: this(Range input, size_t tabSize) { _input = input; _tabSize = tabSize; } static if (isInfinite!Range) { enum bool empty = false; } else { @property bool empty() { return _input.empty && nspaces == 0; } } @property C front() { if (nspaces) return ' '; static if (isSomeString!Range) C c = _input[0]; else C c = _input.front; if (index) return c; dchar dc; if (c < codeUnitLimit!(immutable(C)[])) { dc = c; index = 1; } else { auto r = _input.save; dc = decodeFront(r, index); // lookahead to decode } switch (dc) { case '\r': case '\n': case paraSep: case lineSep: case nelSep: column = 0; break; case '\t': nspaces = _tabSize - (column % _tabSize); column += nspaces; c = ' '; break; default: ++column; break; } return c; } void popFront() { if (!index) front(); if (nspaces) --nspaces; if (!nspaces) { static if (isSomeString!Range) _input = _input[1 .. $]; else _input.popFront(); --index; } } @property typeof(this) save() { auto ret = this; ret._input = _input.save; return ret; } } return Result(r, tabSize); } /// @trusted pure unittest { import std.array; assert(detabber(" \n\tx", 9).array == " \n x"); } auto detabber(Range)(auto ref Range r, size_t tabSize = 8) if (isConvertibleToString!Range) { return detabber!(StringTypeOf!Range)(r, tabSize); } unittest { assert(testAliasedString!detabber( " ab\t asdf ", 8)); } @trusted pure unittest { import std.conv : to; import std.algorithm : cmp; debug(string) эхо("string.detab.unittest\n"); import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring)) { S s = to!S("This \tis\t a fofof\tof list"); assert(cmp(detab(s), "This is a fofof of list") == 0); assert(detab(cast(S)null) is null); assert(detab("").empty); assert(detab("a") == "a"); assert(detab("\t") == " "); assert(detab("\t", 3) == " "); assert(detab("\t", 9) == " "); assert(detab( " ab\t asdf ") == " ab asdf "); assert(detab( " \U00010000b\tasdf ") == " \U00010000b asdf "); assert(detab("\r\t", 9) == "\r "); assert(detab("\n\t", 9) == "\n "); assert(detab("\u0085\t", 9) == "\u0085 "); assert(detab("\u2028\t", 9) == "\u2028 "); assert(detab(" \u2029\t", 9) == " \u2029 "); } }); } /// @trusted pure unittest { import std.utf; import std.array; assert(detabber(" \u2029\t".byChar, 9).array == " \u2029 "); auto r = "hel\tx".byWchar.detabber(); assert(r.front == 'h' && r.front == 'h'); auto s = r.save; r.popFront(); r.popFront(); assert(r.front == 'l'); assert(s.front == 'h'); } /++ Replaces spaces in $(D s) with the optimal number of tabs. All spaces and tabs at the end of a line are removed. Params: s = String to convert. tabSize = Tab columns are $(D tabSize) spaces apart. Returns: GC allocated string with spaces replaced with tabs; use $(LREF entabber) to not allocate. See_Also: $(LREF entabber) +/ auto entab(Range)(Range s, size_t tabSize = 8) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) { import std.array : array; return entabber(s, tabSize).array; } /// unittest { assert(entab(" x \n") == "\tx\n"); } auto entab(Range)(auto ref Range s, size_t tabSize = 8) if (!(isForwardRange!Range && isSomeChar!(ElementEncodingType!Range)) && is(StringTypeOf!Range)) { return entab!(StringTypeOf!Range)(s, tabSize); } unittest { assert(testAliasedString!entab(" x \n")); } /++ Replaces spaces in range $(D r) with the optimal number of tabs. All spaces and tabs at the end of a line are removed. Params: r = string or forward range tabSize = distance between tab stops Returns: lazy forward range with spaces replaced with tabs See_Also: $(LREF entab) +/ auto entabber(Range)(Range r, size_t tabSize = 8) if (isForwardRange!Range && !isConvertibleToString!Range) { import std.uni : lineSep, paraSep, nelSep; import std.utf : codeUnitLimit, decodeFront; assert(tabSize > 0); alias C = Unqual!(ElementEncodingType!Range); static struct Result { private: Range _input; size_t _tabSize; size_t nspaces; size_t ntabs; int column; size_t index; @property C getFront() { static if (isSomeString!Range) return _input[0]; // avoid autodecode else return _input.front; } public: this(Range input, size_t tabSize) { _input = input; _tabSize = tabSize; } @property bool empty() { if (ntabs || nspaces) return false; /* Since trailing spaces are removed, * look ahead for anything that is not a trailing space */ static if (isSomeString!Range) { foreach (c; _input) { if (c != ' ' && c != '\t') return false; } return true; } else { if (_input.empty) return true; C c = _input.front; if (c != ' ' && c != '\t') return false; auto t = _input.save; t.popFront(); foreach (c2; t) { if (c2 != ' ' && c2 != '\t') return false; } return true; } } @property C front() { //writefln(" front(): ntabs = %s nspaces = %s index = %s front = '%s'", ntabs, nspaces, index, getFront()); if (ntabs) return '\t'; if (nspaces) return ' '; C c = getFront(); if (index) return c; dchar dc; if (c < codeUnitLimit!(immutable(C)[])) { index = 1; dc = c; if (c == ' ' || c == '\t') { // Consume input until a non-blank is encountered size_t startcol = column; C cx; static if (isSomeString!Range) { while (1) { assert(_input.length); cx = _input[0]; if (cx == ' ') ++column; else if (cx == '\t') column += _tabSize - (column % _tabSize); else break; _input = _input[1 .. $]; } } else { while (1) { assert(!_input.empty); cx = _input.front; if (cx == ' ') ++column; else if (cx == '\t') column += _tabSize - (column % _tabSize); else break; _input.popFront(); } } // Compute ntabs+nspaces to get from startcol to column auto n = column - startcol; if (n == 1) { nspaces = 1; } else { ntabs = column / _tabSize - startcol / _tabSize; if (ntabs == 0) nspaces = column - startcol; else nspaces = column % _tabSize; } //writefln("\tstartcol = %s, column = %s, _tabSize = %s", startcol, column, _tabSize); //writefln("\tntabs = %s, nspaces = %s", ntabs, nspaces); if (cx < codeUnitLimit!(immutable(C)[])) { dc = cx; index = 1; } else { auto r = _input.save; dc = decodeFront(r, index); // lookahead to decode } switch (dc) { case '\r': case '\n': case paraSep: case lineSep: case nelSep: column = 0; // Spaces followed by newline are ignored ntabs = 0; nspaces = 0; return cx; default: ++column; break; } return ntabs ? '\t' : ' '; } } else { auto r = _input.save; dc = decodeFront(r, index); // lookahead to decode } //writefln("dc = x%x", dc); switch (dc) { case '\r': case '\n': case paraSep: case lineSep: case nelSep: column = 0; break; default: ++column; break; } return c; } void popFront() { //writefln("popFront(): ntabs = %s nspaces = %s index = %s front = '%s'", ntabs, nspaces, index, getFront()); if (!index) front(); if (ntabs) --ntabs; else if (nspaces) --nspaces; else if (!ntabs && !nspaces) { static if (isSomeString!Range) _input = _input[1 .. $]; else _input.popFront(); --index; } } @property typeof(this) save() { auto ret = this; ret._input = _input.save; return ret; } } return Result(r, tabSize); } /// unittest { import std.array; assert(entabber(" x \n").array == "\tx\n"); } auto entabber(Range)(auto ref Range r, size_t tabSize = 8) if (isConvertibleToString!Range) { return entabber!(StringTypeOf!Range)(r, tabSize); } unittest { assert(testAliasedString!entabber(" ab asdf ", 8)); } @safe pure unittest { import std.conv : to; debug(string) эхо("string.entab.unittest\n"); import std.exception; assertCTFEable!( { assert(entab(cast(string) null) is null); assert(entab("").empty); assert(entab("a") == "a"); assert(entab(" ") == ""); assert(entab(" x") == "\tx"); assert(entab(" ab asdf ") == " ab\tasdf"); assert(entab(" ab asdf ") == " ab\t asdf"); assert(entab(" ab \t asdf ") == " ab\t asdf"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\ta"); assert(entab("1234567 \ta") == "1234567\t\t\ta"); assert(entab("a ") == "a"); assert(entab("a\v") == "a\v"); assert(entab("a\f") == "a\f"); assert(entab("a\n") == "a\n"); assert(entab("a\n\r") == "a\n\r"); assert(entab("a\r\n") == "a\r\n"); assert(entab("a\u2028") == "a\u2028"); assert(entab("a\u2029") == "a\u2029"); assert(entab("a\u0085") == "a\u0085"); assert(entab("a ") == "a"); assert(entab("a\t") == "a"); assert(entab("\uFF28\uFF45\uFF4C\uFF4C567 \t\uFF4F \t") == "\uFF28\uFF45\uFF4C\uFF4C567\t\t\uFF4F"); assert(entab(" \naa") == "\naa"); assert(entab(" \r aa") == "\r aa"); assert(entab(" \u2028 aa") == "\u2028 aa"); assert(entab(" \u2029 aa") == "\u2029 aa"); assert(entab(" \u0085 aa") == "\u0085 aa"); }); } @safe pure unittest { import std.utf : byChar; import std.array; assert(entabber(" \u0085 aa".byChar).array == "\u0085 aa"); assert(entabber(" \u2028\t aa \t".byChar).array == "\u2028\t aa"); auto r = entabber("1234", 4); r.popFront(); auto rsave = r.save; r.popFront(); assert(r.front == '3'); assert(rsave.front == '2'); } /++ Replaces the characters in $(D str) which are keys in $(D transTable) with their corresponding values in $(D transTable). $(D transTable) is an AA where its keys are $(D dchar) and its values are either $(D dchar) or some type of string. Also, if $(D toRemove) is given, the characters in it are removed from $(D str) prior to translation. $(D str) itself is unaltered. A copy with the changes is returned. See_Also: $(LREF tr) $(XREF array, replace) Params: str = The original string. transTable = The AA indicating which characters to replace and what to replace them with. toRemove = The characters to remove from the string. +/ C1[] translate(C1, C2 = immutable char)(C1[] str, in dchar[dchar] transTable, const(C2)[] toRemove = null) @safe pure if (isSomeChar!C1 && isSomeChar!C2) { import std.array : appender; auto buffer = appender!(C1[])(); translateImpl(str, transTable, toRemove, buffer); return buffer.data; } /// @safe pure unittest { dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q']; assert(translate("hello world", transTable1) == "h5ll7 w7rld"); assert(translate("hello world", transTable1, "low") == "h5 rd"); string[dchar] transTable2 = ['e' : "5", 'o' : "orange"]; assert(translate("hello world", transTable2) == "h5llorange worangerld"); } @safe pure unittest // issue 13018 { immutable dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q']; assert(translate("hello world", transTable1) == "h5ll7 w7rld"); assert(translate("hello world", transTable1, "low") == "h5 rd"); immutable string[dchar] transTable2 = ['e' : "5", 'o' : "orange"]; assert(translate("hello world", transTable2) == "h5llorange worangerld"); } @trusted pure unittest { import std.conv : to; import std.exception; assertCTFEable!( { foreach (S; TypeTuple!( char[], const( char)[], immutable( char)[], wchar[], const(wchar)[], immutable(wchar)[], dchar[], const(dchar)[], immutable(dchar)[])) { assert(translate(to!S("hello world"), cast(dchar[dchar])['h' : 'q', 'l' : '5']) == to!S("qe55o wor5d")); assert(translate(to!S("hello world"), cast(dchar[dchar])['o' : 'l', 'l' : '\U00010143']) == to!S("he\U00010143\U00010143l wlr\U00010143d")); assert(translate(to!S("hello \U00010143 world"), cast(dchar[dchar])['h' : 'q', 'l': '5']) == to!S("qe55o \U00010143 wor5d")); assert(translate(to!S("hello \U00010143 world"), cast(dchar[dchar])['o' : '0', '\U00010143' : 'o']) == to!S("hell0 o w0rld")); assert(translate(to!S("hello world"), cast(dchar[dchar])null) == to!S("hello world")); foreach (T; TypeTuple!( char[], const( char)[], immutable( char)[], wchar[], const(wchar)[], immutable(wchar)[], dchar[], const(dchar)[], immutable(dchar)[])) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 foreach(R; TypeTuple!(dchar[dchar], const dchar[dchar], immutable dchar[dchar])) { R tt = ['h' : 'q', 'l' : '5']; assert(translate(to!S("hello world"), tt, to!T("r")) == to!S("qe55o wo5d")); assert(translate(to!S("hello world"), tt, to!T("helo")) == to!S(" wrd")); assert(translate(to!S("hello world"), tt, to!T("q5")) == to!S("qe55o wor5d")); } }(); auto s = to!S("hello world"); dchar[dchar] transTable = ['h' : 'q', 'l' : '5']; static assert(is(typeof(s) == typeof(translate(s, transTable)))); } }); } /++ Ditto +/ C1[] translate(C1, S, C2 = immutable char)(C1[] str, in S[dchar] transTable, const(C2)[] toRemove = null) @safe pure if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2) { import std.array : appender; auto buffer = appender!(C1[])(); translateImpl(str, transTable, toRemove, buffer); return buffer.data; } @trusted pure unittest { import std.conv : to; import std.exception; assertCTFEable!( { foreach (S; TypeTuple!( char[], const( char)[], immutable( char)[], wchar[], const(wchar)[], immutable(wchar)[], dchar[], const(dchar)[], immutable(dchar)[])) { assert(translate(to!S("hello world"), ['h' : "yellow", 'l' : "42"]) == to!S("yellowe4242o wor42d")); assert(translate(to!S("hello world"), ['o' : "owl", 'l' : "\U00010143\U00010143"]) == to!S("he\U00010143\U00010143\U00010143\U00010143owl wowlr\U00010143\U00010143d")); assert(translate(to!S("hello \U00010143 world"), ['h' : "yellow", 'l' : "42"]) == to!S("yellowe4242o \U00010143 wor42d")); assert(translate(to!S("hello \U00010143 world"), ['o' : "owl", 'l' : "\U00010143\U00010143"]) == to!S("he\U00010143\U00010143\U00010143\U00010143owl \U00010143 wowlr\U00010143\U00010143d")); assert(translate(to!S("hello \U00010143 world"), ['h' : ""]) == to!S("ello \U00010143 world")); assert(translate(to!S("hello \U00010143 world"), ['\U00010143' : ""]) == to!S("hello world")); assert(translate(to!S("hello world"), cast(string[dchar])null) == to!S("hello world")); foreach (T; TypeTuple!( char[], const( char)[], immutable( char)[], wchar[], const(wchar)[], immutable(wchar)[], dchar[], const(dchar)[], immutable(dchar)[])) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 foreach(R; TypeTuple!(string[dchar], const string[dchar], immutable string[dchar])) { R tt = ['h' : "yellow", 'l' : "42"]; assert(translate(to!S("hello world"), tt, to!T("r")) == to!S("yellowe4242o wo42d")); assert(translate(to!S("hello world"), tt, to!T("helo")) == to!S(" wrd")); assert(translate(to!S("hello world"), tt, to!T("y42")) == to!S("yellowe4242o wor42d")); assert(translate(to!S("hello world"), tt, to!T("hello world")) == to!S("")); assert(translate(to!S("hello world"), tt, to!T("42")) == to!S("yellowe4242o wor42d")); } }(); auto s = to!S("hello world"); string[dchar] transTable = ['h' : "silly", 'l' : "putty"]; static assert(is(typeof(s) == typeof(translate(s, transTable)))); } }); } /++ This is an overload of $(D translate) which takes an existing buffer to write the contents to. Params: str = The original string. transTable = The AA indicating which characters to replace and what to replace them with. toRemove = The characters to remove from the string. buffer = An output range to write the contents to. +/ void translate(C1, C2 = immutable char, Buffer)(C1[] str, in dchar[dchar] transTable, const(C2)[] toRemove, Buffer buffer) if (isSomeChar!C1 && isSomeChar!C2 && isOutputRange!(Buffer, C1)) { translateImpl(str, transTable, toRemove, buffer); } /// @safe pure unittest { import std.array : appender; dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q']; auto buffer = appender!(dchar[])(); translate("hello world", transTable1, null, buffer); assert(buffer.data == "h5ll7 w7rld"); buffer.clear(); translate("hello world", transTable1, "low", buffer); assert(buffer.data == "h5 rd"); buffer.clear(); string[dchar] transTable2 = ['e' : "5", 'o' : "orange"]; translate("hello world", transTable2, null, buffer); assert(buffer.data == "h5llorange worangerld"); } @safe pure unittest // issue 13018 { import std.array : appender; immutable dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q']; auto buffer = appender!(dchar[])(); translate("hello world", transTable1, null, buffer); assert(buffer.data == "h5ll7 w7rld"); buffer.clear(); translate("hello world", transTable1, "low", buffer); assert(buffer.data == "h5 rd"); buffer.clear(); immutable string[dchar] transTable2 = ['e' : "5", 'o' : "orange"]; translate("hello world", transTable2, null, buffer); assert(buffer.data == "h5llorange worangerld"); } /++ Ditto +/ void translate(C1, S, C2 = immutable char, Buffer)(C1[] str, in S[dchar] transTable, const(C2)[] toRemove, Buffer buffer) if (isSomeChar!C1 && isSomeString!S && isSomeChar!C2 && isOutputRange!(Buffer, S)) { translateImpl(str, transTable, toRemove, buffer); } private void translateImpl(C1, T, C2, Buffer)(C1[] str, T transTable, const(C2)[] toRemove, Buffer buffer) { bool[dchar] removeTable; foreach (dchar c; toRemove) removeTable[c] = true; foreach (dchar c; str) { if (c in removeTable) continue; auto newC = c in transTable; if (newC) put(buffer, *newC); else put(buffer, c); } } /++ This is an $(I $(RED ASCII-only)) overload of $(LREF _translate). It will $(I not) work with Unicode. It exists as an optimization for the cases where Unicode processing is not necessary. Unlike the other overloads of $(LREF _translate), this one does not take an AA. Rather, it takes a $(D string) generated by $(LREF makeTransTable). The array generated by $(D makeTransTable) is $(D 256) elements long such that the index is equal to the ASCII character being replaced and the value is equal to the character that it's being replaced with. Note that translate does not decode any of the characters, so you can actually pass it Extended ASCII characters if you want to (ASCII only actually uses $(D 128) characters), but be warned that Extended ASCII characters are not valid Unicode and therefore will result in a $(D UTFException) being thrown from most other Phobos functions. Also, because no decoding occurs, it is possible to use this overload to translate ASCII characters within a proper UTF-8 string without altering the other, non-ASCII characters. It's replacing any code unit greater than $(D 127) with another code unit or replacing any code unit with another code unit greater than $(D 127) which will cause UTF validation issues. See_Also: $(LREF tr) $(XREF array, replace) Params: str = The original string. transTable = The string indicating which characters to replace and what to replace them with. It is generated by $(LREF makeTransTable). toRemove = The characters to remove from the string. +/ C[] translate(C = immutable char)(in char[] str, in char[] transTable, in char[] toRemove = null) @trusted pure nothrow if (is(Unqual!C == char)) in { assert(transTable.length == 256); } body { bool[256] remTable = false; foreach (char c; toRemove) remTable[c] = true; size_t count = 0; foreach (char c; str) { if (!remTable[c]) ++count; } auto buffer = new char[count]; size_t i = 0; foreach (char c; str) { if (!remTable[c]) buffer[i++] = transTable[c]; } return cast(C[])(buffer); } /** * Do same thing as $(LREF makeTransTable) but allocate the translation table * on the GC heap. * * Use $(LREF makeTransTable) instead. */ string makeTrans(in char[] from, in char[] to) @trusted pure nothrow { return makeTransTable(from, to)[].idup; } /// @safe pure nothrow unittest { auto transTable1 = makeTrans("eo5", "57q"); assert(translate("hello world", transTable1) == "h5ll7 w7rld"); assert(translate("hello world", transTable1, "low") == "h5 rd"); } /******* * Construct 256 character translation table, where characters in from[] are replaced * by corresponding characters in to[]. * * Params: * from = array of chars, less than or equal to 256 in length * to = corresponding array of chars to translate to * Returns: * translation array */ char[256] makeTransTable(in char[] from, in char[] to) @safe pure nothrow @nogc in { import std.ascii : isASCII; assert(from.length == to.length); assert(from.length <= 256); foreach (char c; from) assert(std.ascii.isASCII(c)); foreach (char c; to) assert(std.ascii.isASCII(c)); } body { char[256] result = void; foreach (i; 0 .. result.length) result[i] = cast(char)i; foreach (i, c; from) result[c] = to[i]; return result; } @safe pure unittest { import std.conv : to; import std.exception; assertCTFEable!( { foreach (C; TypeTuple!(char, const char, immutable char)) { assert(translate!C("hello world", makeTransTable("hl", "q5")) == to!(C[])("qe55o wor5d")); auto s = to!(C[])("hello world"); auto transTable = makeTransTable("hl", "q5"); static assert(is(typeof(s) == typeof(translate!C(s, transTable)))); } foreach (S; TypeTuple!(char[], const(char)[], immutable(char)[])) { assert(translate(to!S("hello world"), makeTransTable("hl", "q5")) == to!S("qe55o wor5d")); assert(translate(to!S("hello \U00010143 world"), makeTransTable("hl", "q5")) == to!S("qe55o \U00010143 wor5d")); assert(translate(to!S("hello world"), makeTransTable("ol", "1o")) == to!S("heoo1 w1rod")); assert(translate(to!S("hello world"), makeTransTable("", "")) == to!S("hello world")); assert(translate(to!S("hello world"), makeTransTable("12345", "67890")) == to!S("hello world")); assert(translate(to!S("hello \U00010143 world"), makeTransTable("12345", "67890")) == to!S("hello \U00010143 world")); foreach (T; TypeTuple!(char[], const(char)[], immutable(char)[])) (){ // avoid slow optimizations for large functions @@@BUG@@@ 2396 assert(translate(to!S("hello world"), makeTransTable("hl", "q5"), to!T("r")) == to!S("qe55o wo5d")); assert(translate(to!S("hello \U00010143 world"), makeTransTable("hl", "q5"), to!T("r")) == to!S("qe55o \U00010143 wo5d")); assert(translate(to!S("hello world"), makeTransTable("hl", "q5"), to!T("helo")) == to!S(" wrd")); assert(translate(to!S("hello world"), makeTransTable("hl", "q5"), to!T("q5")) == to!S("qe55o wor5d")); }(); } }); } /++ This is an $(I $(RED ASCII-only)) overload of $(D translate) which takes an existing buffer to write the contents to. Params: str = The original string. transTable = The string indicating which characters to replace and what to replace them with. It is generated by $(LREF makeTransTable). toRemove = The characters to remove from the string. buffer = An output range to write the contents to. +/ void translate(C = immutable char, Buffer)(in char[] str, in char[] transTable, in char[] toRemove, Buffer buffer) @trusted pure if (is(Unqual!C == char) && isOutputRange!(Buffer, char)) in { assert(transTable.length == 256); } body { bool[256] remTable = false; foreach (char c; toRemove) remTable[c] = true; foreach (char c; str) { if (!remTable[c]) put(buffer, transTable[c]); } } /// @safe pure unittest { import std.array : appender; auto buffer = appender!(char[])(); auto transTable1 = makeTransTable("eo5", "57q"); translate("hello world", transTable1, null, buffer); assert(buffer.data == "h5ll7 w7rld"); buffer.clear(); translate("hello world", transTable1, "low", buffer); assert(buffer.data == "h5 rd"); } /*********************************************** * See if character c is in the pattern. * Patterns: * * A <i>pattern</i> is an array of characters much like a <i>character * class</i> in regular expressions. A sequence of characters * can be given, such as "abcde". The '-' can represent a range * of characters, as "a-e" represents the same pattern as "abcde". * "a-fA-F0-9" represents all the hex characters. * If the first character of a pattern is '^', then the pattern * is negated, i.e. "^0-9" means any character except a digit. * The functions inPattern, <b>countchars</b>, <b>removeschars</b>, * and <b>squeeze</b> * use patterns. * * Note: In the future, the pattern syntax may be improved * to be more like regular expression character classes. */ bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc if (isSomeString!S) { bool result = false; int range = 0; dchar lastc; foreach (size_t i, dchar p; pattern) { if (p == '^' && i == 0) { result = true; if (i + 1 == pattern.length) return (c == p); // or should this be an error? } else if (range) { range = 0; if (lastc <= c && c <= p || c == p) return !result; } else if (p == '-' && i > result && i + 1 < pattern.length) { range = 1; continue; } else if (c == p) return !result; lastc = p; } return result; } @safe pure @nogc unittest { import std.conv : to; debug(string) эхо("std.string.inPattern.unittest\n"); import std.exception; assertCTFEable!( { assert(inPattern('x', "x") == 1); assert(inPattern('x', "y") == 0); assert(inPattern('x', string.init) == 0); assert(inPattern('x', "^y") == 1); assert(inPattern('x', "yxxy") == 1); assert(inPattern('x', "^yxxy") == 0); assert(inPattern('x', "^abcd") == 1); assert(inPattern('^', "^^") == 0); assert(inPattern('^', "^") == 1); assert(inPattern('^', "a^") == 1); assert(inPattern('x', "a-z") == 1); assert(inPattern('x', "A-Z") == 0); assert(inPattern('x', "^a-z") == 0); assert(inPattern('x', "^A-Z") == 1); assert(inPattern('-', "a-") == 1); assert(inPattern('-', "^A-") == 0); assert(inPattern('a', "z-a") == 1); assert(inPattern('z', "z-a") == 1); assert(inPattern('x', "z-a") == 0); }); } /*********************************************** * See if character c is in the intersection of the patterns. */ bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc if (isSomeString!S) { foreach (string pattern; patterns) { if (!inPattern(c, pattern)) { return false; } } return true; } /******************************************** * Count characters in s that match pattern. */ size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc if (isSomeString!S && isSomeString!S1) { size_t count; foreach (dchar c; s) { count += inPattern(c, pattern); } return count; } @safe pure @nogc unittest { import std.conv : to; debug(string) эхо("std.string.count.unittest\n"); import std.exception; assertCTFEable!( { assert(countchars("abc", "a-c") == 3); assert(countchars("hello world", "or") == 3); }); } /******************************************** * Return string that is s with all characters removed that match pattern. */ S removechars(S)(S s, in S pattern) @safe pure if (isSomeString!S) { import std.utf : encode; Unqual!(typeof(s[0]))[] r; bool changed = false; foreach (size_t i, dchar c; s) { if (inPattern(c, pattern)) { if (!changed) { changed = true; r = s[0 .. i].dup; } continue; } if (changed) { std.utf.encode(r, c); } } if (changed) return r; else return s; } @safe pure unittest { import std.conv : to; debug(string) эхо("std.string.removechars.unittest\n"); import std.exception; assertCTFEable!( { assert(removechars("abc", "a-c").length == 0); assert(removechars("hello world", "or") == "hell wld"); assert(removechars("hello world", "d") == "hello worl"); assert(removechars("hah", "h") == "a"); }); } /*************************************************** * Return string where sequences of a character in s[] from pattern[] * are replaced with a single instance of that character. * If pattern is null, it defaults to all characters. */ S squeeze(S)(S s, in S pattern = null) { import std.utf : encode; Unqual!(typeof(s[0]))[] r; dchar lastc; size_t lasti; int run; bool changed; foreach (size_t i, dchar c; s) { if (run && lastc == c) { changed = true; } else if (pattern is null || inPattern(c, pattern)) { run = 1; if (changed) { if (r is null) r = s[0 .. lasti].dup; std.utf.encode(r, c); } else lasti = i + std.utf.stride(s, i); lastc = c; } else { run = 0; if (changed) { if (r is null) r = s[0 .. lasti].dup; std.utf.encode(r, c); } } } return changed ? ((r is null) ? s[0 .. lasti] : cast(S) r) : s; } @trusted pure unittest { import std.conv : to; debug(string) эхо("std.string.squeeze.unittest\n"); import std.exception; assertCTFEable!( { string s; assert(squeeze("hello") == "helo"); s = "abcd"; assert(squeeze(s) is s); s = "xyzz"; assert(squeeze(s).ptr == s.ptr); // should just be a slice assert(squeeze("hello goodbyee", "oe") == "hello godbye"); }); } /*************************************************************** Finds the position $(D_PARAM pos) of the first character in $(D_PARAM s) that does not match $(D_PARAM pattern) (in the terminology used by $(LINK2 std_string.html,inPattern)). Updates $(D_PARAM s = s[pos..$]). Returns the slice from the beginning of the original (before update) string up to, and excluding, $(D_PARAM pos). The $(D_PARAM munch) function is mostly convenient for skipping certain category of characters (e.g. whitespace) when parsing strings. (In such cases, the return value is not used.) */ S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc { size_t j = s.length; foreach (i, dchar c; s) { if (!inPattern(c, pattern)) { j = i; break; } } scope(exit) s = s[j .. $]; return s[0 .. j]; } /// @safe pure @nogc unittest { string s = "123abc"; string t = munch(s, "0123456789"); assert(t == "123" && s == "abc"); t = munch(s, "0123456789"); assert(t == "" && s == "abc"); } @safe pure @nogc unittest { string s = "123€abc"; string t = munch(s, "0123456789"); assert(t == "123" && s == "€abc"); t = munch(s, "0123456789"); assert(t == "" && s == "€abc"); t = munch(s, "£$€¥"); assert(t == "€" && s == "abc"); } /********************************************** * Return string that is the 'successor' to s[]. * If the rightmost character is a-zA-Z0-9, it is incremented within * its case or digits. If it generates a carry, the process is * repeated with the one to its immediate left. */ S succ(S)(S s) @safe pure if (isSomeString!S) { import std.ascii : isAlphaNum; if (s.length && std.ascii.isAlphaNum(s[$ - 1])) { auto r = s.dup; size_t i = r.length - 1; while (1) { dchar c = s[i]; dchar carry; switch (c) { case '9': c = '0'; carry = '1'; goto Lcarry; case 'z': case 'Z': c -= 'Z' - 'A'; carry = c; Lcarry: r[i] = cast(char)c; if (i == 0) { auto t = new typeof(r[0])[r.length + 1]; t[0] = cast(char) carry; t[1 .. $] = r[]; return t; } i--; break; default: if (std.ascii.isAlphaNum(c)) r[i]++; return r; } } } return s; } /// @safe pure unittest { assert(succ("1") == "2"); assert(succ("9") == "10"); assert(succ("999") == "1000"); assert(succ("zz99") == "aaa00"); } @safe pure unittest { import std.conv : to; debug(string) эхо("std.string.succ.unittest\n"); import std.exception; assertCTFEable!( { assert(succ(string.init) is null); assert(succ("!@#$%") == "!@#$%"); assert(succ("1") == "2"); assert(succ("9") == "10"); assert(succ("999") == "1000"); assert(succ("zz99") == "aaa00"); }); } /++ Replaces the characters in $(D str) which are in $(D from) with the the corresponding characters in $(D to) and returns the resulting string. $(D tr) is based on $(WEB pubs.opengroup.org/onlinepubs/9699919799/utilities/_tr.html, Posix's tr), though it doesn't do everything that the Posix utility does. Params: str = The original string. from = The characters to replace. to = The characters to replace with. modifiers = String containing modifiers. Modifiers: $(BOOKTABLE, $(TR $(TD Modifier) $(TD Description)) $(TR $(TD $(D 'c')) $(TD Complement the list of characters in $(D from))) $(TR $(TD $(D 'd')) $(TD Removes matching characters with no corresponding replacement in $(D to))) $(TR $(TD $(D 's')) $(TD Removes adjacent duplicates in the replaced characters)) ) If the modifier $(D 'd') is present, then the number of characters in $(D to) may be only $(D 0) or $(D 1). If the modifier $(D 'd') is $(I not) present, and $(D to) is empty, then $(D to) is taken to be the same as $(D from). If the modifier $(D 'd') is $(I not) present, and $(D to) is shorter than $(D from), then $(D to) is extended by replicating the last character in $(D to). Both $(D from) and $(D to) may contain ranges using the $(D '-') character (e.g. $(D "a-d") is synonymous with $(D "abcd").) Neither accept a leading $(D '^') as meaning the complement of the string (use the $(D 'c') modifier for that). +/ C1[] tr(C1, C2, C3, C4 = immutable char) (C1[] str, const(C2)[] from, const(C3)[] to, const(C4)[] modifiers = null) { import std.conv : conv_to = to; import std.utf : decode; import std.array : appender; bool mod_c; bool mod_d; bool mod_s; foreach (char c; modifiers) { switch (c) { case 'c': mod_c = 1; break; // complement case 'd': mod_d = 1; break; // delete unreplaced chars case 's': mod_s = 1; break; // squeeze duplicated replaced chars default: assert(0); } } if (to.empty && !mod_d) to = conv_to!(typeof(to))(from); auto result = appender!(C1[])(); bool modified; dchar lastc; foreach (dchar c; str) { dchar lastf; dchar lastt; dchar newc; int n = 0; for (size_t i = 0; i < from.length; ) { dchar f = std.utf.decode(from, i); if (f == '-' && lastf != dchar.init && i < from.length) { dchar nextf = std.utf.decode(from, i); if (lastf <= c && c <= nextf) { n += c - lastf - 1; if (mod_c) goto Lnotfound; goto Lfound; } n += nextf - lastf; lastf = lastf.init; continue; } if (c == f) { if (mod_c) goto Lnotfound; goto Lfound; } lastf = f; n++; } if (!mod_c) goto Lnotfound; n = 0; // consider it 'found' at position 0 Lfound: // Find the nth character in to[] dchar nextt; for (size_t i = 0; i < to.length; ) { dchar t = std.utf.decode(to, i); if (t == '-' && lastt != dchar.init && i < to.length) { nextt = std.utf.decode(to, i); n -= nextt - lastt; if (n < 0) { newc = nextt + n + 1; goto Lnewc; } lastt = dchar.init; continue; } if (n == 0) { newc = t; goto Lnewc; } lastt = t; nextt = t; n--; } if (mod_d) continue; newc = nextt; Lnewc: if (mod_s && modified && newc == lastc) continue; result.put(newc); assert(newc != dchar.init); modified = true; lastc = newc; continue; Lnotfound: result.put(c); lastc = c; modified = false; } return result.data; } unittest { import std.conv : to; debug(string) эхо("std.string.tr.unittest\n"); import std.algorithm : equal; // Complete list of test types; too slow to test'em all // alias TestTypes = TypeTuple!( // char[], const( char)[], immutable( char)[], // wchar[], const(wchar)[], immutable(wchar)[], // dchar[], const(dchar)[], immutable(dchar)[]); // Reduced list of test types alias TestTypes = TypeTuple!(char[], const(wchar)[], immutable(dchar)[]); import std.exception; assertCTFEable!( { foreach (S; TestTypes) { foreach (T; TestTypes) { foreach (U; TestTypes) { assert(equal(tr(to!S("abcdef"), to!T("cd"), to!U("CD")), "abCDef")); assert(equal(tr(to!S("abcdef"), to!T("b-d"), to!U("B-D")), "aBCDef")); assert(equal(tr(to!S("abcdefgh"), to!T("b-dh"), to!U("B-Dx")), "aBCDefgx")); assert(equal(tr(to!S("abcdefgh"), to!T("b-dh"), to!U("B-CDx")), "aBCDefgx")); assert(equal(tr(to!S("abcdefgh"), to!T("b-dh"), to!U("B-BCDx")), "aBCDefgx")); assert(equal(tr(to!S("abcdef"), to!T("ef"), to!U("*"), to!S("c")), "****ef")); assert(equal(tr(to!S("abcdef"), to!T("ef"), to!U(""), to!T("d")), "abcd")); assert(equal(tr(to!S("hello goodbye"), to!T("lo"), to!U(""), to!U("s")), "helo godbye")); assert(equal(tr(to!S("hello goodbye"), to!T("lo"), to!U("x"), "s"), "hex gxdbye")); assert(equal(tr(to!S("14-Jul-87"), to!T("a-zA-Z"), to!U(" "), "cs"), " Jul ")); assert(equal(tr(to!S("Abc"), to!T("AAA"), to!U("XYZ")), "Xbc")); } } auto s = to!S("hello world"); static assert(is(typeof(s) == typeof(tr(s, "he", "if")))); } }); } /* ************************************************ * Version : v0.3 * Author : David L. 'SpottedTiger' Davis * Date Created : 31.May.05 Compiled and Tested with dmd v0.125 * Date Modified : 01.Jun.05 Modified the function to handle the * : imaginary and complex float-point * : datatypes. * : * Licence : Public Domain / Contributed to Digital Mars */ /** * [in] string s can be formatted in the following ways: * * Integer Whole Number: * (for byte, ubyte, short, ushort, int, uint, long, and ulong) * ['+'|'-']digit(s)[U|L|UL] * * examples: 123, 123UL, 123L, +123U, -123L * * Floating-Point Number: * (for float, double, real, ifloat, idouble, and ireal) * ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]] * or [nan|nani|inf|-inf] * * examples: +123., -123.01, 123.3e-10f, 123.3e-10fi, 123.3e-10L * * (for cfloat, cdouble, and creal) * ['+'|'-']digit(s)[.][digit(s)][[e-|e+]digit(s)][+] * [digit(s)[.][digit(s)][[e-|e+]digit(s)][i|f|L|Li|fi]] * or [nan|nani|nan+nani|inf|-inf] * * examples: nan, -123e-1+456.9e-10Li, +123e+10+456i, 123+456 * * [in] bool bAllowSep * False by default, but when set to true it will accept the * separator characters $(D ',') and $(D '__') within the string, but these * characters should be stripped from the string before using any * of the conversion functions like toInt(), toFloat(), and etc * else an error will occur. * * Also please note, that no spaces are allowed within the string * anywhere whether it's a leading, trailing, or embedded space(s), * thus they too must be stripped from the string before using this * function, or any of the conversion functions. */ bool isNumeric(const(char)[] s, in bool bAllowSep = false) @safe pure { import std.algorithm : among; immutable iLen = s.length; if (iLen == 0) return false; // Check for NaN (Not a Number) and for Infinity if (s.among!((a, b) => icmp(a, b) == 0) ("nan", "nani", "nan+nani", "inf", "-inf")) return true; immutable j = s[0].among!('-', '+')() != 0; bool bDecimalPoint, bExponent, bComplex, sawDigits; for (size_t i = j; i < iLen; i++) { immutable c = s[i]; // Digits are good, continue checking // with the popFront character... ;) if (c >= '0' && c <= '9') { sawDigits = true; continue; } // Check for the complex type, and if found // reset the flags for checking the 2nd number. if (c == '+') { if (!i) return false; bDecimalPoint = false; bExponent = false; bComplex = true; sawDigits = false; continue; } // Allow only one exponent per number if (c.among!('e', 'E')()) { // A 2nd exponent found, return not a number if (bExponent || i + 1 >= iLen) return false; // Look forward for the sign, and if // missing then this is not a number. if (!s[i + 1].among!('-', '+')()) return false; bExponent = true; i++; continue; } // Allow only one decimal point per number to be used if (c == '.' ) { // A 2nd decimal point found, return not a number if (bDecimalPoint) return false; bDecimalPoint = true; continue; } // Check for ending literal characters: "f,u,l,i,ul,fi,li", // and whether they're being used with the correct datatype. if (i == iLen - 2) { if (!sawDigits) return false; // Integer Whole Number if (icmp(s[i..iLen], "ul") == 0 && (!bDecimalPoint && !bExponent && !bComplex)) return true; // Floating-Point Number if (s[i..iLen].among!((a, b) => icmp(a, b) == 0)("fi", "li") && (bDecimalPoint || bExponent || bComplex)) return true; if (icmp(s[i..iLen], "ul") == 0 && (bDecimalPoint || bExponent || bComplex)) return false; // Could be a Integer or a Float, thus // all these suffixes are valid for both return s[i..iLen].among!((a, b) => icmp(a, b) == 0) ("ul", "fi", "li") != 0; } if (i == iLen - 1) { if (!sawDigits) return false; // Integer Whole Number if (c.among!('u', 'l', 'U', 'L')() && (!bDecimalPoint && !bExponent && !bComplex)) return true; // Check to see if the last character in the string // is the required 'i' character if (bComplex) return c.among!('i', 'I')() != 0; // Floating-Point Number return c.among!('l', 'L', 'f', 'F', 'i', 'I')() != 0; } // Check if separators are allowed to be in the numeric string if (!bAllowSep || !c.among!('_', ',')()) return false; } return sawDigits; } @safe pure unittest { assert(!isNumeric("F")); assert(!isNumeric("L")); assert(!isNumeric("U")); assert(!isNumeric("i")); assert(!isNumeric("fi")); assert(!isNumeric("ul")); assert(!isNumeric("li")); assert(!isNumeric(".")); assert(!isNumeric("-")); assert(!isNumeric("+")); assert(!isNumeric("e-")); assert(!isNumeric("e+")); assert(!isNumeric(".f")); assert(!isNumeric("e+f")); } @trusted unittest { import std.conv : to; debug(string) эхо("isNumeric(in string, bool = false).unittest\n"); import std.exception; assertCTFEable!( { // Test the isNumeric(in string) function assert(isNumeric("1") == true ); assert(isNumeric("1.0") == true ); assert(isNumeric("1e-1") == true ); assert(isNumeric("12345xxxx890") == false ); assert(isNumeric("567L") == true ); assert(isNumeric("23UL") == true ); assert(isNumeric("-123..56f") == false ); assert(isNumeric("12.3.5.6") == false ); assert(isNumeric(" 12.356") == false ); assert(isNumeric("123 5.6") == false ); assert(isNumeric("1233E-1+1.0e-1i") == true ); assert(isNumeric("123.00E-5+1234.45E-12Li") == true); assert(isNumeric("123.00e-5+1234.45E-12iL") == false); assert(isNumeric("123.00e-5+1234.45e-12uL") == false); assert(isNumeric("123.00E-5+1234.45e-12lu") == false); assert(isNumeric("123fi") == true); assert(isNumeric("123li") == true); assert(isNumeric("--123L") == false); assert(isNumeric("+123.5UL") == false); assert(isNumeric("123f") == true); assert(isNumeric("123.u") == false); // @@@BUG@@ to!string(float) is not CTFEable. // Related: formatValue(T) if (is(FloatingPointTypeOf!T)) if (!__ctfe) { assert(isNumeric(to!string(real.nan)) == true); assert(isNumeric(to!string(-real.infinity)) == true); assert(isNumeric(to!string(123e+2+1234.78Li)) == true); } string s = "$250.99-"; assert(isNumeric(s[1..s.length - 2]) == true); assert(isNumeric(s) == false); assert(isNumeric(s[0..s.length - 1]) == false); }); assert(!isNumeric("-")); assert(!isNumeric("+")); } /***************************** * Soundex algorithm. * * The Soundex algorithm converts a word into 4 characters * based on how the word sounds phonetically. The idea is that * two spellings that sound alike will have the same Soundex * value, which means that Soundex can be used for fuzzy matching * of names. * * Params: * str = String or InputRange to convert to Soundex representation. * * Returns: * The four character array with the Soundex result in it. * The array has zero's in it if there is no Soundex representation for the string. * * See_Also: * $(LINK2 http://en.wikipedia.org/wiki/Soundex, Wikipedia), * $(LUCKY The Soundex Indexing System) * $(LREF soundex) * * Bugs: * Only works well with English names. * There are other arguably better Soundex algorithms, * but this one is the standard one. */ char[4] soundexer(Range)(Range str) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range) { alias C = Unqual!(ElementEncodingType!Range); static immutable dex = // ABCDEFGHIJKLMNOPQRSTUVWXYZ "01230120022455012623010202"; char[4] result = void; size_t b = 0; C lastc; foreach (C c; str) { if (c >= 'a' && c <= 'z') c -= 'a' - 'A'; else if (c >= 'A' && c <= 'Z') { } else { lastc = lastc.init; continue; } if (b == 0) { result[0] = cast(char)c; b++; lastc = dex[c - 'A']; } else { if (c == 'H' || c == 'W') continue; if (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') lastc = lastc.init; c = dex[c - 'A']; if (c != '0' && c != lastc) { result[b] = cast(char)c; b++; lastc = c; } if (b == 4) goto Lret; } } if (b == 0) result[] = 0; else result[b .. 4] = '0'; Lret: return result; } char[4] soundexer(Range)(auto ref Range str) if (isConvertibleToString!Range) { return soundexer!(StringTypeOf!Range)(str); } /***************************** * Like $(LREF soundexer), but with different parameters * and return value. * * Params: * str = String to convert to Soundex representation. * buffer = Optional 4 char array to put the resulting Soundex * characters into. If null, the return value * buffer will be allocated on the heap. * Returns: * The four character array with the Soundex result in it. * Returns null if there is no Soundex representation for the string. * See_Also: * $(LREF soundexer) */ char[] soundex(const(char)[] str, char[] buffer = null) @safe pure nothrow in { assert(!buffer.ptr || buffer.length >= 4); } out (result) { if (result.ptr) { assert(result.length == 4); assert(result[0] >= 'A' && result[0] <= 'Z'); foreach (char c; result[1 .. 4]) assert(c >= '0' && c <= '6'); } } body { char[4] result = soundexer(str); if (result[0] == 0) return null; if (!buffer.ptr) buffer = new char[4]; buffer[] = result[]; return buffer; } @safe pure nothrow unittest { import std.exception; assertCTFEable!( { char[4] buffer; assert(soundex(null) == null); assert(soundex("") == null); assert(soundex("0123^&^^**&^") == null); assert(soundex("Euler") == "E460"); assert(soundex(" Ellery ") == "E460"); assert(soundex("Gauss") == "G200"); assert(soundex("Ghosh") == "G200"); assert(soundex("Hilbert") == "H416"); assert(soundex("Heilbronn") == "H416"); assert(soundex("Knuth") == "K530"); assert(soundex("Kant", buffer) == "K530"); assert(soundex("Lloyd") == "L300"); assert(soundex("Ladd") == "L300"); assert(soundex("Lukasiewicz", buffer) == "L222"); assert(soundex("Lissajous") == "L222"); assert(soundex("Robert") == "R163"); assert(soundex("Rupert") == "R163"); assert(soundex("Rubin") == "R150"); assert(soundex("Washington") == "W252"); assert(soundex("Lee") == "L000"); assert(soundex("Gutierrez") == "G362"); assert(soundex("Pfister") == "P236"); assert(soundex("Jackson") == "J250"); assert(soundex("Tymczak") == "T522"); assert(soundex("Ashcraft") == "A261"); assert(soundex("Woo") == "W000"); assert(soundex("Pilgrim") == "P426"); assert(soundex("Flingjingwaller") == "F452"); assert(soundex("PEARSE") == "P620"); assert(soundex("PIERCE") == "P620"); assert(soundex("Price") == "P620"); assert(soundex("CATHY") == "C300"); assert(soundex("KATHY") == "K300"); assert(soundex("Jones") == "J520"); assert(soundex("johnsons") == "J525"); assert(soundex("Hardin") == "H635"); assert(soundex("Martinez") == "M635"); import std.utf; assert(soundexer("Martinez".byChar ) == "M635"); assert(soundexer("Martinez".byWchar) == "M635"); assert(soundexer("Martinez".byDchar) == "M635"); }); } unittest { assert(testAliasedString!soundexer("Martinez")); } /*************************************************** * Construct an associative array consisting of all * abbreviations that uniquely map to the strings in values. * * This is useful in cases where the user is expected to type * in one of a known set of strings, and the program will helpfully * autocomplete the string once sufficient characters have been * entered that uniquely identify it. * Example: * --- * import std.stdio; * import std.string; * * void main() * { * static string[] list = [ "food", "foxy" ]; * * auto abbrevs = std.string.abbrev(list); * * foreach (key, value; abbrevs) * { * writefln("%s => %s", key, value); * } * } * --- * produces the output: * <pre> * fox =&gt; foxy * food =&gt; food * foxy =&gt; foxy * foo =&gt; food * </pre> */ string[string] abbrev(string[] values) @safe pure { import std.algorithm : sort; string[string] result; // Make a copy when sorting so we follow COW principles. values = values.dup; sort(values); size_t values_length = values.length; size_t lasti = values_length; size_t nexti; string nv; string lv; for (size_t i = 0; i < values_length; i = nexti) { string value = values[i]; // Skip dups for (nexti = i + 1; nexti < values_length; nexti++) { nv = values[nexti]; if (value != values[nexti]) break; } for (size_t j = 0; j < value.length; j += std.utf.stride(value, j)) { string v = value[0 .. j]; if ((nexti == values_length || j > nv.length || v != nv[0 .. j]) && (lasti == values_length || j > lv.length || v != lv[0 .. j])) { result[v] = value; } } result[value] = value; lasti = i; lv = value; } return result; } @trusted pure unittest { import std.conv : to; import std.algorithm : sort; debug(string) эхо("string.abbrev.unittest\n"); import std.exception; assertCTFEable!( { string[] values; values ~= "hello"; values ~= "hello"; values ~= "he"; string[string] r; r = abbrev(values); auto keys = r.keys.dup; sort(keys); assert(keys.length == 4); assert(keys[0] == "he"); assert(keys[1] == "hel"); assert(keys[2] == "hell"); assert(keys[3] == "hello"); assert(r[keys[0]] == "he"); assert(r[keys[1]] == "hello"); assert(r[keys[2]] == "hello"); assert(r[keys[3]] == "hello"); }); } /****************************************** * Compute _column number at the end of the printed form of the string, * assuming the string starts in the leftmost _column, which is numbered * starting from 0. * * Tab characters are expanded into enough spaces to bring the _column number * to the next multiple of tabsize. * If there are multiple lines in the string, the _column number of the last * line is returned. * * Params: * str = string or InputRange to be analyzed * tabsize = number of columns a tab character represents * * Returns: * column number */ size_t column(Range)(Range str, in size_t tabsize = 8) if ((isInputRange!Range && isSomeChar!(Unqual!(ElementEncodingType!Range)) || isNarrowString!Range) && !isConvertibleToString!Range) { static if (is(Unqual!(ElementEncodingType!Range) == char)) { // decoding needed for chars import std.utf: byDchar; return str.byDchar.column(tabsize); } else { // decoding not needed for wchars and dchars import std.uni : lineSep, paraSep, nelSep; size_t column; foreach (const c; str) { switch (c) { case '\t': column = (column + tabsize) / tabsize * tabsize; break; case '\r': case '\n': case paraSep: case lineSep: case nelSep: column = 0; break; default: column++; break; } } return column; } } /// unittest { import std.utf : byChar, byWchar, byDchar; assert(column("1234 ") == 5); assert(column("1234 "w) == 5); assert(column("1234 "d) == 5); assert(column("1234 ".byChar()) == 5); assert(column("1234 "w.byWchar()) == 5); assert(column("1234 "d.byDchar()) == 5); // Tab stops are set at 8 spaces by default; tab characters insert enough // spaces to bring the column position to the next multiple of 8. assert(column("\t") == 8); assert(column("1\t") == 8); assert(column("\t1") == 9); assert(column("123\t") == 8); // Other tab widths are possible by specifying it explicitly: assert(column("\t", 4) == 4); assert(column("1\t", 4) == 4); assert(column("\t1", 4) == 5); assert(column("123\t", 4) == 4); // New lines reset the column number. assert(column("abc\n") == 0); assert(column("abc\n1") == 1); assert(column("abcdefg\r1234") == 4); assert(column("abc\u20281") == 1); assert(column("abc\u20291") == 1); assert(column("abc\u00851") == 1); assert(column("abc\u00861") == 5); } size_t column(Range)(auto ref Range str, in size_t tabsize = 8) if (isConvertibleToString!Range) { return column!(StringTypeOf!Range)(str, tabsize); } unittest { assert(testAliasedString!column("abc\u00861")); } @safe @nogc unittest { import std.conv : to; debug(string) эхо("string.column.unittest\n"); import std.exception; assertCTFEable!( { assert(column(string.init) == 0); assert(column("") == 0); assert(column("\t") == 8); assert(column("abc\t") == 8); assert(column("12345678\t") == 16); }); } /****************************************** * Wrap text into a paragraph. * * The input text string s is formed into a paragraph * by breaking it up into a sequence of lines, delineated * by \n, such that the number of columns is not exceeded * on each line. * The last line is terminated with a \n. * Params: * s = text string to be wrapped * columns = maximum number of _columns in the paragraph * firstindent = string used to _indent first line of the paragraph * indent = string to use to _indent following lines of the paragraph * tabsize = column spacing of tabs in firstindent[] and indent[] * Returns: * resulting paragraph as an allocated string */ S wrap(S)(S s, in size_t columns = 80, S firstindent = null, S indent = null, in size_t tabsize = 8) @safe pure if (isSomeString!S) { typeof(s.dup) result; bool inword; bool first = true; size_t wordstart; const indentcol = column(indent, tabsize); result.length = firstindent.length + s.length; result.length = firstindent.length; result[] = firstindent[]; auto col = column(firstindent, tabsize); foreach (size_t i, dchar c; s) { if (std.uni.isWhite(c)) { if (inword) { if (first) { } else if (col + 1 + (i - wordstart) > columns) { result ~= '\n'; result ~= indent; col = indentcol; } else { result ~= ' '; col += 1; } result ~= s[wordstart .. i]; col += i - wordstart; inword = false; first = false; } } else { if (!inword) { wordstart = i; inword = true; } } } if (inword) { if (col + 1 + (s.length - wordstart) >= columns) { result ~= '\n'; result ~= indent; } else if (result.length != firstindent.length) result ~= ' '; result ~= s[wordstart .. s.length]; } result ~= '\n'; return result; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.wrap.unittest\n"); import std.exception; assertCTFEable!( { assert(wrap(string.init) == "\n"); assert(wrap(" a b df ") == "a b df\n"); assert(wrap(" a b df ", 3) == "a b\ndf\n"); assert(wrap(" a bc df ", 3) == "a\nbc\ndf\n"); assert(wrap(" abcd df ", 3) == "abcd\ndf\n"); assert(wrap("x") == "x\n"); assert(wrap("u u") == "u u\n"); assert(wrap("abcd", 3) == "\nabcd\n"); assert(wrap("a de", 10, "\t", " ", 8) == "\ta\n de\n"); }); } /****************************************** * Removes one level of indentation from a multi-line string. * * This uniformly outdents the text as much as possible. * Whitespace-only lines are always converted to blank lines. * * Does not allocate memory if it does not throw. * * Params: * str = multi-line string * * Returns: * outdented string * * Throws: * ТкстИск if indentation is done with different sequences * of whitespace characters. */ S outdent(S)(S str) @safe pure if(isSomeString!S) { return str.splitLines(KeepTerminator.yes).outdent().join(); } /// @safe pure unittest { enum pretty = q{ import std.stdio; void main() { writeln("Hello"); } }.outdent(); enum ugly = q{ import std.stdio; void main() { writeln("Hello"); } }; assert(pretty == ugly); } /****************************************** * Removes one level of indentation from an array of single-line strings. * * This uniformly outdents the text as much as possible. * Whitespace-only lines are always converted to blank lines. * * Params: * lines = array of single-line strings * * Returns: * lines[] is rewritten in place with outdented lines * * Throws: * ТкстИск if indentation is done with different sequences * of whitespace characters. */ S[] outdent(S)(S[] lines) @safe pure if(isSomeString!S) { import std.algorithm : startsWith; if (lines.empty) { return null; } static S leadingWhiteOf(S str) { return str[ 0 .. $ - stripLeft(str).length ]; } S shortestIndent; foreach (ref line; lines) { auto stripped = line.stripLeft(); if (stripped.empty) { line = line[line.chomp().length .. $]; } else { auto indent = leadingWhiteOf(line); // Comparing number of code units instead of code points is OK here // because this function throws upon inconsistent indentation. if (shortestIndent is null || indent.length < shortestIndent.length) { if (indent.empty) return lines; shortestIndent = indent; } } } foreach (ref line; lines) { auto stripped = line.stripLeft(); if (stripped.empty) { // Do nothing } else if (line.startsWith(shortestIndent)) { line = line[shortestIndent.length .. $]; } else { throw new ТкстИск("outdent: Inconsistent indentation"); } } return lines; } @safe pure unittest { import std.conv : to; debug(string) эхо("string.outdent.unittest\n"); template outdent_testStr(S) { enum S outdent_testStr = " \t\tX \t\U00010143X \t\t \t\t\tX \t "; } template outdent_expected(S) { enum S outdent_expected = " \tX \U00010143X \t\tX "; } import std.exception; assertCTFEable!( { foreach (S; TypeTuple!(string, wstring, dstring)) { enum S blank = ""; assert(blank.outdent() == blank); static assert(blank.outdent() == blank); enum S testStr1 = " \n \t\n "; enum S expected1 = "\n\n"; assert(testStr1.outdent() == expected1); static assert(testStr1.outdent() == expected1); assert(testStr1[0..$-1].outdent() == expected1); static assert(testStr1[0..$-1].outdent() == expected1); enum S testStr2 = "a\n \t\nb"; assert(testStr2.outdent() == testStr2); static assert(testStr2.outdent() == testStr2); enum S testStr3 = " \t\tX \t\U00010143X \t\t \t\t\tX \t "; enum S expected3 = " \tX \U00010143X \t\tX "; assert(testStr3.outdent() == expected3); static assert(testStr3.outdent() == expected3); enum testStr4 = " X\r X\n X\r\n X\u2028 X\u2029 X"; enum expected4 = "X\rX\nX\r\nX\u2028X\u2029X"; assert(testStr4.outdent() == expected4); static assert(testStr4.outdent() == expected4); enum testStr5 = testStr4[0..$-1]; enum expected5 = expected4[0..$-1]; assert(testStr5.outdent() == expected5); static assert(testStr5.outdent() == expected5); enum testStr6 = " \r \n \r\n \u2028 \u2029"; enum expected6 = "\r\n\r\n\u2028\u2029"; assert(testStr6.outdent() == expected6); static assert(testStr6.outdent() == expected6); enum testStr7 = " a \n b "; enum expected7 = "a \nb "; assert(testStr7.outdent() == expected7); static assert(testStr7.outdent() == expected7); } }); } /** Assume the given array of integers $(D arr) is a well-formed UTF string and return it typed as a UTF string. $(D ubyte) becomes $(D char), $(D ushort) becomes $(D wchar) and $(D uint) becomes $(D dchar). Type qualifiers are preserved. Params: arr = array of bytes, ubytes, shorts, ushorts, ints, or uints Returns: arr retyped as an array of chars, wchars, or dchars See_Also: $(LREF representation) */ auto assumeUTF(T)(T[] arr) pure if(staticIndexOf!(Unqual!T, ubyte, ushort, uint) != -1) { import std.utf : validate; alias ToUTFType(U) = TypeTuple!(char, wchar, dchar)[U.sizeof / 2]; auto asUTF = cast(ModifyTypePreservingTQ!(ToUTFType, T)[])arr; debug validate(asUTF); return asUTF; } /// @safe pure unittest { string a = "Hölo World"; immutable(ubyte)[] b = a.representation; string c = b.assumeUTF; assert(a == c); } pure unittest { import std.algorithm : equal; foreach(T; TypeTuple!(char[], wchar[], dchar[])) { immutable T jti = "Hello World"; T jt = jti.dup; static if(is(T == char[])) { auto gt = cast(ubyte[])jt; auto gtc = cast(const(ubyte)[])jt; auto gti = cast(immutable(ubyte)[])jt; } else static if(is(T == wchar[])) { auto gt = cast(ushort[])jt; auto gtc = cast(const(ushort)[])jt; auto gti = cast(immutable(ushort)[])jt; } else static if(is(T == dchar[])) { auto gt = cast(uint[])jt; auto gtc = cast(const(uint)[])jt; auto gti = cast(immutable(uint)[])jt; } auto ht = assumeUTF(gt); auto htc = assumeUTF(gtc); auto hti = assumeUTF(gti); assert(equal(jt, ht)); assert(equal(jt, htc)); assert(equal(jt, hti)); } } +/
D
/Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Serialize.swift.o : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Serialize~partial.swiftmodule : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/JSON.build/JSON+Serialize~partial.swiftdoc : /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONRepresentable.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/Sequence+Convertible.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Parse.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Serialize.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Bytes.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSONContext.swift /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/checkouts/json.git-9153249592855998091/Sources/JSON/JSON+Fuzzy.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/ObjectiveC.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/libc.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Node.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/PathIndexable.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Debugging.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/CoreGraphics.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/IOKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CHTTP.build/module.modulemap /Users/AleixDiaz/Desktop/VaporProject/LaSalleChat/.build/x86_64-apple-macosx10.10/debug/CSQLite.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/Darwin.apinotes
D
// Written in the D programming language. /** * Contains the elementary mathematical functions (powers, roots, * and trigonometric functions), and low-level floating-point operations. * Mathematical special functions are available in `std.mathspecial`. * $(SCRIPT inhibitQuickIndex = 1;) $(DIVC quickindex, $(BOOKTABLE , $(TR $(TH Category) $(TH Members) ) $(TR $(TDNW Constants) $(TD $(MYREF E) $(MYREF PI) $(MYREF PI_2) $(MYREF PI_4) $(MYREF M_1_PI) $(MYREF M_2_PI) $(MYREF M_2_SQRTPI) $(MYREF LN10) $(MYREF LN2) $(MYREF LOG2) $(MYREF LOG2E) $(MYREF LOG2T) $(MYREF LOG10E) $(MYREF SQRT2) $(MYREF SQRT1_2) )) $(TR $(TDNW Classics) $(TD $(MYREF abs) $(MYREF fabs) $(MYREF sqrt) $(MYREF cbrt) $(MYREF hypot) $(MYREF poly) $(MYREF nextPow2) $(MYREF truncPow2) )) $(TR $(TDNW Trigonometry) $(TD $(MYREF sin) $(MYREF cos) $(MYREF tan) $(MYREF asin) $(MYREF acos) $(MYREF atan) $(MYREF atan2) $(MYREF sinh) $(MYREF cosh) $(MYREF tanh) $(MYREF asinh) $(MYREF acosh) $(MYREF atanh) $(MYREF expi) )) $(TR $(TDNW Rounding) $(TD $(MYREF ceil) $(MYREF floor) $(MYREF round) $(MYREF lround) $(MYREF trunc) $(MYREF rint) $(MYREF lrint) $(MYREF nearbyint) $(MYREF rndtol) $(MYREF quantize) )) $(TR $(TDNW Exponentiation & Logarithms) $(TD $(MYREF pow) $(MYREF exp) $(MYREF exp2) $(MYREF expm1) $(MYREF ldexp) $(MYREF frexp) $(MYREF log) $(MYREF log2) $(MYREF log10) $(MYREF logb) $(MYREF ilogb) $(MYREF log1p) $(MYREF scalbn) )) $(TR $(TDNW Modulus) $(TD $(MYREF fmod) $(MYREF modf) $(MYREF remainder) )) $(TR $(TDNW Floating-point operations) $(TD $(MYREF approxEqual) $(MYREF feqrel) $(MYREF fdim) $(MYREF fmax) $(MYREF fmin) $(MYREF fma) $(MYREF nextDown) $(MYREF nextUp) $(MYREF nextafter) $(MYREF NaN) $(MYREF getNaNPayload) $(MYREF cmp) )) $(TR $(TDNW Introspection) $(TD $(MYREF isFinite) $(MYREF isIdentical) $(MYREF isInfinity) $(MYREF isNaN) $(MYREF isNormal) $(MYREF isSubnormal) $(MYREF signbit) $(MYREF sgn) $(MYREF copysign) $(MYREF isPowerOf2) )) $(TR $(TDNW Hardware Control) $(TD $(MYREF IeeeFlags) $(MYREF FloatingPointControl) )) ) ) * The functionality closely follows the IEEE754-2008 standard for * floating-point arithmetic, including the use of camelCase names rather * than C99-style lower case names. All of these functions behave correctly * when presented with an infinity or NaN. * * The following IEEE 'real' formats are currently supported: * $(UL * $(LI 64 bit Big-endian 'double' (eg PowerPC)) * $(LI 128 bit Big-endian 'quadruple' (eg SPARC)) * $(LI 64 bit Little-endian 'double' (eg x86-SSE2)) * $(LI 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium)) * $(LI 128 bit Little-endian 'quadruple' (not implemented on any known processor!)) * $(LI Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support) * ) * Unlike C, there is no global 'errno' variable. Consequently, almost all of * these functions are pure nothrow. * * Macros: * TABLE_SV = <table border="1" cellpadding="4" cellspacing="0"> * <caption>Special Values</caption> * $0</table> * SVH = $(TR $(TH $1) $(TH $2)) * SV = $(TR $(TD $1) $(TD $2)) * TH3 = $(TR $(TH $1) $(TH $2) $(TH $3)) * TD3 = $(TR $(TD $1) $(TD $2) $(TD $3)) * TABLE_DOMRG = <table border="1" cellpadding="4" cellspacing="0"> * $(SVH Domain X, Range Y) $(SV $1, $2) * </table> * DOMAIN=$1 * RANGE=$1 * NAN = $(RED NAN) * SUP = <span style="vertical-align:super;font-size:smaller">$0</span> * GAMMA = &#915; * THETA = &theta; * INTEGRAL = &#8747; * INTEGRATE = $(BIG &#8747;<sub>$(SMALL $1)</sub><sup>$2</sup>) * POWER = $1<sup>$2</sup> * SUB = $1<sub>$2</sub> * BIGSUM = $(BIG &Sigma; <sup>$2</sup><sub>$(SMALL $1)</sub>) * CHOOSE = $(BIG &#40;) <sup>$(SMALL $1)</sup><sub>$(SMALL $2)</sub> $(BIG &#41;) * PLUSMN = &plusmn; * INFIN = &infin; * PLUSMNINF = &plusmn;&infin; * PI = &pi; * LT = &lt; * GT = &gt; * SQRT = &radic; * HALF = &frac12; * * Copyright: Copyright The D Language Foundation 2000 - 2011. * D implementations of tan, atan, atan2, exp, expm1, exp2, log, log10, log1p, * log2, floor, ceil and lrint functions are based on the CEPHES math library, * which is Copyright (C) 2001 Stephen L. Moshier $(LT)[email protected]$(GT) * and are incorporated herein by permission of the author. The author * reserves the right to distribute this material elsewhere under different * copying permissions. These modifications are distributed here under * the following terms: * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: $(HTTP digitalmars.com, Walter Bright), Don Clugston, * Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger * Source: $(PHOBOSSRC std/math.d) */ module std.math; version (Win64) { version (D_InlineAsm_X86_64) version = Win64_DMD_InlineAsm; } static import core.math; static import core.stdc.math; static import core.stdc.fenv; import std.traits : CommonType, isFloatingPoint, isIntegral, isNumeric, isSigned, isUnsigned, Largest, Unqual; version (LDC) { import ldc.intrinsics; } version (DigitalMars) { version = INLINE_YL2X; // x87 has opcodes for these } version (X86) version = X86_Any; version (X86_64) version = X86_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (AArch64) version = ARM_Any; version (ARM) version = ARM_Any; version (S390) version = IBMZ_Any; version (SPARC) version = SPARC_Any; version (SPARC64) version = SPARC_Any; version (SystemZ) version = IBMZ_Any; version (RISCV32) version = RISCV_Any; version (RISCV64) version = RISCV_Any; version (D_InlineAsm_X86) { version = InlineAsm_X86_Any; } else version (D_InlineAsm_X86_64) { version = InlineAsm_X86_Any; } version (CRuntime_Microsoft) { version (InlineAsm_X86_Any) version = MSVC_InlineAsm; } version (X86_64) version = StaticallyHaveSSE; version (X86) version (OSX) version = StaticallyHaveSSE; version (StaticallyHaveSSE) { private enum bool haveSSE = true; } else version (X86) { static import core.cpuid; private alias haveSSE = core.cpuid.sse; } version (unittest) private { static if (real.sizeof > double.sizeof) enum uint useDigits = 16; else enum uint useDigits = 15; /****************************************** * Compare floating point numbers to n decimal digits of precision. * Returns: * 1 match * 0 nomatch */ private bool equalsDigit(real x, real y, uint ndigits) @safe nothrow @nogc { import core.stdc.stdio : sprintf; if (signbit(x) != signbit(y)) return 0; if (isInfinity(x) && isInfinity(y)) return 1; if (isInfinity(x) || isInfinity(y)) return 0; if (isNaN(x) && isNaN(y)) return 1; if (isNaN(x) || isNaN(y)) return 0; char[30] bufx; char[30] bufy; assert(ndigits < bufx.length); int ix; int iy; version (CRuntime_Microsoft) alias real_t = double; else alias real_t = real; () @trusted { ix = sprintf(bufx.ptr, "%.*Lg", ndigits, cast(real_t) x); iy = sprintf(bufy.ptr, "%.*Lg", ndigits, cast(real_t) y); } (); assert(ix < bufx.length && ix > 0); assert(ix < bufy.length && ix > 0); return bufx[0 .. ix] == bufy[0 .. iy]; } } package: // The following IEEE 'real' formats are currently supported. version (LittleEndian) { static assert(real.mant_dig == 53 || real.mant_dig == 64 || real.mant_dig == 113, "Only 64-bit, 80-bit, and 128-bit reals"~ " are supported for LittleEndian CPUs"); } else { static assert(real.mant_dig == 53 || real.mant_dig == 113, "Only 64-bit and 128-bit reals are supported for BigEndian CPUs."); } // Underlying format exposed through floatTraits enum RealFormat { ieeeHalf, ieeeSingle, ieeeDouble, ieeeExtended, // x87 80-bit real ieeeExtended53, // x87 real rounded to precision of double. ibmExtended, // IBM 128-bit extended ieeeQuadruple, } // Constants used for extracting the components of the representation. // They supplement the built-in floating point properties. template floatTraits(T) { // EXPMASK is a ushort mask to select the exponent portion (without sign) // EXPSHIFT is the number of bits the exponent is left-shifted by in its ushort // EXPBIAS is the exponent bias - 1 (exp == EXPBIAS yields ×2^-1). // EXPPOS_SHORT is the index of the exponent when represented as a ushort array. // SIGNPOS_BYTE is the index of the sign when represented as a ubyte array. // RECIP_EPSILON is the value such that (smallest_subnormal) * RECIP_EPSILON == T.min_normal enum T RECIP_EPSILON = (1/T.epsilon); static if (T.mant_dig == 24) { // Single precision float enum ushort EXPMASK = 0x7F80; enum ushort EXPSHIFT = 7; enum ushort EXPBIAS = 0x3F00; enum uint EXPMASK_INT = 0x7F80_0000; enum uint MANTISSAMASK_INT = 0x007F_FFFF; enum realFormat = RealFormat.ieeeSingle; version (LittleEndian) { enum EXPPOS_SHORT = 1; enum SIGNPOS_BYTE = 3; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 53) { static if (T.sizeof == 8) { // Double precision float, or real == double enum ushort EXPMASK = 0x7FF0; enum ushort EXPSHIFT = 4; enum ushort EXPBIAS = 0x3FE0; enum uint EXPMASK_INT = 0x7FF0_0000; enum uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only enum realFormat = RealFormat.ieeeDouble; version (LittleEndian) { enum EXPPOS_SHORT = 3; enum SIGNPOS_BYTE = 7; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.sizeof == 12) { // Intel extended real80 rounded to double enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended53; version (LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static assert(false, "No traits support for " ~ T.stringof); } else static if (T.mant_dig == 64) { // Intel extended real80 enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeExtended; version (LittleEndian) { enum EXPPOS_SHORT = 4; enum SIGNPOS_BYTE = 9; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 113) { // Quadruple precision float enum ushort EXPMASK = 0x7FFF; enum ushort EXPSHIFT = 0; enum ushort EXPBIAS = 0x3FFE; enum realFormat = RealFormat.ieeeQuadruple; version (LittleEndian) { enum EXPPOS_SHORT = 7; enum SIGNPOS_BYTE = 15; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static if (T.mant_dig == 106) { // IBM Extended doubledouble enum ushort EXPMASK = 0x7FF0; enum ushort EXPSHIFT = 4; enum realFormat = RealFormat.ibmExtended; // For IBM doubledouble the larger magnitude double comes first. // It's really a double[2] and arrays don't index differently // between little and big-endian targets. enum DOUBLEPAIR_MSB = 0; enum DOUBLEPAIR_LSB = 1; // The exponent/sign byte is for most significant part. version (LittleEndian) { enum EXPPOS_SHORT = 3; enum SIGNPOS_BYTE = 7; } else { enum EXPPOS_SHORT = 0; enum SIGNPOS_BYTE = 0; } } else static assert(false, "No traits support for " ~ T.stringof); } // These apply to all floating-point types version (LittleEndian) { enum MANTISSA_LSB = 0; enum MANTISSA_MSB = 1; } else { enum MANTISSA_LSB = 1; enum MANTISSA_MSB = 0; } // Common code for math implementations. // Helper for floor/ceil T floorImpl(T)(const T x) @trusted pure nothrow @nogc { alias F = floatTraits!(T); // Take care not to trigger library calls from the compiler, // while ensuring that we don't get defeated by some optimizers. union floatBits { T rv; ushort[T.sizeof/2] vu; // Other kinds of extractors for real formats. static if (F.realFormat == RealFormat.ieeeSingle) int vi; } floatBits y = void; y.rv = x; // Find the exponent (power of 2) // Do this by shifting the raw value so that the exponent lies in the low bits, // then mask out the sign bit, and subtract the bias. static if (F.realFormat == RealFormat.ieeeSingle) { int exp = ((y.vi >> (T.mant_dig - 1)) & 0xff) - 0x7f; } else static if (F.realFormat == RealFormat.ieeeDouble) { int exp = ((y.vu[F.EXPPOS_SHORT] >> 4) & 0x7ff) - 0x3ff; version (LittleEndian) int pos = 0; else int pos = 3; } else static if (F.realFormat == RealFormat.ieeeExtended) { int exp = (y.vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) int pos = 0; else int pos = 4; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { int exp = (y.vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) int pos = 0; else int pos = 7; } else static assert(false, "Not implemented for this architecture"); if (exp < 0) { if (x < 0.0) return -1.0; else return 0.0; } static if (F.realFormat == RealFormat.ieeeSingle) { if (exp < (T.mant_dig - 1)) { // Clear all bits representing the fraction part. const uint fraction_mask = F.MANTISSAMASK_INT >> exp; if ((y.vi & fraction_mask) != 0) { // If 'x' is negative, then first substract 1.0 from the value. if (y.vi < 0) y.vi += 0x00800000 >> exp; y.vi &= ~fraction_mask; } } } else { exp = (T.mant_dig - 1) - exp; // Zero 16 bits at a time. while (exp >= 16) { version (LittleEndian) y.vu[pos++] = 0; else y.vu[pos--] = 0; exp -= 16; } // Clear the remaining bits. if (exp > 0) y.vu[pos] &= 0xffff ^ ((1 << exp) - 1); if ((x < 0.0) && (x != y.rv)) y.rv -= 1.0; } return y.rv; } public: // Values obtained from Wolfram Alpha. 116 bits ought to be enough for anybody. // Wolfram Alpha LLC. 2011. Wolfram|Alpha. http://www.wolframalpha.com/input/?i=e+in+base+16 (access July 6, 2011). enum real E = 0x1.5bf0a8b1457695355fb8ac404e7a8p+1L; /** e = 2.718281... */ enum real LOG2T = 0x1.a934f0979a3715fc9257edfe9b5fbp+1L; /** $(SUB log, 2)10 = 3.321928... */ enum real LOG2E = 0x1.71547652b82fe1777d0ffda0d23a8p+0L; /** $(SUB log, 2)e = 1.442695... */ enum real LOG2 = 0x1.34413509f79fef311f12b35816f92p-2L; /** $(SUB log, 10)2 = 0.301029... */ enum real LOG10E = 0x1.bcb7b1526e50e32a6ab7555f5a67cp-2L; /** $(SUB log, 10)e = 0.434294... */ enum real LN2 = 0x1.62e42fefa39ef35793c7673007e5fp-1L; /** ln 2 = 0.693147... */ enum real LN10 = 0x1.26bb1bbb5551582dd4adac5705a61p+1L; /** ln 10 = 2.302585... */ enum real PI = 0x1.921fb54442d18469898cc51701b84p+1L; /** &pi; = 3.141592... */ enum real PI_2 = PI/2; /** $(PI) / 2 = 1.570796... */ enum real PI_4 = PI/4; /** $(PI) / 4 = 0.785398... */ enum real M_1_PI = 0x1.45f306dc9c882a53f84eafa3ea69cp-2L; /** 1 / $(PI) = 0.318309... */ enum real M_2_PI = 2*M_1_PI; /** 2 / $(PI) = 0.636619... */ enum real M_2_SQRTPI = 0x1.20dd750429b6d11ae3a914fed7fd8p+0L; /** 2 / $(SQRT)$(PI) = 1.128379... */ enum real SQRT2 = 0x1.6a09e667f3bcc908b2fb1366ea958p+0L; /** $(SQRT)2 = 1.414213... */ enum real SQRT1_2 = SQRT2/2; /** $(SQRT)$(HALF) = 0.707106... */ // Note: Make sure the magic numbers in compiler backend for x87 match these. // it's quite tricky check for a type who will trigger a deprecation when accessed template isDeprecatedComplex(T) { static if (__traits(isDeprecated, T)) { enum isDeprecatedComplex = true; } else { enum m = T.mangleof; // cfloat, cdouble, creal // ifloat, idouble, ireal enum isDeprecatedComplex = m == "q" || m == "r" || m == "c" || m == "o" || m == "p" || m == "j"; } } @safe deprecated unittest { static assert(isDeprecatedComplex!cfloat); static assert(isDeprecatedComplex!cdouble); static assert(isDeprecatedComplex!creal); static assert(isDeprecatedComplex!ifloat); static assert(isDeprecatedComplex!idouble); static assert(isDeprecatedComplex!ireal); static assert(!isDeprecatedComplex!float); static assert(!isDeprecatedComplex!double); static assert(!isDeprecatedComplex!real); } /*********************************** * Calculates the absolute value of a number * * Params: * Num = (template parameter) type of number * x = real number value * * Returns: * The absolute value of the number. If floating-point or integral, * the return type will be the same as the input; */ auto abs(Num)(Num x) if ((is(Unqual!Num == short) || is(Unqual!Num == byte)) || (is(typeof(Num.init >= 0)) && is(typeof(-Num.init)))) { static if (isFloatingPoint!(Num)) return fabs(x); else { static if (is(Unqual!Num == short) || is(Unqual!Num == byte)) return x >= 0 ? x : cast(Num) -int(x); else return x >= 0 ? x : -x; } } /// ditto @safe pure nothrow @nogc unittest { assert(isIdentical(abs(-0.0L), 0.0L)); assert(isNaN(abs(real.nan))); assert(abs(-real.infinity) == real.infinity); assert(abs(-56) == 56); assert(abs(2321312L) == 2321312L); } version (TestComplex) deprecated @safe pure nothrow @nogc unittest { assert(abs(-3.2Li) == 3.2L); assert(abs(71.6Li) == 71.6L); assert(abs(-1L+1i) == sqrt(2.0L)); } @safe pure nothrow @nogc unittest { short s = -8; byte b = -8; assert(abs(s) == 8); assert(abs(b) == 8); immutable(byte) c = -8; assert(abs(c) == 8); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ T f = 3; assert(abs(f) == f); assert(abs(-f) == f); }} } version (TestComplex) deprecated @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(cfloat, cdouble, creal)) {{ T f = -12+3i; assert(abs(f) == hypot(f.re, f.im)); assert(abs(-f) == hypot(f.re, f.im)); }} } import std.meta : AliasSeq; deprecated("Please use std.complex") static foreach (Num; AliasSeq!(cfloat, cdouble, creal, ifloat, idouble, ireal)) { auto abs(Num z) @safe pure nothrow @nogc { enum m = Num.mangleof; // cfloat, cdouble, creal static if (m == "q" || m == "r" || m == "c") return hypot(z.re, z.im); // ifloat, idouble, ireal else static if (m == "o" || m == "p" || m == "j") return fabs(z.im); else static assert(0, "Unsupported type: " ~ Num.stringof); } } // https://issues.dlang.org/show_bug.cgi?id=19162 @safe unittest { struct Vector(T, int size) { T x, y, z; } static auto abs(T, int size)(auto ref const Vector!(T, size) v) { return v; } Vector!(int, 3) v; assert(abs(v) == v); } /* * Complex conjugate * * conj(x + iy) = x - iy * * Note that z * conj(z) = $(POWER z.re, 2) - $(POWER z.im, 2) * is always a real number */ deprecated("Please use std.complex.conj") auto conj(Num)(Num z) @safe pure nothrow @nogc if (is(Num* : const(cfloat*)) || is(Num* : const(cdouble*)) || is(Num* : const(creal*))) { //FIXME //Issue 14206 static if (is(Num* : const(cdouble*))) return cast(cdouble) conj(cast(creal) z); else return z.re - z.im*1fi; } deprecated("Please use std.complex.conj") auto conj(Num)(Num y) @safe pure nothrow @nogc if (is(Num* : const(ifloat*)) || is(Num* : const(idouble*)) || is(Num* : const(ireal*))) { return -y; } deprecated @safe pure nothrow @nogc unittest { creal c = 7 + 3Li; assert(conj(c) == 7-3Li); ireal z = -3.2Li; assert(conj(z) == -z); } //Issue 14206 deprecated @safe pure nothrow @nogc unittest { cdouble c = 7 + 3i; assert(conj(c) == 7-3i); idouble z = -3.2i; assert(conj(z) == -z); } //Issue 14206 deprecated @safe pure nothrow @nogc unittest { cfloat c = 7f + 3fi; assert(conj(c) == 7f-3fi); ifloat z = -3.2fi; assert(conj(z) == -z); } /*********************************** * Returns cosine of x. x is in radians. * * $(TABLE_SV * $(TR $(TH x) $(TH cos(x)) $(TH invalid?)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) $(TD yes) ) * ) * Bugs: * Results are undefined if |x| >= $(POWER 2,64). */ real cos(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.cos(x); } //FIXME ///ditto double cos(double x) @safe pure nothrow @nogc { return cos(cast(real) x); } //FIXME ///ditto float cos(float x) @safe pure nothrow @nogc { return cos(cast(real) x); } /// @safe unittest { assert(cos(0.0) == 1.0); assert(cos(1.0).approxEqual(0.540)); assert(cos(3.0).approxEqual(-0.989)); } @safe unittest { real function(real) pcos = &cos; assert(pcos != null); } /*********************************** * Returns $(HTTP en.wikipedia.org/wiki/Sine, sine) of x. x is in $(HTTP en.wikipedia.org/wiki/Radian, radians). * * $(TABLE_SV * $(TH3 x , sin(x) , invalid?) * $(TD3 $(NAN) , $(NAN) , yes ) * $(TD3 $(PLUSMN)0.0, $(PLUSMN)0.0, no ) * $(TD3 $(PLUSMNINF), $(NAN) , yes ) * ) * * Params: * x = angle in radians (not degrees) * Returns: * sine of x * See_Also: * $(MYREF cos), $(MYREF tan), $(MYREF asin) * Bugs: * Results are undefined if |x| >= $(POWER 2,64). */ real sin(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.sin(x); } //FIXME ///ditto double sin(double x) @safe pure nothrow @nogc { return sin(cast(real) x); } //FIXME ///ditto float sin(float x) @safe pure nothrow @nogc { return sin(cast(real) x); } /// @safe unittest { import std.math : sin, PI; import std.stdio : writefln; void someFunc() { real x = 30.0; auto result = sin(x * (PI / 180)); // convert degrees to radians writefln("The sine of %s degrees is %s", x, result); } } @safe unittest { real function(real) psin = &sin; assert(psin != null); } /* * Returns sine for complex and imaginary arguments. * * sin(z) = sin(z.re)*cosh(z.im) + cos(z.re)*sinh(z.im)i * * If both sin($(THETA)) and cos($(THETA)) are required, * it is most efficient to use expi($(THETA)). */ deprecated("Use std.complex.sin") auto sin(creal z) @safe pure nothrow @nogc { const creal cs = expi(z.re); const creal csh = coshisinh(z.im); return cs.im * csh.re + cs.re * csh.im * 1i; } /* ditto */ deprecated("Use std.complex.sin") auto sin(ireal y) @safe pure nothrow @nogc { return cosh(y.im)*1i; } deprecated @safe pure nothrow @nogc unittest { assert(sin(0.0+0.0i) == 0.0); assert(sin(2.0+0.0i) == sin(2.0L) ); } /* * cosine, complex and imaginary * * cos(z) = cos(z.re)*cosh(z.im) - sin(z.re)*sinh(z.im)i */ deprecated("Use std.complex.cos") auto cos(creal z) @safe pure nothrow @nogc { const creal cs = expi(z.re); const creal csh = coshisinh(z.im); return cs.re * csh.re - cs.im * csh.im * 1i; } /* ditto */ deprecated("Use std.complex.cos") real cos(ireal y) @safe pure nothrow @nogc { return cosh(y.im); } deprecated @safe pure nothrow @nogc unittest { assert(cos(0.0+0.0i)==1.0); assert(cos(1.3L+0.0i)==cos(1.3L)); assert(cos(5.2Li)== cosh(5.2L)); } /**************************************************************************** * Returns tangent of x. x is in radians. * * $(TABLE_SV * $(TR $(TH x) $(TH tan(x)) $(TH invalid?)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD $(NAN)) $(TD yes)) * ) */ real tan(real x) @trusted pure nothrow @nogc // TODO: @safe { version (InlineAsm_X86_Any) { if (!__ctfe) return tanAsm(x); } return tanImpl(x); } /// ditto double tan(double x) @safe pure nothrow @nogc { return __ctfe ? cast(double) tan(cast(real) x) : tanImpl(x); } /// ditto float tan(float x) @safe pure nothrow @nogc { return __ctfe ? cast(float) tan(cast(real) x) : tanImpl(x); } /// @safe unittest { assert(isIdentical(tan(0.0), 0.0)); assert(tan(PI).approxEqual(0)); assert(tan(PI / 3).approxEqual(sqrt(3.0))); } version (InlineAsm_X86_Any) private real tanAsm(real x) @trusted pure nothrow @nogc { version (D_InlineAsm_X86) { asm pure nothrow @nogc { fld x[EBP] ; // load theta fxam ; // test for oddball values fstsw AX ; sahf ; jc trigerr ; // x is NAN, infinity, or empty // 387's can handle subnormals SC18: fptan ; fstsw AX ; sahf ; jnp Clear1 ; // C2 = 1 (x is out of range) // Do argument reduction to bring x into range fldpi ; fxch ; SC17: fprem1 ; fstsw AX ; sahf ; jp SC17 ; fstp ST(1) ; // remove pi from stack jmp SC18 ; trigerr: jnp Lret ; // if theta is NAN, return theta fstp ST(0) ; // dump theta } return real.nan; Clear1: asm pure nothrow @nogc{ fstp ST(0) ; // dump X, which is always 1 } Lret: {} } else version (D_InlineAsm_X86_64) { version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX] ; // load theta } } else { asm pure nothrow @nogc { fld x[RBP] ; // load theta } } asm pure nothrow @nogc { fxam ; // test for oddball values fstsw AX ; test AH,1 ; jnz trigerr ; // x is NAN, infinity, or empty // 387's can handle subnormals SC18: fptan ; fstsw AX ; test AH,4 ; jz Clear1 ; // C2 = 1 (x is out of range) // Do argument reduction to bring x into range fldpi ; fxch ; SC17: fprem1 ; fstsw AX ; test AH,4 ; jnz SC17 ; fstp ST(1) ; // remove pi from stack jmp SC18 ; trigerr: test AH,4 ; jz Lret ; // if theta is NAN, return theta fstp ST(0) ; // dump theta } return real.nan; Clear1: asm pure nothrow @nogc{ fstp ST(0) ; // dump X, which is always 1 } Lret: {} } else static assert(0); } private T tanImpl(T)(T x) @safe pure nothrow @nogc { // Coefficients for tan(x) and PI/4 split into three parts. enum realFormat = floatTraits!T.realFormat; static if (realFormat == RealFormat.ieeeQuadruple) { static immutable T[6] P = [ 2.883414728874239697964612246732416606301E10L, -2.307030822693734879744223131873392503321E9L, 5.160188250214037865511600561074819366815E7L, -4.249691853501233575668486667664718192660E5L, 1.272297782199996882828849455156962260810E3L, -9.889929415807650724957118893791829849557E-1L ]; static immutable T[7] Q = [ 8.650244186622719093893836740197250197602E10L, -4.152206921457208101480801635640958361612E10L, 2.758476078803232151774723646710890525496E9L, -5.733709132766856723608447733926138506824E7L, 4.529422062441341616231663543669583527923E5L, -1.317243702830553658702531997959756728291E3L, 1.0 ]; enum T P1 = 7.853981633974483067550664827649598009884357452392578125E-1L; enum T P2 = 2.8605943630549158983813312792950660807511260829685741796657E-18L; enum T P3 = 2.1679525325309452561992610065108379921905808E-35L; } else static if (realFormat == RealFormat.ieeeExtended || realFormat == RealFormat.ieeeDouble) { static immutable T[3] P = [ -1.7956525197648487798769E7L, 1.1535166483858741613983E6L, -1.3093693918138377764608E4L, ]; static immutable T[5] Q = [ -5.3869575592945462988123E7L, 2.5008380182335791583922E7L, -1.3208923444021096744731E6L, 1.3681296347069295467845E4L, 1.0000000000000000000000E0L, ]; enum T P1 = 7.853981554508209228515625E-1L; enum T P2 = 7.946627356147928367136046290398E-9L; enum T P3 = 3.061616997868382943065164830688E-17L; } else static if (realFormat == RealFormat.ieeeSingle) { static immutable T[6] P = [ 3.33331568548E-1, 1.33387994085E-1, 5.34112807005E-2, 2.44301354525E-2, 3.11992232697E-3, 9.38540185543E-3, ]; enum T P1 = 0.78515625; enum T P2 = 2.4187564849853515625E-4; enum T P3 = 3.77489497744594108E-8; } else static assert(0, "no coefficients for tan()"); // Special cases. if (x == cast(T) 0.0 || isNaN(x)) return x; if (isInfinity(x)) return T.nan; // Make argument positive but save the sign. bool sign = false; if (signbit(x)) { sign = true; x = -x; } // Compute x mod PI/4. static if (realFormat == RealFormat.ieeeSingle) { enum T FOPI = 4 / PI; int j = cast(int) (FOPI * x); T y = j; T z; } else { T y = floor(x / cast(T) PI_4); // Strip high bits of integer part. enum T highBitsFactor = (realFormat == RealFormat.ieeeDouble ? 0x1p3 : 0x1p4); enum T highBitsInv = 1.0 / highBitsFactor; T z = y * highBitsInv; // Compute y - 2^numHighBits * (y / 2^numHighBits). z = y - highBitsFactor * floor(z); // Integer and fraction part modulo one octant. int j = cast(int)(z); } // Map zeros and singularities to origin. if (j & 1) { j += 1; y += cast(T) 1.0; } z = ((x - y * P1) - y * P2) - y * P3; const T zz = z * z; enum T zzThreshold = (realFormat == RealFormat.ieeeSingle ? 1.0e-4L : realFormat == RealFormat.ieeeDouble ? 1.0e-14L : 1.0e-20L); if (zz > zzThreshold) { static if (realFormat == RealFormat.ieeeSingle) y = z + z * (zz * poly(zz, P)); else y = z + z * (zz * poly(zz, P) / poly(zz, Q)); } else y = z; if (j & 2) y = (cast(T) -1.0) / y; return (sign) ? -y : y; } @safe @nogc nothrow unittest { static void testTan(T)() { // ±0 const T zero = 0.0; assert(isIdentical(tan(zero), zero)); assert(isIdentical(tan(-zero), -zero)); // ±∞ const T inf = T.infinity; assert(isNaN(tan(inf))); assert(isNaN(tan(-inf))); // NaN const T specialNaN = NaN(0x0123L); assert(isIdentical(tan(specialNaN), specialNaN)); static immutable T[2][] vals = [ // angle, tan [ .5, .5463024898], [ 1, 1.557407725], [ 1.5, 14.10141995], [ 2, -2.185039863], [ 2.5,-.7470222972], [ 3, -.1425465431], [ 3.5, .3745856402], [ 4, 1.157821282], [ 4.5, 4.637332055], [ 5, -3.380515006], [ 5.5,-.9955840522], [ 6, -.2910061914], [ 6.5, .2202772003], [ 10, .6483608275], // special angles [ PI_4, 1], //[ PI_2, T.infinity], // PI_2 is not _exactly_ pi/2. [ 3*PI_4, -1], [ PI, 0], [ 5*PI_4, 1], //[ 3*PI_2, -T.infinity], [ 7*PI_4, -1], [ 2*PI, 0], ]; foreach (ref val; vals) { T x = val[0]; T r = val[1]; T t = tan(x); //printf("tan(%Lg) = %Lg, should be %Lg\n", cast(real) x, cast(real) t, cast(real) r); assert(approxEqual(r, t)); x = -x; r = -r; t = tan(x); //printf("tan(%Lg) = %Lg, should be %Lg\n", cast(real) x, cast(real) t, cast(real) r); assert(approxEqual(r, t)); } } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double, float)) testTan!T(); assert(equalsDigit(tan(PI / 3), std.math.sqrt(3.0L), useDigits)); } /*************** * Calculates the arc cosine of x, * returning a value ranging from 0 to $(PI). * * $(TABLE_SV * $(TR $(TH x) $(TH acos(x)) $(TH invalid?)) * $(TR $(TD $(GT)1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes)) * ) */ real acos(real x) @safe pure nothrow @nogc { return atan2(sqrt(1-x*x), x); } /// ditto double acos(double x) @safe pure nothrow @nogc { return acos(cast(real) x); } /// ditto float acos(float x) @safe pure nothrow @nogc { return acos(cast(real) x); } /// @safe unittest { assert(acos(0.0).approxEqual(1.570)); assert(acos(0.5).approxEqual(std.math.PI / 3)); assert(acos(PI).isNaN); } @safe @nogc nothrow unittest { assert(equalsDigit(acos(0.5), std.math.PI / 3, useDigits)); } /*************** * Calculates the arc sine of x, * returning a value ranging from -$(PI)/2 to $(PI)/2. * * $(TABLE_SV * $(TR $(TH x) $(TH asin(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(GT)1.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD $(LT)-1.0) $(TD $(NAN)) $(TD yes)) * ) */ real asin(real x) @safe pure nothrow @nogc { return atan2(x, sqrt(1-x*x)); } /// ditto double asin(double x) @safe pure nothrow @nogc { return asin(cast(real) x); } /// ditto float asin(float x) @safe pure nothrow @nogc { return asin(cast(real) x); } /// @safe unittest { assert(isIdentical(asin(0.0), 0.0)); assert(asin(0.5).approxEqual(PI / 6)); assert(asin(PI).isNaN); } @safe @nogc nothrow unittest { assert(equalsDigit(asin(0.5), PI / 6, useDigits)); } /*************** * Calculates the arc tangent of x, * returning a value ranging from -$(PI)/2 to $(PI)/2. * * $(TABLE_SV * $(TR $(TH x) $(TH atan(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(NAN)) $(TD yes)) * ) */ real atan(real x) @safe pure nothrow @nogc { version (InlineAsm_X86_Any) { if (!__ctfe) return atan2Asm(x, 1.0L); } return atanImpl(x); } /// ditto double atan(double x) @safe pure nothrow @nogc { return __ctfe ? cast(double) atan(cast(real) x) : atanImpl(x); } /// ditto float atan(float x) @safe pure nothrow @nogc { return __ctfe ? cast(float) atan(cast(real) x) : atanImpl(x); } /// @safe unittest { assert(isIdentical(atan(0.0), 0.0)); assert(atan(sqrt(3.0)).approxEqual(PI / 3)); } private T atanImpl(T)(T x) @safe pure nothrow @nogc { // Coefficients for atan(x) enum realFormat = floatTraits!T.realFormat; static if (realFormat == RealFormat.ieeeQuadruple) { static immutable T[9] P = [ -6.880597774405940432145577545328795037141E2L, -2.514829758941713674909996882101723647996E3L, -3.696264445691821235400930243493001671932E3L, -2.792272753241044941703278827346430350236E3L, -1.148164399808514330375280133523543970854E3L, -2.497759878476618348858065206895055957104E2L, -2.548067867495502632615671450650071218995E1L, -8.768423468036849091777415076702113400070E-1L, -6.635810778635296712545011270011752799963E-4L ]; static immutable T[9] Q = [ 2.064179332321782129643673263598686441900E3L, 8.782996876218210302516194604424986107121E3L, 1.547394317752562611786521896296215170819E4L, 1.458510242529987155225086911411015961174E4L, 7.928572347062145288093560392463784743935E3L, 2.494680540950601626662048893678584497900E3L, 4.308348370818927353321556740027020068897E2L, 3.566239794444800849656497338030115886153E1L, 1.0 ]; } else static if (realFormat == RealFormat.ieeeExtended) { static immutable T[5] P = [ -5.0894116899623603312185E1L, -9.9988763777265819915721E1L, -6.3976888655834347413154E1L, -1.4683508633175792446076E1L, -8.6863818178092187535440E-1L, ]; static immutable T[6] Q = [ 1.5268235069887081006606E2L, 3.9157570175111990631099E2L, 3.6144079386152023162701E2L, 1.4399096122250781605352E2L, 2.2981886733594175366172E1L, 1.0000000000000000000000E0L, ]; } else static if (realFormat == RealFormat.ieeeDouble) { static immutable T[5] P = [ -6.485021904942025371773E1L, -1.228866684490136173410E2L, -7.500855792314704667340E1L, -1.615753718733365076637E1L, -8.750608600031904122785E-1L, ]; static immutable T[6] Q = [ 1.945506571482613964425E2L, 4.853903996359136964868E2L, 4.328810604912902668951E2L, 1.650270098316988542046E2L, 2.485846490142306297962E1L, 1.000000000000000000000E0L, ]; enum T MOREBITS = 6.123233995736765886130E-17L; } else static if (realFormat == RealFormat.ieeeSingle) { static immutable T[4] P = [ -3.33329491539E-1, 1.99777106478E-1, -1.38776856032E-1, 8.05374449538E-2, ]; } else static assert(0, "no coefficients for atan()"); // tan(PI/8) enum T TAN_PI_8 = 0.414213562373095048801688724209698078569672L; // tan(3 * PI/8) enum T TAN3_PI_8 = 2.414213562373095048801688724209698078569672L; // Special cases. if (x == cast(T) 0.0) return x; if (isInfinity(x)) return copysign(cast(T) PI_2, x); // Make argument positive but save the sign. bool sign = false; if (signbit(x)) { sign = true; x = -x; } static if (realFormat == RealFormat.ieeeDouble) // special case for double precision { short flag = 0; T y; if (x > TAN3_PI_8) { y = PI_2; flag = 1; x = -(1.0 / x); } else if (x <= 0.66) { y = 0.0; } else { y = PI_4; flag = 2; x = (x - 1.0)/(x + 1.0); } T z = x * x; z = z * poly(z, P) / poly(z, Q); z = x * z + x; if (flag == 2) z += 0.5 * MOREBITS; else if (flag == 1) z += MOREBITS; y = y + z; } else { // Range reduction. T y; if (x > TAN3_PI_8) { y = PI_2; x = -((cast(T) 1.0) / x); } else if (x > TAN_PI_8) { y = PI_4; x = (x - cast(T) 1.0)/(x + cast(T) 1.0); } else y = 0.0; // Rational form in x^^2. const T z = x * x; static if (realFormat == RealFormat.ieeeSingle) y += poly(z, P) * z * x + x; else y = y + (poly(z, P) / poly(z, Q)) * z * x + x; } return (sign) ? -y : y; } @safe @nogc nothrow unittest { static void testAtan(T)() { // ±0 const T zero = 0.0; assert(isIdentical(atan(zero), zero)); assert(isIdentical(atan(-zero), -zero)); // ±∞ const T inf = T.infinity; assert(approxEqual(atan(inf), cast(T) PI_2)); assert(approxEqual(atan(-inf), cast(T) -PI_2)); // NaN const T specialNaN = NaN(0x0123L); assert(isIdentical(atan(specialNaN), specialNaN)); static immutable T[2][] vals = [ // x, atan(x) [ 0.25, 0.2449786631 ], [ 0.5, 0.4636476090 ], [ 1, PI_4 ], [ 1.5, 0.9827937232 ], [ 10, 1.4711276743 ], ]; foreach (ref val; vals) { T x = val[0]; T r = val[1]; T a = atan(x); //printf("atan(%Lg) = %Lg, should be %Lg\n", cast(real) x, cast(real) a, cast(real) r); assert(approxEqual(r, a)); x = -x; r = -r; a = atan(x); //printf("atan(%Lg) = %Lg, should be %Lg\n", cast(real) x, cast(real) a, cast(real) r); assert(approxEqual(r, a)); } } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double, float)) testAtan!T(); assert(equalsDigit(atan(std.math.sqrt(3.0L)), PI / 3, useDigits)); } /*************** * Calculates the arc tangent of y / x, * returning a value ranging from -$(PI) to $(PI). * * $(TABLE_SV * $(TR $(TH y) $(TH x) $(TH atan(y, x))) * $(TR $(TD $(NAN)) $(TD anything) $(TD $(NAN)) ) * $(TR $(TD anything) $(TD $(NAN)) $(TD $(NAN)) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(GT)0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)0.0) $(TD +0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(LT)0.0) $(TD $(PLUSMN)$(PI))) * $(TR $(TD $(PLUSMN)0.0) $(TD -0.0) $(TD $(PLUSMN)$(PI))) * $(TR $(TD $(GT)0.0) $(TD $(PLUSMN)0.0) $(TD $(PI)/2) ) * $(TR $(TD $(LT)0.0) $(TD $(PLUSMN)0.0) $(TD -$(PI)/2) ) * $(TR $(TD $(GT)0.0) $(TD $(INFIN)) $(TD $(PLUSMN)0.0) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD anything) $(TD $(PLUSMN)$(PI)/2)) * $(TR $(TD $(GT)0.0) $(TD -$(INFIN)) $(TD $(PLUSMN)$(PI)) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(INFIN)) $(TD $(PLUSMN)$(PI)/4)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD -$(INFIN)) $(TD $(PLUSMN)3$(PI)/4)) * ) */ real atan2(real y, real x) @trusted pure nothrow @nogc // TODO: @safe { version (InlineAsm_X86_Any) { if (!__ctfe) return atan2Asm(y, x); } return atan2Impl(y, x); } /// ditto double atan2(double y, double x) @safe pure nothrow @nogc { return __ctfe ? cast(double) atan2(cast(real) y, cast(real) x) : atan2Impl(y, x); } /// ditto float atan2(float y, float x) @safe pure nothrow @nogc { return __ctfe ? cast(float) atan2(cast(real) y, cast(real) x) : atan2Impl(y, x); } /// @safe unittest { assert(atan2(1.0, sqrt(3.0)).approxEqual(PI / 6)); } version (InlineAsm_X86_Any) private real atan2Asm(real y, real x) @trusted pure nothrow @nogc { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [RDX]; // y fld real ptr [RCX]; // x fpatan; ret; } } else { asm pure nothrow @nogc { fld y; fld x; fpatan; } } } private T atan2Impl(T)(T y, T x) @safe pure nothrow @nogc { // Special cases. if (isNaN(x) || isNaN(y)) return T.nan; if (y == cast(T) 0.0) { if (x >= 0 && !signbit(x)) return copysign(0, y); else return copysign(cast(T) PI, y); } if (x == cast(T) 0.0) return copysign(cast(T) PI_2, y); if (isInfinity(x)) { if (signbit(x)) { if (isInfinity(y)) return copysign(3 * cast(T) PI_4, y); else return copysign(cast(T) PI, y); } else { if (isInfinity(y)) return copysign(cast(T) PI_4, y); else return copysign(cast(T) 0.0, y); } } if (isInfinity(y)) return copysign(cast(T) PI_2, y); // Call atan and determine the quadrant. T z = atan(y / x); if (signbit(x)) { if (signbit(y)) z = z - cast(T) PI; else z = z + cast(T) PI; } if (z == cast(T) 0.0) return copysign(z, y); return z; } @safe @nogc nothrow unittest { static void testAtan2(T)() { // NaN const T nan = T.nan; assert(isNaN(atan2(nan, cast(T) 1))); assert(isNaN(atan2(cast(T) 1, nan))); const T inf = T.infinity; static immutable T[3][] vals = [ // y, x, atan2(y, x) // ±0 [ 0.0, 1.0, 0.0 ], [ -0.0, 1.0, -0.0 ], [ 0.0, 0.0, 0.0 ], [ -0.0, 0.0, -0.0 ], [ 0.0, -1.0, PI ], [ -0.0, -1.0, -PI ], [ 0.0, -0.0, PI ], [ -0.0, -0.0, -PI ], [ 1.0, 0.0, PI_2 ], [ 1.0, -0.0, PI_2 ], [ -1.0, 0.0, -PI_2 ], [ -1.0, -0.0, -PI_2 ], // ±∞ [ 1.0, inf, 0.0 ], [ -1.0, inf, -0.0 ], [ 1.0, -inf, PI ], [ -1.0, -inf, -PI ], [ inf, 1.0, PI_2 ], [ inf, -1.0, PI_2 ], [ -inf, 1.0, -PI_2 ], [ -inf, -1.0, -PI_2 ], [ inf, inf, PI_4 ], [ -inf, inf, -PI_4 ], [ inf, -inf, 3 * PI_4 ], [ -inf, -inf, -3 * PI_4 ], [ 1.0, 1.0, PI_4 ], [ -2.0, 2.0, -PI_4 ], [ 3.0, -3.0, 3 * PI_4 ], [ -4.0, -4.0, -3 * PI_4 ], [ 0.75, 0.25, 1.249045772398 ], [ -0.5, 0.375, -0.927295218002 ], [ 0.5, -0.125, 1.815774989922 ], [ -0.75, -0.5, -2.158798930342 ], ]; foreach (ref val; vals) { const T y = val[0]; const T x = val[1]; const T r = val[2]; const T a = atan2(y, x); //printf("atan2(%Lg, %Lg) = %Lg, should be %Lg\n", cast(real) y, cast(real) x, cast(real) a, cast(real) r); if (r == 0) assert(isIdentical(r, a)); // check sign else assert(approxEqual(r, a)); } } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double, float)) testAtan2!T(); assert(equalsDigit(atan2(1.0L, std.math.sqrt(3.0L)), PI / 6, useDigits)); } /*********************************** * Calculates the hyperbolic cosine of x. * * $(TABLE_SV * $(TR $(TH x) $(TH cosh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)0.0) $(TD no) ) * ) */ real cosh(real x) @safe pure nothrow @nogc { // cosh = (exp(x)+exp(-x))/2. // The naive implementation works correctly. const real y = exp(x); return (y + 1.0/y) * 0.5; } /// ditto double cosh(double x) @safe pure nothrow @nogc { return cosh(cast(real) x); } /// ditto float cosh(float x) @safe pure nothrow @nogc { return cosh(cast(real) x); } /// @safe unittest { assert(cosh(0.0) == 1.0); assert(cosh(1.0).approxEqual((E + 1.0 / E) / 2)); } @safe @nogc nothrow unittest { assert(equalsDigit(cosh(1.0), (E + 1.0 / E) / 2, useDigits)); } /*********************************** * Calculates the hyperbolic sine of x. * * $(TABLE_SV * $(TR $(TH x) $(TH sinh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)$(INFIN)) $(TD no)) * ) */ real sinh(real x) @safe pure nothrow @nogc { // sinh(x) = (exp(x)-exp(-x))/2; // Very large arguments could cause an overflow, but // the maximum value of x for which exp(x) + exp(-x)) != exp(x) // is x = 0.5 * (real.mant_dig) * LN2. // = 22.1807 for real80. if (fabs(x) > real.mant_dig * LN2) { return copysign(0.5 * exp(fabs(x)), x); } const real y = expm1(x); return 0.5 * y / (y+1) * (y+2); } /// ditto double sinh(double x) @safe pure nothrow @nogc { return sinh(cast(real) x); } /// ditto float sinh(float x) @safe pure nothrow @nogc { return sinh(cast(real) x); } /// @safe unittest { assert(isIdentical(sinh(0.0), 0.0)); assert(sinh(1.0).approxEqual((E - 1.0 / E) / 2)); } @safe @nogc nothrow unittest { assert(equalsDigit(sinh(1.0), (E - 1.0 / E) / 2, useDigits)); } /*********************************** * Calculates the hyperbolic tangent of x. * * $(TABLE_SV * $(TR $(TH x) $(TH tanh(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)1.0) $(TD no)) * ) */ real tanh(real x) @safe pure nothrow @nogc { // tanh(x) = (exp(x) - exp(-x))/(exp(x)+exp(-x)) if (fabs(x) > real.mant_dig * LN2) { return copysign(1, x); } const real y = expm1(2*x); return y / (y + 2); } /// ditto double tanh(double x) @safe pure nothrow @nogc { return tanh(cast(real) x); } /// ditto float tanh(float x) @safe pure nothrow @nogc { return tanh(cast(real) x); } /// @safe unittest { assert(isIdentical(tanh(0.0), 0.0)); assert(tanh(1.0).approxEqual(sinh(1.0) / cosh(1.0))); } @safe @nogc nothrow unittest { assert(equalsDigit(tanh(1.0), sinh(1.0) / cosh(1.0), 15)); } package: /* Returns cosh(x) + I * sinh(x) * Only one call to exp() is performed. */ deprecated("Use std.complex") auto coshisinh(real x) @safe pure nothrow @nogc { // See comments for cosh, sinh. if (fabs(x) > real.mant_dig * LN2) { const real y = exp(fabs(x)); return y * 0.5 + 0.5i * copysign(y, x); } else { const real y = expm1(x); return (y + 1.0 + 1.0/(y + 1.0)) * 0.5 + 0.5i * y / (y+1) * (y+2); } } deprecated @safe pure nothrow @nogc unittest { creal c = coshisinh(3.0L); assert(c.re == cosh(3.0L)); assert(c.im == sinh(3.0L)); } public: /*********************************** * Calculates the inverse hyperbolic cosine of x. * * Mathematically, acosh(x) = log(x + sqrt( x*x - 1)) * * $(TABLE_DOMRG * $(DOMAIN 1..$(INFIN)), * $(RANGE 0..$(INFIN)) * ) * * $(TABLE_SV * $(SVH x, acosh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(LT)1, $(NAN) ) * $(SV 1, 0 ) * $(SV +$(INFIN),+$(INFIN)) * ) */ real acosh(real x) @safe pure nothrow @nogc { if (x > 1/real.epsilon) return LN2 + log(x); else return log(x + sqrt(x*x - 1)); } /// ditto double acosh(double x) @safe pure nothrow @nogc { return acosh(cast(real) x); } /// ditto float acosh(float x) @safe pure nothrow @nogc { return acosh(cast(real) x); } /// @safe @nogc nothrow unittest { assert(isNaN(acosh(0.9))); assert(isNaN(acosh(real.nan))); assert(isIdentical(acosh(1.0), 0.0)); assert(acosh(real.infinity) == real.infinity); assert(isNaN(acosh(0.5))); } @safe @nogc nothrow unittest { assert(equalsDigit(acosh(cosh(3.0)), 3, useDigits)); } /*********************************** * Calculates the inverse hyperbolic sine of x. * * Mathematically, * --------------- * asinh(x) = log( x + sqrt( x*x + 1 )) // if x >= +0 * asinh(x) = -log(-x + sqrt( x*x + 1 )) // if x <= -0 * ------------- * * $(TABLE_SV * $(SVH x, asinh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(PLUSMN)0, $(PLUSMN)0 ) * $(SV $(PLUSMN)$(INFIN),$(PLUSMN)$(INFIN)) * ) */ real asinh(real x) @safe pure nothrow @nogc { return (fabs(x) > 1 / real.epsilon) // beyond this point, x*x + 1 == x*x ? copysign(LN2 + log(fabs(x)), x) // sqrt(x*x + 1) == 1 + x * x / ( 1 + sqrt(x*x + 1) ) : copysign(log1p(fabs(x) + x*x / (1 + sqrt(x*x + 1)) ), x); } /// ditto double asinh(double x) @safe pure nothrow @nogc { return asinh(cast(real) x); } /// ditto float asinh(float x) @safe pure nothrow @nogc { return asinh(cast(real) x); } /// @safe @nogc nothrow unittest { assert(isIdentical(asinh(0.0), 0.0)); assert(isIdentical(asinh(-0.0), -0.0)); assert(asinh(real.infinity) == real.infinity); assert(asinh(-real.infinity) == -real.infinity); assert(isNaN(asinh(real.nan))); } @safe unittest { assert(equalsDigit(asinh(sinh(3.0)), 3, useDigits)); } /*********************************** * Calculates the inverse hyperbolic tangent of x, * returning a value from ranging from -1 to 1. * * Mathematically, atanh(x) = log( (1+x)/(1-x) ) / 2 * * $(TABLE_DOMRG * $(DOMAIN -$(INFIN)..$(INFIN)), * $(RANGE -1 .. 1) * ) * $(BR) * $(TABLE_SV * $(SVH x, acosh(x) ) * $(SV $(NAN), $(NAN) ) * $(SV $(PLUSMN)0, $(PLUSMN)0) * $(SV -$(INFIN), -0) * ) */ real atanh(real x) @safe pure nothrow @nogc { // log( (1+x)/(1-x) ) == log ( 1 + (2*x)/(1-x) ) return 0.5 * log1p( 2 * x / (1 - x) ); } /// ditto double atanh(double x) @safe pure nothrow @nogc { return atanh(cast(real) x); } /// ditto float atanh(float x) @safe pure nothrow @nogc { return atanh(cast(real) x); } /// @safe @nogc nothrow unittest { assert(isIdentical(atanh(0.0), 0.0)); assert(isIdentical(atanh(-0.0),-0.0)); assert(isNaN(atanh(real.nan))); assert(isNaN(atanh(-real.infinity))); assert(atanh(0.0) == 0); } @safe unittest { assert(equalsDigit(atanh(tanh(0.5L)), 0.5, useDigits)); } /***************************************** * Returns x rounded to a long value using the current rounding mode. * If the integer value of x is * greater than long.max, the result is * indeterminate. */ long rndtol(real x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.rndtol(x); } //FIXME ///ditto long rndtol(double x) @safe pure nothrow @nogc { return rndtol(cast(real) x); } //FIXME ///ditto long rndtol(float x) @safe pure nothrow @nogc { return rndtol(cast(real) x); } /// @safe unittest { assert(rndtol(1.0) == 1L); assert(rndtol(1.2) == 1L); assert(rndtol(1.7) == 2L); assert(rndtol(1.0001) == 1L); } @safe unittest { long function(real) prndtol = &rndtol; assert(prndtol != null); } /** $(RED Deprecated. Please use $(LREF round) instead.) Returns `x` rounded to a `long` value using the `FE_TONEAREST` rounding mode. If the integer value of `x` is greater than `long.max`, the result is indeterminate. Only works with the Digital Mars C Runtime. Params: x = the number to round Returns: `x` rounded to an integer value */ deprecated("rndtonl is to be removed by 2.089. Please use round instead") extern (C) real rndtonl(real x); /// deprecated @system unittest { version (CRuntime_DigitalMars) { assert(rndtonl(1.0) is -real.nan); assert(rndtonl(1.2) is -real.nan); assert(rndtonl(1.7) is -real.nan); assert(rndtonl(1.0001) is -real.nan); } } /*************************************** * Compute square root of x. * * $(TABLE_SV * $(TR $(TH x) $(TH sqrt(x)) $(TH invalid?)) * $(TR $(TD -0.0) $(TD -0.0) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no)) * ) */ float sqrt(float x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } /// ditto double sqrt(double x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } /// ditto real sqrt(real x) @nogc @safe pure nothrow { pragma(inline, true); return core.math.sqrt(x); } /// @safe pure nothrow @nogc unittest { assert(sqrt(2.0).feqrel(1.4142) > 16); assert(sqrt(9.0).feqrel(3.0) > 16); assert(isNaN(sqrt(-1.0f))); assert(isNaN(sqrt(-1.0))); assert(isNaN(sqrt(-1.0L))); } @safe unittest { float function(float) psqrtf = &sqrt; assert(psqrtf != null); double function(double) psqrtd = &sqrt; assert(psqrtd != null); real function(real) psqrtr = &sqrt; assert(psqrtr != null); //ctfe enum ZX80 = sqrt(7.0f); enum ZX81 = sqrt(7.0); enum ZX82 = sqrt(7.0L); } deprecated("Use std.complex.sqrt") auto sqrt(creal z) @nogc @safe pure nothrow { creal c; real x,y,w,r; if (z == 0) { c = 0 + 0i; } else { const real z_re = z.re; const real z_im = z.im; x = fabs(z_re); y = fabs(z_im); if (x >= y) { r = y / x; w = sqrt(x) * sqrt(0.5 * (1 + sqrt(1 + r * r))); } else { r = x / y; w = sqrt(y) * sqrt(0.5 * (r + sqrt(1 + r * r))); } if (z_re >= 0) { c = w + (z_im / (w + w)) * 1.0i; } else { if (z_im < 0) w = -w; c = z_im / (w + w) + w * 1.0i; } } return c; } /** * Calculates e$(SUPERSCRIPT x). * * $(TABLE_SV * $(TR $(TH x) $(TH e$(SUPERSCRIPT x)) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD +0.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real exp(real x) @trusted pure nothrow @nogc // TODO: @safe { version (D_InlineAsm_X86) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). if (!__ctfe) return exp2Asm(LOG2E*x); } else version (D_InlineAsm_X86_64) { // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). if (!__ctfe) return exp2Asm(LOG2E*x); } return expImpl(x); } /// ditto double exp(double x) @safe pure nothrow @nogc { return __ctfe ? cast(double) exp(cast(real) x) : expImpl(x); } /// ditto float exp(float x) @safe pure nothrow @nogc { return __ctfe ? cast(float) exp(cast(real) x) : expImpl(x); } /// @safe unittest { assert(exp(0.0) == 1.0); assert(exp(3.0).feqrel(E * E * E) > 16); } private T expImpl(T)(T x) @safe pure nothrow @nogc { alias F = floatTraits!T; static if (F.realFormat == RealFormat.ieeeSingle) { static immutable T[6] P = [ 5.0000001201E-1, 1.6666665459E-1, 4.1665795894E-2, 8.3334519073E-3, 1.3981999507E-3, 1.9875691500E-4, ]; enum T C1 = 0.693359375; enum T C2 = -2.12194440e-4; // Overflow and Underflow limits. enum T OF = 88.72283905206835; enum T UF = -103.278929903431851103; // ln(2^-149) } else static if (F.realFormat == RealFormat.ieeeDouble) { // Coefficients for exp(x) static immutable T[3] P = [ 9.99999999999999999910E-1L, 3.02994407707441961300E-2L, 1.26177193074810590878E-4L, ]; static immutable T[4] Q = [ 2.00000000000000000009E0L, 2.27265548208155028766E-1L, 2.52448340349684104192E-3L, 3.00198505138664455042E-6L, ]; // C1 + C2 = LN2. enum T C1 = 6.93145751953125E-1; enum T C2 = 1.42860682030941723212E-6; // Overflow and Underflow limits. enum T OF = 7.09782712893383996732E2; // ln((1-2^-53) * 2^1024) enum T UF = -7.451332191019412076235E2; // ln(2^-1075) } else static if (F.realFormat == RealFormat.ieeeExtended) { // Coefficients for exp(x) static immutable T[3] P = [ 9.9999999999999999991025E-1L, 3.0299440770744196129956E-2L, 1.2617719307481059087798E-4L, ]; static immutable T[4] Q = [ 2.0000000000000000000897E0L, 2.2726554820815502876593E-1L, 2.5244834034968410419224E-3L, 3.0019850513866445504159E-6L, ]; // C1 + C2 = LN2. enum T C1 = 6.9314575195312500000000E-1L; enum T C2 = 1.4286068203094172321215E-6L; // Overflow and Underflow limits. enum T OF = 1.1356523406294143949492E4L; // ln((1-2^-64) * 2^16384) enum T UF = -1.13994985314888605586758E4L; // ln(2^-16446) } else static if (F.realFormat == RealFormat.ieeeQuadruple) { // Coefficients for exp(x) - 1 static immutable T[5] P = [ 9.999999999999999999999999999999999998502E-1L, 3.508710990737834361215404761139478627390E-2L, 2.708775201978218837374512615596512792224E-4L, 6.141506007208645008909088812338454698548E-7L, 3.279723985560247033712687707263393506266E-10L ]; static immutable T[6] Q = [ 2.000000000000000000000000000000000000150E0, 2.368408864814233538909747618894558968880E-1L, 3.611828913847589925056132680618007270344E-3L, 1.504792651814944826817779302637284053660E-5L, 1.771372078166251484503904874657985291164E-8L, 2.980756652081995192255342779918052538681E-12L ]; // C1 + C2 = LN2. enum T C1 = 6.93145751953125E-1L; enum T C2 = 1.428606820309417232121458176568075500134E-6L; // Overflow and Underflow limits. enum T OF = 1.135583025911358400418251384584930671458833e4L; enum T UF = -1.143276959615573793352782661133116431383730e4L; } else static assert(0, "Not implemented for this architecture"); // Special cases. if (isNaN(x)) return x; if (x > OF) return real.infinity; if (x < UF) return 0.0; // Express: e^^x = e^^g * 2^^n // = e^^g * e^^(n * LOG2E) // = e^^(g + n * LOG2E) T xx = floor((cast(T) LOG2E) * x + cast(T) 0.5); const int n = cast(int) xx; x -= xx * C1; x -= xx * C2; static if (F.realFormat == RealFormat.ieeeSingle) { xx = x * x; x = poly(x, P) * xx + x + 1.0f; } else { // Rational approximation for exponential of the fractional part: // e^^x = 1 + 2x P(x^^2) / (Q(x^^2) - P(x^^2)) xx = x * x; const T px = x * poly(xx, P); x = px / (poly(xx, Q) - px); x = (cast(T) 1.0) + (cast(T) 2.0) * x; } // Scale by power of 2. x = ldexp(x, n); return x; } version (InlineAsm_X86_Any) @safe @nogc nothrow unittest { FloatingPointControl ctrl; if (FloatingPointControl.hasExceptionTraps) ctrl.disableExceptions(FloatingPointControl.allExceptions); ctrl.rounding = FloatingPointControl.roundToNearest; static void testExp(T)() { enum realFormat = floatTraits!T.realFormat; static if (realFormat == RealFormat.ieeeQuadruple) { static immutable T[2][] exptestpoints = [ // x exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069bc972dfefab6df34p+0L ], [ 3.0L, E*E*E ], [ 0x1.6p+13L, 0x1.6e509d45728655cdb4840542acb5p+16250L ], // near overflow [ 0x1.7p+13L, T.infinity ], // close overflow [ 0x1p+80L, T.infinity ], // far overflow [ T.infinity, T.infinity ], [-0x1.18p+13L, 0x1.5e4bf54b4807034ea97fef0059a6p-12927L ], // near underflow [-0x1.625p+13L, 0x1.a6bd68a39d11fec3a250cd97f524p-16358L ], // ditto [-0x1.62dafp+13L, 0x0.cb629e9813b80ed4d639e875be6cp-16382L ], // near underflow - subnormal [-0x1.6549p+13L, 0x0.0000000000000000000000000001p-16382L ], // ditto [-0x1.655p+13L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static if (realFormat == RealFormat.ieeeExtended) { static immutable T[2][] exptestpoints = [ // x exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069bc97p+0L ], [ 3.0L, E*E*E ], [ 0x1.1p+13L, 0x1.29aeffefc8ec645p+12557L ], // near overflow [ 0x1.7p+13L, T.infinity ], // close overflow [ 0x1p+80L, T.infinity ], // far overflow [ T.infinity, T.infinity ], [-0x1.18p+13L, 0x1.5e4bf54b4806db9p-12927L ], // near underflow [-0x1.625p+13L, 0x1.a6bd68a39d11f35cp-16358L ], // ditto [-0x1.62dafp+13L, 0x1.96c53d30277021dp-16383L ], // near underflow - subnormal [-0x1.643p+13L, 0x1p-16444L ], // ditto [-0x1.645p+13L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static if (realFormat == RealFormat.ieeeDouble) { static immutable T[2][] exptestpoints = [ // x, exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61298e1e069cp+0L ], [ 3.0L, E*E*E ], [ 0x1.6p+9L, 0x1.93bf4ec282efbp+1015L ], // near overflow [ 0x1.7p+9L, T.infinity ], // close overflow [ 0x1p+80L, T.infinity ], // far overflow [ T.infinity, T.infinity ], [-0x1.6p+9L, 0x1.44a3824e5285fp-1016L ], // near underflow [-0x1.64p+9L, 0x0.06f84920bb2d4p-1022L ], // near underflow - subnormal [-0x1.743p+9L, 0x0.0000000000001p-1022L ], // ditto [-0x1.8p+9L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static if (realFormat == RealFormat.ieeeSingle) { static immutable T[2][] exptestpoints = [ // x, exp(x) [ 1.0L, E ], [ 0.5L, 0x1.a61299p+0L ], [ 3.0L, E*E*E ], [ 0x1.62p+6L, 0x1.99b988p+127L ], // near overflow [ 0x1.7p+6L, T.infinity ], // close overflow [ 0x1p+80L, T.infinity ], // far overflow [ T.infinity, T.infinity ], [-0x1.5cp+6L, 0x1.666d0ep-126L ], // near underflow [-0x1.7p+6L, 0x0.026a42p-126L ], // near underflow - subnormal [-0x1.9cp+6L, 0x0.000002p-126L ], // ditto [-0x1.ap+6L, 0 ], // close underflow [-0x1p+30L, 0 ], // far underflow ]; } else static assert(0, "No exp() tests for real type!"); const minEqualMantissaBits = T.mant_dig - 2; T x; IeeeFlags f; foreach (ref pair; exptestpoints) { resetIeeeFlags(); x = exp(pair[0]); //printf("exp(%La) = %La, should be %La\n", cast(real) pair[0], cast(real) x, cast(real) pair[1]); assert(feqrel(x, pair[1]) >= minEqualMantissaBits); } // Ideally, exp(0) would not set the inexact flag. // Unfortunately, fldl2e sets it! // So it's not realistic to avoid setting it. assert(exp(cast(T) 0.0) == 1.0); // NaN propagation. Doesn't set flags, bcos was already NaN. resetIeeeFlags(); x = exp(T.nan); f = ieeeFlags; assert(isIdentical(abs(x), T.nan)); assert(f.flags == 0); resetIeeeFlags(); x = exp(-T.nan); f = ieeeFlags; assert(isIdentical(abs(x), T.nan)); assert(f.flags == 0); x = exp(NaN(0x123)); assert(isIdentical(x, NaN(0x123))); } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double, float)) testExp!T(); // High resolution test (verified against GNU MPFR/Mathematica). assert(exp(0.5L) == 0x1.A612_98E1_E069_BC97_2DFE_FAB6_DF34p+0L); assert(equalsDigit(exp(3.0L), E * E * E, useDigits)); } /** * Calculates the value of the natural logarithm base (e) * raised to the power of x, minus 1. * * For very small x, expm1(x) is more accurate * than exp(x)-1. * * $(TABLE_SV * $(TR $(TH x) $(TH e$(SUPERSCRIPT x)-1) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD -1.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real expm1(real x) @trusted pure nothrow @nogc // TODO: @safe { version (InlineAsm_X86_Any) { if (!__ctfe) return expm1Asm(x); } return expm1Impl(x); } /// ditto double expm1(double x) @safe pure nothrow @nogc { return __ctfe ? cast(double) expm1(cast(real) x) : expm1Impl(x); } /// ditto float expm1(float x) @safe pure nothrow @nogc { // no single-precision version in Cephes => use double precision return __ctfe ? cast(float) expm1(cast(real) x) : cast(float) expm1Impl(cast(double) x); } /// @safe unittest { assert(isIdentical(expm1(0.0), 0.0)); assert(expm1(1.0).feqrel(1.71828) > 16); assert(expm1(2.0).feqrel(6.3890) > 16); } version (InlineAsm_X86_Any) private real expm1Asm(real x) @trusted pure nothrow @nogc { version (D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 asm pure nothrow @nogc { /* expm1() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * expm1(x) = 2^^(rndint(y))* 2^^(y-rndint(y)) - 1 where y = LN2*x. * = 2rndy * 2ym1 + 2rndy - 1, where 2rndy = 2^^(rndint(y)) * and 2ym1 = (2^^(y-rndint(y))-1). * If 2rndy < 0.5*real.epsilon, result is -1. * Implementation is otherwise the same as for exp2() */ naked; fld real ptr [ESP+4] ; // x mov AX, [ESP+4+8]; // AX = exponent and sign sub ESP, 12+8; // Create scratch space on the stack // [ESP,ESP+2] = scratchint // [ESP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [ESP+8], 0; mov dword ptr [ESP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fldl2e; fmulp ST(1), ST; // y = x*log2(e) fist dword ptr [ESP]; // scratchint = rndint(y) fisub dword ptr [ESP]; // y - rndint(y) // and now set scratchreal exponent mov EAX, [ESP]; add EAX, 0x3fff; jle short L_largenegative; cmp EAX,0x8000; jge short L_largepositive; mov [ESP+8+8],AX; f2xm1; // 2ym1 = 2^^(y-rndint(y)) -1 fld real ptr [ESP+8] ; // 2rndy = 2^^rndint(y) fmul ST(1), ST; // ST=2rndy, ST(1)=2rndy*2ym1 fld1; fsubp ST(1), ST; // ST = 2rndy-1, ST(1) = 2rndy * 2ym1 - 1 faddp ST(1), ST; // ST = 2rndy * 2ym1 + 2rndy - 1 add ESP,12+8; ret PARAMSIZE; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; L_largepositive: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [ESP+8+8], 0x7FFE; fstp ST(0); fld real ptr [ESP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add ESP,12+8; ret PARAMSIZE; L_largenegative: fstp ST(0); fld1; fchs; // return -1. Underflow flag is not set. add ESP,12+8; ret PARAMSIZE; } } else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { naked; } version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX]; // x mov AX,[RCX+8]; // AX = exponent and sign } } else { asm pure nothrow @nogc { fld real ptr [RSP+8]; // x mov AX,[RSP+8+8]; // AX = exponent and sign } } asm pure nothrow @nogc { /* expm1() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * expm1(x) = 2^(rndint(y))* 2^(y-rndint(y)) - 1 where y = LN2*x. * = 2rndy * 2ym1 + 2rndy - 1, where 2rndy = 2^(rndint(y)) * and 2ym1 = (2^(y-rndint(y))-1). * If 2rndy < 0.5*real.epsilon, result is -1. * Implementation is otherwise the same as for exp2() */ sub RSP, 24; // Create scratch space on the stack // [RSP,RSP+2] = scratchint // [RSP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [RSP+8], 0; mov dword ptr [RSP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fldl2e; fmul ; // y = x*log2(e) fist dword ptr [RSP]; // scratchint = rndint(y) fisub dword ptr [RSP]; // y - rndint(y) // and now set scratchreal exponent mov EAX, [RSP]; add EAX, 0x3fff; jle short L_largenegative; cmp EAX,0x8000; jge short L_largepositive; mov [RSP+8+8],AX; f2xm1; // 2^(y-rndint(y)) -1 fld real ptr [RSP+8] ; // 2^rndint(y) fmul ST(1), ST; fld1; fsubp ST(1), ST; fadd; add RSP,24; ret; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x test AX, 0x0200; jnz L_largenegative; L_largepositive: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [RSP+8+8], 0x7FFE; fstp ST(0); fld real ptr [RSP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add RSP,24; ret; L_largenegative: fstp ST(0); fld1; fchs; // return -1. Underflow flag is not set. add RSP,24; ret; } } else static assert(0); } private T expm1Impl(T)(T x) @safe pure nothrow @nogc { // Coefficients for exp(x) - 1 and overflow/underflow limits. enum realFormat = floatTraits!T.realFormat; static if (realFormat == RealFormat.ieeeQuadruple) { static immutable T[8] P = [ 2.943520915569954073888921213330863757240E8L, -5.722847283900608941516165725053359168840E7L, 8.944630806357575461578107295909719817253E6L, -7.212432713558031519943281748462837065308E5L, 4.578962475841642634225390068461943438441E4L, -1.716772506388927649032068540558788106762E3L, 4.401308817383362136048032038528753151144E1L, -4.888737542888633647784737721812546636240E-1L ]; static immutable T[9] Q = [ 1.766112549341972444333352727998584753865E9L, -7.848989743695296475743081255027098295771E8L, 1.615869009634292424463780387327037251069E8L, -2.019684072836541751428967854947019415698E7L, 1.682912729190313538934190635536631941751E6L, -9.615511549171441430850103489315371768998E4L, 3.697714952261803935521187272204485251835E3L, -8.802340681794263968892934703309274564037E1L, 1.0 ]; enum T OF = 1.1356523406294143949491931077970764891253E4L; enum T UF = -1.143276959615573793352782661133116431383730e4L; } else static if (realFormat == RealFormat.ieeeExtended) { static immutable T[5] P = [ -1.586135578666346600772998894928250240826E4L, 2.642771505685952966904660652518429479531E3L, -3.423199068835684263987132888286791620673E2L, 1.800826371455042224581246202420972737840E1L, -5.238523121205561042771939008061958820811E-1L, ]; static immutable T[6] Q = [ -9.516813471998079611319047060563358064497E4L, 3.964866271411091674556850458227710004570E4L, -7.207678383830091850230366618190187434796E3L, 7.206038318724600171970199625081491823079E2L, -4.002027679107076077238836622982900945173E1L, 1.0 ]; enum T OF = 1.1356523406294143949492E4L; enum T UF = -4.5054566736396445112120088E1L; } else static if (realFormat == RealFormat.ieeeDouble) { static immutable T[3] P = [ 9.9999999999999999991025E-1, 3.0299440770744196129956E-2, 1.2617719307481059087798E-4, ]; static immutable T[4] Q = [ 2.0000000000000000000897E0, 2.2726554820815502876593E-1, 2.5244834034968410419224E-3, 3.0019850513866445504159E-6, ]; } else static assert(0, "no coefficients for expm1()"); static if (realFormat == RealFormat.ieeeDouble) // special case for double precision { if (x < -0.5 || x > 0.5) return exp(x) - 1.0; if (x == 0.0) return x; const T xx = x * x; x = x * poly(xx, P); x = x / (poly(xx, Q) - x); return x + x; } else { // C1 + C2 = LN2. enum T C1 = 6.9314575195312500000000E-1L; enum T C2 = 1.428606820309417232121458176568075500134E-6L; // Special cases. if (x > OF) return real.infinity; if (x == cast(T) 0.0) return x; if (x < UF) return -1.0; // Express x = LN2 (n + remainder), remainder not exceeding 1/2. int n = cast(int) floor((cast(T) 0.5) + x / cast(T) LN2); x -= n * C1; x -= n * C2; // Rational approximation: // exp(x) - 1 = x + 0.5 x^^2 + x^^3 P(x) / Q(x) T px = x * poly(x, P); T qx = poly(x, Q); const T xx = x * x; qx = x + ((cast(T) 0.5) * xx + xx * px / qx); // We have qx = exp(remainder LN2) - 1, so: // exp(x) - 1 = 2^^n (qx + 1) - 1 = 2^^n qx + 2^^n - 1. px = ldexp(cast(T) 1.0, n); x = px * qx + (px - cast(T) 1.0); return x; } } @safe @nogc nothrow unittest { static void testExpm1(T)() { // NaN assert(isNaN(expm1(cast(T) T.nan))); static immutable T[] xs = [ -2, -0.75, -0.3, 0.0, 0.1, 0.2, 0.5, 1.0 ]; foreach (x; xs) { const T e = expm1(x); const T r = exp(x) - 1; //printf("expm1(%Lg) = %Lg, should approximately be %Lg\n", cast(real) x, cast(real) e, cast(real) r); assert(approxEqual(r, e)); } } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double)) testExpm1!T(); } /** * Calculates 2$(SUPERSCRIPT x). * * $(TABLE_SV * $(TR $(TH x) $(TH exp2(x)) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) ) * $(TR $(TD -$(INFIN)) $(TD +0.0) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) ) * ) */ real exp2(real x) @nogc @trusted pure nothrow // TODO: @safe { version (InlineAsm_X86_Any) { if (!__ctfe) return exp2Asm(x); } return exp2Impl(x); } /// ditto double exp2(double x) @nogc @safe pure nothrow { return __ctfe ? cast(double) exp2(cast(real) x) : exp2Impl(x); } /// ditto float exp2(float x) @nogc @safe pure nothrow { return __ctfe ? cast(float) exp2(cast(real) x) : exp2Impl(x); } /// @safe unittest { assert(isIdentical(exp2(0.0), 1.0)); assert(exp2(2.0).feqrel(4.0) > 16); assert(exp2(8.0).feqrel(256.0) > 16); } @safe unittest { version (CRuntime_Microsoft) {} else // aexp2/exp2f/exp2l not implemented { assert( core.stdc.math.exp2f(0.0f) == 1 ); assert( core.stdc.math.exp2 (0.0) == 1 ); assert( core.stdc.math.exp2l(0.0L) == 1 ); } } version (InlineAsm_X86_Any) private real exp2Asm(real x) @nogc @trusted pure nothrow { version (D_InlineAsm_X86) { enum PARAMSIZE = (real.sizeof+3)&(0xFFFF_FFFC); // always a multiple of 4 asm pure nothrow @nogc { /* exp2() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * exp2(x) = 2^^(rndint(x))* 2^^(y-rndint(x)) * The trick for high performance is to avoid the fscale(28cycles on core2), * frndint(19 cycles), leaving f2xm1(19 cycles) as the only slow instruction. * * We can do frndint by using fist. BUT we can't use it for huge numbers, * because it will set the Invalid Operation flag if overflow or NaN occurs. * Fortunately, whenever this happens the result would be zero or infinity. * * We can perform fscale by directly poking into the exponent. BUT this doesn't * work for the (very rare) cases where the result is subnormal. So we fall back * to the slow method in that case. */ naked; fld real ptr [ESP+4] ; // x mov AX, [ESP+4+8]; // AX = exponent and sign sub ESP, 12+8; // Create scratch space on the stack // [ESP,ESP+2] = scratchint // [ESP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [ESP+8], 0; mov dword ptr [ESP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fist dword ptr [ESP]; // scratchint = rndint(x) fisub dword ptr [ESP]; // x - rndint(x) // and now set scratchreal exponent mov EAX, [ESP]; add EAX, 0x3fff; jle short L_subnormal; cmp EAX,0x8000; jge short L_overflow; mov [ESP+8+8],AX; L_normal: f2xm1; fld1; faddp ST(1), ST; // 2^^(x-rndint(x)) fld real ptr [ESP+8] ; // 2^^rndint(x) add ESP,12+8; fmulp ST(1), ST; ret PARAMSIZE; L_subnormal: // Result will be subnormal. // In this rare case, the simple poking method doesn't work. // The speed doesn't matter, so use the slow fscale method. fild dword ptr [ESP]; // scratchint fld1; fscale; fstp real ptr [ESP+8]; // scratchreal = 2^^scratchint fstp ST(0); // drop scratchint jmp L_normal; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min_normal // squaring it will return 0, setting underflow flag mov word ptr [ESP+8+8], 1; test AX, 0x0200; jnz L_waslargenegative; L_overflow: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [ESP+8+8], 0x7FFE; L_waslargenegative: fstp ST(0); fld real ptr [ESP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add ESP,12+8; ret PARAMSIZE; } } else version (D_InlineAsm_X86_64) { asm pure nothrow @nogc { naked; } version (Win64) { asm pure nothrow @nogc { fld real ptr [RCX]; // x mov AX,[RCX+8]; // AX = exponent and sign } } else { asm pure nothrow @nogc { fld real ptr [RSP+8]; // x mov AX,[RSP+8+8]; // AX = exponent and sign } } asm pure nothrow @nogc { /* exp2() for x87 80-bit reals, IEEE754-2008 conformant. * Author: Don Clugston. * * exp2(x) = 2^(rndint(x))* 2^(y-rndint(x)) * The trick for high performance is to avoid the fscale(28cycles on core2), * frndint(19 cycles), leaving f2xm1(19 cycles) as the only slow instruction. * * We can do frndint by using fist. BUT we can't use it for huge numbers, * because it will set the Invalid Operation flag is overflow or NaN occurs. * Fortunately, whenever this happens the result would be zero or infinity. * * We can perform fscale by directly poking into the exponent. BUT this doesn't * work for the (very rare) cases where the result is subnormal. So we fall back * to the slow method in that case. */ sub RSP, 24; // Create scratch space on the stack // [RSP,RSP+2] = scratchint // [RSP+4..+6, +8..+10, +10] = scratchreal // set scratchreal mantissa = 1.0 mov dword ptr [RSP+8], 0; mov dword ptr [RSP+8+4], 0x80000000; and AX, 0x7FFF; // drop sign bit cmp AX, 0x401D; // avoid InvalidException in fist jae L_extreme; fist dword ptr [RSP]; // scratchint = rndint(x) fisub dword ptr [RSP]; // x - rndint(x) // and now set scratchreal exponent mov EAX, [RSP]; add EAX, 0x3fff; jle short L_subnormal; cmp EAX,0x8000; jge short L_overflow; mov [RSP+8+8],AX; L_normal: f2xm1; fld1; fadd; // 2^(x-rndint(x)) fld real ptr [RSP+8] ; // 2^rndint(x) add RSP,24; fmulp ST(1), ST; ret; L_subnormal: // Result will be subnormal. // In this rare case, the simple poking method doesn't work. // The speed doesn't matter, so use the slow fscale method. fild dword ptr [RSP]; // scratchint fld1; fscale; fstp real ptr [RSP+8]; // scratchreal = 2^scratchint fstp ST(0); // drop scratchint jmp L_normal; L_extreme: // Extreme exponent. X is very large positive, very // large negative, infinity, or NaN. fxam; fstsw AX; test AX, 0x0400; // NaN_or_zero, but we already know x != 0 jz L_was_nan; // if x is NaN, returns x // set scratchreal = real.min // squaring it will return 0, setting underflow flag mov word ptr [RSP+8+8], 1; test AX, 0x0200; jnz L_waslargenegative; L_overflow: // Set scratchreal = real.max. // squaring it will create infinity, and set overflow flag. mov word ptr [RSP+8+8], 0x7FFE; L_waslargenegative: fstp ST(0); fld real ptr [RSP+8]; // load scratchreal fmul ST(0), ST; // square it, to create havoc! L_was_nan: add RSP,24; ret; } } else static assert(0); } private T exp2Impl(T)(T x) @nogc @safe pure nothrow { // Coefficients for exp2(x) enum realFormat = floatTraits!T.realFormat; static if (realFormat == RealFormat.ieeeQuadruple) { static immutable T[5] P = [ 9.079594442980146270952372234833529694788E12L, 1.530625323728429161131811299626419117557E11L, 5.677513871931844661829755443994214173883E8L, 6.185032670011643762127954396427045467506E5L, 1.587171580015525194694938306936721666031E2L ]; static immutable T[6] Q = [ 2.619817175234089411411070339065679229869E13L, 1.490560994263653042761789432690793026977E12L, 1.092141473886177435056423606755843616331E10L, 2.186249607051644894762167991800811827835E7L, 1.236602014442099053716561665053645270207E4L, 1.0 ]; } else static if (realFormat == RealFormat.ieeeExtended) { static immutable T[3] P = [ 2.0803843631901852422887E6L, 3.0286971917562792508623E4L, 6.0614853552242266094567E1L, ]; static immutable T[4] Q = [ 6.0027204078348487957118E6L, 3.2772515434906797273099E5L, 1.7492876999891839021063E3L, 1.0000000000000000000000E0L, ]; } else static if (realFormat == RealFormat.ieeeDouble) { static immutable T[3] P = [ 1.51390680115615096133E3L, 2.02020656693165307700E1L, 2.30933477057345225087E-2L, ]; static immutable T[3] Q = [ 4.36821166879210612817E3L, 2.33184211722314911771E2L, 1.00000000000000000000E0L, ]; } else static if (realFormat == RealFormat.ieeeSingle) { static immutable T[6] P = [ 6.931472028550421E-001L, 2.402264791363012E-001L, 5.550332471162809E-002L, 9.618437357674640E-003L, 1.339887440266574E-003L, 1.535336188319500E-004L, ]; } else static assert(0, "no coefficients for exp2()"); // Overflow and Underflow limits. enum T OF = T.max_exp; enum T UF = T.min_exp - 1; // Special cases. if (isNaN(x)) return x; if (x > OF) return real.infinity; if (x < UF) return 0.0; static if (realFormat == RealFormat.ieeeSingle) // special case for single precision { // The following is necessary because range reduction blows up. if (x == 0.0f) return 1.0f; // Separate into integer and fractional parts. const T i = floor(x); int n = cast(int) i; x -= i; if (x > 0.5f) { n += 1; x -= 1.0f; } // Rational approximation: // exp2(x) = 1.0 + x P(x) x = 1.0f + x * poly(x, P); } else { // Separate into integer and fractional parts. const T i = floor(x + cast(T) 0.5); int n = cast(int) i; x -= i; // Rational approximation: // exp2(x) = 1.0 + 2x P(x^^2) / (Q(x^^2) - P(x^^2)) const T xx = x * x; const T px = x * poly(xx, P); x = px / (poly(xx, Q) - px); x = (cast(T) 1.0) + (cast(T) 2.0) * x; } // Scale by power of 2. x = ldexp(x, n); return x; } @safe @nogc nothrow unittest { assert(feqrel(exp2(0.5L), SQRT2) >= real.mant_dig -1); assert(exp2(8.0L) == 256.0); assert(exp2(-9.0L)== 1.0L/512.0); static void testExp2(T)() { // NaN const T specialNaN = NaN(0x0123L); assert(isIdentical(exp2(specialNaN), specialNaN)); // over-/underflow enum T OF = T.max_exp; enum T UF = T.min_exp - T.mant_dig; assert(isIdentical(exp2(OF + 1), cast(T) T.infinity)); assert(isIdentical(exp2(UF - 1), cast(T) 0.0)); static immutable T[2][] vals = [ // x, exp2(x) [ 0.0, 1.0 ], [ -0.0, 1.0 ], [ 0.5, SQRT2 ], [ 8.0, 256.0 ], [ -9.0, 1.0 / 512 ], ]; foreach (ref val; vals) { const T x = val[0]; const T r = val[1]; const T e = exp2(x); //printf("exp2(%Lg) = %Lg, should be %Lg\n", cast(real) x, cast(real) e, cast(real) r); assert(approxEqual(r, e)); } } import std.meta : AliasSeq; foreach (T; AliasSeq!(real, double, float)) testExp2!T(); } /* * Calculate cos(y) + i sin(y). * * On many CPUs (such as x86), this is a very efficient operation; * almost twice as fast as calculating sin(y) and cos(y) separately, * and is the preferred method when both are required. */ deprecated("Use std.complex.expi") creal expi(real y) @trusted pure nothrow @nogc { version (InlineAsm_X86_Any) { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [ECX]; fsincos; fxch ST(1), ST(0); ret; } } else { asm pure nothrow @nogc { fld y; fsincos; fxch ST(1), ST(0); } } } else { return cos(y) + sin(y)*1i; } } deprecated @safe pure nothrow @nogc unittest { assert(expi(1.3e5L) == cos(1.3e5L) + sin(1.3e5L) * 1i); assert(expi(0.0L) == 1L + 0.0Li); } /********************************************************************* * Separate floating point value into significand and exponent. * * Returns: * Calculate and return $(I x) and $(I exp) such that * value =$(I x)*2$(SUPERSCRIPT exp) and * .5 $(LT)= |$(I x)| $(LT) 1.0 * * $(I x) has same sign as value. * * $(TABLE_SV * $(TR $(TH value) $(TH returns) $(TH exp)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD 0)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD int.max)) * $(TR $(TD -$(INFIN)) $(TD -$(INFIN)) $(TD int.min)) * $(TR $(TD $(PLUSMN)$(NAN)) $(TD $(PLUSMN)$(NAN)) $(TD int.min)) * ) */ T frexp(T)(const T value, out int exp) @trusted pure nothrow @nogc if (isFloatingPoint!T) { Unqual!T vf = value; ushort* vu = cast(ushort*)&vf; static if (is(Unqual!T == float)) int* vi = cast(int*)&vf; else long* vl = cast(long*)&vf; int ex; alias F = floatTraits!T; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; static if (F.realFormat == RealFormat.ieeeExtended) { if (ex) { // If exponent is non-zero if (ex == F.EXPMASK) // infinity or NaN { if (*vl & 0x7FFF_FFFF_FFFF_FFFF) // NaN { *vl |= 0xC000_0000_0000_0000; // convert NaNS to NaNQ exp = int.min; } else if (vu[F.EXPPOS_SHORT] & 0x8000) // negative infinity exp = int.min; else // positive infinity exp = int.max; } else { exp = ex - F.EXPBIAS; vu[F.EXPPOS_SHORT] = (0x8000 & vu[F.EXPPOS_SHORT]) | 0x3FFE; } } else if (!*vl) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ex - F.EXPBIAS - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = ((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3FFE; } return vf; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) { // infinity or NaN if (vl[MANTISSA_LSB] | (vl[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) // NaN { // convert NaNS to NaNQ vl[MANTISSA_MSB] |= 0x0000_8000_0000_0000; exp = int.min; } else if (vu[F.EXPPOS_SHORT] & 0x8000) // negative infinity exp = int.min; else // positive infinity exp = int.max; } else { exp = ex - F.EXPBIAS; vu[F.EXPPOS_SHORT] = F.EXPBIAS | (0x8000 & vu[F.EXPPOS_SHORT]); } } else if ((vl[MANTISSA_LSB] | (vl[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) == 0) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ex - F.EXPBIAS - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = F.EXPBIAS | (0x8000 & vu[F.EXPPOS_SHORT]); } return vf; } else static if (F.realFormat == RealFormat.ieeeDouble) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if (*vl == 0x7FF0_0000_0000_0000) // positive infinity { exp = int.max; } else if (*vl == 0xFFF0_0000_0000_0000) // negative infinity exp = int.min; else { // NaN *vl |= 0x0008_0000_0000_0000; // convert NaNS to NaNQ exp = int.min; } } else { exp = (ex - F.EXPBIAS) >> 4; vu[F.EXPPOS_SHORT] = cast(ushort)((0x800F & vu[F.EXPPOS_SHORT]) | 0x3FE0); } } else if (!(*vl & 0x7FFF_FFFF_FFFF_FFFF)) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ((ex - F.EXPBIAS) >> 4) - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = cast(ushort)(((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3FE0); } return vf; } else static if (F.realFormat == RealFormat.ieeeSingle) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if (*vi == 0x7F80_0000) // positive infinity { exp = int.max; } else if (*vi == 0xFF80_0000) // negative infinity exp = int.min; else { // NaN *vi |= 0x0040_0000; // convert NaNS to NaNQ exp = int.min; } } else { exp = (ex - F.EXPBIAS) >> 7; vu[F.EXPPOS_SHORT] = cast(ushort)((0x807F & vu[F.EXPPOS_SHORT]) | 0x3F00); } } else if (!(*vi & 0x7FFF_FFFF)) { // vf is +-0.0 exp = 0; } else { // subnormal vf *= F.RECIP_EPSILON; ex = vu[F.EXPPOS_SHORT] & F.EXPMASK; exp = ((ex - F.EXPBIAS) >> 7) - T.mant_dig + 1; vu[F.EXPPOS_SHORT] = cast(ushort)(((-1 - F.EXPMASK) & vu[F.EXPPOS_SHORT]) | 0x3F00); } return vf; } else // static if (F.realFormat == RealFormat.ibmExtended) { assert(0, "frexp not implemented"); } } /// @safe unittest { int exp; real mantissa = frexp(123.456L, exp); assert(approxEqual(mantissa * pow(2.0L, cast(real) exp), 123.456L)); assert(frexp(-real.nan, exp) && exp == int.min); assert(frexp(real.nan, exp) && exp == int.min); assert(frexp(-real.infinity, exp) == -real.infinity && exp == int.min); assert(frexp(real.infinity, exp) == real.infinity && exp == int.max); assert(frexp(-0.0, exp) == -0.0 && exp == 0); assert(frexp(0.0, exp) == 0.0 && exp == 0); } @safe @nogc nothrow unittest { int exp; real mantissa = frexp(123.456L, exp); // check if values are equal to 19 decimal digits of precision assert(equalsDigit(mantissa * pow(2.0L, cast(real) exp), 123.456L, 19)); } @safe unittest { import std.meta : AliasSeq; import std.typecons : tuple, Tuple; static foreach (T; AliasSeq!(real, double, float)) {{ Tuple!(T, T, int)[] vals = // x,frexp,exp [ tuple(T(0.0), T( 0.0 ), 0), tuple(T(-0.0), T( -0.0), 0), tuple(T(1.0), T( .5 ), 1), tuple(T(-1.0), T( -.5 ), 1), tuple(T(2.0), T( .5 ), 2), tuple(T(float.min_normal/2.0f), T(.5), -126), tuple(T.infinity, T.infinity, int.max), tuple(-T.infinity, -T.infinity, int.min), tuple(T.nan, T.nan, int.min), tuple(-T.nan, -T.nan, int.min), // Phobos issue #16026: tuple(3 * (T.min_normal * T.epsilon), T( .75), (T.min_exp - T.mant_dig) + 2) ]; foreach (elem; vals) { T x = elem[0]; T e = elem[1]; int exp = elem[2]; int eptr; T v = frexp(x, eptr); assert(isIdentical(e, v)); assert(exp == eptr); } static if (floatTraits!(T).realFormat == RealFormat.ieeeExtended) { static T[3][] extendedvals = [ // x,frexp,exp [0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal [0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063], [T.min_normal, .5, -16381], [T.min_normal/2.0L, .5, -16382] // subnormal ]; foreach (elem; extendedvals) { T x = elem[0]; T e = elem[1]; int exp = cast(int) elem[2]; int eptr; T v = frexp(x, eptr); assert(isIdentical(e, v)); assert(exp == eptr); } } }} } @safe unittest { import std.meta : AliasSeq; void foo() { static foreach (T; AliasSeq!(real, double, float)) {{ int exp; const T a = 1; immutable T b = 2; auto c = frexp(a, exp); auto d = frexp(b, exp); }} } } /****************************************** * Extracts the exponent of x as a signed integral value. * * If x is not a special value, the result is the same as * $(D cast(int) logb(x)). * * $(TABLE_SV * $(TR $(TH x) $(TH ilogb(x)) $(TH Range error?)) * $(TR $(TD 0) $(TD FP_ILOGB0) $(TD yes)) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD int.max) $(TD no)) * $(TR $(TD $(NAN)) $(TD FP_ILOGBNAN) $(TD no)) * ) */ int ilogb(T)(const T x) @trusted pure nothrow @nogc if (isFloatingPoint!T) { import core.bitop : bsr; alias F = floatTraits!T; union floatBits { T rv; ushort[T.sizeof/2] vu; uint[T.sizeof/4] vui; static if (T.sizeof >= 8) ulong[T.sizeof/8] vul; } floatBits y = void; y.rv = x; int ex = y.vu[F.EXPPOS_SHORT] & F.EXPMASK; static if (F.realFormat == RealFormat.ieeeExtended) { if (ex) { // If exponent is non-zero if (ex == F.EXPMASK) // infinity or NaN { if (y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF) // NaN return FP_ILOGBNAN; else // +-infinity return int.max; } else { return ex - F.EXPBIAS - 1; } } else if (!y.vul[0]) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(y.vul[0]); } } else static if (F.realFormat == RealFormat.ieeeQuadruple) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) { // infinity or NaN if (y.vul[MANTISSA_LSB] | ( y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) // NaN return FP_ILOGBNAN; else // +- infinity return int.max; } else { return ex - F.EXPBIAS - 1; } } else if ((y.vul[MANTISSA_LSB] | (y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF)) == 0) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal const ulong msb = y.vul[MANTISSA_MSB] & 0x0000_FFFF_FFFF_FFFF; const ulong lsb = y.vul[MANTISSA_LSB]; if (msb) return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(msb) + 64; else return ex - F.EXPBIAS - T.mant_dig + 1 + bsr(lsb); } } else static if (F.realFormat == RealFormat.ieeeDouble) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if ((y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FF0_0000_0000_0000) // +- infinity return int.max; else // NaN return FP_ILOGBNAN; } else { return ((ex - F.EXPBIAS) >> 4) - 1; } } else if (!(y.vul[0] & 0x7FFF_FFFF_FFFF_FFFF)) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal enum MANTISSAMASK_64 = ((cast(ulong) F.MANTISSAMASK_INT) << 32) | 0xFFFF_FFFF; return ((ex - F.EXPBIAS) >> 4) - T.mant_dig + 1 + bsr(y.vul[0] & MANTISSAMASK_64); } } else static if (F.realFormat == RealFormat.ieeeSingle) { if (ex) // If exponent is non-zero { if (ex == F.EXPMASK) // infinity or NaN { if ((y.vui[0] & 0x7FFF_FFFF) == 0x7F80_0000) // +- infinity return int.max; else // NaN return FP_ILOGBNAN; } else { return ((ex - F.EXPBIAS) >> 7) - 1; } } else if (!(y.vui[0] & 0x7FFF_FFFF)) { // vf is +-0.0 return FP_ILOGB0; } else { // subnormal const uint mantissa = y.vui[0] & F.MANTISSAMASK_INT; return ((ex - F.EXPBIAS) >> 7) - T.mant_dig + 1 + bsr(mantissa); } } else // static if (F.realFormat == RealFormat.ibmExtended) { assert(0, "ilogb not implemented"); } } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc if (isIntegral!T && isUnsigned!T) { import core.bitop : bsr; if (x == 0) return FP_ILOGB0; else { static assert(T.sizeof <= ulong.sizeof, "integer size too large for the current ilogb implementation"); return bsr(x); } } /// ditto int ilogb(T)(const T x) @safe pure nothrow @nogc if (isIntegral!T && isSigned!T) { import std.traits : Unsigned; // Note: abs(x) can not be used because the return type is not Unsigned and // the return value would be wrong for x == int.min Unsigned!T absx = x >= 0 ? x : -x; return ilogb(absx); } /// @safe pure unittest { assert(ilogb(1) == 0); assert(ilogb(3) == 1); assert(ilogb(3.0) == 1); assert(ilogb(100_000_000) == 26); assert(ilogb(0) == FP_ILOGB0); assert(ilogb(0.0) == FP_ILOGB0); assert(ilogb(double.nan) == FP_ILOGBNAN); assert(ilogb(double.infinity) == int.max); } /** Special return values of $(LREF ilogb). */ alias FP_ILOGB0 = core.stdc.math.FP_ILOGB0; /// ditto alias FP_ILOGBNAN = core.stdc.math.FP_ILOGBNAN; /// @safe pure unittest { assert(ilogb(0) == FP_ILOGB0); assert(ilogb(0.0) == FP_ILOGB0); assert(ilogb(double.nan) == FP_ILOGBNAN); } @safe nothrow @nogc unittest { import std.meta : AliasSeq; import std.typecons : Tuple; static foreach (F; AliasSeq!(float, double, real)) {{ alias T = Tuple!(F, int); T[13] vals = // x, ilogb(x) [ T( F.nan , FP_ILOGBNAN ), T( -F.nan , FP_ILOGBNAN ), T( F.infinity, int.max ), T( -F.infinity, int.max ), T( 0.0 , FP_ILOGB0 ), T( -0.0 , FP_ILOGB0 ), T( 2.0 , 1 ), T( 2.0001 , 1 ), T( 1.9999 , 0 ), T( 0.5 , -1 ), T( 123.123 , 6 ), T( -123.123 , 6 ), T( 0.123 , -4 ), ]; foreach (elem; vals) { assert(ilogb(elem[0]) == elem[1]); } }} // min_normal and subnormals assert(ilogb(-float.min_normal) == -126); assert(ilogb(nextUp(-float.min_normal)) == -127); assert(ilogb(nextUp(-float(0.0))) == -149); assert(ilogb(-double.min_normal) == -1022); assert(ilogb(nextUp(-double.min_normal)) == -1023); assert(ilogb(nextUp(-double(0.0))) == -1074); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { assert(ilogb(-real.min_normal) == -16382); assert(ilogb(nextUp(-real.min_normal)) == -16383); assert(ilogb(nextUp(-real(0.0))) == -16445); } else static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { assert(ilogb(-real.min_normal) == -1022); assert(ilogb(nextUp(-real.min_normal)) == -1023); assert(ilogb(nextUp(-real(0.0))) == -1074); } // test integer types assert(ilogb(0) == FP_ILOGB0); assert(ilogb(int.max) == 30); assert(ilogb(int.min) == 31); assert(ilogb(uint.max) == 31); assert(ilogb(long.max) == 62); assert(ilogb(long.min) == 63); assert(ilogb(ulong.max) == 63); } /******************************************* * Compute n * 2$(SUPERSCRIPT exp) * References: frexp */ real ldexp(real n, int exp) @nogc @safe pure nothrow { pragma(inline, true); return core.math.ldexp(n, exp); } //FIXME ///ditto double ldexp(double n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) n, exp); } //FIXME ///ditto float ldexp(float n, int exp) @safe pure nothrow @nogc { return ldexp(cast(real) n, exp); } /// @nogc @safe pure nothrow unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ T r; r = ldexp(3.0L, 3); assert(r == 24); r = ldexp(cast(T) 3.0, cast(int) 3); assert(r == 24); T n = 3.0; int exp = 3; r = ldexp(n, exp); assert(r == 24); }} } @safe pure nothrow @nogc unittest { static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended || floatTraits!(real).realFormat == RealFormat.ieeeQuadruple) { assert(ldexp(1.0L, -16384) == 0x1p-16384L); assert(ldexp(1.0L, -16382) == 0x1p-16382L); int x; real n = frexp(0x1p-16384L, x); assert(n == 0.5L); assert(x==-16383); assert(ldexp(n, x)==0x1p-16384L); } else static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { assert(ldexp(1.0L, -1024) == 0x1p-1024L); assert(ldexp(1.0L, -1022) == 0x1p-1022L); int x; real n = frexp(0x1p-1024L, x); assert(n == 0.5L); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024L); } else static assert(false, "Floating point type real not supported"); } /* workaround Issue 14718, float parsing depends on platform strtold @safe pure nothrow @nogc unittest { assert(ldexp(1.0, -1024) == 0x1p-1024); assert(ldexp(1.0, -1022) == 0x1p-1022); int x; double n = frexp(0x1p-1024, x); assert(n == 0.5); assert(x==-1023); assert(ldexp(n, x)==0x1p-1024); } @safe pure nothrow @nogc unittest { assert(ldexp(1.0f, -128) == 0x1p-128f); assert(ldexp(1.0f, -126) == 0x1p-126f); int x; float n = frexp(0x1p-128f, x); assert(n == 0.5f); assert(x==-127); assert(ldexp(n, x)==0x1p-128f); } */ @safe @nogc nothrow unittest { static real[3][] vals = // value,exp,ldexp [ [ 0, 0, 0], [ 1, 0, 1], [ -1, 0, -1], [ 1, 1, 2], [ 123, 10, 125952], [ real.max, int.max, real.infinity], [ real.max, -int.max, 0], [ real.min_normal, -int.max, 0], ]; int i; for (i = 0; i < vals.length; i++) { real x = vals[i][0]; int exp = cast(int) vals[i][1]; real z = vals[i][2]; real l = ldexp(x, exp); assert(equalsDigit(z, l, 7)); } real function(real, int) pldexp = &ldexp; assert(pldexp != null); } private { version (INLINE_YL2X) {} else { static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) { // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) static immutable real[13] logCoeffsP = [ 1.313572404063446165910279910527789794488E4L, 7.771154681358524243729929227226708890930E4L, 2.014652742082537582487669938141683759923E5L, 3.007007295140399532324943111654767187848E5L, 2.854829159639697837788887080758954924001E5L, 1.797628303815655343403735250238293741397E5L, 7.594356839258970405033155585486712125861E4L, 2.128857716871515081352991964243375186031E4L, 3.824952356185897735160588078446136783779E3L, 4.114517881637811823002128927449878962058E2L, 2.321125933898420063925789532045674660756E1L, 4.998469661968096229986658302195402690910E-1L, 1.538612243596254322971797716843006400388E-6L ]; static immutable real[13] logCoeffsQ = [ 3.940717212190338497730839731583397586124E4L, 2.626900195321832660448791748036714883242E5L, 7.777690340007566932935753241556479363645E5L, 1.347518538384329112529391120390701166528E6L, 1.514882452993549494932585972882995548426E6L, 1.158019977462989115839826904108208787040E6L, 6.132189329546557743179177159925690841200E5L, 2.248234257620569139969141618556349415120E5L, 5.605842085972455027590989944010492125825E4L, 9.147150349299596453976674231612674085381E3L, 9.104928120962988414618126155557301584078E2L, 4.839208193348159620282142911143429644326E1L, 1.0 ]; // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) // where z = 2(x-1)/(x+1) static immutable real[6] logCoeffsR = [ -8.828896441624934385266096344596648080902E-1L, 8.057002716646055371965756206836056074715E1L, -2.024301798136027039250415126250455056397E3L, 2.048819892795278657810231591630928516206E4L, -8.977257995689735303686582344659576526998E4L, 1.418134209872192732479751274970992665513E5L ]; static immutable real[6] logCoeffsS = [ 1.701761051846631278975701529965589676574E6L -1.332535117259762928288745111081235577029E6L, 4.001557694070773974936904547424676279307E5L, -5.748542087379434595104154610899551484314E4L, 3.998526750980007367835804959888064681098E3L, -1.186359407982897997337150403816839480438E2L, 1.0 ]; } else { // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) static immutable real[7] logCoeffsP = [ 2.0039553499201281259648E1L, 5.7112963590585538103336E1L, 6.0949667980987787057556E1L, 2.9911919328553073277375E1L, 6.5787325942061044846969E0L, 4.9854102823193375972212E-1L, 4.5270000862445199635215E-5L, ]; static immutable real[7] logCoeffsQ = [ 6.0118660497603843919306E1L, 2.1642788614495947685003E2L, 3.0909872225312059774938E2L, 2.2176239823732856465394E2L, 8.3047565967967209469434E1L, 1.5062909083469192043167E1L, 1.0000000000000000000000E0L, ]; // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) // where z = 2(x-1)/(x+1) static immutable real[4] logCoeffsR = [ -3.5717684488096787370998E1L, 1.0777257190312272158094E1L, -7.1990767473014147232598E-1L, 1.9757429581415468984296E-3L, ]; static immutable real[4] logCoeffsS = [ -4.2861221385716144629696E2L, 1.9361891836232102174846E2L, -2.6201045551331104417768E1L, 1.0000000000000000000000E0L, ]; } } } /************************************** * Calculate the natural logarithm of x. * * $(TABLE_SV * $(TR $(TH x) $(TH log(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) * ) */ real log(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, LN2); else { // C1 + C2 = LN2. enum real C1 = 6.93145751953125E-1L; enum real C2 = 1.428606820309417232121458176568075500134E-6L; // Special cases. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; z = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); z += exp * C2; z += x; z += exp * C1; return z; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else { x = x - 1.0; } z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y += exp * C2; z = y - ldexp(z, -1); // Note, the sum of above terms does not exceed x/4, // so it contributes at most about 1/4 lsb to the error. z += x; z += exp * C1; return z; } } /// @safe pure nothrow @nogc unittest { assert(feqrel(log(E), 1) >= real.mant_dig - 1); } /************************************** * Calculate the base-10 logarithm of x. * * $(TABLE_SV * $(TR $(TH x) $(TH log10(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) * ) */ real log10(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, LOG2); else { // log10(2) split into two parts. enum real L102A = 0.3125L; enum real L102B = -1.14700043360188047862611052755069732318101185E-2L; // log10(e) split into two parts. enum real L10EA = 0.5L; enum real L10EB = -6.570551809674817234887108108339491770560299E-2L; // Special cases are the same as for log. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); goto Ldone; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else x = x - 1.0; z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y = y - ldexp(z, -1); // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). // This sequence of operations is critical and it may be horribly // defeated by some compiler optimizers. Ldone: z = y * L10EB; z += x * L10EB; z += exp * L102B; z += y * L10EA; z += x * L10EA; z += exp * L102A; return z; } } /// @safe pure nothrow @nogc unittest { assert(fabs(log10(1000) - 3) < .000001); } /** * Calculates the natural logarithm of 1 + x. * * For very small x, log1p(x) will be more accurate than * log(1 + x). * * $(TABLE_SV * $(TR $(TH x) $(TH log1p(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) $(TD no)) * $(TR $(TD -1.0) $(TD -$(INFIN)) $(TD yes) $(TD no)) * $(TR $(TD $(LT)-1.0) $(TD -$(NAN)) $(TD no) $(TD yes)) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no)) * ) */ real log1p(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) { // On x87, yl2xp1 is valid if and only if -0.5 <= lg(x) <= 0.5, // ie if -0.29 <= x <= 0.414 return (fabs(x) <= 0.25) ? core.math.yl2xp1(x, LN2) : core.math.yl2x(x+1, LN2); } else { // Special cases. if (isNaN(x) || x == 0.0) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == -1.0) return -real.infinity; if (x < -1.0) return real.nan; return log(x + 1.0); } } /// @safe pure unittest { assert(isIdentical(log1p(0.0), 0.0)); assert(log1p(1.0).feqrel(0.69314) > 16); assert(log1p(-1.0) == -real.infinity); assert(isNaN(log1p(-2.0))); assert(log1p(real.nan) is real.nan); assert(log1p(-real.nan) is -real.nan); assert(log1p(real.infinity) == real.infinity); } /*************************************** * Calculates the base-2 logarithm of x: * $(SUB log, 2)x * * $(TABLE_SV * $(TR $(TH x) $(TH log2(x)) $(TH divide by 0?) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) $(TD no) ) * $(TR $(TD $(LT)0.0) $(TD $(NAN)) $(TD no) $(TD yes) ) * $(TR $(TD +$(INFIN)) $(TD +$(INFIN)) $(TD no) $(TD no) ) * ) */ real log2(real x) @safe pure nothrow @nogc { version (INLINE_YL2X) return core.math.yl2x(x, 1); else { // Special cases are the same as for log. if (isNaN(x)) return x; if (isInfinity(x) && !signbit(x)) return x; if (x == 0.0) return -real.infinity; if (x < 0.0) return real.nan; // Separate mantissa from exponent. // Note, frexp is used so that denormal numbers will be handled properly. real y, z; int exp; x = frexp(x, exp); // Logarithm using log(x) = z + z^^3 R(z) / S(z), // where z = 2(x - 1)/(x + 1) if ((exp > 2) || (exp < -2)) { if (x < SQRT1_2) { // 2(2x - 1)/(2x + 1) exp -= 1; z = x - 0.5; y = 0.5 * z + 0.5; } else { // 2(x - 1)/(x + 1) z = x - 0.5; z -= 0.5; y = 0.5 * x + 0.5; } x = z / y; z = x * x; y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); goto Ldone; } // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) if (x < SQRT1_2) { // 2x - 1 exp -= 1; x = ldexp(x, 1) - 1.0; } else x = x - 1.0; z = x * x; y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); y = y - ldexp(z, -1); // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). // This sequence of operations is critical and it may be horribly // defeated by some compiler optimizers. Ldone: z = y * (LOG2E - 1.0); z += x * (LOG2E - 1.0); z += y; z += x; z += exp; return z; } } /// @safe unittest { assert(approxEqual(log2(1024.0L), 10)); } @safe @nogc nothrow unittest { // check if values are equal to 19 decimal digits of precision assert(equalsDigit(log2(1024.0L), 10, 19)); } /***************************************** * Extracts the exponent of x as a signed integral value. * * If x is subnormal, it is treated as if it were normalized. * For a positive, finite x: * * 1 $(LT)= $(I x) * FLT_RADIX$(SUPERSCRIPT -logb(x)) $(LT) FLT_RADIX * * $(TABLE_SV * $(TR $(TH x) $(TH logb(x)) $(TH divide by 0?) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) $(TD no)) * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) ) * ) */ real logb(real x) @trusted nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fxtract ; fstp ST(0) ; ret ; } } else version (MSVC_InlineAsm) { asm pure nothrow @nogc { fld x ; fxtract ; fstp ST(0) ; } } else return core.stdc.math.logbl(x); } /// @safe @nogc nothrow unittest { assert(logb(1.0) == 0); assert(logb(100.0) == 6); assert(logb(0.0) == -real.infinity); assert(logb(real.infinity) == real.infinity); assert(logb(-real.infinity) == real.infinity); } /************************************ * Calculates the remainder from the calculation x/y. * Returns: * The value of x - i * y, where i is the number of times that y can * be completely subtracted from x. The result has the same sign as x. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH fmod(x, y)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD not 0.0) $(TD $(PLUSMN)0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD $(NAN)) $(TD yes)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(NAN)) $(TD yes)) * $(TR $(TD !=$(PLUSMNINF)) $(TD $(PLUSMNINF)) $(TD x) $(TD no)) * ) */ real fmod(real x, real y) @trusted nothrow @nogc { version (CRuntime_Microsoft) { return x % y; } else return core.stdc.math.fmodl(x, y); } /// @safe unittest { assert(isIdentical(fmod(0.0, 1.0), 0.0)); assert(fmod(5.0, 3.0).feqrel(2.0) > 16); assert(isNaN(fmod(5.0, 0.0))); } /************************************ * Breaks x into an integral part and a fractional part, each of which has * the same sign as x. The integral part is stored in i. * Returns: * The fractional part of x. * * $(TABLE_SV * $(TR $(TH x) $(TH i (on input)) $(TH modf(x, i)) $(TH i (on return))) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(PLUSMNINF))) * ) */ real modf(real x, ref real i) @trusted nothrow @nogc { version (CRuntime_Microsoft) { i = trunc(x); return copysign(isInfinity(x) ? 0.0 : x - i, x); } else return core.stdc.math.modfl(x,&i); } /// @safe unittest { real frac; real intpart; frac = modf(3.14159, intpart); assert(intpart.feqrel(3.0) > 16); assert(frac.feqrel(0.14159) > 16); } /************************************* * Efficiently calculates x * 2$(SUPERSCRIPT n). * * scalbn handles underflow and overflow in * the same fashion as the basic arithmetic operators. * * $(TABLE_SV * $(TR $(TH x) $(TH scalb(x))) * $(TR $(TD $(PLUSMNINF)) $(TD $(PLUSMNINF)) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) ) * ) */ real scalbn(real x, int n) @trusted nothrow @nogc { version (InlineAsm_X86_Any) { // scalbnl is not supported on DMD-Windows, so use asm pure nothrow @nogc. version (Win64) { asm pure nothrow @nogc { naked ; mov 16[RSP],RCX ; fild word ptr 16[RSP] ; fld real ptr [RDX] ; fscale ; fstp ST(1) ; ret ; } } else { asm pure nothrow @nogc { fild n; fld x; fscale; fstp ST(1); } } } else { return core.stdc.math.scalbnl(x, n); } } /// @safe nothrow @nogc unittest { assert(scalbn(-real.infinity, 5) == -real.infinity); } /*************** * Calculates the cube root of x. * * $(TABLE_SV * $(TR $(TH $(I x)) $(TH cbrt(x)) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)0.0) $(TD no) ) * $(TR $(TD $(NAN)) $(TD $(NAN)) $(TD yes) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD $(PLUSMN)$(INFIN)) $(TD no) ) * ) */ real cbrt(real x) @trusted nothrow @nogc { version (CRuntime_Microsoft) { version (INLINE_YL2X) return copysign(exp2(core.math.yl2x(fabs(x), 1.0L/3.0L)), x); else return core.stdc.math.cbrtl(x); } else return core.stdc.math.cbrtl(x); } /// @safe unittest { assert(cbrt(1.0).feqrel(1.0) > 16); assert(cbrt(27.0).feqrel(3.0) > 16); assert(cbrt(15.625).feqrel(2.5) > 16); } /******************************* * Returns |x| * * $(TABLE_SV * $(TR $(TH x) $(TH fabs(x))) * $(TR $(TD $(PLUSMN)0.0) $(TD +0.0) ) * $(TR $(TD $(PLUSMN)$(INFIN)) $(TD +$(INFIN)) ) * ) */ real fabs(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.fabs(x); } //FIXME ///ditto double fabs(double x) @safe pure nothrow @nogc { return fabs(cast(real) x); } //FIXME ///ditto float fabs(float x) @safe pure nothrow @nogc { return fabs(cast(real) x); } /// @safe unittest { assert(isIdentical(fabs(0.0), 0.0)); assert(isIdentical(fabs(-0.0), 0.0)); assert(fabs(-10.0) == 10.0); } @safe unittest { real function(real) pfabs = &fabs; assert(pfabs != null); } /*********************************************************************** * Calculates the length of the * hypotenuse of a right-angled triangle with sides of length x and y. * The hypotenuse is the value of the square root of * the sums of the squares of x and y: * * sqrt($(POWER x, 2) + $(POWER y, 2)) * * Note that hypot(x, y), hypot(y, x) and * hypot(x, -y) are equivalent. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH hypot(x, y)) $(TH invalid?)) * $(TR $(TD x) $(TD $(PLUSMN)0.0) $(TD |x|) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD y) $(TD +$(INFIN)) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD $(NAN)) $(TD +$(INFIN)) $(TD no)) * ) */ real hypot(real x, real y) @safe pure nothrow @nogc { // Scale x and y to avoid underflow and overflow. // If one is huge and the other tiny, return the larger. // If both are huge, avoid overflow by scaling by 1/sqrt(real.max/2). // If both are tiny, avoid underflow by scaling by sqrt(real.min_normal*real.epsilon). enum real SQRTMIN = 0.5 * sqrt(real.min_normal); // This is a power of 2. enum real SQRTMAX = 1.0L / SQRTMIN; // 2^^((max_exp)/2) = nextUp(sqrt(real.max)) static assert(2*(SQRTMAX/2)*(SQRTMAX/2) <= real.max); // Proves that sqrt(real.max) ~~ 0.5/sqrt(real.min_normal) static assert(real.min_normal*real.max > 2 && real.min_normal*real.max <= 4); real u = fabs(x); real v = fabs(y); if (!(u >= v)) // check for NaN as well. { v = u; u = fabs(y); if (u == real.infinity) return u; // hypot(inf, nan) == inf if (v == real.infinity) return v; // hypot(nan, inf) == inf } // Now u >= v, or else one is NaN. if (v >= SQRTMAX*0.5) { // hypot(huge, huge) -- avoid overflow u *= SQRTMIN*0.5; v *= SQRTMIN*0.5; return sqrt(u*u + v*v) * SQRTMAX * 2.0; } if (u <= SQRTMIN) { // hypot (tiny, tiny) -- avoid underflow // This is only necessary to avoid setting the underflow // flag. u *= SQRTMAX / real.epsilon; v *= SQRTMAX / real.epsilon; return sqrt(u*u + v*v) * SQRTMIN * real.epsilon; } if (u * real.epsilon > v) { // hypot (huge, tiny) = huge return u; } // both are in the normal range return sqrt(u*u + v*v); } /// @safe unittest { assert(hypot(1.0, 1.0).feqrel(1.4142) > 16); assert(hypot(3.0, 4.0).feqrel(5.0) > 16); assert(hypot(real.infinity, 1.0) == real.infinity); assert(hypot(real.infinity, real.nan) == real.infinity); } @safe unittest { static real[3][] vals = // x,y,hypot [ [ 0.0, 0.0, 0.0], [ 0.0, -0.0, 0.0], [ -0.0, -0.0, 0.0], [ 3.0, 4.0, 5.0], [ -300, -400, 500], [0.0, 7.0, 7.0], [9.0, 9*real.epsilon, 9.0], [88/(64*sqrt(real.min_normal)), 105/(64*sqrt(real.min_normal)), 137/(64*sqrt(real.min_normal))], [88/(128*sqrt(real.min_normal)), 105/(128*sqrt(real.min_normal)), 137/(128*sqrt(real.min_normal))], [3*real.min_normal*real.epsilon, 4*real.min_normal*real.epsilon, 5*real.min_normal*real.epsilon], [ real.min_normal, real.min_normal, sqrt(2.0L)*real.min_normal], [ real.max/sqrt(2.0L), real.max/sqrt(2.0L), real.max], [ real.infinity, real.nan, real.infinity], [ real.nan, real.infinity, real.infinity], [ real.nan, real.nan, real.nan], [ real.nan, real.max, real.nan], [ real.max, real.nan, real.nan], ]; for (int i = 0; i < vals.length; i++) { real x = vals[i][0]; real y = vals[i][1]; real z = vals[i][2]; real h = hypot(x, y); assert(isIdentical(z,h) || feqrel(z, h) >= real.mant_dig - 1); } } /************************************** * Returns the value of x rounded upward to the next integer * (toward positive infinity). */ real ceil(real x) @trusted pure nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x08 ; // round to +infinity mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version (MSVC_InlineAsm) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x08 ; // round to +infinity mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else { // Special cases. if (isNaN(x) || isInfinity(x)) return x; real y = floorImpl(x); if (y < x) y += 1.0; return y; } } /// @safe pure nothrow @nogc unittest { assert(ceil(+123.456L) == +124); assert(ceil(-123.456L) == -123); assert(ceil(-1.234L) == -1); assert(ceil(-0.123L) == 0); assert(ceil(0.0L) == 0); assert(ceil(+0.123L) == 1); assert(ceil(+1.234L) == 2); assert(ceil(real.infinity) == real.infinity); assert(isNaN(ceil(real.nan))); assert(isNaN(ceil(real.init))); } /// ditto double ceil(double x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x)) return x; double y = floorImpl(x); if (y < x) y += 1.0; return y; } @safe pure nothrow @nogc unittest { assert(ceil(+123.456) == +124); assert(ceil(-123.456) == -123); assert(ceil(-1.234) == -1); assert(ceil(-0.123) == 0); assert(ceil(0.0) == 0); assert(ceil(+0.123) == 1); assert(ceil(+1.234) == 2); assert(ceil(double.infinity) == double.infinity); assert(isNaN(ceil(double.nan))); assert(isNaN(ceil(double.init))); } /// ditto float ceil(float x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x)) return x; float y = floorImpl(x); if (y < x) y += 1.0; return y; } @safe pure nothrow @nogc unittest { assert(ceil(+123.456f) == +124); assert(ceil(-123.456f) == -123); assert(ceil(-1.234f) == -1); assert(ceil(-0.123f) == 0); assert(ceil(0.0f) == 0); assert(ceil(+0.123f) == 1); assert(ceil(+1.234f) == 2); assert(ceil(float.infinity) == float.infinity); assert(isNaN(ceil(float.nan))); assert(isNaN(ceil(float.init))); } /************************************** * Returns the value of x rounded downward to the next integer * (toward negative infinity). */ real floor(real x) @trusted pure nothrow @nogc { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x04 ; // round to -infinity mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version (MSVC_InlineAsm) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x04 ; // round to -infinity mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } } /// @safe pure nothrow @nogc unittest { assert(floor(+123.456L) == +123); assert(floor(-123.456L) == -124); assert(floor(+123.0L) == +123); assert(floor(-124.0L) == -124); assert(floor(-1.234L) == -2); assert(floor(-0.123L) == -1); assert(floor(0.0L) == 0); assert(floor(+0.123L) == 0); assert(floor(+1.234L) == 1); assert(floor(real.infinity) == real.infinity); assert(isNaN(floor(real.nan))); assert(isNaN(floor(real.init))); } /// ditto double floor(double x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } @safe pure nothrow @nogc unittest { assert(floor(+123.456) == +123); assert(floor(-123.456) == -124); assert(floor(+123.0) == +123); assert(floor(-124.0) == -124); assert(floor(-1.234) == -2); assert(floor(-0.123) == -1); assert(floor(0.0) == 0); assert(floor(+0.123) == 0); assert(floor(+1.234) == 1); assert(floor(double.infinity) == double.infinity); assert(isNaN(floor(double.nan))); assert(isNaN(floor(double.init))); } /// ditto float floor(float x) @trusted pure nothrow @nogc { // Special cases. if (isNaN(x) || isInfinity(x) || x == 0.0) return x; return floorImpl(x); } @safe pure nothrow @nogc unittest { assert(floor(+123.456f) == +123); assert(floor(-123.456f) == -124); assert(floor(+123.0f) == +123); assert(floor(-124.0f) == -124); assert(floor(-1.234f) == -2); assert(floor(-0.123f) == -1); assert(floor(0.0f) == 0); assert(floor(+0.123f) == 0); assert(floor(+1.234f) == 1); assert(floor(float.infinity) == float.infinity); assert(isNaN(floor(float.nan))); assert(isNaN(floor(float.init))); } /** * Round `val` to a multiple of `unit`. `rfunc` specifies the rounding * function to use; by default this is `rint`, which uses the current * rounding mode. */ Unqual!F quantize(alias rfunc = rint, F)(const F val, const F unit) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { typeof(return) ret = val; if (unit != 0) { const scaled = val / unit; if (!scaled.isInfinity) ret = rfunc(scaled) * unit; } return ret; } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize(0.01L) == 12345.68L); assert(12345.6789L.quantize!floor(0.01L) == 12345.67L); assert(12345.6789L.quantize(22.0L) == 12342.0L); } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize(0) == 12345.6789L); assert(12345.6789L.quantize(real.infinity).isNaN); assert(12345.6789L.quantize(real.nan).isNaN); assert(real.infinity.quantize(0.01L) == real.infinity); assert(real.infinity.quantize(real.nan).isNaN); assert(real.nan.quantize(0.01L).isNaN); assert(real.nan.quantize(real.infinity).isNaN); assert(real.nan.quantize(real.nan).isNaN); } /** * Round `val` to a multiple of `pow(base, exp)`. `rfunc` specifies the * rounding function to use; by default this is `rint`, which uses the * current rounding mode. */ Unqual!F quantize(real base, alias rfunc = rint, F, E)(const F val, const E exp) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F && isIntegral!E) { // TODO: Compile-time optimization for power-of-two bases? return quantize!rfunc(val, pow(cast(F) base, exp)); } /// ditto Unqual!F quantize(real base, long exp = 1, alias rfunc = rint, F)(const F val) if (is(typeof(rfunc(F.init)) : F) && isFloatingPoint!F) { enum unit = cast(F) pow(base, exp); return quantize!rfunc(val, unit); } /// @safe pure nothrow @nogc unittest { assert(12345.6789L.quantize!10(-2) == 12345.68L); assert(12345.6789L.quantize!(10, -2) == 12345.68L); assert(12345.6789L.quantize!(10, floor)(-2) == 12345.67L); assert(12345.6789L.quantize!(10, -2, floor) == 12345.67L); assert(12345.6789L.quantize!22(1) == 12342.0L); assert(12345.6789L.quantize!22 == 12342.0L); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (F; AliasSeq!(real, double, float)) {{ const maxL10 = cast(int) F.max.log10.floor; const maxR10 = pow(cast(F) 10, maxL10); assert((cast(F) 0.9L * maxR10).quantize!10(maxL10) == maxR10); assert((cast(F)-0.9L * maxR10).quantize!10(maxL10) == -maxR10); assert(F.max.quantize(F.min_normal) == F.max); assert((-F.max).quantize(F.min_normal) == -F.max); assert(F.min_normal.quantize(F.max) == 0); assert((-F.min_normal).quantize(F.max) == 0); assert(F.min_normal.quantize(F.min_normal) == F.min_normal); assert((-F.min_normal).quantize(F.min_normal) == -F.min_normal); }} } /****************************************** * Rounds x to the nearest integer value, using the current rounding * mode. * * Unlike the rint functions, nearbyint does not raise the * FE_INEXACT exception. * * Note: * Not implemented for Microsoft C Runtime */ real nearbyint(real x) @safe pure nothrow @nogc { version (CRuntime_Microsoft) assert(0, "nearbyintl not implemented in Microsoft C library"); else return core.stdc.math.nearbyintl(x); } /// @safe pure unittest { version (CRuntime_Microsoft) {} else { assert(nearbyint(0.4) == 0); assert(nearbyint(0.5) == 0); assert(nearbyint(0.6) == 1); assert(nearbyint(100.0) == 100); assert(isNaN(nearbyint(real.nan))); assert(nearbyint(real.infinity) == real.infinity); assert(nearbyint(-real.infinity) == -real.infinity); } } /********************************** * Rounds x to the nearest integer value, using the current rounding * mode. * * If the return value is not equal to x, the FE_INEXACT * exception is raised. * * $(LREF nearbyint) performs the same operation, but does * not set the FE_INEXACT exception. */ real rint(real x) @safe pure nothrow @nogc { pragma(inline, true); return core.math.rint(x); } //FIXME ///ditto double rint(double x) @safe pure nothrow @nogc { return rint(cast(real) x); } //FIXME ///ditto float rint(float x) @safe pure nothrow @nogc { return rint(cast(real) x); } /// @safe unittest { version (InlineAsm_X86_Any) { resetIeeeFlags(); assert(rint(0.4) == 0); assert(ieeeFlags.inexact); assert(rint(0.5) == 0); assert(rint(0.6) == 1); assert(rint(100.0) == 100); assert(isNaN(rint(real.nan))); assert(rint(real.infinity) == real.infinity); assert(rint(-real.infinity) == -real.infinity); } } @safe unittest { real function(real) print = &rint; assert(print != null); } /*************************************** * Rounds x to the nearest integer value, using the current rounding * mode. * * This is generally the fastest method to convert a floating-point number * to an integer. Note that the results from this function * depend on the rounding mode, if the fractional part of x is exactly 0.5. * If using the default rounding mode (ties round to even integers) * lrint(4.5) == 4, lrint(5.5)==6. */ long lrint(real x) @trusted pure nothrow @nogc { version (InlineAsm_X86_Any) { version (Win64) { asm pure nothrow @nogc { naked; fld real ptr [RCX]; fistp qword ptr 8[RSP]; mov RAX,8[RSP]; ret; } } else { long n; asm pure nothrow @nogc { fld x; fistp n; } return n; } } else { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { long result; // Rounding limit when casting from real(double) to ulong. enum real OF = 4.50359962737049600000E15L; uint* vi = cast(uint*)(&x); // Find the exponent and sign uint msb = vi[MANTISSA_MSB]; uint lsb = vi[MANTISSA_LSB]; int exp = ((msb >> 20) & 0x7ff) - 0x3ff; const int sign = msb >> 31; msb &= 0xfffff; msb |= 0x100000; if (exp < 63) { if (exp >= 52) result = (cast(long) msb << (exp - 20)) | (lsb << (exp - 52)); else { // Adjust x and check result. const real j = sign ? -OF : OF; x = (j + x) - j; msb = vi[MANTISSA_MSB]; lsb = vi[MANTISSA_LSB]; exp = ((msb >> 20) & 0x7ff) - 0x3ff; msb &= 0xfffff; msb |= 0x100000; if (exp < 0) result = 0; else if (exp < 20) result = cast(long) msb >> (20 - exp); else if (exp == 20) result = cast(long) msb; else result = (cast(long) msb << (exp - 20)) | (lsb >> (52 - exp)); } } else { // It is left implementation defined when the number is too large. return cast(long) x; } return sign ? -result : result; } else static if (F.realFormat == RealFormat.ieeeExtended) { long result; // Rounding limit when casting from real(80-bit) to ulong. enum real OF = 9.22337203685477580800E18L; ushort* vu = cast(ushort*)(&x); uint* vi = cast(uint*)(&x); // Find the exponent and sign int exp = (vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; const int sign = (vu[F.EXPPOS_SHORT] >> 15) & 1; if (exp < 63) { // Adjust x and check result. const real j = sign ? -OF : OF; x = (j + x) - j; exp = (vu[F.EXPPOS_SHORT] & 0x7fff) - 0x3fff; version (LittleEndian) { if (exp < 0) result = 0; else if (exp <= 31) result = vi[1] >> (31 - exp); else result = (cast(long) vi[1] << (exp - 31)) | (vi[0] >> (63 - exp)); } else { if (exp < 0) result = 0; else if (exp <= 31) result = vi[1] >> (31 - exp); else result = (cast(long) vi[1] << (exp - 31)) | (vi[2] >> (63 - exp)); } } else { // It is left implementation defined when the number is too large // to fit in a 64bit long. return cast(long) x; } return sign ? -result : result; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const vu = cast(ushort*)(&x); // Find the exponent and sign const sign = (vu[F.EXPPOS_SHORT] >> 15) & 1; if ((vu[F.EXPPOS_SHORT] & F.EXPMASK) - (F.EXPBIAS + 1) > 63) { // The result is left implementation defined when the number is // too large to fit in a 64 bit long. return cast(long) x; } // Force rounding of lower bits according to current rounding // mode by adding ±2^-112 and subtracting it again. enum OF = 5.19229685853482762853049632922009600E33L; const j = sign ? -OF : OF; x = (j + x) - j; const exp = (vu[F.EXPPOS_SHORT] & F.EXPMASK) - (F.EXPBIAS + 1); const implicitOne = 1UL << 48; auto vl = cast(ulong*)(&x); vl[MANTISSA_MSB] &= implicitOne - 1; vl[MANTISSA_MSB] |= implicitOne; long result; if (exp < 0) result = 0; else if (exp <= 48) result = vl[MANTISSA_MSB] >> (48 - exp); else result = (vl[MANTISSA_MSB] << (exp - 48)) | (vl[MANTISSA_LSB] >> (112 - exp)); return sign ? -result : result; } else { static assert(false, "real type not supported by lrint()"); } } } /// @safe pure nothrow @nogc unittest { assert(lrint(4.5) == 4); assert(lrint(5.5) == 6); assert(lrint(-4.5) == -4); assert(lrint(-5.5) == -6); assert(lrint(int.max - 0.5) == 2147483646L); assert(lrint(int.max + 0.5) == 2147483648L); assert(lrint(int.min - 0.5) == -2147483648L); assert(lrint(int.min + 0.5) == -2147483648L); } static if (real.mant_dig >= long.sizeof * 8) { @safe pure nothrow @nogc unittest { assert(lrint(long.max - 1.5L) == long.max - 1); assert(lrint(long.max - 0.5L) == long.max - 1); assert(lrint(long.min + 0.5L) == long.min); assert(lrint(long.min + 1.5L) == long.min + 2); } } /******************************************* * Return the value of x rounded to the nearest integer. * If the fractional part of x is exactly 0.5, the return value is * rounded away from zero. * * Returns: * A `real`. */ auto round(real x) @trusted nothrow @nogc { version (CRuntime_Microsoft) { auto old = FloatingPointControl.getControlState(); FloatingPointControl.setControlState( (old & (-1 - FloatingPointControl.roundingMask)) | FloatingPointControl.roundToZero ); x = rint((x >= 0) ? x + 0.5 : x - 0.5); FloatingPointControl.setControlState(old); return x; } else return core.stdc.math.roundl(x); } /// @safe nothrow @nogc unittest { assert(round(4.5) == 5); assert(round(5.4) == 5); assert(round(-4.5) == -5); assert(round(-5.1) == -5); } // assure purity on Posix version (Posix) { @safe pure nothrow @nogc unittest { assert(round(4.5) == 5); } } /********************************************** * Return the value of x rounded to the nearest integer. * * If the fractional part of x is exactly 0.5, the return value is rounded * away from zero. * * $(BLUE This function is Posix-Only.) */ long lround(real x) @trusted nothrow @nogc { version (Posix) return core.stdc.math.llroundl(x); else assert(0, "lround not implemented"); } /// @safe nothrow @nogc unittest { version (Posix) { assert(lround(0.49) == 0); assert(lround(0.5) == 1); assert(lround(1.5) == 2); } } /** Returns the integer portion of x, dropping the fractional portion. This is also known as "chop" rounding. `pure` on all platforms. */ real trunc(real x) @trusted nothrow @nogc pure { version (Win64_DMD_InlineAsm) { asm pure nothrow @nogc { naked ; fld real ptr [RCX] ; fstcw 8[RSP] ; mov AL,9[RSP] ; mov DL,AL ; and AL,0xC3 ; or AL,0x0C ; // round to 0 mov 9[RSP],AL ; fldcw 8[RSP] ; frndint ; mov 9[RSP],DL ; fldcw 8[RSP] ; ret ; } } else version (MSVC_InlineAsm) { short cw; asm pure nothrow @nogc { fld x ; fstcw cw ; mov AL,byte ptr cw+1 ; mov DL,AL ; and AL,0xC3 ; or AL,0x0C ; // round to 0 mov byte ptr cw+1,AL ; fldcw cw ; frndint ; mov byte ptr cw+1,DL ; fldcw cw ; } } else return core.stdc.math.truncl(x); } /// @safe pure unittest { assert(trunc(0.01) == 0); assert(trunc(0.49) == 0); assert(trunc(0.5) == 0); assert(trunc(1.5) == 1); } /**************************************************** * Calculate the remainder x REM y, following IEC 60559. * * REM is the value of x - y * n, where n is the integer nearest the exact * value of x / y. * If |n - x / y| == 0.5, n is even. * If the result is zero, it has the same sign as x. * Otherwise, the sign of the result is the sign of x / y. * Precision mode has no effect on the remainder functions. * * remquo returns `n` in the parameter `n`. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH remainder(x, y)) $(TH n) $(TH invalid?)) * $(TR $(TD $(PLUSMN)0.0) $(TD not 0.0) $(TD $(PLUSMN)0.0) $(TD 0.0) $(TD no)) * $(TR $(TD $(PLUSMNINF)) $(TD anything) $(TD -$(NAN)) $(TD ?) $(TD yes)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD $(PLUSMN)$(NAN)) $(TD ?) $(TD yes)) * $(TR $(TD != $(PLUSMNINF)) $(TD $(PLUSMNINF)) $(TD x) $(TD ?) $(TD no)) * ) * * $(BLUE `remquo` and `remainder` not supported on Windows.) */ real remainder(real x, real y) @trusted nothrow @nogc { version (CRuntime_Microsoft) { int n; return remquo(x, y, n); } else return core.stdc.math.remainderl(x, y); } /// ditto real remquo(real x, real y, out int n) @trusted nothrow @nogc /// ditto { version (Posix) return core.stdc.math.remquol(x, y, &n); else assert(0, "remquo not implemented"); } /// @safe @nogc nothrow unittest { version (Posix) { assert(remainder(5.1, 3.0).feqrel(-0.9) > 16); assert(remainder(-5.1, 3.0).feqrel(0.9) > 16); assert(remainder(0.0, 3.0) == 0.0); assert(isNaN(remainder(1.0, 0.0))); assert(isNaN(remainder(-1.0, 0.0))); } } /// @safe @nogc nothrow unittest { version (Posix) { int n; assert(remquo(5.1, 3.0, n).feqrel(-0.9) > 16 && n == 2); assert(remquo(-5.1, 3.0, n).feqrel(0.9) > 16 && n == -2); assert(remquo(0.0, 3.0, n) == 0.0 && n == 0); } } /** IEEE exception status flags ('sticky bits') These flags indicate that an exceptional floating-point condition has occurred. They indicate that a NaN or an infinity has been generated, that a result is inexact, or that a signalling NaN has been encountered. If floating-point exceptions are enabled (unmasked), a hardware exception will be generated instead of setting these flags. */ struct IeeeFlags { nothrow @nogc: private: // The x87 FPU status register is 16 bits. // The Pentium SSE2 status register is 32 bits. // The ARM and PowerPC FPSCR is a 32-bit register. // The SPARC FSR is a 32bit register (64 bits for SPARC 7 & 8, but high bits are uninteresting). // The RISC-V (32 & 64 bit) fcsr is 32-bit register. uint flags; version (CRuntime_Microsoft) { // Microsoft uses hardware-incompatible custom constants in fenv.h (core.stdc.fenv). // Applies to both x87 status word (16 bits) and SSE2 status word(32 bits). enum : int { INEXACT_MASK = 0x20, UNDERFLOW_MASK = 0x10, OVERFLOW_MASK = 0x08, DIVBYZERO_MASK = 0x04, INVALID_MASK = 0x01, EXCEPTIONS_MASK = 0b11_1111 } // Don't bother about subnormals, they are not supported on most CPUs. // SUBNORMAL_MASK = 0x02; } else { enum : int { INEXACT_MASK = core.stdc.fenv.FE_INEXACT, UNDERFLOW_MASK = core.stdc.fenv.FE_UNDERFLOW, OVERFLOW_MASK = core.stdc.fenv.FE_OVERFLOW, DIVBYZERO_MASK = core.stdc.fenv.FE_DIVBYZERO, INVALID_MASK = core.stdc.fenv.FE_INVALID, EXCEPTIONS_MASK = core.stdc.fenv.FE_ALL_EXCEPT, } } private: static uint getIeeeFlags() @trusted pure { version (InlineAsm_X86_Any) { ushort sw; asm pure nothrow @nogc { fstsw sw; } // OR the result with the SSE2 status register (MXCSR). if (haveSSE) { uint mxcsr; asm pure nothrow @nogc { stmxcsr mxcsr; } return (sw | mxcsr) & EXCEPTIONS_MASK; } else return sw & EXCEPTIONS_MASK; } else version (SPARC) { /* int retval; asm pure nothrow @nogc { st %fsr, retval; } return retval; */ assert(0, "Not yet supported"); } else version (ARM) { assert(false, "Not yet supported."); } else assert(0, "Not yet supported"); } static void resetIeeeFlags() @trusted { version (InlineAsm_X86_Any) { asm nothrow @nogc { fnclex; } // Also clear exception flags in MXCSR, SSE's control register. if (haveSSE) { uint mxcsr; asm nothrow @nogc { stmxcsr mxcsr; } mxcsr &= ~EXCEPTIONS_MASK; asm nothrow @nogc { ldmxcsr mxcsr; } } } else { /* SPARC: int tmpval; asm pure nothrow @nogc { st %fsr, tmpval; } tmpval &=0xFFFF_FC00; asm pure nothrow @nogc { ld tmpval, %fsr; } */ assert(0, "Not yet supported"); } } public: version (IeeeFlagsSupport) { /** * The result cannot be represented exactly, so rounding occurred. * Example: `x = sin(0.1);` */ @property bool inexact() @safe const { return (flags & INEXACT_MASK) != 0; } /** * A zero was generated by underflow * Example: `x = real.min*real.epsilon/2;` */ @property bool underflow() @safe const { return (flags & UNDERFLOW_MASK) != 0; } /** * An infinity was generated by overflow * Example: `x = real.max*2;` */ @property bool overflow() @safe const { return (flags & OVERFLOW_MASK) != 0; } /** * An infinity was generated by division by zero * Example: `x = 3/0.0;` */ @property bool divByZero() @safe const { return (flags & DIVBYZERO_MASK) != 0; } /** * A machine NaN was generated. * Example: `x = real.infinity * 0.0;` */ @property bool invalid() @safe const { return (flags & INVALID_MASK) != 0; } } } /// @safe unittest { version (InlineAsm_X86_Any) { static void func() { int a = 10 * 10; } real a = 3.5; // Set all the flags to zero resetIeeeFlags(); assert(!ieeeFlags.divByZero); // Perform a division by zero. a /= 0.0L; assert(a == real.infinity); assert(ieeeFlags.divByZero); // Create a NaN a *= 0.0L; assert(ieeeFlags.invalid); assert(isNaN(a)); // Check that calling func() has no effect on the // status flags. IeeeFlags f = ieeeFlags; func(); assert(ieeeFlags == f); } } version (InlineAsm_X86_Any) @safe unittest { import std.meta : AliasSeq; static struct Test { void delegate() @trusted action; bool function() @trusted ieeeCheck; } static foreach (T; AliasSeq!(float, double, real)) {{ T x; /* Needs to be here to trick -O. It would optimize away the calculations if x were local to the function literals. */ auto tests = [ Test( () { x = 1; x += 0.1; }, () => ieeeFlags.inexact ), Test( () { x = T.min_normal; x /= T.max; }, () => ieeeFlags.underflow ), Test( () { x = T.max; x += T.max; }, () => ieeeFlags.overflow ), Test( () { x = 1; x /= 0; }, () => ieeeFlags.divByZero ), Test( () { x = 0; x /= 0; }, () => ieeeFlags.invalid ) ]; foreach (test; tests) { resetIeeeFlags(); assert(!test.ieeeCheck()); test.action(); assert(test.ieeeCheck()); } }} } version (X86_Any) { version = IeeeFlagsSupport; } else version (PPC_Any) { version = IeeeFlagsSupport; } else version (RISCV_Any) { version = IeeeFlagsSupport; } else version (MIPS_Any) { version = IeeeFlagsSupport; } else version (ARM_Any) { version = IeeeFlagsSupport; } /// Set all of the floating-point status flags to false. void resetIeeeFlags() @trusted nothrow @nogc { IeeeFlags.resetIeeeFlags(); } /// @safe unittest { version (InlineAsm_X86_Any) { resetIeeeFlags(); real a = 3.5; a /= 0.0L; assert(a == real.infinity); assert(ieeeFlags.divByZero); resetIeeeFlags(); assert(!ieeeFlags.divByZero); } } /// Returns: snapshot of the current state of the floating-point status flags @property IeeeFlags ieeeFlags() @trusted pure nothrow @nogc { return IeeeFlags(IeeeFlags.getIeeeFlags()); } /// @safe nothrow unittest { version (InlineAsm_X86_Any) { resetIeeeFlags(); real a = 3.5; a /= 0.0L; assert(a == real.infinity); assert(ieeeFlags.divByZero); a *= 0.0L; assert(isNaN(a)); assert(ieeeFlags.invalid); } } /** Control the Floating point hardware Change the IEEE754 floating-point rounding mode and the floating-point hardware exceptions. By default, the rounding mode is roundToNearest and all hardware exceptions are disabled. For most applications, debugging is easier if the $(I division by zero), $(I overflow), and $(I invalid operation) exceptions are enabled. These three are combined into a $(I severeExceptions) value for convenience. Note in particular that if $(I invalidException) is enabled, a hardware trap will be generated whenever an uninitialized floating-point variable is used. All changes are temporary. The previous state is restored at the end of the scope. Example: ---- { FloatingPointControl fpctrl; // Enable hardware exceptions for division by zero, overflow to infinity, // invalid operations, and uninitialized floating-point variables. fpctrl.enableExceptions(FloatingPointControl.severeExceptions); // This will generate a hardware exception, if x is a // default-initialized floating point variable: real x; // Add `= 0` or even `= real.nan` to not throw the exception. real y = x * 3.0; // The exception is only thrown for default-uninitialized NaN-s. // NaN-s with other payload are valid: real z = y * real.nan; // ok // The set hardware exceptions and rounding modes will be disabled when // leaving this scope. } ---- */ struct FloatingPointControl { nothrow @nogc: alias RoundingMode = uint; /// version (StdDdoc) { enum : RoundingMode { /** IEEE rounding modes. * The default mode is roundToNearest. * * roundingMask = A mask of all rounding modes. */ roundToNearest, roundDown, /// ditto roundUp, /// ditto roundToZero, /// ditto roundingMask, /// ditto } } else version (CRuntime_Microsoft) { // Microsoft uses hardware-incompatible custom constants in fenv.h (core.stdc.fenv). enum : RoundingMode { roundToNearest = 0x0000, roundDown = 0x0400, roundUp = 0x0800, roundToZero = 0x0C00, roundingMask = roundToNearest | roundDown | roundUp | roundToZero, } } else { enum : RoundingMode { roundToNearest = core.stdc.fenv.FE_TONEAREST, roundDown = core.stdc.fenv.FE_DOWNWARD, roundUp = core.stdc.fenv.FE_UPWARD, roundToZero = core.stdc.fenv.FE_TOWARDZERO, roundingMask = roundToNearest | roundDown | roundUp | roundToZero, } } /*** * Change the floating-point hardware rounding mode * * Changing the rounding mode in the middle of a function can interfere * with optimizations of floating point expressions, as the optimizer assumes * that the rounding mode does not change. * It is best to change the rounding mode only at the * beginning of the function, and keep it until the function returns. * It is also best to add the line: * --- * pragma(inline, false); * --- * as the first line of the function so it will not get inlined. * Params: * newMode = the new rounding mode */ @property void rounding(RoundingMode newMode) @trusted { initialize(); setControlState((getControlState() & (-1 - roundingMask)) | (newMode & roundingMask)); } /// Returns: the currently active rounding mode @property static RoundingMode rounding() @trusted pure { return cast(RoundingMode)(getControlState() & roundingMask); } alias ExceptionMask = uint; /// version (StdDdoc) { enum : ExceptionMask { /** IEEE hardware exceptions. * By default, all exceptions are masked (disabled). * * severeExceptions = The overflow, division by zero, and invalid * exceptions. */ subnormalException, inexactException, /// ditto underflowException, /// ditto overflowException, /// ditto divByZeroException, /// ditto invalidException, /// ditto severeExceptions, /// ditto allExceptions, /// ditto } } else version (ARM_Any) { enum : ExceptionMask { subnormalException = 0x8000, inexactException = 0x1000, underflowException = 0x0800, overflowException = 0x0400, divByZeroException = 0x0200, invalidException = 0x0100, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException | subnormalException, } } else version (PPC_Any) { enum : ExceptionMask { inexactException = 0x0008, divByZeroException = 0x0010, underflowException = 0x0020, overflowException = 0x0040, invalidException = 0x0080, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (HPPA) { enum : ExceptionMask { inexactException = 0x01, underflowException = 0x02, overflowException = 0x04, divByZeroException = 0x08, invalidException = 0x10, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (MIPS_Any) { enum : ExceptionMask { inexactException = 0x0080, divByZeroException = 0x0400, overflowException = 0x0200, underflowException = 0x0100, invalidException = 0x0800, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (SPARC_Any) { enum : ExceptionMask { inexactException = 0x0800000, divByZeroException = 0x1000000, overflowException = 0x4000000, underflowException = 0x2000000, invalidException = 0x8000000, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (IBMZ_Any) { enum : ExceptionMask { inexactException = 0x08000000, divByZeroException = 0x40000000, overflowException = 0x20000000, underflowException = 0x10000000, invalidException = 0x80000000, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (RISCV_Any) { enum : ExceptionMask { inexactException = 0x01, divByZeroException = 0x02, underflowException = 0x04, overflowException = 0x08, invalidException = 0x10, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException, } } else version (X86_Any) { enum : ExceptionMask { inexactException = 0x20, underflowException = 0x10, overflowException = 0x08, divByZeroException = 0x04, subnormalException = 0x02, invalidException = 0x01, severeExceptions = overflowException | divByZeroException | invalidException, allExceptions = severeExceptions | underflowException | inexactException | subnormalException, } } else static assert(false, "Not implemented for this architecture"); version (ARM_Any) { static bool hasExceptionTraps_impl() @safe { auto oldState = getControlState(); // If exceptions are not supported, we set the bit but read it back as zero // https://sourceware.org/ml/libc-ports/2012-06/msg00091.html setControlState(oldState | divByZeroException); immutable result = (getControlState() & allExceptions) != 0; setControlState(oldState); return result; } } public: /// Returns: true if the current FPU supports exception trapping @property static bool hasExceptionTraps() @safe pure { version (X86_Any) return true; else version (PPC_Any) return true; else version (MIPS_Any) return true; else version (ARM_Any) { // The hasExceptionTraps_impl function is basically pure, // as it restores all global state auto fptr = ( () @trusted => cast(bool function() @safe pure nothrow @nogc)&hasExceptionTraps_impl)(); return fptr(); } else assert(0, "Not yet supported"); } /// Enable (unmask) specific hardware exceptions. Multiple exceptions may be ORed together. void enableExceptions(ExceptionMask exceptions) @trusted { assert(hasExceptionTraps); initialize(); version (X86_Any) setControlState(getControlState() & ~(exceptions & allExceptions)); else setControlState(getControlState() | (exceptions & allExceptions)); } /// Disable (mask) specific hardware exceptions. Multiple exceptions may be ORed together. void disableExceptions(ExceptionMask exceptions) @trusted { assert(hasExceptionTraps); initialize(); version (X86_Any) setControlState(getControlState() | (exceptions & allExceptions)); else setControlState(getControlState() & ~(exceptions & allExceptions)); } /// Returns: the exceptions which are currently enabled (unmasked) @property static ExceptionMask enabledExceptions() @trusted pure { assert(hasExceptionTraps); version (X86_Any) return (getControlState() & allExceptions) ^ allExceptions; else return (getControlState() & allExceptions); } /// Clear all pending exceptions, then restore the original exception state and rounding mode. ~this() @trusted { clearExceptions(); if (initialized) setControlState(savedState); } private: ControlState savedState; bool initialized = false; version (ARM_Any) { alias ControlState = uint; } else version (HPPA) { alias ControlState = uint; } else version (PPC_Any) { alias ControlState = uint; } else version (MIPS_Any) { alias ControlState = uint; } else version (SPARC_Any) { alias ControlState = ulong; } else version (IBMZ_Any) { alias ControlState = uint; } else version (RISCV_Any) { alias ControlState = uint; } else version (X86_Any) { alias ControlState = ushort; } else static assert(false, "Not implemented for this architecture"); void initialize() @safe { // BUG: This works around the absence of this() constructors. if (initialized) return; clearExceptions(); savedState = getControlState(); initialized = true; } // Clear all pending exceptions static void clearExceptions() @safe { resetIeeeFlags(); } // Read from the control register static ControlState getControlState() @trusted pure { version (D_InlineAsm_X86) { short cont; asm pure nothrow @nogc { xor EAX, EAX; fstcw cont; } return cont; } else version (D_InlineAsm_X86_64) { short cont; asm pure nothrow @nogc { xor RAX, RAX; fstcw cont; } return cont; } else assert(0, "Not yet supported"); } // Set the control register static void setControlState(ControlState newState) @trusted { version (InlineAsm_X86_Any) { asm nothrow @nogc { fclex; fldcw newState; } // Also update MXCSR, SSE's control register. if (haveSSE) { uint mxcsr; asm nothrow @nogc { stmxcsr mxcsr; } /* In the FPU control register, rounding mode is in bits 10 and 11. In MXCSR it's in bits 13 and 14. */ mxcsr &= ~(roundingMask << 3); // delete old rounding mode mxcsr |= (newState & roundingMask) << 3; // write new rounding mode /* In the FPU control register, masks are bits 0 through 5. In MXCSR they're 7 through 12. */ mxcsr &= ~(allExceptions << 7); // delete old masks mxcsr |= (newState & allExceptions) << 7; // write new exception masks asm nothrow @nogc { ldmxcsr mxcsr; } } } else assert(0, "Not yet supported"); } } /// @safe unittest { version (InlineAsm_X86_Any) { FloatingPointControl fpctrl; fpctrl.rounding = FloatingPointControl.roundDown; assert(lrint(1.5) == 1.0); fpctrl.rounding = FloatingPointControl.roundUp; assert(lrint(1.4) == 2.0); fpctrl.rounding = FloatingPointControl.roundToNearest; assert(lrint(1.5) == 2.0); } } version (InlineAsm_X86_Any) @safe unittest { void ensureDefaults() { assert(FloatingPointControl.rounding == FloatingPointControl.roundToNearest); if (FloatingPointControl.hasExceptionTraps) assert(FloatingPointControl.enabledExceptions == 0); } { FloatingPointControl ctrl; } ensureDefaults(); { FloatingPointControl ctrl; ctrl.rounding = FloatingPointControl.roundDown; assert(FloatingPointControl.rounding == FloatingPointControl.roundDown); } ensureDefaults(); if (FloatingPointControl.hasExceptionTraps) { FloatingPointControl ctrl; ctrl.enableExceptions(FloatingPointControl.divByZeroException | FloatingPointControl.overflowException); assert(ctrl.enabledExceptions == (FloatingPointControl.divByZeroException | FloatingPointControl.overflowException)); ctrl.rounding = FloatingPointControl.roundUp; assert(FloatingPointControl.rounding == FloatingPointControl.roundUp); } ensureDefaults(); } version (InlineAsm_X86_Any) @safe unittest // rounding { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ /* Be careful with changing the rounding mode, it interferes * with common subexpressions. Changing rounding modes should * be done with separate functions that are not inlined. */ { static T addRound(T)(uint rm) { pragma(inline, false); FloatingPointControl fpctrl; fpctrl.rounding = rm; T x = 1; x += 0.1; return x; } T u = addRound!(T)(FloatingPointControl.roundUp); T d = addRound!(T)(FloatingPointControl.roundDown); T z = addRound!(T)(FloatingPointControl.roundToZero); assert(u > d); assert(z == d); } { static T subRound(T)(uint rm) { pragma(inline, false); FloatingPointControl fpctrl; fpctrl.rounding = rm; T x = -1; x -= 0.1; return x; } T u = subRound!(T)(FloatingPointControl.roundUp); T d = subRound!(T)(FloatingPointControl.roundDown); T z = subRound!(T)(FloatingPointControl.roundToZero); assert(u > d); assert(z == u); } }} } /********************************* * Determines if $(D_PARAM x) is NaN. * Params: * x = a floating point number. * Returns: * `true` if $(D_PARAM x) is Nan. */ bool isNaN(X)(X x) @nogc @trusted pure nothrow if (isFloatingPoint!(X)) { version (all) { return x != x; } else { /* Code kept for historical context. At least on Intel, the simple test x != x uses one dedicated instruction (ucomiss/ucomisd) that runs in one cycle. Code for 80- and 128-bits is larger but still smaller than the integrals-based solutions below. Future revisions may enable the code below conditionally depending on hardware. */ alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { const uint p = *cast(uint *)&x; // Sign bit (MSB) is irrelevant so mask it out. // Next 8 bits should be all set. // At least one bit among the least significant 23 bits should be set. return (p & 0x7FFF_FFFF) > 0x7F80_0000; } else static if (F.realFormat == RealFormat.ieeeDouble) { const ulong p = *cast(ulong *)&x; // Sign bit (MSB) is irrelevant so mask it out. // Next 11 bits should be all set. // At least one bit among the least significant 52 bits should be set. return (p & 0x7FFF_FFFF_FFFF_FFFF) > 0x7FF0_0000_0000_0000; } else static if (F.realFormat == RealFormat.ieeeExtended) { const ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; const ulong ps = *cast(ulong *)&x; return e == F.EXPMASK && ps & 0x7FFF_FFFF_FFFF_FFFF; // not infinity } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; const ulong psLsb = (cast(ulong *)&x)[MANTISSA_LSB]; const ulong psMsb = (cast(ulong *)&x)[MANTISSA_MSB]; return e == F.EXPMASK && (psLsb | (psMsb& 0x0000_FFFF_FFFF_FFFF)) != 0; } else { return x != x; } } } /// @safe pure nothrow @nogc unittest { assert( isNaN(float.init)); assert( isNaN(-double.init)); assert( isNaN(real.nan)); assert( isNaN(-real.nan)); assert(!isNaN(cast(float) 53.6)); assert(!isNaN(cast(real)-53.6)); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ // CTFE-able tests assert(isNaN(T.init)); assert(isNaN(-T.init)); assert(isNaN(T.nan)); assert(isNaN(-T.nan)); assert(!isNaN(T.infinity)); assert(!isNaN(-T.infinity)); assert(!isNaN(cast(T) 53.6)); assert(!isNaN(cast(T)-53.6)); // Runtime tests shared T f; f = T.init; assert(isNaN(f)); assert(isNaN(-f)); f = T.nan; assert(isNaN(f)); assert(isNaN(-f)); f = T.infinity; assert(!isNaN(f)); assert(!isNaN(-f)); f = cast(T) 53.6; assert(!isNaN(f)); assert(!isNaN(-f)); }} } /********************************* * Determines if $(D_PARAM x) is finite. * Params: * x = a floating point number. * Returns: * `true` if $(D_PARAM x) is finite. */ bool isFinite(X)(X x) @trusted pure nothrow @nogc { alias F = floatTraits!(X); ushort* pe = cast(ushort *)&x; return (pe[F.EXPPOS_SHORT] & F.EXPMASK) != F.EXPMASK; } /// @safe pure nothrow @nogc unittest { assert( isFinite(1.23f)); assert( isFinite(float.max)); assert( isFinite(float.min_normal)); assert(!isFinite(float.nan)); assert(!isFinite(float.infinity)); } @safe pure nothrow @nogc unittest { assert(isFinite(1.23)); assert(isFinite(double.max)); assert(isFinite(double.min_normal)); assert(!isFinite(double.nan)); assert(!isFinite(double.infinity)); assert(isFinite(1.23L)); assert(isFinite(real.max)); assert(isFinite(real.min_normal)); assert(!isFinite(real.nan)); assert(!isFinite(real.infinity)); } /********************************* * Determines if $(D_PARAM x) is normalized. * * A normalized number must not be zero, subnormal, infinite nor $(NAN). * * Params: * x = a floating point number. * Returns: * `true` if $(D_PARAM x) is normalized. */ /* Need one for each format because subnormal floats might * be converted to normal reals. */ bool isNormal(X)(X x) @trusted pure nothrow @nogc { alias F = floatTraits!(X); ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; return (e != F.EXPMASK && e != 0); } /// @safe pure nothrow @nogc unittest { float f = 3; double d = 500; real e = 10e+48; assert(isNormal(f)); assert(isNormal(d)); assert(isNormal(e)); f = d = e = 0; assert(!isNormal(f)); assert(!isNormal(d)); assert(!isNormal(e)); assert(!isNormal(real.infinity)); assert(isNormal(-real.max)); assert(!isNormal(real.min_normal/4)); } /********************************* * Determines if $(D_PARAM x) is subnormal. * * Subnormals (also known as "denormal number"), have a 0 exponent * and a 0 most significant mantissa bit. * * Params: * x = a floating point number. * Returns: * `true` if $(D_PARAM x) is a denormal number. */ bool isSubnormal(X)(X x) @trusted pure nothrow @nogc { /* Need one for each format because subnormal floats might be converted to normal reals. */ alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { uint *p = cast(uint *)&x; return (*p & F.EXPMASK_INT) == 0 && *p & F.MANTISSAMASK_INT; } else static if (F.realFormat == RealFormat.ieeeDouble) { uint *p = cast(uint *)&x; return (p[MANTISSA_MSB] & F.EXPMASK_INT) == 0 && (p[MANTISSA_LSB] || p[MANTISSA_MSB] & F.MANTISSAMASK_INT); } else static if (F.realFormat == RealFormat.ieeeQuadruple) { ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; long* ps = cast(long *)&x; return (e == 0 && ((ps[MANTISSA_LSB]|(ps[MANTISSA_MSB]& 0x0000_FFFF_FFFF_FFFF)) != 0)); } else static if (F.realFormat == RealFormat.ieeeExtended) { ushort* pe = cast(ushort *)&x; long* ps = cast(long *)&x; return (pe[F.EXPPOS_SHORT] & F.EXPMASK) == 0 && *ps > 0; } else { static assert(false, "Not implemented for this architecture"); } } /// @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ T f; for (f = 1.0; !isSubnormal(f); f /= 2) assert(f != 0); }} } /********************************* * Determines if $(D_PARAM x) is $(PLUSMN)$(INFIN). * Params: * x = a floating point number. * Returns: * `true` if $(D_PARAM x) is $(PLUSMN)$(INFIN). */ bool isInfinity(X)(X x) @nogc @trusted pure nothrow if (isFloatingPoint!(X)) { alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle) { return ((*cast(uint *)&x) & 0x7FFF_FFFF) == 0x7F80_0000; } else static if (F.realFormat == RealFormat.ieeeDouble) { return ((*cast(ulong *)&x) & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FF0_0000_0000_0000; } else static if (F.realFormat == RealFormat.ieeeExtended) { const ushort e = cast(ushort)(F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]); const ulong ps = *cast(ulong *)&x; // On Motorola 68K, infinity can have hidden bit = 1 or 0. On x86, it is always 1. return e == F.EXPMASK && (ps & 0x7FFF_FFFF_FFFF_FFFF) == 0; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { const long psLsb = (cast(long *)&x)[MANTISSA_LSB]; const long psMsb = (cast(long *)&x)[MANTISSA_MSB]; return (psLsb == 0) && (psMsb & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FFF_0000_0000_0000; } else { return (x < -X.max) || (X.max < x); } } /// @nogc @safe pure nothrow unittest { assert(!isInfinity(float.init)); assert(!isInfinity(-float.init)); assert(!isInfinity(float.nan)); assert(!isInfinity(-float.nan)); assert(isInfinity(float.infinity)); assert(isInfinity(-float.infinity)); assert(isInfinity(-1.0f / 0.0f)); } @safe pure nothrow @nogc unittest { // CTFE-able tests assert(!isInfinity(double.init)); assert(!isInfinity(-double.init)); assert(!isInfinity(double.nan)); assert(!isInfinity(-double.nan)); assert(isInfinity(double.infinity)); assert(isInfinity(-double.infinity)); assert(isInfinity(-1.0 / 0.0)); assert(!isInfinity(real.init)); assert(!isInfinity(-real.init)); assert(!isInfinity(real.nan)); assert(!isInfinity(-real.nan)); assert(isInfinity(real.infinity)); assert(isInfinity(-real.infinity)); assert(isInfinity(-1.0L / 0.0L)); // Runtime tests shared float f; f = float.init; assert(!isInfinity(f)); assert(!isInfinity(-f)); f = float.nan; assert(!isInfinity(f)); assert(!isInfinity(-f)); f = float.infinity; assert(isInfinity(f)); assert(isInfinity(-f)); f = (-1.0f / 0.0f); assert(isInfinity(f)); shared double d; d = double.init; assert(!isInfinity(d)); assert(!isInfinity(-d)); d = double.nan; assert(!isInfinity(d)); assert(!isInfinity(-d)); d = double.infinity; assert(isInfinity(d)); assert(isInfinity(-d)); d = (-1.0 / 0.0); assert(isInfinity(d)); shared real e; e = real.init; assert(!isInfinity(e)); assert(!isInfinity(-e)); e = real.nan; assert(!isInfinity(e)); assert(!isInfinity(-e)); e = real.infinity; assert(isInfinity(e)); assert(isInfinity(-e)); e = (-1.0L / 0.0L); assert(isInfinity(e)); } /********************************* * Is the binary representation of x identical to y? * * Same as ==, except that positive and negative zero are not identical, * and two $(NAN)s are identical if they have the same 'payload'. */ bool isIdentical(real x, real y) @trusted pure nothrow @nogc { // We're doing a bitwise comparison so the endianness is irrelevant. long* pxs = cast(long *)&x; long* pys = cast(long *)&y; alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { return pxs[0] == pys[0]; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { return pxs[0] == pys[0] && pxs[1] == pys[1]; } else static if (F.realFormat == RealFormat.ieeeExtended) { ushort* pxe = cast(ushort *)&x; ushort* pye = cast(ushort *)&y; return pxe[4] == pye[4] && pxs[0] == pys[0]; } else { assert(0, "isIdentical not implemented"); } } /// @safe @nogc pure nothrow unittest { assert( isIdentical(0.0, 0.0)); assert( isIdentical(1.0, 1.0)); assert( isIdentical(real.infinity, real.infinity)); assert( isIdentical(-real.infinity, -real.infinity)); assert(!isIdentical(0.0, -0.0)); assert(!isIdentical(real.nan, -real.nan)); assert(!isIdentical(real.infinity, -real.infinity)); } /********************************* * Return 1 if sign bit of e is set, 0 if not. */ int signbit(X)(X x) @nogc @trusted pure nothrow { alias F = floatTraits!(X); return ((cast(ubyte *)&x)[F.SIGNPOS_BYTE] & 0x80) != 0; } /// @nogc @safe pure nothrow unittest { assert(!signbit(float.nan)); assert(signbit(-float.nan)); assert(!signbit(168.1234f)); assert(signbit(-168.1234f)); assert(!signbit(0.0f)); assert(signbit(-0.0f)); assert(signbit(-float.max)); assert(!signbit(float.max)); assert(!signbit(double.nan)); assert(signbit(-double.nan)); assert(!signbit(168.1234)); assert(signbit(-168.1234)); assert(!signbit(0.0)); assert(signbit(-0.0)); assert(signbit(-double.max)); assert(!signbit(double.max)); assert(!signbit(real.nan)); assert(signbit(-real.nan)); assert(!signbit(168.1234L)); assert(signbit(-168.1234L)); assert(!signbit(0.0L)); assert(signbit(-0.0L)); assert(signbit(-real.max)); assert(!signbit(real.max)); } /** Params: to = the numeric value to use from = the sign value to use Returns: a value composed of to with from's sign bit. */ R copysign(R, X)(R to, X from) @trusted pure nothrow @nogc if (isFloatingPoint!(R) && isFloatingPoint!(X)) { ubyte* pto = cast(ubyte *)&to; const ubyte* pfrom = cast(ubyte *)&from; alias T = floatTraits!(R); alias F = floatTraits!(X); pto[T.SIGNPOS_BYTE] &= 0x7F; pto[T.SIGNPOS_BYTE] |= pfrom[F.SIGNPOS_BYTE] & 0x80; return to; } /// ditto R copysign(R, X)(X to, R from) @trusted pure nothrow @nogc if (isIntegral!(X) && isFloatingPoint!(R)) { return copysign(cast(R) to, from); } /// @safe pure nothrow @nogc unittest { assert(copysign(1.0, 1.0) == 1.0); assert(copysign(1.0, -0.0) == -1.0); assert(copysign(1UL, -1.0) == -1.0); assert(copysign(-1.0, -1.0) == -1.0); assert(copysign(real.infinity, -1.0) == -real.infinity); assert(copysign(real.nan, 1.0) is real.nan); assert(copysign(-real.nan, 1.0) is real.nan); assert(copysign(real.nan, -1.0) is -real.nan); } @safe pure nothrow @nogc unittest { import std.meta : AliasSeq; static foreach (X; AliasSeq!(float, double, real, int, long)) { static foreach (Y; AliasSeq!(float, double, real)) {{ X x = 21; Y y = 23.8; Y e = void; e = copysign(x, y); assert(e == 21.0); e = copysign(-x, y); assert(e == 21.0); e = copysign(x, -y); assert(e == -21.0); e = copysign(-x, -y); assert(e == -21.0); static if (isFloatingPoint!X) { e = copysign(X.nan, y); assert(isNaN(e) && !signbit(e)); e = copysign(X.nan, -y); assert(isNaN(e) && signbit(e)); } }} } } /********************************* Returns `-1` if $(D x < 0), `x` if $(D x == 0), `1` if $(D x > 0), and $(NAN) if x==$(NAN). */ F sgn(F)(F x) @safe pure nothrow @nogc if (isFloatingPoint!F || isIntegral!F) { // @@@TODO@@@: make this faster return x > 0 ? 1 : x < 0 ? -1 : x; } /// @safe pure nothrow @nogc unittest { assert(sgn(168.1234) == 1); assert(sgn(-168.1234) == -1); assert(sgn(0.0) == 0); assert(sgn(-0.0) == 0); } // Functions for NaN payloads /* * A 'payload' can be stored in the significand of a $(NAN). One bit is required * to distinguish between a quiet and a signalling $(NAN). This leaves 22 bits * of payload for a float; 51 bits for a double; 62 bits for an 80-bit real; * and 111 bits for a 128-bit quad. */ /** * Create a quiet $(NAN), storing an integer inside the payload. * * For floats, the largest possible payload is 0x3F_FFFF. * For doubles, it is 0x3_FFFF_FFFF_FFFF. * For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF. */ real NaN(ulong payload) @trusted pure nothrow @nogc { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeExtended) { // real80 (in x86 real format, the implied bit is actually // not implied but a real bit which is stored in the real) ulong v = 3; // implied bit = 1, quiet bit = 1 } else { ulong v = 1; // no implied bit. quiet bit = 1 } ulong a = payload; // 22 Float bits ulong w = a & 0x3F_FFFF; a -= w; v <<=22; v |= w; a >>=22; // 29 Double bits v <<=29; w = a & 0xFFF_FFFF; v |= w; a -= w; a >>=29; static if (F.realFormat == RealFormat.ieeeDouble) { v |= 0x7FF0_0000_0000_0000; real x; * cast(ulong *)(&x) = v; return x; } else { v <<=11; a &= 0x7FF; v |= a; real x = real.nan; // Extended real bits static if (F.realFormat == RealFormat.ieeeQuadruple) { v <<= 1; // there's no implicit bit version (LittleEndian) { *cast(ulong*)(6+cast(ubyte*)(&x)) = v; } else { *cast(ulong*)(2+cast(ubyte*)(&x)) = v; } } else { *cast(ulong *)(&x) = v; } return x; } } /// @safe @nogc pure nothrow unittest { real a = NaN(1_000_000); assert(isNaN(a)); assert(getNaNPayload(a) == 1_000_000); } @system pure nothrow @nogc unittest // not @safe because taking address of local. { static if (floatTraits!(real).realFormat == RealFormat.ieeeDouble) { auto x = NaN(1); auto xl = *cast(ulong*)&x; assert(xl & 0x8_0000_0000_0000UL); //non-signaling bit, bit 52 assert((xl & 0x7FF0_0000_0000_0000UL) == 0x7FF0_0000_0000_0000UL); //all exp bits set } } /** * Extract an integral payload from a $(NAN). * * Returns: * the integer payload as a ulong. * * For floats, the largest possible payload is 0x3F_FFFF. * For doubles, it is 0x3_FFFF_FFFF_FFFF. * For 80-bit or 128-bit reals, it is 0x3FFF_FFFF_FFFF_FFFF. */ ulong getNaNPayload(real x) @trusted pure nothrow @nogc { // assert(isNaN(x)); alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { ulong m = *cast(ulong *)(&x); // Make it look like an 80-bit significand. // Skip exponent, and quiet bit m &= 0x0007_FFFF_FFFF_FFFF; m <<= 11; } else static if (F.realFormat == RealFormat.ieeeQuadruple) { version (LittleEndian) { ulong m = *cast(ulong*)(6+cast(ubyte*)(&x)); } else { ulong m = *cast(ulong*)(2+cast(ubyte*)(&x)); } m >>= 1; // there's no implicit bit } else { ulong m = *cast(ulong *)(&x); } // ignore implicit bit and quiet bit const ulong f = m & 0x3FFF_FF00_0000_0000L; ulong w = f >>> 40; w |= (m & 0x00FF_FFFF_F800L) << (22 - 11); w |= (m & 0x7FF) << 51; return w; } /// @safe @nogc pure nothrow unittest { real a = NaN(1_000_000); assert(isNaN(a)); assert(getNaNPayload(a) == 1_000_000); } debug(UnitTest) { @safe pure nothrow @nogc unittest { real nan4 = NaN(0x789_ABCD_EF12_3456); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended || floatTraits!(real).realFormat == RealFormat.ieeeQuadruple) { assert(getNaNPayload(nan4) == 0x789_ABCD_EF12_3456); } else { assert(getNaNPayload(nan4) == 0x1_ABCD_EF12_3456); } double nan5 = nan4; assert(getNaNPayload(nan5) == 0x1_ABCD_EF12_3456); float nan6 = nan4; assert(getNaNPayload(nan6) == 0x12_3456); nan4 = NaN(0xFABCD); assert(getNaNPayload(nan4) == 0xFABCD); nan6 = nan4; assert(getNaNPayload(nan6) == 0xFABCD); nan5 = NaN(0x100_0000_0000_3456); assert(getNaNPayload(nan5) == 0x0000_0000_3456); } } /** * Calculate the next largest floating point value after x. * * Return the least number greater than x that is representable as a real; * thus, it gives the next point on the IEEE number line. * * $(TABLE_SV * $(SVH x, nextUp(x) ) * $(SV -$(INFIN), -real.max ) * $(SV $(PLUSMN)0.0, real.min_normal*real.epsilon ) * $(SV real.max, $(INFIN) ) * $(SV $(INFIN), $(INFIN) ) * $(SV $(NAN), $(NAN) ) * ) */ real nextUp(real x) @trusted pure nothrow @nogc { alias F = floatTraits!(real); static if (F.realFormat == RealFormat.ieeeDouble) { return nextUp(cast(double) x); } else static if (F.realFormat == RealFormat.ieeeQuadruple) { ushort e = F.EXPMASK & (cast(ushort *)&x)[F.EXPPOS_SHORT]; if (e == F.EXPMASK) { // NaN or Infinity if (x == -real.infinity) return -real.max; return x; // +Inf and NaN are unchanged. } auto ps = cast(ulong *)&x; if (ps[MANTISSA_MSB] & 0x8000_0000_0000_0000) { // Negative number if (ps[MANTISSA_LSB] == 0 && ps[MANTISSA_MSB] == 0x8000_0000_0000_0000) { // it was negative zero, change to smallest subnormal ps[MANTISSA_LSB] = 1; ps[MANTISSA_MSB] = 0; return x; } if (ps[MANTISSA_LSB] == 0) --ps[MANTISSA_MSB]; --ps[MANTISSA_LSB]; } else { // Positive number ++ps[MANTISSA_LSB]; if (ps[MANTISSA_LSB] == 0) ++ps[MANTISSA_MSB]; } return x; } else static if (F.realFormat == RealFormat.ieeeExtended) { // For 80-bit reals, the "implied bit" is a nuisance... ushort *pe = cast(ushort *)&x; ulong *ps = cast(ulong *)&x; if ((pe[F.EXPPOS_SHORT] & F.EXPMASK) == F.EXPMASK) { // First, deal with NANs and infinity if (x == -real.infinity) return -real.max; return x; // +Inf and NaN are unchanged. } if (pe[F.EXPPOS_SHORT] & 0x8000) { // Negative number -- need to decrease the significand --*ps; // Need to mask with 0x7FFF... so subnormals are treated correctly. if ((*ps & 0x7FFF_FFFF_FFFF_FFFF) == 0x7FFF_FFFF_FFFF_FFFF) { if (pe[F.EXPPOS_SHORT] == 0x8000) // it was negative zero { *ps = 1; pe[F.EXPPOS_SHORT] = 0; // smallest subnormal. return x; } --pe[F.EXPPOS_SHORT]; if (pe[F.EXPPOS_SHORT] == 0x8000) return x; // it's become a subnormal, implied bit stays low. *ps = 0xFFFF_FFFF_FFFF_FFFF; // set the implied bit return x; } return x; } else { // Positive number -- need to increase the significand. // Works automatically for positive zero. ++*ps; if ((*ps & 0x7FFF_FFFF_FFFF_FFFF) == 0) { // change in exponent ++pe[F.EXPPOS_SHORT]; *ps = 0x8000_0000_0000_0000; // set the high bit } } return x; } else // static if (F.realFormat == RealFormat.ibmExtended) { assert(0, "nextUp not implemented"); } } /** ditto */ double nextUp(double x) @trusted pure nothrow @nogc { ulong *ps = cast(ulong *)&x; if ((*ps & 0x7FF0_0000_0000_0000) == 0x7FF0_0000_0000_0000) { // First, deal with NANs and infinity if (x == -x.infinity) return -x.max; return x; // +INF and NAN are unchanged. } if (*ps & 0x8000_0000_0000_0000) // Negative number { if (*ps == 0x8000_0000_0000_0000) // it was negative zero { *ps = 0x0000_0000_0000_0001; // change to smallest subnormal return x; } --*ps; } else { // Positive number ++*ps; } return x; } /** ditto */ float nextUp(float x) @trusted pure nothrow @nogc { uint *ps = cast(uint *)&x; if ((*ps & 0x7F80_0000) == 0x7F80_0000) { // First, deal with NANs and infinity if (x == -x.infinity) return -x.max; return x; // +INF and NAN are unchanged. } if (*ps & 0x8000_0000) // Negative number { if (*ps == 0x8000_0000) // it was negative zero { *ps = 0x0000_0001; // change to smallest subnormal return x; } --*ps; } else { // Positive number ++*ps; } return x; } /// @safe @nogc pure nothrow unittest { assert(nextUp(1.0 - 1.0e-6).feqrel(0.999999) > 16); assert(nextUp(1.0 - real.epsilon).feqrel(1.0) > 16); } /** * Calculate the next smallest floating point value before x. * * Return the greatest number less than x that is representable as a real; * thus, it gives the previous point on the IEEE number line. * * $(TABLE_SV * $(SVH x, nextDown(x) ) * $(SV $(INFIN), real.max ) * $(SV $(PLUSMN)0.0, -real.min_normal*real.epsilon ) * $(SV -real.max, -$(INFIN) ) * $(SV -$(INFIN), -$(INFIN) ) * $(SV $(NAN), $(NAN) ) * ) */ real nextDown(real x) @safe pure nothrow @nogc { return -nextUp(-x); } /** ditto */ double nextDown(double x) @safe pure nothrow @nogc { return -nextUp(-x); } /** ditto */ float nextDown(float x) @safe pure nothrow @nogc { return -nextUp(-x); } /// @safe pure nothrow @nogc unittest { assert( nextDown(1.0 + real.epsilon) == 1.0); } @safe pure nothrow @nogc unittest { static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { // Tests for 80-bit reals assert(isIdentical(nextUp(NaN(0xABC)), NaN(0xABC))); // negative numbers assert( nextUp(-real.infinity) == -real.max ); assert( nextUp(-1.0L-real.epsilon) == -1.0 ); assert( nextUp(-2.0L) == -2.0 + real.epsilon); // subnormals and zero assert( nextUp(-real.min_normal) == -real.min_normal*(1-real.epsilon) ); assert( nextUp(-real.min_normal*(1-real.epsilon)) == -real.min_normal*(1-2*real.epsilon) ); assert( isIdentical(-0.0L, nextUp(-real.min_normal*real.epsilon)) ); assert( nextUp(-0.0L) == real.min_normal*real.epsilon ); assert( nextUp(0.0L) == real.min_normal*real.epsilon ); assert( nextUp(real.min_normal*(1-real.epsilon)) == real.min_normal ); assert( nextUp(real.min_normal) == real.min_normal*(1+real.epsilon) ); // positive numbers assert( nextUp(1.0L) == 1.0 + real.epsilon ); assert( nextUp(2.0L-real.epsilon) == 2.0 ); assert( nextUp(real.max) == real.infinity ); assert( nextUp(real.infinity)==real.infinity ); } double n = NaN(0xABC); assert(isIdentical(nextUp(n), n)); // negative numbers assert( nextUp(-double.infinity) == -double.max ); assert( nextUp(-1-double.epsilon) == -1.0 ); assert( nextUp(-2.0) == -2.0 + double.epsilon); // subnormals and zero assert( nextUp(-double.min_normal) == -double.min_normal*(1-double.epsilon) ); assert( nextUp(-double.min_normal*(1-double.epsilon)) == -double.min_normal*(1-2*double.epsilon) ); assert( isIdentical(-0.0, nextUp(-double.min_normal*double.epsilon)) ); assert( nextUp(0.0) == double.min_normal*double.epsilon ); assert( nextUp(-0.0) == double.min_normal*double.epsilon ); assert( nextUp(double.min_normal*(1-double.epsilon)) == double.min_normal ); assert( nextUp(double.min_normal) == double.min_normal*(1+double.epsilon) ); // positive numbers assert( nextUp(1.0) == 1.0 + double.epsilon ); assert( nextUp(2.0-double.epsilon) == 2.0 ); assert( nextUp(double.max) == double.infinity ); float fn = NaN(0xABC); assert(isIdentical(nextUp(fn), fn)); float f = -float.min_normal*(1-float.epsilon); float f1 = -float.min_normal; assert( nextUp(f1) == f); f = 1.0f+float.epsilon; f1 = 1.0f; assert( nextUp(f1) == f ); f1 = -0.0f; assert( nextUp(f1) == float.min_normal*float.epsilon); assert( nextUp(float.infinity)==float.infinity ); assert(nextDown(1.0L+real.epsilon)==1.0); assert(nextDown(1.0+double.epsilon)==1.0); f = 1.0f+float.epsilon; assert(nextDown(f)==1.0); assert(nextafter(1.0+real.epsilon, -real.infinity)==1.0); } /****************************************** * Calculates the next representable value after x in the direction of y. * * If y > x, the result will be the next largest floating-point value; * if y < x, the result will be the next smallest value. * If x == y, the result is y. * * Remarks: * This function is not generally very useful; it's almost always better to use * the faster functions nextUp() or nextDown() instead. * * The FE_INEXACT and FE_OVERFLOW exceptions will be raised if x is finite and * the function result is infinite. The FE_INEXACT and FE_UNDERFLOW * exceptions will be raised if the function value is subnormal, and x is * not equal to y. */ T nextafter(T)(const T x, const T y) @safe pure nothrow @nogc { if (x == y) return y; return ((y>x) ? nextUp(x) : nextDown(x)); } /// @safe pure nothrow @nogc unittest { float a = 1; assert(is(typeof(nextafter(a, a)) == float)); assert(nextafter(a, a.infinity) > a); double b = 2; assert(is(typeof(nextafter(b, b)) == double)); assert(nextafter(b, b.infinity) > b); real c = 3; assert(is(typeof(nextafter(c, c)) == real)); assert(nextafter(c, c.infinity) > c); } //real nexttoward(real x, real y) { return core.stdc.math.nexttowardl(x, y); } /** * Returns the positive difference between x and y. * * Equivalent to `fmax(x-y, 0)`. * * Returns: * $(TABLE_SV * $(TR $(TH x, y) $(TH fdim(x, y))) * $(TR $(TD x $(GT) y) $(TD x - y)) * $(TR $(TD x $(LT)= y) $(TD +0.0)) * ) */ real fdim(real x, real y) @safe pure nothrow @nogc { return (x < y) ? +0.0 : x - y; } /// @safe pure nothrow @nogc unittest { assert(fdim(2.0, 0.0) == 2.0); assert(fdim(-2.0, 0.0) == 0.0); assert(fdim(real.infinity, 2.0) == real.infinity); assert(isNaN(fdim(real.nan, 2.0))); assert(isNaN(fdim(2.0, real.nan))); assert(isNaN(fdim(real.nan, real.nan))); } /** * Returns the larger of x and y. * * If one of the arguments is a NaN, the other is returned. */ real fmax(real x, real y) @safe pure nothrow @nogc { return (y > x || isNaN(x)) ? y : x; } /// @safe pure nothrow @nogc unittest { assert(fmax(0.0, 2.0) == 2.0); assert(fmax(-2.0, 0.0) == 0.0); assert(fmax(real.infinity, 2.0) == real.infinity); assert(fmax(real.nan, 2.0) == 2.0); assert(fmax(2.0, real.nan) == 2.0); } /** * Returns the smaller of x and y. * * If one of the arguments is a NaN, the other is returned. */ real fmin(real x, real y) @safe pure nothrow @nogc { return (y < x || isNaN(x)) ? y : x; } /// @safe pure nothrow @nogc unittest { assert(fmin(0.0, 2.0) == 0.0); assert(fmin(-2.0, 0.0) == -2.0); assert(fmin(real.infinity, 2.0) == 2.0); assert(fmin(real.nan, 2.0) == 2.0); assert(fmin(2.0, real.nan) == 2.0); } /************************************** * Returns (x * y) + z, rounding only once according to the * current rounding mode. * * BUGS: Not currently implemented - rounds twice. */ real fma(real x, real y, real z) @safe pure nothrow @nogc { return (x * y) + z; } /// @safe pure nothrow @nogc unittest { assert(fma(0.0, 2.0, 2.0) == 2.0); assert(fma(2.0, 2.0, 2.0) == 6.0); assert(fma(real.infinity, 2.0, 2.0) == real.infinity); assert(fma(real.nan, 2.0, 2.0) is real.nan); assert(fma(2.0, 2.0, real.nan) is real.nan); } /** * Compute the value of x $(SUPERSCRIPT n), where n is an integer */ Unqual!F pow(F, G)(F x, G n) @nogc @trusted pure nothrow if (isFloatingPoint!(F) && isIntegral!(G)) { import std.traits : Unsigned; real p = 1.0, v = void; Unsigned!(Unqual!G) m = n; if (n < 0) { switch (n) { case -1: return 1 / x; case -2: return 1 / (x * x); default: } m = cast(typeof(m))(0 - n); v = p / x; } else { switch (n) { case 0: return 1.0; case 1: return x; case 2: return x * x; default: } v = x; } while (1) { if (m & 1) p *= v; m >>= 1; if (!m) break; v *= v; } return p; } /// @safe pure nothrow @nogc unittest { assert(pow(2.0, 5) == 32.0); assert(pow(1.5, 9).feqrel(38.4433) > 16); assert(pow(real.nan, 2) is real.nan); assert(pow(real.infinity, 2) == real.infinity); } @safe pure nothrow @nogc unittest { // Make sure it instantiates and works properly on immutable values and // with various integer and float types. immutable real x = 46; immutable float xf = x; immutable double xd = x; immutable uint one = 1; immutable ushort two = 2; immutable ubyte three = 3; immutable ulong eight = 8; immutable int neg1 = -1; immutable short neg2 = -2; immutable byte neg3 = -3; immutable long neg8 = -8; assert(pow(x,0) == 1.0); assert(pow(xd,one) == x); assert(pow(xf,two) == x * x); assert(pow(x,three) == x * x * x); assert(pow(x,eight) == (x * x) * (x * x) * (x * x) * (x * x)); assert(pow(x, neg1) == 1 / x); // Test disabled on most targets. // See https://issues.dlang.org/show_bug.cgi?id=5628 version (X86_64) enum BUG5628 = false; else version (ARM) enum BUG5628 = false; else enum BUG5628 = true; static if (BUG5628) { assert(pow(xd, neg2) == 1 / (x * x)); assert(pow(xf, neg8) == 1 / ((x * x) * (x * x) * (x * x) * (x * x))); } assert(feqrel(pow(x, neg3), 1 / (x * x * x)) >= real.mant_dig - 1); } @safe @nogc nothrow unittest { assert(equalsDigit(pow(2.0L, 10.0L), 1024, 19)); } /** Compute the value of an integer x, raised to the power of a positive * integer n. * * If both x and n are 0, the result is 1. * If n is negative, an integer divide error will occur at runtime, * regardless of the value of x. */ typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @nogc @trusted pure nothrow if (isIntegral!(F) && isIntegral!(G)) { if (n<0) return x/0; // Only support positive powers typeof(return) p, v = void; Unqual!G m = n; switch (m) { case 0: p = 1; break; case 1: p = x; break; case 2: p = x * x; break; default: v = x; p = 1; while (1) { if (m & 1) p *= v; m >>= 1; if (!m) break; v *= v; } break; } return p; } /// @safe pure nothrow @nogc unittest { immutable int one = 1; immutable byte two = 2; immutable ubyte three = 3; immutable short four = 4; immutable long ten = 10; assert(pow(two, three) == 8); assert(pow(two, ten) == 1024); assert(pow(one, ten) == 1); assert(pow(ten, four) == 10_000); assert(pow(four, 10) == 1_048_576); assert(pow(three, four) == 81); } /**Computes integer to floating point powers.*/ real pow(I, F)(I x, F y) @nogc @trusted pure nothrow if (isIntegral!I && isFloatingPoint!F) { return pow(cast(real) x, cast(Unqual!F) y); } /// @safe pure nothrow @nogc unittest { assert(pow(2, 5.0) == 32.0); assert(pow(7, 3.0) == 343.0); assert(pow(2, real.nan) is real.nan); assert(pow(2, real.infinity) == real.infinity); } /** * Calculates x$(SUPERSCRIPT y). * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH pow(x, y)) * $(TH div 0) $(TH invalid?)) * $(TR $(TD anything) $(TD $(PLUSMN)0.0) $(TD 1.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(GT) 1) $(TD +$(INFIN)) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(LT) 1) $(TD +$(INFIN)) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(GT) 1) $(TD -$(INFIN)) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD |x| $(LT) 1) $(TD -$(INFIN)) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD +$(INFIN)) $(TD $(GT) 0.0) $(TD +$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD +$(INFIN)) $(TD $(LT) 0.0) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD odd integer $(GT) 0.0) $(TD -$(INFIN)) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD $(GT) 0.0, not odd integer) $(TD +$(INFIN)) * $(TD no) $(TD no)) * $(TR $(TD -$(INFIN)) $(TD odd integer $(LT) 0.0) $(TD -0.0) * $(TD no) $(TD no) ) * $(TR $(TD -$(INFIN)) $(TD $(LT) 0.0, not odd integer) $(TD +0.0) * $(TD no) $(TD no) ) * $(TR $(TD $(PLUSMN)1.0) $(TD $(PLUSMN)$(INFIN)) $(TD -$(NAN)) * $(TD no) $(TD yes) ) * $(TR $(TD $(LT) 0.0) $(TD finite, nonintegral) $(TD $(NAN)) * $(TD no) $(TD yes)) * $(TR $(TD $(PLUSMN)0.0) $(TD odd integer $(LT) 0.0) $(TD $(PLUSMNINF)) * $(TD yes) $(TD no) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(LT) 0.0, not odd integer) $(TD +$(INFIN)) * $(TD yes) $(TD no)) * $(TR $(TD $(PLUSMN)0.0) $(TD odd integer $(GT) 0.0) $(TD $(PLUSMN)0.0) * $(TD no) $(TD no) ) * $(TR $(TD $(PLUSMN)0.0) $(TD $(GT) 0.0, not odd integer) $(TD +0.0) * $(TD no) $(TD no) ) * ) */ Unqual!(Largest!(F, G)) pow(F, G)(F x, G y) @nogc @trusted pure nothrow if (isFloatingPoint!(F) && isFloatingPoint!(G)) { alias Float = typeof(return); static real impl(real x, real y) @nogc pure nothrow { // Special cases. if (isNaN(y)) return y; if (isNaN(x) && y != 0.0) return x; // Even if x is NaN. if (y == 0.0) return 1.0; if (y == 1.0) return x; if (isInfinity(y)) { if (fabs(x) > 1) { if (signbit(y)) return +0.0; else return F.infinity; } else if (fabs(x) == 1) { return y * 0; // generate NaN. } else // < 1 { if (signbit(y)) return F.infinity; else return +0.0; } } if (isInfinity(x)) { if (signbit(x)) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } else if (y < 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } } else { if (y > 0.0) return F.infinity; else if (y < 0.0) return +0.0; } } if (x == 0.0) { if (signbit(x)) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } else if (y < 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } } else { if (y > 0.0) return +0.0; else if (y < 0.0) return F.infinity; } } if (x == 1.0) return 1.0; if (y >= F.max) { if ((x > 0.0 && x < 1.0) || (x > -1.0 && x < 0.0)) return 0.0; if (x > 1.0 || x < -1.0) return F.infinity; } if (y <= -F.max) { if ((x > 0.0 && x < 1.0) || (x > -1.0 && x < 0.0)) return F.infinity; if (x > 1.0 || x < -1.0) return 0.0; } if (x >= F.max) { if (y > 0.0) return F.infinity; else return 0.0; } if (x <= -F.max) { long i = cast(long) y; if (y > 0.0) { if (i == y && i & 1) return -F.infinity; else return F.infinity; } else if (y < 0.0) { if (i == y && i & 1) return -0.0; else return +0.0; } } // Integer power of x. long iy = cast(long) y; if (iy == y && fabs(y) < 32_768.0) return pow(x, iy); real sign = 1.0; if (x < 0) { // Result is real only if y is an integer // Check for a non-zero fractional part enum maxOdd = pow(2.0L, real.mant_dig) - 1.0L; static if (maxOdd > ulong.max) { // Generic method, for any FP type if (floor(y) != y) return sqrt(x); // Complex result -- create a NaN const hy = ldexp(y, -1); if (floor(hy) != hy) sign = -1.0; } else { // Much faster, if ulong has enough precision const absY = fabs(y); if (absY <= maxOdd) { const uy = cast(ulong) absY; if (uy != absY) return sqrt(x); // Complex result -- create a NaN if (uy & 1) sign = -1.0; } } x = -x; } version (INLINE_YL2X) { // If x > 0, x ^^ y == 2 ^^ ( y * log2(x) ) // TODO: This is not accurate in practice. A fast and accurate // (though complicated) method is described in: // "An efficient rounding boundary test for pow(x, y) // in double precision", C.Q. Lauter and V. Lefèvre, INRIA (2007). return sign * exp2( core.math.yl2x(x, y) ); } else { // If x > 0, x ^^ y == 2 ^^ ( y * log2(x) ) // TODO: This is not accurate in practice. A fast and accurate // (though complicated) method is described in: // "An efficient rounding boundary test for pow(x, y) // in double precision", C.Q. Lauter and V. Lefèvre, INRIA (2007). Float w = exp2(y * log2(x)); return sign * w; } } return impl(x, y); } /// @safe pure nothrow @nogc unittest { assert(pow(1.0, 2.0) == 1.0); assert(pow(0.0, 0.0) == 1.0); assert(pow(1.5, 10.0).feqrel(57.665) > 16); // special values assert(pow(1.5, real.infinity) == real.infinity); assert(pow(0.5, real.infinity) == 0.0); assert(pow(1.5, -real.infinity) == 0.0); assert(pow(0.5, -real.infinity) == real.infinity); assert(pow(real.infinity, 1.0) == real.infinity); assert(pow(real.infinity, -1.0) == 0.0); assert(pow(-real.infinity, 1.0) == -real.infinity); assert(pow(-real.infinity, 2.0) == real.infinity); assert(pow(-real.infinity, -1.0) == -0.0); assert(pow(-real.infinity, -2.0) == 0.0); assert(pow(1.0, real.infinity) is -real.nan); assert(pow(0.0, -1.0) == real.infinity); assert(pow(real.nan, 0.0) == 1.0); } @safe pure nothrow @nogc unittest { // Test all the special values. These unittests can be run on Windows // by temporarily changing the version (linux) to version (all). immutable float zero = 0; immutable real one = 1; immutable double two = 2; immutable float three = 3; immutable float fnan = float.nan; immutable double dnan = double.nan; immutable real rnan = real.nan; immutable dinf = double.infinity; immutable rninf = -real.infinity; assert(pow(fnan, zero) == 1); assert(pow(dnan, zero) == 1); assert(pow(rnan, zero) == 1); assert(pow(two, dinf) == double.infinity); assert(isIdentical(pow(0.2f, dinf), +0.0)); assert(pow(0.99999999L, rninf) == real.infinity); assert(isIdentical(pow(1.000000001, rninf), +0.0)); assert(pow(dinf, 0.001) == dinf); assert(isIdentical(pow(dinf, -0.001), +0.0)); assert(pow(rninf, 3.0L) == rninf); assert(pow(rninf, 2.0L) == real.infinity); assert(isIdentical(pow(rninf, -3.0), -0.0)); assert(isIdentical(pow(rninf, -2.0), +0.0)); // @@@BUG@@@ somewhere version (OSX) {} else assert(isNaN(pow(one, dinf))); version (OSX) {} else assert(isNaN(pow(-one, dinf))); assert(isNaN(pow(-0.2, PI))); // boundary cases. Note that epsilon == 2^^-n for some n, // so 1/epsilon == 2^^n is always even. assert(pow(-1.0L, 1/real.epsilon - 1.0L) == -1.0L); assert(pow(-1.0L, 1/real.epsilon) == 1.0L); assert(isNaN(pow(-1.0L, 1/real.epsilon-0.5L))); assert(isNaN(pow(-1.0L, -1/real.epsilon+0.5L))); assert(pow(0.0, -3.0) == double.infinity); assert(pow(-0.0, -3.0) == -double.infinity); assert(pow(0.0, -PI) == double.infinity); assert(pow(-0.0, -PI) == double.infinity); assert(isIdentical(pow(0.0, 5.0), 0.0)); assert(isIdentical(pow(-0.0, 5.0), -0.0)); assert(isIdentical(pow(0.0, 6.0), 0.0)); assert(isIdentical(pow(-0.0, 6.0), 0.0)); // Issue #14786 fixed immutable real maxOdd = pow(2.0L, real.mant_dig) - 1.0L; assert(pow(-1.0L, maxOdd) == -1.0L); assert(pow(-1.0L, -maxOdd) == -1.0L); assert(pow(-1.0L, maxOdd + 1.0L) == 1.0L); assert(pow(-1.0L, -maxOdd + 1.0L) == 1.0L); assert(pow(-1.0L, maxOdd - 1.0L) == 1.0L); assert(pow(-1.0L, -maxOdd - 1.0L) == 1.0L); // Now, actual numbers. assert(approxEqual(pow(two, three), 8.0)); assert(approxEqual(pow(two, -2.5), 0.1767767)); // Test integer to float power. immutable uint twoI = 2; assert(approxEqual(pow(twoI, three), 8.0)); } /** Computes the value of a positive integer `x`, raised to the power `n`, modulo `m`. * * Params: * x = base * n = exponent * m = modulus * * Returns: * `x` to the power `n`, modulo `m`. * The return type is the largest of `x`'s and `m`'s type. * * The function requires that all values have unsigned types. */ Unqual!(Largest!(F, H)) powmod(F, G, H)(F x, G n, H m) if (isUnsigned!F && isUnsigned!G && isUnsigned!H) { import std.meta : AliasSeq; alias T = Unqual!(Largest!(F, H)); static if (T.sizeof <= 4) { alias DoubleT = AliasSeq!(void, ushort, uint, void, ulong)[T.sizeof]; } static T mulmod(T a, T b, T c) { static if (T.sizeof == 8) { static T addmod(T a, T b, T c) { b = c - b; if (a >= b) return a - b; else return c - b + a; } T result = 0, tmp; b %= c; while (a > 0) { if (a & 1) result = addmod(result, b, c); a >>= 1; b = addmod(b, b, c); } return result; } else { DoubleT result = cast(DoubleT) (cast(DoubleT) a * cast(DoubleT) b); return result % c; } } T base = x, result = 1, modulus = m; Unqual!G exponent = n; while (exponent > 0) { if (exponent & 1) result = mulmod(result, base, modulus); base = mulmod(base, base, modulus); exponent >>= 1; } return result; } /// @safe pure nothrow @nogc unittest { assert(powmod(1U, 10U, 3U) == 1); assert(powmod(3U, 2U, 6U) == 3); assert(powmod(5U, 5U, 15U) == 5); assert(powmod(2U, 3U, 5U) == 3); assert(powmod(2U, 4U, 5U) == 1); assert(powmod(2U, 5U, 5U) == 2); } @safe pure nothrow @nogc unittest { ulong a = 18446744073709551615u, b = 20u, c = 18446744073709551610u; assert(powmod(a, b, c) == 95367431640625u); a = 100; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 18223853583554725198u); a = 117; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 11493139548346411394u); a = 134; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 10979163786734356774u); a = 151; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 7023018419737782840u); a = 168; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 58082701842386811u); a = 185; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 17423478386299876798u); a = 202; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 5522733478579799075u); a = 219; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 15230218982491623487u); a = 236; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 5198328724976436000u); a = 0; b = 7919; c = 18446744073709551557u; assert(powmod(a, b, c) == 0); a = 123; b = 0; c = 18446744073709551557u; assert(powmod(a, b, c) == 1); immutable ulong a1 = 253, b1 = 7919, c1 = 18446744073709551557u; assert(powmod(a1, b1, c1) == 3883707345459248860u); uint x = 100 ,y = 7919, z = 1844674407u; assert(powmod(x, y, z) == 1613100340u); x = 134; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 734956622u); x = 151; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 1738696945u); x = 168; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 1247580927u); x = 185; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 1293855176u); x = 202; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 1566963682u); x = 219; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 181227807u); x = 236; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 217988321u); x = 253; y = 7919; z = 1844674407u; assert(powmod(x, y, z) == 1588843243u); x = 0; y = 7919; z = 184467u; assert(powmod(x, y, z) == 0); x = 123; y = 0; z = 1844674u; assert(powmod(x, y, z) == 1); immutable ubyte x1 = 117; immutable uint y1 = 7919; immutable uint z1 = 1844674407u; auto res = powmod(x1, y1, z1); assert(is(typeof(res) == uint)); assert(res == 9479781u); immutable ushort x2 = 123; immutable uint y2 = 203; immutable ubyte z2 = 113; auto res2 = powmod(x2, y2, z2); assert(is(typeof(res2) == ushort)); assert(res2 == 42u); } /************************************** * To what precision is x equal to y? * * Returns: the number of mantissa bits which are equal in x and y. * eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision. * * $(TABLE_SV * $(TR $(TH x) $(TH y) $(TH feqrel(x, y))) * $(TR $(TD x) $(TD x) $(TD real.mant_dig)) * $(TR $(TD x) $(TD $(GT)= 2*x) $(TD 0)) * $(TR $(TD x) $(TD $(LT)= x/2) $(TD 0)) * $(TR $(TD $(NAN)) $(TD any) $(TD 0)) * $(TR $(TD any) $(TD $(NAN)) $(TD 0)) * ) */ int feqrel(X)(const X x, const X y) @trusted pure nothrow @nogc if (isFloatingPoint!(X)) { /* Public Domain. Author: Don Clugston, 18 Aug 2005. */ alias F = floatTraits!(X); static if (F.realFormat == RealFormat.ieeeSingle || F.realFormat == RealFormat.ieeeDouble || F.realFormat == RealFormat.ieeeExtended || F.realFormat == RealFormat.ieeeQuadruple) { if (x == y) return X.mant_dig; // ensure diff != 0, cope with INF. Unqual!X diff = fabs(x - y); ushort *pa = cast(ushort *)(&x); ushort *pb = cast(ushort *)(&y); ushort *pd = cast(ushort *)(&diff); // The difference in abs(exponent) between x or y and abs(x-y) // is equal to the number of significand bits of x which are // equal to y. If negative, x and y have different exponents. // If positive, x and y are equal to 'bitsdiff' bits. // AND with 0x7FFF to form the absolute value. // To avoid out-by-1 errors, we subtract 1 so it rounds down // if the exponents were different. This means 'bitsdiff' is // always 1 lower than we want, except that if bitsdiff == 0, // they could have 0 or 1 bits in common. int bitsdiff = ((( (pa[F.EXPPOS_SHORT] & F.EXPMASK) + (pb[F.EXPPOS_SHORT] & F.EXPMASK) - (1 << F.EXPSHIFT)) >> 1) - (pd[F.EXPPOS_SHORT] & F.EXPMASK)) >> F.EXPSHIFT; if ( (pd[F.EXPPOS_SHORT] & F.EXPMASK) == 0) { // Difference is subnormal // For subnormals, we need to add the number of zeros that // lie at the start of diff's significand. // We do this by multiplying by 2^^real.mant_dig diff *= F.RECIP_EPSILON; return bitsdiff + X.mant_dig - ((pd[F.EXPPOS_SHORT] & F.EXPMASK) >> F.EXPSHIFT); } if (bitsdiff > 0) return bitsdiff + 1; // add the 1 we subtracted before // Avoid out-by-1 errors when factor is almost 2. if (bitsdiff == 0 && ((pa[F.EXPPOS_SHORT] ^ pb[F.EXPPOS_SHORT]) & F.EXPMASK) == 0) { return 1; } else return 0; } else { static assert(false, "Not implemented for this architecture"); } } /// @safe pure unittest { assert(feqrel(2.0, 2.0) == 53); assert(feqrel(2.0f, 2.0f) == 24); assert(feqrel(2.0, double.nan) == 0); // Test that numbers are within n digits of each // other by testing if feqrel > n * log2(10) // five digits assert(feqrel(2.0, 2.00001) > 16); // ten digits assert(feqrel(2.0, 2.00000000001) > 33); } @safe pure nothrow @nogc unittest { void testFeqrel(F)() { // Exact equality assert(feqrel(F.max, F.max) == F.mant_dig); assert(feqrel!(F)(0.0, 0.0) == F.mant_dig); assert(feqrel(F.infinity, F.infinity) == F.mant_dig); // a few bits away from exact equality F w=1; for (int i = 1; i < F.mant_dig - 1; ++i) { assert(feqrel!(F)(1.0 + w * F.epsilon, 1.0) == F.mant_dig-i); assert(feqrel!(F)(1.0 - w * F.epsilon, 1.0) == F.mant_dig-i); assert(feqrel!(F)(1.0, 1 + (w-1) * F.epsilon) == F.mant_dig - i + 1); w*=2; } assert(feqrel!(F)(1.5+F.epsilon, 1.5) == F.mant_dig-1); assert(feqrel!(F)(1.5-F.epsilon, 1.5) == F.mant_dig-1); assert(feqrel!(F)(1.5-F.epsilon, 1.5+F.epsilon) == F.mant_dig-2); // Numbers that are close assert(feqrel!(F)(0x1.Bp+84, 0x1.B8p+84) == 5); assert(feqrel!(F)(0x1.8p+10, 0x1.Cp+10) == 2); assert(feqrel!(F)(1.5 * (1 - F.epsilon), 1.0L) == 2); assert(feqrel!(F)(1.5, 1.0) == 1); assert(feqrel!(F)(2 * (1 - F.epsilon), 1.0L) == 1); // Factors of 2 assert(feqrel(F.max, F.infinity) == 0); assert(feqrel!(F)(2 * (1 - F.epsilon), 1.0L) == 1); assert(feqrel!(F)(1.0, 2.0) == 0); assert(feqrel!(F)(4.0, 1.0) == 0); // Extreme inequality assert(feqrel(F.nan, F.nan) == 0); assert(feqrel!(F)(0.0L, -F.nan) == 0); assert(feqrel(F.nan, F.infinity) == 0); assert(feqrel(F.infinity, -F.infinity) == 0); assert(feqrel(F.max, -F.max) == 0); assert(feqrel(F.min_normal / 8, F.min_normal / 17) == 3); const F Const = 2; immutable F Immutable = 2; auto Compiles = feqrel(Const, Immutable); } assert(feqrel(7.1824L, 7.1824L) == real.mant_dig); testFeqrel!(real)(); testFeqrel!(double)(); testFeqrel!(float)(); } package: // Not public yet /* Return the value that lies halfway between x and y on the IEEE number line. * * Formally, the result is the arithmetic mean of the binary significands of x * and y, multiplied by the geometric mean of the binary exponents of x and y. * x and y must have the same sign, and must not be NaN. * Note: this function is useful for ensuring O(log n) behaviour in algorithms * involving a 'binary chop'. * * Special cases: * If x and y are within a factor of 2, (ie, feqrel(x, y) > 0), the return value * is the arithmetic mean (x + y) / 2. * If x and y are even powers of 2, the return value is the geometric mean, * ieeeMean(x, y) = sqrt(x * y). * */ T ieeeMean(T)(const T x, const T y) @trusted pure nothrow @nogc in { // both x and y must have the same sign, and must not be NaN. assert(signbit(x) == signbit(y)); assert(x == x && y == y); } do { // Runtime behaviour for contract violation: // If signs are opposite, or one is a NaN, return 0. if (!((x >= 0 && y >= 0) || (x <= 0 && y <= 0))) return 0.0; // The implementation is simple: cast x and y to integers, // average them (avoiding overflow), and cast the result back to a floating-point number. alias F = floatTraits!(T); T u; static if (F.realFormat == RealFormat.ieeeExtended) { // There's slight additional complexity because they are actually // 79-bit reals... ushort *ue = cast(ushort *)&u; ulong *ul = cast(ulong *)&u; ushort *xe = cast(ushort *)&x; ulong *xl = cast(ulong *)&x; ushort *ye = cast(ushort *)&y; ulong *yl = cast(ulong *)&y; // Ignore the useless implicit bit. (Bonus: this prevents overflows) ulong m = ((*xl) & 0x7FFF_FFFF_FFFF_FFFFL) + ((*yl) & 0x7FFF_FFFF_FFFF_FFFFL); // @@@ BUG? @@@ // Cast shouldn't be here ushort e = cast(ushort) ((xe[F.EXPPOS_SHORT] & F.EXPMASK) + (ye[F.EXPPOS_SHORT] & F.EXPMASK)); if (m & 0x8000_0000_0000_0000L) { ++e; m &= 0x7FFF_FFFF_FFFF_FFFFL; } // Now do a multi-byte right shift const uint c = e & 1; // carry e >>= 1; m >>>= 1; if (c) m |= 0x4000_0000_0000_0000L; // shift carry into significand if (e) *ul = m | 0x8000_0000_0000_0000L; // set implicit bit... else *ul = m; // ... unless exponent is 0 (subnormal or zero). ue[4]= e | (xe[F.EXPPOS_SHORT]& 0x8000); // restore sign bit } else static if (F.realFormat == RealFormat.ieeeQuadruple) { // This would be trivial if 'ucent' were implemented... ulong *ul = cast(ulong *)&u; ulong *xl = cast(ulong *)&x; ulong *yl = cast(ulong *)&y; // Multi-byte add, then multi-byte right shift. import core.checkedint : addu; bool carry; ulong ml = addu(xl[MANTISSA_LSB], yl[MANTISSA_LSB], carry); ulong mh = carry + (xl[MANTISSA_MSB] & 0x7FFF_FFFF_FFFF_FFFFL) + (yl[MANTISSA_MSB] & 0x7FFF_FFFF_FFFF_FFFFL); ul[MANTISSA_MSB] = (mh >>> 1) | (xl[MANTISSA_MSB] & 0x8000_0000_0000_0000); ul[MANTISSA_LSB] = (ml >>> 1) | (mh & 1) << 63; } else static if (F.realFormat == RealFormat.ieeeDouble) { ulong *ul = cast(ulong *)&u; ulong *xl = cast(ulong *)&x; ulong *yl = cast(ulong *)&y; ulong m = (((*xl) & 0x7FFF_FFFF_FFFF_FFFFL) + ((*yl) & 0x7FFF_FFFF_FFFF_FFFFL)) >>> 1; m |= ((*xl) & 0x8000_0000_0000_0000L); *ul = m; } else static if (F.realFormat == RealFormat.ieeeSingle) { uint *ul = cast(uint *)&u; uint *xl = cast(uint *)&x; uint *yl = cast(uint *)&y; uint m = (((*xl) & 0x7FFF_FFFF) + ((*yl) & 0x7FFF_FFFF)) >>> 1; m |= ((*xl) & 0x8000_0000); *ul = m; } else { assert(0, "Not implemented"); } return u; } @safe pure nothrow @nogc unittest { assert(ieeeMean(-0.0,-1e-20)<0); assert(ieeeMean(0.0,1e-20)>0); assert(ieeeMean(1.0L,4.0L)==2L); assert(ieeeMean(2.0*1.013,8.0*1.013)==4*1.013); assert(ieeeMean(-1.0L,-4.0L)==-2L); assert(ieeeMean(-1.0,-4.0)==-2); assert(ieeeMean(-1.0f,-4.0f)==-2f); assert(ieeeMean(-1.0,-2.0)==-1.5); assert(ieeeMean(-1*(1+8*real.epsilon),-2*(1+8*real.epsilon)) ==-1.5*(1+5*real.epsilon)); assert(ieeeMean(0x1p60,0x1p-10)==0x1p25); static if (floatTraits!(real).realFormat == RealFormat.ieeeExtended) { assert(ieeeMean(1.0L,real.infinity)==0x1p8192L); assert(ieeeMean(0.0L,real.infinity)==1.5); } assert(ieeeMean(0.5*real.min_normal*(1-4*real.epsilon),0.5*real.min_normal) == 0.5*real.min_normal*(1-2*real.epsilon)); } public: /*********************************** * Evaluate polynomial A(x) = $(SUB a, 0) + $(SUB a, 1)x + $(SUB a, 2)$(POWER x,2) * + $(SUB a,3)$(POWER x,3); ... * * Uses Horner's rule A(x) = $(SUB a, 0) + x($(SUB a, 1) + x($(SUB a, 2) * + x($(SUB a, 3) + ...))) * Params: * x = the value to evaluate. * A = array of coefficients $(SUB a, 0), $(SUB a, 1), etc. */ Unqual!(CommonType!(T1, T2)) poly(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc if (isFloatingPoint!T1 && isFloatingPoint!T2) in { assert(A.length > 0); } do { static if (is(Unqual!T2 == real)) { return polyImpl(x, A); } else { return polyImplBase(x, A); } } /// ditto Unqual!(CommonType!(T1, T2)) poly(T1, T2, int N)(T1 x, ref const T2[N] A) @safe pure nothrow @nogc if (isFloatingPoint!T1 && isFloatingPoint!T2 && N > 0 && N <= 10) { // statically unrolled version for up to 10 coefficients typeof(return) r = A[N - 1]; static foreach (i; 1 .. N) { r *= x; r += A[N - 1 - i]; } return r; } /// @safe nothrow @nogc unittest { real x = 3.1; static real[] pp = [56.1, 32.7, 6]; assert(poly(x, pp) == (56.1L + (32.7L + 6.0L * x) * x)); } @safe nothrow @nogc unittest { double x = 3.1; static double[] pp = [56.1, 32.7, 6]; double y = x; y *= 6.0; y += 32.7; y *= x; y += 56.1; assert(poly(x, pp) == y); } @safe unittest { static assert(poly(3.0, [1.0, 2.0, 3.0]) == 34); } private Unqual!(CommonType!(T1, T2)) polyImplBase(T1, T2)(T1 x, in T2[] A) @trusted pure nothrow @nogc if (isFloatingPoint!T1 && isFloatingPoint!T2) { ptrdiff_t i = A.length - 1; typeof(return) r = A[i]; while (--i >= 0) { r *= x; r += A[i]; } return r; } private real polyImpl(real x, in real[] A) @trusted pure nothrow @nogc { version (D_InlineAsm_X86) { if (__ctfe) { return polyImplBase(x, A); } version (Windows) { // BUG: This code assumes a frame pointer in EBP. asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX][ECX*8] ; add EDX,ECX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -10[EDX] ; sub EDX,10 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else version (linux) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else version (OSX) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; add EDX,EDX ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -16[EDX] ; sub EDX,16 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else version (FreeBSD) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else version (Solaris) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else version (DragonFlyBSD) { asm pure nothrow @nogc // assembler by W. Bright { // EDX = (A.length - 1) * real.sizeof mov ECX,A[EBP] ; // ECX = A.length dec ECX ; lea EDX,[ECX*8] ; lea EDX,[EDX][ECX*4] ; add EDX,A+4[EBP] ; fld real ptr [EDX] ; // ST0 = coeff[ECX] jecxz return_ST ; fld x[EBP] ; // ST0 = x fxch ST(1) ; // ST1 = x, ST0 = r align 4 ; L2: fmul ST,ST(1) ; // r *= x fld real ptr -12[EDX] ; sub EDX,12 ; // deg-- faddp ST(1),ST ; dec ECX ; jne L2 ; fxch ST(1) ; // ST1 = r, ST0 = x fstp ST(0) ; // dump x align 4 ; return_ST: ; } } else { static assert(0); } } else { return polyImplBase(x, A); } } /** Computes whether two values are approximately equal, admitting a maximum relative difference, and a maximum absolute difference. Params: lhs = First item to compare. rhs = Second item to compare. maxRelDiff = Maximum allowable difference relative to `rhs`. Defaults to `1e-2`. maxAbsDiff = Maximum absolute difference. Defaults to `1e-5`. Returns: `true` if the two items are approximately equal under either criterium. If one item is a range, and the other is a single value, then the result is the logical and-ing of calling `approxEqual` on each element of the ranged item against the single item. If both items are ranges, then `approxEqual` returns `true` if and only if the ranges have the same number of elements and if `approxEqual` evaluates to `true` for each pair of elements. See_Also: Use $(LREF feqrel) to get the number of equal bits in the mantissa. */ bool approxEqual(T, U, V)(T lhs, U rhs, V maxRelDiff, V maxAbsDiff = 1e-5) { import std.range.primitives : empty, front, isInputRange, popFront; static if (isInputRange!T) { static if (isInputRange!U) { // Two ranges for (;; lhs.popFront(), rhs.popFront()) { if (lhs.empty) return rhs.empty; if (rhs.empty) return lhs.empty; if (!approxEqual(lhs.front, rhs.front, maxRelDiff, maxAbsDiff)) return false; } } else static if (isIntegral!U) { // convert rhs to real return approxEqual(lhs, real(rhs), maxRelDiff, maxAbsDiff); } else { // lhs is range, rhs is number for (; !lhs.empty; lhs.popFront()) { if (!approxEqual(lhs.front, rhs, maxRelDiff, maxAbsDiff)) return false; } return true; } } else { static if (isInputRange!U) { // lhs is number, rhs is range for (; !rhs.empty; rhs.popFront()) { if (!approxEqual(lhs, rhs.front, maxRelDiff, maxAbsDiff)) return false; } return true; } else static if (isIntegral!T || isIntegral!U) { // convert both lhs and rhs to real return approxEqual(real(lhs), real(rhs), maxRelDiff, maxAbsDiff); } else { // two numbers //static assert(is(T : real) && is(U : real)); if (rhs == 0) { return fabs(lhs) <= maxAbsDiff; } static if (is(typeof(lhs.infinity)) && is(typeof(rhs.infinity))) { if (lhs == lhs.infinity && rhs == rhs.infinity || lhs == -lhs.infinity && rhs == -rhs.infinity) return true; } return fabs((lhs - rhs) / rhs) <= maxRelDiff || maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff; } } } /// ditto bool approxEqual(T, U)(T lhs, U rhs) { return approxEqual(lhs, rhs, 1e-2, 1e-5); } /// @safe pure nothrow unittest { assert(approxEqual(1.0, 1.0099)); assert(!approxEqual(1.0, 1.011)); float[] arr1 = [ 1.0, 2.0, 3.0 ]; double[] arr2 = [ 1.001, 1.999, 3 ]; assert(approxEqual(arr1, arr2)); real num = real.infinity; assert(num == real.infinity); // Passes. assert(approxEqual(num, real.infinity)); // Fails. num = -real.infinity; assert(num == -real.infinity); // Passes. assert(approxEqual(num, -real.infinity)); // Fails. assert(!approxEqual(3, 0)); assert(approxEqual(3, 3)); assert(approxEqual(3.0, 3)); assert(approxEqual([3, 3, 3], 3.0)); assert(approxEqual([3.0, 3.0, 3.0], 3)); int a = 10; assert(approxEqual(10, a)); } @safe pure nothrow @nogc unittest { real num = real.infinity; assert(num == real.infinity); // Passes. assert(approxEqual(num, real.infinity)); // Fails. } @safe pure nothrow @nogc unittest { float f = sqrt(2.0f); assert(fabs(f * f - 2.0f) < .00001); double d = sqrt(2.0); assert(fabs(d * d - 2.0) < .00001); real r = sqrt(2.0L); assert(fabs(r * r - 2.0) < .00001); } @safe pure nothrow @nogc unittest { float f = fabs(-2.0f); assert(f == 2); double d = fabs(-2.0); assert(d == 2); real r = fabs(-2.0L); assert(r == 2); } @safe pure nothrow @nogc unittest { float f = sin(-2.0f); assert(fabs(f - -0.909297f) < .00001); double d = sin(-2.0); assert(fabs(d - -0.909297f) < .00001); real r = sin(-2.0L); assert(fabs(r - -0.909297f) < .00001); } @safe pure nothrow @nogc unittest { float f = cos(-2.0f); assert(fabs(f - -0.416147f) < .00001); double d = cos(-2.0); assert(fabs(d - -0.416147f) < .00001); real r = cos(-2.0L); assert(fabs(r - -0.416147f) < .00001); } @safe pure nothrow @nogc unittest { float f = tan(-2.0f); assert(fabs(f - 2.18504f) < .00001); double d = tan(-2.0); assert(fabs(d - 2.18504f) < .00001); real r = tan(-2.0L); assert(fabs(r - 2.18504f) < .00001); // Verify correct behavior for large inputs assert(!isNaN(tan(0x1p63))); assert(!isNaN(tan(-0x1p63))); static if (real.mant_dig >= 64) { assert(!isNaN(tan(0x1p300L))); assert(!isNaN(tan(-0x1p300L))); } } @safe pure nothrow unittest { // issue 6381: floor/ceil should be usable in pure function. auto x = floor(1.2); auto y = ceil(1.2); } @safe pure nothrow unittest { // relative comparison depends on rhs, make sure proper side is used when // comparing range to single value. Based on bugzilla issue 15763 auto a = [2e-3 - 1e-5]; auto b = 2e-3 + 1e-5; assert(a[0].approxEqual(b)); assert(!b.approxEqual(a[0])); assert(a.approxEqual(b)); assert(!b.approxEqual(a)); } /*********************************** * Defines a total order on all floating-point numbers. * * The order is defined as follows: * $(UL * $(LI All numbers in [-$(INFIN), +$(INFIN)] are ordered * the same way as by built-in comparison, with the exception of * -0.0, which is less than +0.0;) * $(LI If the sign bit is set (that is, it's 'negative'), $(NAN) is less * than any number; if the sign bit is not set (it is 'positive'), * $(NAN) is greater than any number;) * $(LI $(NAN)s of the same sign are ordered by the payload ('negative' * ones - in reverse order).) * ) * * Returns: * negative value if `x` precedes `y` in the order specified above; * 0 if `x` and `y` are identical, and positive value otherwise. * * See_Also: * $(MYREF isIdentical) * Standards: Conforms to IEEE 754-2008 */ int cmp(T)(const(T) x, const(T) y) @nogc @trusted pure nothrow if (isFloatingPoint!T) { alias F = floatTraits!T; static if (F.realFormat == RealFormat.ieeeSingle || F.realFormat == RealFormat.ieeeDouble) { static if (T.sizeof == 4) alias UInt = uint; else alias UInt = ulong; union Repainter { T number; UInt bits; } enum msb = ~(UInt.max >>> 1); import std.typecons : Tuple; Tuple!(Repainter, Repainter) vars = void; vars[0].number = x; vars[1].number = y; foreach (ref var; vars) if (var.bits & msb) var.bits = ~var.bits; else var.bits |= msb; if (vars[0].bits < vars[1].bits) return -1; else if (vars[0].bits > vars[1].bits) return 1; else return 0; } else static if (F.realFormat == RealFormat.ieeeExtended53 || F.realFormat == RealFormat.ieeeExtended || F.realFormat == RealFormat.ieeeQuadruple) { static if (F.realFormat == RealFormat.ieeeQuadruple) alias RemT = ulong; else alias RemT = ushort; struct Bits { ulong bulk; RemT rem; } union Repainter { T number; Bits bits; ubyte[T.sizeof] bytes; } import std.typecons : Tuple; Tuple!(Repainter, Repainter) vars = void; vars[0].number = x; vars[1].number = y; foreach (ref var; vars) if (var.bytes[F.SIGNPOS_BYTE] & 0x80) { var.bits.bulk = ~var.bits.bulk; var.bits.rem = cast(typeof(var.bits.rem))(-1 - var.bits.rem); // ~var.bits.rem } else { var.bytes[F.SIGNPOS_BYTE] |= 0x80; } version (LittleEndian) { if (vars[0].bits.rem < vars[1].bits.rem) return -1; else if (vars[0].bits.rem > vars[1].bits.rem) return 1; else if (vars[0].bits.bulk < vars[1].bits.bulk) return -1; else if (vars[0].bits.bulk > vars[1].bits.bulk) return 1; else return 0; } else { if (vars[0].bits.bulk < vars[1].bits.bulk) return -1; else if (vars[0].bits.bulk > vars[1].bits.bulk) return 1; else if (vars[0].bits.rem < vars[1].bits.rem) return -1; else if (vars[0].bits.rem > vars[1].bits.rem) return 1; else return 0; } } else { // IBM Extended doubledouble does not follow the general // sign-exponent-significand layout, so has to be handled generically const int xSign = signbit(x), ySign = signbit(y); if (xSign == 1 && ySign == 1) return cmp(-y, -x); else if (xSign == 1) return -1; else if (ySign == 1) return 1; else if (x < y) return -1; else if (x == y) return 0; else if (x > y) return 1; else if (isNaN(x) && !isNaN(y)) return 1; else if (isNaN(y) && !isNaN(x)) return -1; else if (getNaNPayload(x) < getNaNPayload(y)) return -1; else if (getNaNPayload(x) > getNaNPayload(y)) return 1; else return 0; } } /// Most numbers are ordered naturally. @safe unittest { assert(cmp(-double.infinity, -double.max) < 0); assert(cmp(-double.max, -100.0) < 0); assert(cmp(-100.0, -0.5) < 0); assert(cmp(-0.5, 0.0) < 0); assert(cmp(0.0, 0.5) < 0); assert(cmp(0.5, 100.0) < 0); assert(cmp(100.0, double.max) < 0); assert(cmp(double.max, double.infinity) < 0); assert(cmp(1.0, 1.0) == 0); } /// Positive and negative zeroes are distinct. @safe unittest { assert(cmp(-0.0, +0.0) < 0); assert(cmp(+0.0, -0.0) > 0); } /// Depending on the sign, $(NAN)s go to either end of the spectrum. @safe unittest { assert(cmp(-double.nan, -double.infinity) < 0); assert(cmp(double.infinity, double.nan) < 0); assert(cmp(-double.nan, double.nan) < 0); } /// $(NAN)s of the same sign are ordered by the payload. @safe unittest { assert(cmp(NaN(10), NaN(20)) < 0); assert(cmp(-NaN(20), -NaN(10)) < 0); } @safe unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ T[] values = [-cast(T) NaN(20), -cast(T) NaN(10), -T.nan, -T.infinity, -T.max, -T.max / 2, T(-16.0), T(-1.0).nextDown, T(-1.0), T(-1.0).nextUp, T(-0.5), -T.min_normal, (-T.min_normal).nextUp, -2 * T.min_normal * T.epsilon, -T.min_normal * T.epsilon, T(-0.0), T(0.0), T.min_normal * T.epsilon, 2 * T.min_normal * T.epsilon, T.min_normal.nextDown, T.min_normal, T(0.5), T(1.0).nextDown, T(1.0), T(1.0).nextUp, T(16.0), T.max / 2, T.max, T.infinity, T.nan, cast(T) NaN(10), cast(T) NaN(20)]; foreach (i, x; values) { foreach (y; values[i + 1 .. $]) { assert(cmp(x, y) < 0); assert(cmp(y, x) > 0); } assert(cmp(x, x) == 0); } }} } private enum PowType { floor, ceil } pragma(inline, true) private T powIntegralImpl(PowType type, T)(T val) { import core.bitop : bsr; if (val == 0 || (type == PowType.ceil && (val > T.max / 2 || val == T.min))) return 0; else { static if (isSigned!T) return cast(Unqual!T) (val < 0 ? -(T(1) << bsr(0 - val) + type) : T(1) << bsr(val) + type); else return cast(Unqual!T) (T(1) << bsr(val) + type); } } private T powFloatingPointImpl(PowType type, T)(T x) { if (!x.isFinite) return x; if (!x) return x; int exp; auto y = frexp(x, exp); static if (type == PowType.ceil) y = ldexp(cast(T) 0.5, exp + 1); else y = ldexp(cast(T) 0.5, exp); if (!y.isFinite) return cast(T) 0.0; y = copysign(y, x); return y; } /** * Gives the next power of two after `val`. `T` can be any built-in * numerical type. * * If the operation would lead to an over/underflow, this function will * return `0`. * * Params: * val = any number * * Returns: * the next power of two after `val` */ T nextPow2(T)(const T val) if (isIntegral!T) { return powIntegralImpl!(PowType.ceil)(val); } /// ditto T nextPow2(T)(const T val) if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.ceil)(val); } /// @safe @nogc pure nothrow unittest { assert(nextPow2(2) == 4); assert(nextPow2(10) == 16); assert(nextPow2(4000) == 4096); assert(nextPow2(-2) == -4); assert(nextPow2(-10) == -16); assert(nextPow2(uint.max) == 0); assert(nextPow2(uint.min) == 0); assert(nextPow2(size_t.max) == 0); assert(nextPow2(size_t.min) == 0); assert(nextPow2(int.max) == 0); assert(nextPow2(int.min) == 0); assert(nextPow2(long.max) == 0); assert(nextPow2(long.min) == 0); } /// @safe @nogc pure nothrow unittest { assert(nextPow2(2.1) == 4.0); assert(nextPow2(-2.0) == -4.0); assert(nextPow2(0.25) == 0.5); assert(nextPow2(-4.0) == -8.0); assert(nextPow2(double.max) == 0.0); assert(nextPow2(double.infinity) == double.infinity); } @safe @nogc pure nothrow unittest { assert(nextPow2(ubyte(2)) == 4); assert(nextPow2(ubyte(10)) == 16); assert(nextPow2(byte(2)) == 4); assert(nextPow2(byte(10)) == 16); assert(nextPow2(short(2)) == 4); assert(nextPow2(short(10)) == 16); assert(nextPow2(short(4000)) == 4096); assert(nextPow2(ushort(2)) == 4); assert(nextPow2(ushort(10)) == 16); assert(nextPow2(ushort(4000)) == 4096); } @safe @nogc pure nothrow unittest { foreach (ulong i; 1 .. 62) { assert(nextPow2(1UL << i) == 2UL << i); assert(nextPow2((1UL << i) - 1) == 1UL << i); assert(nextPow2((1UL << i) + 1) == 2UL << i); assert(nextPow2((1UL << i) + (1UL<<(i-1))) == 2UL << i); } } @safe @nogc pure nothrow unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) {{ enum T subNormal = T.min_normal / 2; static if (subNormal) assert(nextPow2(subNormal) == T.min_normal); assert(nextPow2(T(0.0)) == 0.0); assert(nextPow2(T(2.0)) == 4.0); assert(nextPow2(T(2.1)) == 4.0); assert(nextPow2(T(3.1)) == 4.0); assert(nextPow2(T(4.0)) == 8.0); assert(nextPow2(T(0.25)) == 0.5); assert(nextPow2(T(-2.0)) == -4.0); assert(nextPow2(T(-2.1)) == -4.0); assert(nextPow2(T(-3.1)) == -4.0); assert(nextPow2(T(-4.0)) == -8.0); assert(nextPow2(T(-0.25)) == -0.5); assert(nextPow2(T.max) == 0); assert(nextPow2(-T.max) == 0); assert(nextPow2(T.infinity) == T.infinity); assert(nextPow2(T.init).isNaN); }} } @safe @nogc pure nothrow unittest // Issue 15973 { assert(nextPow2(uint.max / 2) == uint.max / 2 + 1); assert(nextPow2(uint.max / 2 + 2) == 0); assert(nextPow2(int.max / 2) == int.max / 2 + 1); assert(nextPow2(int.max / 2 + 2) == 0); assert(nextPow2(int.min + 1) == int.min); } /** * Gives the last power of two before `val`. $(T) can be any built-in * numerical type. * * Params: * val = any number * * Returns: * the last power of two before `val` */ T truncPow2(T)(const T val) if (isIntegral!T) { return powIntegralImpl!(PowType.floor)(val); } /// ditto T truncPow2(T)(const T val) if (isFloatingPoint!T) { return powFloatingPointImpl!(PowType.floor)(val); } /// @safe @nogc pure nothrow unittest { assert(truncPow2(3) == 2); assert(truncPow2(4) == 4); assert(truncPow2(10) == 8); assert(truncPow2(4000) == 2048); assert(truncPow2(-5) == -4); assert(truncPow2(-20) == -16); assert(truncPow2(uint.max) == int.max + 1); assert(truncPow2(uint.min) == 0); assert(truncPow2(ulong.max) == long.max + 1); assert(truncPow2(ulong.min) == 0); assert(truncPow2(int.max) == (int.max / 2) + 1); assert(truncPow2(int.min) == int.min); assert(truncPow2(long.max) == (long.max / 2) + 1); assert(truncPow2(long.min) == long.min); } /// @safe @nogc pure nothrow unittest { assert(truncPow2(2.1) == 2.0); assert(truncPow2(7.0) == 4.0); assert(truncPow2(-1.9) == -1.0); assert(truncPow2(0.24) == 0.125); assert(truncPow2(-7.0) == -4.0); assert(truncPow2(double.infinity) == double.infinity); } @safe @nogc pure nothrow unittest { assert(truncPow2(ubyte(3)) == 2); assert(truncPow2(ubyte(4)) == 4); assert(truncPow2(ubyte(10)) == 8); assert(truncPow2(byte(3)) == 2); assert(truncPow2(byte(4)) == 4); assert(truncPow2(byte(10)) == 8); assert(truncPow2(ushort(3)) == 2); assert(truncPow2(ushort(4)) == 4); assert(truncPow2(ushort(10)) == 8); assert(truncPow2(ushort(4000)) == 2048); assert(truncPow2(short(3)) == 2); assert(truncPow2(short(4)) == 4); assert(truncPow2(short(10)) == 8); assert(truncPow2(short(4000)) == 2048); } @safe @nogc pure nothrow unittest { foreach (ulong i; 1 .. 62) { assert(truncPow2(2UL << i) == 2UL << i); assert(truncPow2((2UL << i) + 1) == 2UL << i); assert(truncPow2((2UL << i) - 1) == 1UL << i); assert(truncPow2((2UL << i) - (2UL<<(i-1))) == 1UL << i); } } @safe @nogc pure nothrow unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(float, double, real)) { assert(truncPow2(T(0.0)) == 0.0); assert(truncPow2(T(4.0)) == 4.0); assert(truncPow2(T(2.1)) == 2.0); assert(truncPow2(T(3.5)) == 2.0); assert(truncPow2(T(7.0)) == 4.0); assert(truncPow2(T(0.24)) == 0.125); assert(truncPow2(T(-2.0)) == -2.0); assert(truncPow2(T(-2.1)) == -2.0); assert(truncPow2(T(-3.1)) == -2.0); assert(truncPow2(T(-7.0)) == -4.0); assert(truncPow2(T(-0.24)) == -0.125); assert(truncPow2(T.infinity) == T.infinity); assert(truncPow2(T.init).isNaN); } } /** Check whether a number is an integer power of two. Note that only positive numbers can be integer powers of two. This function always return `false` if `x` is negative or zero. Params: x = the number to test Returns: `true` if `x` is an integer power of two. */ bool isPowerOf2(X)(const X x) pure @safe nothrow @nogc if (isNumeric!X) { static if (isFloatingPoint!X) { int exp; const X sig = frexp(x, exp); return (exp != int.min) && (sig is cast(X) 0.5L); } else { static if (isSigned!X) { auto y = cast(typeof(x + 0))x; return y > 0 && !(y & (y - 1)); } else { auto y = cast(typeof(x + 0u))x; return (y & -y) > (y - 1); } } } /// @safe unittest { assert( isPowerOf2(1.0L)); assert( isPowerOf2(2.0L)); assert( isPowerOf2(0.5L)); assert( isPowerOf2(pow(2.0L, 96))); assert( isPowerOf2(pow(2.0L, -77))); assert(!isPowerOf2(-2.0L)); assert(!isPowerOf2(-0.5L)); assert(!isPowerOf2(0.0L)); assert(!isPowerOf2(4.315)); assert(!isPowerOf2(1.0L / 3.0L)); assert(!isPowerOf2(real.nan)); assert(!isPowerOf2(real.infinity)); } /// @safe unittest { assert( isPowerOf2(1)); assert( isPowerOf2(2)); assert( isPowerOf2(1uL << 63)); assert(!isPowerOf2(-4)); assert(!isPowerOf2(0)); assert(!isPowerOf2(1337u)); } @safe unittest { import std.meta : AliasSeq; immutable smallP2 = pow(2.0L, -62); immutable bigP2 = pow(2.0L, 50); immutable smallP7 = pow(7.0L, -35); immutable bigP7 = pow(7.0L, 30); static foreach (X; AliasSeq!(float, double, real)) {{ immutable min_sub = X.min_normal * X.epsilon; foreach (x; [smallP2, min_sub, X.min_normal, .25L, 0.5L, 1.0L, 2.0L, 8.0L, pow(2.0L, X.max_exp - 1), bigP2]) { assert( isPowerOf2(cast(X) x)); assert(!isPowerOf2(cast(X)-x)); } foreach (x; [0.0L, 3 * min_sub, smallP7, 0.1L, 1337.0L, bigP7, X.max, real.nan, real.infinity]) { assert(!isPowerOf2(cast(X) x)); assert(!isPowerOf2(cast(X)-x)); } }} static foreach (X; AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong)) {{ foreach (x; [1, 2, 4, 8, (X.max >>> 1) + 1]) { assert( isPowerOf2(cast(X) x)); static if (isSigned!X) assert(!isPowerOf2(cast(X)-x)); } foreach (x; [0, 3, 5, 13, 77, X.min, X.max]) assert(!isPowerOf2(cast(X) x)); }} }
D
module deimos.cef3.download_handler; // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the name Chromium Embedded // Framework nor the names of its contributors may be used to endorse // or promote products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // --------------------------------------------------------------------------- // // This file was generated by the CEF translator tool and should not edited // by hand. See the translator.README.txt file in the tools directory for // more information. // extern(C) { import deimos.cef3.base; import deimos.cef3.browser; import deimos.cef3.download_item; /// // Callback structure used to asynchronously continue a download. /// struct cef_before_download_callback_t { /// // Base structure. /// cef_base_t base; /// // Call to continue the download. Set |download_path| to the full file path // for the download including the file name or leave blank to use the // suggested name and the default temp directory. Set |show_dialog| to true // (1) if you do wish to show the default "Save As" dialog. /// extern(System) void function(cef_before_download_callback_t* self, const(cef_string_t)* download_path, int show_dialog) cont; } /// // Callback structure used to asynchronously cancel a download. /// struct cef_download_item_callback_t { /// // Base structure. /// cef_base_t base; /// // Call to cancel the download. /// extern(System) void function(cef_download_item_callback_t* self) cancel; } /// // Structure used to handle file downloads. The functions of this structure will // called on the browser process UI thread. /// struct cef_download_handler_t { /// // Base structure. /// cef_base_t base; /// // Called before a download begins. |suggested_name| is the suggested name for // the download file. By default the download will be canceled. Execute // |callback| either asynchronously or in this function to continue the // download if desired. Do not keep a reference to |download_item| outside of // this function. /// extern(System) void function(cef_download_handler_t* self, cef_browser_t* browser, cef_download_item_t* download_item, const(cef_string_t)* suggested_name, cef_before_download_callback_t* callback) on_before_download; /// // Called when a download's status or progress information has been updated. // Execute |callback| either asynchronously or in this function to cancel the // download if desired. Do not keep a reference to |download_item| outside of // this function. /// extern(System) void function(cef_download_handler_t* self, cef_browser_t* browser, cef_download_item_t* download_item, cef_download_item_callback_t* callback) on_download_updated; } }
D
module bindbc.libsoundio.bindstatic; import bindbc.libsoundio.types; version(BindLibsoundio_Static): extern(C): @nogc: nothrow: static if (libsoundioSupport >= LibsoundioSupport.libsoundio11) { /// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch const(char)* soundio_version_string (); /// See also ::soundio_version_string, ::soundio_version_minor, ::soundio_version_patch int soundio_version_major (); /// See also ::soundio_version_major, ::soundio_version_string, ::soundio_version_patch int soundio_version_minor (); /// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_string int soundio_version_patch (); } /// Create a SoundIo context. You may create multiple instances of this to /// connect to multiple backends. Sets all fields to defaults. /// Returns `NULL` if and only if memory could not be allocated. /// See also ::soundio_destroy SoundIo* soundio_create (); void soundio_destroy (SoundIo* soundio); /// Tries ::soundio_connect_backend on all available backends in order. /// Possible errors: /// * #SoundIoErrorInvalid - already connected /// * #SoundIoErrorNoMem /// * #SoundIoErrorSystemResources /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` /// See also ::soundio_disconnect int soundio_connect (SoundIo* soundio); /// Instead of calling ::soundio_connect you may call this function to try a /// specific backend. /// Possible errors: /// * #SoundIoErrorInvalid - already connected or invalid backend parameter /// * #SoundIoErrorNoMem /// * #SoundIoErrorBackendUnavailable - backend was not compiled in /// * #SoundIoErrorSystemResources /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` /// * #SoundIoErrorInitAudioBackend - requested `backend` is not active /// * #SoundIoErrorBackendDisconnected - backend disconnected while connecting /// See also ::soundio_disconnect int soundio_connect_backend (SoundIo* soundio, SoundIoBackend backend); void soundio_disconnect (SoundIo* soundio); /// Get a string representation of a #SoundIoError const(char)* soundio_strerror (int error); /// Get a string representation of a #SoundIoBackend const(char)* soundio_backend_name (SoundIoBackend backend); /// Returns the number of available backends. int soundio_backend_count (SoundIo* soundio); /// get the available backend at the specified index /// (0 <= index < ::soundio_backend_count) SoundIoBackend soundio_get_backend (SoundIo* soundio, int index); /// Returns whether libsoundio was compiled with backend. bool soundio_have_backend (SoundIoBackend backend); /// Atomically update information for all connected devices. Note that calling /// this function merely flips a pointer; the actual work of collecting device /// information is done elsewhere. It is performant to call this function many /// times per second. /// /// When you call this, the following callbacks might be called: /// * SoundIo::on_devices_change /// * SoundIo::on_backend_disconnect /// This is the only time those callbacks can be called. /// /// This must be called from the same thread as the thread in which you call /// these functions: /// * ::soundio_input_device_count /// * ::soundio_output_device_count /// * ::soundio_get_input_device /// * ::soundio_get_output_device /// * ::soundio_default_input_device_index /// * ::soundio_default_output_device_index /// /// Note that if you do not care about learning about updated devices, you /// might call this function only once ever and never call /// ::soundio_wait_events. void soundio_flush_events (SoundIo* soundio); /// This function calls ::soundio_flush_events then blocks until another event /// is ready or you call ::soundio_wakeup. Be ready for spurious wakeups. void soundio_wait_events (SoundIo* soundio); /// Makes ::soundio_wait_events stop blocking. void soundio_wakeup (SoundIo* soundio); /// If necessary you can manually trigger a device rescan. Normally you will /// not ever have to call this function, as libsoundio listens to system events /// for device changes and responds to them by rescanning devices and preparing /// the new device information for you to be atomically replaced when you call /// ::soundio_flush_events. However you might run into cases where you want to /// force trigger a device rescan, for example if an ALSA device has a /// SoundIoDevice::probe_error. /// /// After you call this you still have to use ::soundio_flush_events or /// ::soundio_wait_events and then wait for the /// SoundIo::on_devices_change callback. /// /// This can be called from any thread context except for /// SoundIoOutStream::write_callback and SoundIoInStream::read_callback void soundio_force_device_scan (SoundIo* soundio); // Channel Layouts /// Returns whether the channel count field and each channel id matches in /// the supplied channel layouts. bool soundio_channel_layout_equal ( const(SoundIoChannelLayout)* a, const(SoundIoChannelLayout)* b); const(char)* soundio_get_channel_name (SoundIoChannelId id); /// Given UTF-8 encoded text which is the name of a channel such as /// "Front Left", "FL", or "front-left", return the corresponding /// SoundIoChannelId. Returns SoundIoChannelIdInvalid for no match. SoundIoChannelId soundio_parse_channel_id (const(char)* str, int str_len); /// Returns the number of builtin channel layouts. int soundio_channel_layout_builtin_count (); /// Returns a builtin channel layout. 0 <= `index` < ::soundio_channel_layout_builtin_count /// /// Although `index` is of type `int`, it should be a valid /// #SoundIoChannelLayoutId enum value. const(SoundIoChannelLayout)* soundio_channel_layout_get_builtin (int index); /// Get the default builtin channel layout for the given number of channels. const(SoundIoChannelLayout)* soundio_channel_layout_get_default (int channel_count); /// Return the index of `channel` in `layout`, or `-1` if not found. int soundio_channel_layout_find_channel ( const(SoundIoChannelLayout)* layout, SoundIoChannelId channel); /// Populates the name field of layout if it matches a builtin one. /// returns whether it found a match bool soundio_channel_layout_detect_builtin (SoundIoChannelLayout* layout); /// Iterates over preferred_layouts. Returns the first channel layout in /// preferred_layouts which matches one of the channel layouts in /// available_layouts. Returns NULL if none matches. const(SoundIoChannelLayout)* soundio_best_matching_channel_layout ( const(SoundIoChannelLayout)* preferred_layouts, int preferred_layout_count, const(SoundIoChannelLayout)* available_layouts, int available_layout_count); /// Sorts by channel count, descending. void soundio_sort_channel_layouts (SoundIoChannelLayout* layouts, int layout_count); // Sample Formats /// Returns -1 on invalid format. int soundio_get_bytes_per_sample (SoundIoFormat format); /// A frame is one sample per channel. int soundio_get_bytes_per_frame (SoundIoFormat format, int channel_count); /// Sample rate is the number of frames per second. int soundio_get_bytes_per_second ( SoundIoFormat format, int channel_count, int sample_rate); /// Returns string representation of `format`. const(char)* soundio_format_string (SoundIoFormat format); // Devices /// When you call ::soundio_flush_events, a snapshot of all device state is /// saved and these functions merely access the snapshot data. When you want /// to check for new devices, call ::soundio_flush_events. Or you can call /// ::soundio_wait_events to block until devices change. If an error occurs /// scanning devices in a background thread, SoundIo::on_backend_disconnect is called /// with the error code. /// Get the number of input devices. /// Returns -1 if you never called ::soundio_flush_events. int soundio_input_device_count (SoundIo* soundio); /// Get the number of output devices. /// Returns -1 if you never called ::soundio_flush_events. int soundio_output_device_count (SoundIo* soundio); /// Always returns a device. Call ::soundio_device_unref when done. /// `index` must be 0 <= index < ::soundio_input_device_count /// Returns NULL if you never called ::soundio_flush_events or if you provide /// invalid parameter values. SoundIoDevice* soundio_get_input_device (SoundIo* soundio, int index); /// Always returns a device. Call ::soundio_device_unref when done. /// `index` must be 0 <= index < ::soundio_output_device_count /// Returns NULL if you never called ::soundio_flush_events or if you provide /// invalid parameter values. SoundIoDevice* soundio_get_output_device (SoundIo* soundio, int index); /// returns the index of the default input device /// returns -1 if there are no devices or if you never called /// ::soundio_flush_events. int soundio_default_input_device_index (SoundIo* soundio); /// returns the index of the default output device /// returns -1 if there are no devices or if you never called /// ::soundio_flush_events. int soundio_default_output_device_index (SoundIo* soundio); /// Add 1 to the reference count of `device`. void soundio_device_ref (SoundIoDevice* device); /// Remove 1 to the reference count of `device`. Clean up if it was the last /// reference. void soundio_device_unref (SoundIoDevice* device); /// Return `true` if and only if the devices have the same SoundIoDevice::id, /// SoundIoDevice::is_raw, and SoundIoDevice::aim are the same. bool soundio_device_equal (const(SoundIoDevice)* a, const(SoundIoDevice)* b); /// Sorts channel layouts by channel count, descending. void soundio_device_sort_channel_layouts (SoundIoDevice* device); /// Convenience function. Returns whether `format` is included in the device's /// supported formats. bool soundio_device_supports_format ( SoundIoDevice* device, SoundIoFormat format); /// Convenience function. Returns whether `layout` is included in the device's /// supported channel layouts. bool soundio_device_supports_layout ( SoundIoDevice* device, const(SoundIoChannelLayout)* layout); /// Convenience function. Returns whether `sample_rate` is included in the /// device's supported sample rates. bool soundio_device_supports_sample_rate ( SoundIoDevice* device, int sample_rate); /// Convenience function. Returns the available sample rate nearest to /// `sample_rate`, rounding up. int soundio_device_nearest_sample_rate (SoundIoDevice* device, int sample_rate); // Output Streams /// Allocates memory and sets defaults. Next you should fill out the struct fields /// and then call ::soundio_outstream_open. Sets all fields to defaults. /// Returns `NULL` if and only if memory could not be allocated. /// See also ::soundio_outstream_destroy SoundIoOutStream* soundio_outstream_create (SoundIoDevice* device); /// You may not call this function from the SoundIoOutStream::write_callback thread context. void soundio_outstream_destroy (SoundIoOutStream* outstream); /// After you call this function, SoundIoOutStream::software_latency is set to /// the correct value. /// /// The next thing to do is call ::soundio_outstream_start. /// If this function returns an error, the outstream is in an invalid state and /// you must call ::soundio_outstream_destroy on it. /// /// Possible errors: /// * #SoundIoErrorInvalid /// * SoundIoDevice::aim is not #SoundIoDeviceAimOutput /// * SoundIoOutStream::format is not valid /// * SoundIoOutStream::channel_count is greater than #SOUNDIO_MAX_CHANNELS /// * #SoundIoErrorNoMem /// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorSystemResources /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` /// * #SoundIoErrorIncompatibleBackend - SoundIoOutStream::channel_count is /// greater than the number of channels the backend can handle. /// * #SoundIoErrorIncompatibleDevice - stream parameters requested are not /// compatible with the chosen device. int soundio_outstream_open (SoundIoOutStream* outstream); /// After you call this function, SoundIoOutStream::write_callback will be called. /// /// This function might directly call SoundIoOutStream::write_callback. /// /// Possible errors: /// * #SoundIoErrorStreaming /// * #SoundIoErrorNoMem /// * #SoundIoErrorSystemResources /// * #SoundIoErrorBackendDisconnected int soundio_outstream_start (SoundIoOutStream* outstream); /// Call this function when you are ready to begin writing to the device buffer. /// * `outstream` - (in) The output stream you want to write to. /// * `areas` - (out) The memory addresses you can write data to, one per /// channel. It is OK to modify the pointers if that helps you iterate. /// * `frame_count` - (in/out) Provide the number of frames you want to write. /// Returned will be the number of frames you can actually write, which is /// also the number of frames that will be written when you call /// ::soundio_outstream_end_write. The value returned will always be less /// than or equal to the value provided. /// It is your responsibility to call this function exactly as many times as /// necessary to meet the `frame_count_min` and `frame_count_max` criteria from /// SoundIoOutStream::write_callback. /// You must call this function only from the SoundIoOutStream::write_callback thread context. /// After calling this function, write data to `areas` and then call /// ::soundio_outstream_end_write. /// If this function returns an error, do not call ::soundio_outstream_end_write. /// /// Possible errors: /// * #SoundIoErrorInvalid /// * `*frame_count` <= 0 /// * `*frame_count` < `frame_count_min` or `*frame_count` > `frame_count_max` /// * function called too many times without respecting `frame_count_max` /// * #SoundIoErrorStreaming /// * #SoundIoErrorUnderflow - an underflow caused this call to fail. You might /// also get a SoundIoOutStream::underflow_callback, and you might not get /// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming, /// the outstream is still in a valid state and streaming can continue. /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now /// be discovered that the device uses non-byte-aligned access, in which /// case this error code is returned. int soundio_outstream_begin_write ( SoundIoOutStream* outstream, SoundIoChannelArea** areas, int* frame_count); /// Commits the write that you began with ::soundio_outstream_begin_write. /// You must call this function only from the SoundIoOutStream::write_callback thread context. /// /// Possible errors: /// * #SoundIoErrorStreaming /// * #SoundIoErrorUnderflow - an underflow caused this call to fail. You might /// also get a SoundIoOutStream::underflow_callback, and you might not get /// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming, /// the outstream is still in a valid state and streaming can continue. int soundio_outstream_end_write (SoundIoOutStream* outstream); /// Clears the output stream buffer. /// This function can be called from any thread. /// This function can be called regardless of whether the outstream is paused /// or not. /// Some backends do not support clearing the buffer. On these backends this /// function will return SoundIoErrorIncompatibleBackend. /// Some devices do not support clearing the buffer. On these devices this /// function might return SoundIoErrorIncompatibleDevice. /// Possible errors: /// /// * #SoundIoErrorStreaming /// * #SoundIoErrorIncompatibleBackend /// * #SoundIoErrorIncompatibleDevice int soundio_outstream_clear_buffer (SoundIoOutStream* outstream); /// If the underlying backend and device support pausing, this pauses the /// stream. SoundIoOutStream::write_callback may be called a few more times if /// the buffer is not full. /// Pausing might put the hardware into a low power state which is ideal if your /// software is silent for some time. /// This function may be called from any thread context, including /// SoundIoOutStream::write_callback. /// Pausing when already paused or unpausing when already unpaused has no /// effect and returns #SoundIoErrorNone. /// /// Possible errors: /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorStreaming /// * #SoundIoErrorIncompatibleDevice - device does not support /// pausing/unpausing. This error code might not be returned even if the /// device does not support pausing/unpausing. /// * #SoundIoErrorIncompatibleBackend - backend does not support /// pausing/unpausing. /// * #SoundIoErrorInvalid - outstream not opened and started int soundio_outstream_pause (SoundIoOutStream* outstream, bool pause); /// Obtain the total number of seconds that the next frame written after the /// last frame written with ::soundio_outstream_end_write will take to become /// audible. This includes both software and hardware latency. In other words, /// if you call this function directly after calling ::soundio_outstream_end_write, /// this gives you the number of seconds that the next frame written will take /// to become audible. /// /// This function must be called only from within SoundIoOutStream::write_callback. /// /// Possible errors: /// * #SoundIoErrorStreaming int soundio_outstream_get_latency ( SoundIoOutStream* outstream, double* out_latency); static if (libsoundioSupport >= LibsoundioSupport.libsoundio20) { int soundio_outstream_set_volume (SoundIoOutStream* outstream, double volume); } // Input Streams /// Allocates memory and sets defaults. Next you should fill out the struct fields /// and then call ::soundio_instream_open. Sets all fields to defaults. /// Returns `NULL` if and only if memory could not be allocated. /// See also ::soundio_instream_destroy SoundIoInStream* soundio_instream_create (SoundIoDevice* device); /// You may not call this function from SoundIoInStream::read_callback. void soundio_instream_destroy (SoundIoInStream* instream); /// After you call this function, SoundIoInStream::software_latency is set to the correct /// value. /// The next thing to do is call ::soundio_instream_start. /// If this function returns an error, the instream is in an invalid state and /// you must call ::soundio_instream_destroy on it. /// /// Possible errors: /// * #SoundIoErrorInvalid /// * device aim is not #SoundIoDeviceAimInput /// * format is not valid /// * requested layout channel count > #SOUNDIO_MAX_CHANNELS /// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorNoMem /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorSystemResources /// * #SoundIoErrorNoSuchClient /// * #SoundIoErrorIncompatibleBackend /// * #SoundIoErrorIncompatibleDevice int soundio_instream_open (SoundIoInStream* instream); /// After you call this function, SoundIoInStream::read_callback will be called. /// /// Possible errors: /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorStreaming /// * #SoundIoErrorOpeningDevice /// * #SoundIoErrorSystemResources int soundio_instream_start (SoundIoInStream* instream); /// Call this function when you are ready to begin reading from the device /// buffer. /// * `instream` - (in) The input stream you want to read from. /// * `areas` - (out) The memory addresses you can read data from. It is OK /// to modify the pointers if that helps you iterate. There might be a "hole" /// in the buffer. To indicate this, `areas` will be `NULL` and `frame_count` /// tells how big the hole is in frames. /// * `frame_count` - (in/out) - Provide the number of frames you want to read; /// returns the number of frames you can actually read. The returned value /// will always be less than or equal to the provided value. If the provided /// value is less than `frame_count_min` from SoundIoInStream::read_callback this function /// returns with #SoundIoErrorInvalid. /// It is your responsibility to call this function no more and no fewer than the /// correct number of times according to the `frame_count_min` and /// `frame_count_max` criteria from SoundIoInStream::read_callback. /// You must call this function only from the SoundIoInStream::read_callback thread context. /// After calling this function, read data from `areas` and then use /// ::soundio_instream_end_read` to actually remove the data from the buffer /// and move the read index forward. ::soundio_instream_end_read should not be /// called if the buffer is empty (`frame_count` == 0), but it should be called /// if there is a hole. /// /// Possible errors: /// * #SoundIoErrorInvalid /// * `*frame_count` < `frame_count_min` or `*frame_count` > `frame_count_max` /// * #SoundIoErrorStreaming /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now /// be discovered that the device uses non-byte-aligned access, in which /// case this error code is returned. int soundio_instream_begin_read ( SoundIoInStream* instream, SoundIoChannelArea** areas, int* frame_count); /// This will drop all of the frames from when you called /// ::soundio_instream_begin_read. /// You must call this function only from the SoundIoInStream::read_callback thread context. /// You must call this function only after a successful call to /// ::soundio_instream_begin_read. /// /// Possible errors: /// * #SoundIoErrorStreaming int soundio_instream_end_read (SoundIoInStream* instream); /// If the underyling device supports pausing, this pauses the stream and /// prevents SoundIoInStream::read_callback from being called. Otherwise this returns /// #SoundIoErrorIncompatibleDevice. /// This function may be called from any thread. /// Pausing when already paused or unpausing when already unpaused has no /// effect and always returns #SoundIoErrorNone. /// /// Possible errors: /// * #SoundIoErrorBackendDisconnected /// * #SoundIoErrorStreaming /// * #SoundIoErrorIncompatibleDevice - device does not support pausing/unpausing int soundio_instream_pause (SoundIoInStream* instream, bool pause); /// Obtain the number of seconds that the next frame of sound being /// captured will take to arrive in the buffer, plus the amount of time that is /// represented in the buffer. This includes both software and hardware latency. /// /// This function must be called only from within SoundIoInStream::read_callback. /// /// Possible errors: /// * #SoundIoErrorStreaming int soundio_instream_get_latency ( SoundIoInStream* instream, double* out_latency); /// A ring buffer is a single-reader single-writer lock-free fixed-size queue. /// libsoundio ring buffers use memory mapping techniques to enable a /// contiguous buffer when reading or writing across the boundary of the ring /// buffer's capacity. /// `requested_capacity` in bytes. /// Returns `NULL` if and only if memory could not be allocated. /// Use ::soundio_ring_buffer_capacity to get the actual capacity, which might /// be greater for alignment purposes. /// See also ::soundio_ring_buffer_destroy SoundIoRingBuffer* soundio_ring_buffer_create (SoundIo* soundio, int requested_capacity); void soundio_ring_buffer_destroy (SoundIoRingBuffer* ring_buffer); /// When you create a ring buffer, capacity might be more than the requested /// capacity for alignment purposes. This function returns the actual capacity. int soundio_ring_buffer_capacity (SoundIoRingBuffer* ring_buffer); /// Do not write more than capacity. char* soundio_ring_buffer_write_ptr (SoundIoRingBuffer* ring_buffer); /// `count` in bytes. void soundio_ring_buffer_advance_write_ptr (SoundIoRingBuffer* ring_buffer, int count); /// Do not read more than capacity. char* soundio_ring_buffer_read_ptr (SoundIoRingBuffer* ring_buffer); /// `count` in bytes. void soundio_ring_buffer_advance_read_ptr (SoundIoRingBuffer* ring_buffer, int count); /// Returns how many bytes of the buffer is used, ready for reading. int soundio_ring_buffer_fill_count (SoundIoRingBuffer* ring_buffer); /// Returns how many bytes of the buffer is free, ready for writing. int soundio_ring_buffer_free_count (SoundIoRingBuffer* ring_buffer); /// Must be called by the writer. void soundio_ring_buffer_clear (SoundIoRingBuffer* ring_buffer);
D
import globals; import misc.image; import math.all; import misc.logger; import math.all;; import gl.all; import vga2d; import mousex; import utils; import oldfonts; import vutils; import palettes; import bullettime; import players; import cheatcode; import postprocessing; import particles, bullet, powerup; import std.stdio; import sdl.all; import camera; import map; import overlay; import derelict.opengl.extension.sgis.generate_mipmap; import sound, joy; final class Game { private { bool _mainPlayerMustReborn; Texture2D m_fbTex; Overlay _overlay; Image m_ui; box2i m_viewport; SoundManager m_soundManager; CheatcodeManager m_cheatcodeManager; Texture2D m_mainTexture; Map _map; FBO m_mainFBO, m_defaultFBO; PostProcessing m_postProcessing; Shader m_blit; ParticleManager m_particleManager; BulletPool m_bulletPool; bool m_usePostProcessing = false; int _tipIndex; Random _random; float _zoomFactor; double _localTime; Camera _camera; bool _paused; float _timeBeforeReborn = 0.f; void renewTipIndex() { _tipIndex = abs(_random.nextRange(TIPS.length)); } void setZoomfactor(float zoom) { _zoomFactor = clamp(zoom, 0.5f, 1.5f); } } public { ParticleManager particles() { return m_particleManager; } Camera camera() { return _camera; } } public { this(box2i viewport, bool usePostProcessing) { _mainPlayerMustReborn = true; _random = Random(); renewTipIndex(); setZoomfactor(1.f); _paused = false; _localTime = 0.0; _camera = new Camera(); _map = new Map(); m_usePostProcessing = usePostProcessing; _overlay = new Overlay(); info(">create m_fbTex"); m_fbTex = new Texture2D(SCREENX, SCREENY, Texture.IFormat.RGBA8, false, false, false); m_fbTex.minFilter = Texture.Filter.NEAREST; m_fbTex.magFilter = Texture.Filter.NEAREST; m_fbTex.wrapS = Texture.Wrap.CLAMP_TO_EDGE; m_fbTex.wrapT = Texture.Wrap.CLAMP_TO_EDGE; info("<create m_fbTex"); if (m_usePostProcessing) { info(">create main texture"); m_mainTexture = new Texture2D(viewport.width, viewport.height, Texture.IFormat.RGBA8, true, false, false); m_mainTexture.minFilter = Texture.Filter.LINEAR_MIPMAP_LINEAR; m_mainTexture.magFilter = Texture.Filter.LINEAR; m_mainTexture.wrapS = Texture.Wrap.CLAMP_TO_EDGE; m_mainTexture.wrapT = Texture.Wrap.CLAMP_TO_EDGE; m_mainTexture.generateMipmaps(); GL.check; info("<create main texture"); } if (m_usePostProcessing) { info(">create m_mainFBO"); m_mainFBO = new FBO(); m_mainFBO.color[0].setTarget(m_mainTexture, 0); m_mainFBO.setWrite(FBO.Component.COLORS); int drawBuffer[1]; drawBuffer[0] = 0; m_mainFBO.setDrawBuffers(drawBuffer[]); m_mainFBO.check(); //m_mainFBO.use(); info("<create m_mainFBO"); info(">create default FBO"); m_defaultFBO = new FBO(true); info("<create default FBO"); } GL.clear(); GL.check(); if (m_usePostProcessing) { info(">create postProcessing"); m_postProcessing = new PostProcessing(m_defaultFBO, m_mainTexture, viewport, m_fbTex); info("<create postProcessing"); info(">m_blit"); m_blit = new Shader("data/blit.vs", "data/blit.fs"); info("<m_blit"); } m_viewport = viewport; // sound info(">create m_soundManager"); m_soundManager = new SoundManager(_camera); info("<create m_soundManager"); m_cheatcodeManager = new CheatcodeManager(this); m_particleManager = new ParticleManager(this, _camera); m_bulletPool = new BulletPool(); } void close() { m_soundManager.close(); } void addZoomFactor(float x) { setZoomfactor(_zoomFactor + x); } void keyTyped(wchar ch) { if (ch == 'p') pause(); if (ch == 'm') m_soundManager.toggleMusic(); else m_cheatcodeManager.keyTyped(ch); } double ratio() { return SCREENX / cast(double)SCREENY; } void suicide() { if (player !is null) { player.damage(10.f); } } void newGame() { if (((player is null) || player.dead) && (_timeBeforeReborn <= 0)) { _mainPlayerMustReborn = true; _camera.nodizzy(); } } void respawnEnnemies() { playerkillia; } void pause() { _paused = !_paused; m_soundManager.setPaused(_paused); } bool isPaused() { return _paused; } void progress(ref MouseState mouse, double dt) { _localTime += dt; m_soundManager.timePassed(dt); if (joyButton(1)) newGame(); _timeBeforeReborn = max!(float)(_timeBeforeReborn - dt, 0.f); BulletTime.progress(dt); if (_mainPlayerMustReborn) { vec2f posBirth = _camera.position(); float playerBirthAngle = _camera.angle() + PI_2_F; player = new Player(this, true, posBirth, playerBirthAngle); m_soundManager.setMainPlayer(player); _mainPlayerMustReborn = false; renewTipIndex(); } bool playerWasAlive = player !is null && !player.dead; if ((_localTime > 22) && (allEnemiesAreDead())) // new game { initenemies; } int minPowerupCount = 5 + level; if (powerupIndex < minPowerupCount) { addPowerup(_map.randomPoint(), vec2f(0), 0, 0); } if (player !is null) player.intelligence(mouse, dt); for (int i = 0; i < ia.length; ++i) { if (ia[i] !is null) { ia[i].intelligence(mouse, dt); } } if (player !is null) player.move(_map, dt); for (int i = 0; i < ia.length; ++i) { if (ia[i] !is null) { ia[i].move(_map, dt); } } m_particleManager.move(_map, dt); m_bulletPool.move(_map, dt); for (int i = 0; i < powerupIndex; ++i) { powerupPool[i].move(_map, dt); } m_bulletPool.checkCollision(dt); m_bulletPool.removeDead(); for (int i = 0; i < powerupIndex; ++i) { powerupPool[i].checkCollision(dt); } removeDeadPowerups(); foreach(Player p; ia) { Player.computeCollision(m_soundManager, player, p); } for (int i = 0; i < ia.length; ++i) for (int j = i + 1; j < ia.length; ++j) Player.computeCollision(m_soundManager, ia[i], ia[j]); // camera bool isRotateViewNow = (player !is null); if ((player !is null) && (!player.dead)) { float advance = isRotateViewNow ? 7.f : 5.f; float constantAdvance = isRotateViewNow ? 75.f : 0.f; vec2f targetPos = player.pos + player.mov * advance + polarOld(player.angle, 1.f) * constantAdvance; float targetAngle = isRotateViewNow ? normalizeAngle(player.angle - PI_2_F) : 0.f; _camera.setTarget(targetPos, targetAngle); } bool playerIsDead = player !is null && player.dead; if (playerWasAlive && playerIsDead) _timeBeforeReborn = 1.4f; _camera.progress(dt, isRotateViewNow); } void showBars() { if (player !is null) { int s = (SCREENY / 2) - 14; // bullet time bar float bu = 2.f * BulletTime.fraction; _overlay.drawBar(SCREENX - 29, SCREENY - 14,max(s, cast(int)round(s * bu)), bu, rgb(160,24,160)); // energy bar _overlay.drawBar(SCREENX - 18, SCREENY - 14, max(s, cast(int)round(player.energy / cast(float)ENERGYMAX * s)), player.energy / cast(float)ENERGYMAX, rgb(252, 26, 15)); // life bar _overlay.drawBar(SCREENX - 7, SCREENY - 14, max(s, cast(int)round(player.life*s)),player.life, rgb(42, 6, 245)); // invicibility bar _overlay.drawBar(SCREENX - 7, SCREENY - 14, max(s,cast(int)round(player.life*s)),player.life * min(3.f, player.invincibility) / 3.f, rgb(252, 26, 15)); if (player.isInvincible) { _overlay._mb.drawFilledBox(SCREENX - 11, SCREENY - 4, SCREENX - 3, SCREENY - 12, rgb(128,128,128)); } } } void draw() { if (m_usePostProcessing) { m_mainFBO.use(); GL.viewport = box2i(0, 0, m_viewport.width, m_viewport.height); GL.clear(); } else { GL.viewport = m_viewport; } if (_localTime < 5.0) { setZoomfactor(0.85f + 0.35f * sin(-PI_2_F + PI_F * _localTime / 5)); } _overlay.clearBuffer(); if ((player !is null) && (player.dead) && (!_paused)) { _overlay.drawHelpScreen(TIPS[_tipIndex], _timeBeforeReborn == 0.f); } else if (_paused) { _overlay.drawPauseScreen(); } else if (_localTime >= 5.0 && _localTime < 21.0) { _overlay.drawIntroductoryText((_localTime - 5) / 16.0); } GL.disable(GL.BLEND); GL.disable(GL.ALPHA_TEST); mat4f projectionMatrix = mat4f.scale(1 / ratio, 1.f, 1.f); float viewScale = 2.f * (1.0f / _zoomFactor) / SCREENY; mat4f modelViewMatrix = mat4f.scale(vec3f(viewScale, viewScale,1.f)) * mat4f.rotateZ(-_camera.angle()) * mat4f.translate(vec3f(-_camera.position(), 0.f)); setProjectionMatrix(projectionMatrix); setModelViewMatrix(modelViewMatrix); if (m_usePostProcessing) { m_blit.use; } _map.draw(_camera); m_particleManager.draw(); showPowerups(_overlay._text); m_bulletPool.draw(); if (player !is null) player.show(); foreach (ref p; ia) { if (p !is null) p.show(); } if (m_usePostProcessing) { m_blit.unuse; //m_mainFBO.setDrawBuffers(0); } _overlay.drawStatus(); drawMinimap(_camera, _map, m_bulletPool); showBars(); GL.enable(GL.ALPHA_TEST); GL.alphaFunc(GL.GREATER, 0.001f); m_fbTex.setSubImage(0, 0, 0, SCREENX, SCREENY, Texture.Format.RGBA, Texture.Type.UBYTE, _overlay._mb.ptr); { int texUnit = m_fbTex.use(); GL.enable(GL.BLEND); GL.blend(GL.BlendMode.ADD, GL.BlendFactor.SRC_ALPHA, GL.BlendFactor.ONE_MINUS_SRC_ALPHA); setProjectionMatrix(mat4f.identity); setModelViewMatrix(mat4f.identity); GL.color(vec4f(1.f,1.f,1.f, 1.f)); GL.begin(GL.QUADS); GL.texCoord(texUnit, m_fbTex.smin, m_fbTex.tmax); GL.vertex(-1,-1); GL.texCoord(texUnit, m_fbTex.smax, m_fbTex.tmax); GL.vertex(+1,-1); GL.texCoord(texUnit, m_fbTex.smax, m_fbTex.tmin); GL.vertex(+1,+1); GL.texCoord(texUnit, m_fbTex.smin, m_fbTex.tmin); GL.vertex(-1,+1); GL.end(); m_fbTex.unuse(); } if (m_usePostProcessing) { vec3f globalColor = _paused ? vec3f(0.7f,0.7f,1.1f) : vec3f(1.f,1.f,1.f); m_postProcessing.render(projectionMatrix * modelViewMatrix, globalColor); } } } public { void addBullet(vec2f pos, vec2f mov, vec3f color, float angle, int guided, Player owner) { m_bulletPool.add(this, pos, mov, color, angle, guided, owner); } void addPowerup(vec2f pos, vec2f mov, float angle, float v) { if (powerupIndex >= MAX_POWERUPS) return; powerupPool[powerupIndex++] = new Powerup(this, pos, mov + polarOld(angle, 1.f) * v); } void initenemies() { level++; if (level > 1) soundManager.playSound(_camera.position() + vec2f(0.001f), 1.f, SOUND.PSCHIT); int realLevel = min(NUMBER_OF_IA, level); for (int i = 0; i < realLevel; ++i) { float a = i * 6.2831 / cast(float)(realLevel); assert(!isNaN(a)); vec2f p = polarOld(a, 1.f) * (10 + 5.0 * realLevel); ia[i] = new Player(this, false, p, a); } } SoundManager soundManager() { return m_soundManager; } } }
D
/** * Written in the D programming language. * This module provides Win32-specific support for sections. * * Copyright: Copyright Digital Mars 2008 - 2012. * License: Distributed under the * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). * (See accompanying file LICENSE) * Authors: Walter Bright, Sean Kelly, Martin Nowak * Source: $(DRUNTIMESRC src/rt/_sections_win32.d) */ module rt.sections_win32; version(Win32): // debug = PRINTF; debug(PRINTF) import core.stdc.stdio; import rt.minfo; struct SectionGroup { static int opApply(scope int delegate(ref SectionGroup) dg) { return dg(_sections); } static int opApplyReverse(scope int delegate(ref SectionGroup) dg) { return dg(_sections); } @property immutable(ModuleInfo*)[] modules() const { return _moduleGroup.modules; } @property ref inout(ModuleGroup) moduleGroup() inout { return _moduleGroup; } @property inout(void[])[] gcRanges() inout { return _gcRanges[]; } private: ModuleGroup _moduleGroup; void[][1] _gcRanges; } void initSections() { _sections._moduleGroup = ModuleGroup(getModuleInfos()); auto pbeg = cast(void*)&_xi_a; auto pend = cast(void*)&_end; _sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; } void finiSections() { } void[] initTLSRanges() { auto pbeg = cast(void*)&_tlsstart; auto pend = cast(void*)&_tlsend; return pbeg[0 .. pend - pbeg]; } void finiTLSRanges(void[] rng) { } void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow { dg(rng.ptr, rng.ptr + rng.length); } private: __gshared SectionGroup _sections; // Windows: this gets initialized by minit.asm extern(C) __gshared immutable(ModuleInfo*)[] _moduleinfo_array; extern(C) void _minit(); immutable(ModuleInfo*)[] getModuleInfos() out (result) { foreach(m; result) assert(m !is null); } body { // _minit directly alters the global _moduleinfo_array _minit(); return _moduleinfo_array; } extern(C) { extern __gshared { int _xi_a; // &_xi_a just happens to be start of data segment //int _edata; // &_edata is start of BSS segment int _end; // &_end is past end of BSS } extern { int _tlsstart; int _tlsend; } }
D
/** Administras rimedojn de la SDL biblioteko. Authors: masaniwa Copyright: 2019 masaniwa License: MIT */ module sdlraii.raii; import sdlraii.except : SDL_Exception; import sdlraii.release : SDL_Release; import std.conv : to; import std.exception : enforce; version (unittest) { import dunit.toolkit; } version (sdlraii_testmock) { import sdlraii.testmock.sdl2; } else { import derelict.sdl2.sdl; } /** Administras rimedon. Params: T = Tipo de puntero de la rimedo. */ struct SDL_RAII(T) { /** Konstruas la strukturon. Params: exp = Esprimo por akiri rimedon de la SDL biblioteko. Ĉi tiu rimedo estos administrata. Throws: `SDL_Exception` Kiam malsukcesas akiri rimedon. */ this(lazy T exp) @trusted { res = exp.enforce(new SDL_Exception(SDL_GetError().to!string)); } this(this) @disable; ~this() { if (_dtorFlag) { return; } SDL_Release!T(res); res = null; _dtorFlag = true; } /** Akiras punteron de la rimedo. Returns: La puntero de la rimedo. */ T ptr() @nogc nothrow pure @safe out (val) { assert(val, `The return value should not be null.`); } do { return res; } private bool _dtorFlag = false; private T res; // Puntero de rimedo, kiu estas administrata. invariant { assert(_dtorFlag || res !is null, `The resource should not be null.`); } } @system unittest { { SDL_DestroyWindow.callcount = 0; SDL_Window window; SDL_RAII!(SDL_Window*)(&window).ptr.assertTruthy; SDL_DestroyWindow.callcount.assertEqual(1); } { SDL_DestroyRenderer.callcount = 0; SDL_Renderer renderer; SDL_RAII!(SDL_Renderer*)(&renderer).ptr.assertTruthy; SDL_DestroyRenderer.callcount.assertEqual(1); } { SDL_DestroyTexture.callcount = 0; SDL_Texture texture; SDL_RAII!(SDL_Texture*)(&texture).ptr.assertTruthy; SDL_DestroyTexture.callcount.assertEqual(1); } { SDL_FreeSurface.callcount = 0; SDL_Surface surface; SDL_RAII!(SDL_Surface*)(&surface).ptr.assertTruthy; SDL_FreeSurface.callcount.assertEqual(1); } { SDL_FreeFormat.callcount = 0; SDL_PixelFormat format; SDL_RAII!(SDL_PixelFormat*)(&format).ptr.assertTruthy; SDL_FreeFormat.callcount.assertEqual(1); } { SDL_FreePalette.callcount = 0; SDL_Palette palette; SDL_RAII!(SDL_Palette*)(&palette).ptr.assertTruthy; SDL_FreePalette.callcount.assertEqual(1); } { SDL_FreeCursor.callcount = 0; SDL_Cursor cursor; SDL_RAII!(SDL_Cursor*)(&cursor).ptr.assertTruthy; SDL_FreeCursor.callcount.assertEqual(1); } { SDL_JoystickClose.callcount = 0; SDL_Joystick joystick; SDL_RAII!(SDL_Joystick*)(&joystick).ptr.assertTruthy; SDL_JoystickClose.callcount.assertEqual(1); } { SDL_GameControllerClose.callcount = 0; SDL_GameController controller; SDL_RAII!(SDL_GameController*)(&controller).ptr.assertTruthy; SDL_GameControllerClose.callcount.assertEqual(1); } { SDL_HapticClose.callcount = 0; SDL_Haptic haptic; SDL_RAII!(SDL_Haptic*)(&haptic).ptr.assertTruthy; SDL_HapticClose.callcount.assertEqual(1); } { Mix_FreeChunk.callcount = 0; Mix_Chunk chunk; SDL_RAII!(Mix_Chunk*)(&chunk).ptr.assertTruthy; Mix_FreeChunk.callcount.assertEqual(1); } { Mix_FreeMusic.callcount = 0; Mix_Music music; SDL_RAII!(Mix_Music*)(&music).ptr.assertTruthy; Mix_FreeMusic.callcount.assertEqual(1); } { TTF_CloseFont.callcount = 0; TTF_Font font; SDL_RAII!(TTF_Font*)(&font).ptr.assertTruthy; TTF_CloseFont.callcount.assertEqual(1); } { SDLNet_FreePacket.callcount = 0; UDPpacket packet; SDL_RAII!(UDPpacket*)(&packet).ptr.assertTruthy; SDLNet_FreePacket.callcount.assertEqual(1); } { SDLNet_FreePacketV.callcount = 0; UDPpacket* packetV; SDL_RAII!(UDPpacket**)(&packetV).ptr.assertTruthy; SDLNet_FreePacketV.callcount.assertEqual(1); } { SDLNet_FreeSocketSet.callcount = 0; _SDLNet_SocketSet set; SDL_RAII!(SDLNet_SocketSet)(&set).ptr.assertTruthy; SDLNet_FreeSocketSet.callcount.assertEqual(1); } { SDL_GetError.value = `Alice`; SDL_RAII!(SDL_Window*)(null).assertThrow!SDL_Exception(`Alice`); } }
D
/* * [The "BSD license"] * Copyright (c) 2013 Terence Parr * Copyright (c) 2013 Sam Harwell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ module antlr.v4.runtime.atn.BasicState; import antlr.v4.runtime.atn.ATNState; import antlr.v4.runtime.atn.StateNames; /** * TODO add class description */ class BasicState : ATNState { /** * @uml * @override */ public override int getStateType() { return StateNames.BASIC; } }
D