code
stringlengths
3
10M
language
stringclasses
31 values
module android.java.android.database.CrossProcessCursor; public import android.java.android.database.CrossProcessCursor_d_interface; import arsd.jni : ImportExportImpl; mixin ImportExportImpl!CrossProcessCursor; import import1 = android.java.java.lang.Class; import import0 = android.java.android.database.CursorWindow;
D
module godot.audiostreamplayback; import std.meta : AliasSeq, staticIndexOf; import std.traits : Unqual; import godot.d.meta; import godot.core; import godot.c; import godot.object; import godot.reference; @GodotBaseClass struct AudioStreamPlayback { static immutable string _GODOT_internal_name = "AudioStreamPlayback"; public: union { godot_object _godot_object; Reference base; } alias base this; alias BaseClasses = AliasSeq!(typeof(base), typeof(base).BaseClasses); package(godot) void* opCast(T : void*)() const { return cast(void*)_godot_object.ptr; } godot_object opCast(T : godot_object)() const { return cast(godot_object)_godot_object; } bool opEquals(in AudioStreamPlayback other) const { return _godot_object.ptr is other._godot_object.ptr; } AudioStreamPlayback opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } bool opCast(T : bool)() const { return _godot_object.ptr !is null; } inout(T) opCast(T)() inout if(isGodotBaseClass!T) { static assert(staticIndexOf!(AudioStreamPlayback, T.BaseClasses) != -1, "Godot class "~T.stringof~" does not inherit AudioStreamPlayback"); if(_godot_object.ptr is null) return T.init; String c = String(T._GODOT_internal_name); if(is_class(c)) return inout(T)(_godot_object); return T.init; } inout(T) opCast(T)() inout if(extendsGodotBaseClass!T) { static assert(is(typeof(T.owner) : AudioStreamPlayback) || staticIndexOf!(AudioStreamPlayback, typeof(T.owner).BaseClasses) != -1, "D class "~T.stringof~" does not extend AudioStreamPlayback"); if(_godot_object.ptr is null) return null; if(has_method(String(`_GDNATIVE_D_typeid`))) { Object o = cast(Object)godot_nativescript_get_userdata(opCast!godot_object); return cast(inout(T))o; } return null; } static AudioStreamPlayback _new() { static godot_class_constructor constructor; if(constructor is null) constructor = godot_get_class_constructor("AudioStreamPlayback"); if(constructor is null) return typeof(this).init; return cast(AudioStreamPlayback)(constructor()); } }
D
# FIXED F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/source/F2837xD_PieCtrl.c F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_device.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/assert.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/linkage.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdarg.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdbool.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stddef.h F2837xD_PieCtrl.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdint.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_adc.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_analogsubsys.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cla.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cmpss.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cputimer.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dac.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dcsm.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dma.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_ecap.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_emif.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_epwm.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_epwm_xbar.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_eqep.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_flash.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_gpio.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_i2c.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_input_xbar.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_ipc.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_mcbsp.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_memconfig.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_nmiintrupt.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_output_xbar.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_piectrl.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_pievect.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sci.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sdfm.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_spi.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sysctrl.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_upp.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_xbar.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_xint.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Examples.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_GlobalPrototypes.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_cputimervars.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Cla_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_EPwm_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Adc_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Emif_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Gpio_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_I2c_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Ipc_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Pie_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Dma_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_SysCtrl_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Upp_defines.h F2837xD_PieCtrl.obj: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_defaultisr.h C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/source/F2837xD_PieCtrl.c: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_device.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/assert.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/linkage.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdarg.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdbool.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stddef.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.1.LTS/include/stdint.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_adc.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_analogsubsys.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cla.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cmpss.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_cputimer.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dac.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dcsm.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_dma.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_ecap.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_emif.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_epwm.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_epwm_xbar.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_eqep.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_flash.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_gpio.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_i2c.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_input_xbar.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_ipc.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_mcbsp.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_memconfig.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_nmiintrupt.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_output_xbar.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_piectrl.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_pievect.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sci.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sdfm.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_spi.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_sysctrl.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_upp.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_xbar.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_headers/include/F2837xD_xint.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Examples.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_GlobalPrototypes.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_cputimervars.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Cla_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_EPwm_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Adc_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Emif_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Gpio_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_I2c_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Ipc_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Pie_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Dma_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_SysCtrl_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_Upp_defines.h: C:/ti/controlSUITE/device_support/F2837xD/v210/F2837xD_common/include/F2837xD_defaultisr.h:
D
/* area2048 'SHIP CTRL' 'ship.d' 2003/12/01 jumpei isshiki */ private import std.math; //private import std.intrinsic; private import SDL; version (USE_GLES) { private import opengles; } else { private import opengl; } private import util_sdl; private import util_pad; private import util_snd; private import bulletml; private import bulletcommand; private import main; private import init; private import define; private import task; private import effect; private import gctrl; private import system; private import bg; private import stg; private import enemy; const float START_X = +0.0f; const float START_Y = +768.0f; const float RANK_ADD = (1.0f / 2400.0f); const int PAD_SHOT = PAD_BUTTON1; const int PAD_BOMB = PAD_BUTTON2; int ship_id; float ship_px; float ship_py; int ship_bomb = 0; int ship_bomb_wait = 0; int ship_lock = 0; int ship_trg; private const float SHIP_SRATE = 1.0f / SQRT2; private const float SHIP_SX1 = 8.0f; private const float SHIP_SY1 = 8.0f; private const float SHIP_SX2 = (SHIP_SX1 * SHIP_SRATE); private const float SHIP_SY2 = (SHIP_SY1 * SHIP_SRATE); private const float ACC_RATE = 30.0f; private const float SHIP_AREAMAX = (1024.0f - 22.0f); private const float SSHOT_AREAMAX = (1024.0f + 16.0f); private int ship_pad = 0; private int ship_pbk = 0; private int ship_cnt = 0; private float[] ship_poly = [ +0.0f,+0.0f, -1.0f,+7.0f, -3.0f,+0.0f, -8.0f,-4.0f, -3.0f,-5.0f, -1.0f,-8.0f, +1.0f,-8.0f, +3.0f,-5.0f, +8.0f,-4.0f, +3.0f,+0.0f, +1.0f,+7.0f, -1.0f,+7.0f, ]; private float[] ship_line = [ -1.0f,+7.0f, -3.0f,+0.0f, -8.0f,-4.0f, -3.0f,-5.0f, -1.0f,-8.0f, +1.0f,-8.0f, +3.0f,-5.0f, +8.0f,-4.0f, +3.0f,+0.0f, +1.0f,+7.0f, ]; private float[] sshot_body = [ -2.0f,+16.0f, -4.0f,-16.0f, +4.0f,-16.0f, +2.0f,+16.0f, ]; private float[] barrier_poly = [ +0.0f,-16.0f, +16.0f, +0.0f, +0.0f,+16.0f, -16.0f, +0.0f, ]; private float[][] ship_move = [ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 0 PAD_NONE */ [ 0.0f, +0.0f,-SHIP_SY1, +0.0f,+SHIP_SY1 ], /* 1 PAD_UP */ [ PI, +0.0f,+SHIP_SY1, +0.0f,+SHIP_SY1 ], /* 2 PAD_DOWN */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 3 PAD_NONE */ [ (PI + PI_2),+SHIP_SX1, +0.0f,+SHIP_SX1, +0.0f ], /* 4 PAD_LEFT */ [ (PI * 2.0f - PI_4),+SHIP_SX2,-SHIP_SY2,+SHIP_SX2,+SHIP_SY2 ], /* 5 PAD_UP+PAD_LEFT */ [ (PI + PI_4),+SHIP_SX2,+SHIP_SY2,+SHIP_SX2,+SHIP_SY2 ], /* 6 PAD_DOWN+PAD_LEFT */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 7 NONE */ [ PI_2,-SHIP_SX1, +0.0f,+SHIP_SX1, +0.0f ], /* 8 PAD_RIGHT */ [ PI_4,-SHIP_SX2,-SHIP_SY2,+SHIP_SX2,+SHIP_SY2 ], /* 9 PAD_UP+PAD_RIGHT */ [ (PI - PI_4),-SHIP_SX2,+SHIP_SY2,+SHIP_SX2,+SHIP_SY2 ], /* 10 PAD_DOWN+PAD_RIGHT */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 11 NONE */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 12 NONE */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 13 NONE */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 14 NONE */ [ 0.0f, +0.0f, +0.0f, +0.0f, +0.0f ], /* 15 NONE */ ]; private int old_dat; private int pad_dat; private int trg_dat; private int demo_move; private int demo_fire; private int demo_eid; void TSKship(int id) { double[XY] tpos; float acc; BulletCommand cmd = TskBuf[id].bullet_command; switch(TskBuf[id].step){ case 0: ship_id = id; TskBuf[id].tskid |= TSKID_MUTEKI; TskBuf[id].px = START_X; TskBuf[id].py = START_Y; ship_px = TskBuf[id].px; ship_py = TskBuf[id].py; TskBuf[id].tid = id; TskBuf[id].fp_draw = &TSKshipDraw; TskBuf[id].fp_exit = &TSKshipExit; TskBuf[id].simple = &TSKsshotSimple; TskBuf[id].active = &TSKsshotActive; TskBuf[id].target = &getShipShotDirection; TskBuf[id].cx = 2.0f; TskBuf[id].cy = 2.0f; TskBuf[id].pz = 0.0f; TskBuf[id].rot = 0.0f; TskBuf[id].alpha = 0.0f; TskBuf[id].body_list.length = ship_poly.length / 2; TskBuf[id].body_ang.length = ship_poly.length / 2; for(int i = 0; i < TskBuf[id].body_list.length; i++){ tpos[X] = ship_poly[i*2+0]; tpos[Y] = ship_poly[i*2+1]; TskBuf[id].body_ang[i][X] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Y] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Z] = 0.0f; tpos[X] = fabs(tpos[X]); tpos[Y] = fabs(tpos[Y]); TskBuf[id].body_ang[i][W] = sqrt(pow(tpos[X],2.0) + pow(tpos[Y],2.0)); } TskBuf[id].line_list.length = ship_line.length / 2; TskBuf[id].line_ang.length = ship_line.length / 2; for(int i = 0; i < TskBuf[id].line_list.length; i++){ tpos[X] = ship_line[i*2+0]; tpos[Y] = ship_line[i*2+1]; TskBuf[id].line_ang[i][X] = atan2(tpos[X], tpos[Y]); TskBuf[id].line_ang[i][Y] = atan2(tpos[X], tpos[Y]); TskBuf[id].line_ang[i][Z] = 0.0f; tpos[X] = fabs(tpos[X]); tpos[Y] = fabs(tpos[Y]); TskBuf[id].line_ang[i][W] = sqrt(pow(tpos[X],2.0) + pow(tpos[Y],2.0)); } ship_bomb_wait = 0; TskBuf[id].wait = 120; TskBuf[id].cnt = TskBuf[id].wait; cmd = new BulletCommand(); TskBuf[id].bullet_command = cmd; setTSK(GROUP_03,&TSKlock); old_dat = 0; pad_dat = 0; trg_dat = 0; demo_move = 0; demo_fire = 0; demo_eid = -1; TskBuf[id].step++; break; case 1: if(!TskBuf[id].wait){ TskBuf[id].fp_int = &TSKshipInt; TskBuf[id].tskid &= ~TSKID_MUTEKI; TskBuf[id].alpha = 1.0f; TskBuf[id].step++; BombON(); }else{ TskBuf[id].wait--; if(TskBuf[id].cnt) TskBuf[id].alpha += 1.0f / TskBuf[id].cnt; } case 2: old_dat = pad_dat; pad_dat = getAttractPadData(id); trg_dat = getAttractTrgData(id,pad_dat,old_dat); /* ロック処理 */ ship_trg = getNearEnemy(id,512.0f); if((trg_dat & PAD_SHOT) && ship_trg != -1){ ship_lock = 1; TskBuf[id].trg_id = ship_trg; }else if(!(pad_dat & PAD_SHOT) || ship_trg == -1){ ship_lock = 0; TskBuf[id].trg_id = -1; } /* 方向取得(敏感に反応しないための処理) */ int trg = trg_dat & PAD_DIR; int pad = pad_dat & PAD_DIR; if(trg){ ship_pad = pad; ship_pbk = pad; ship_cnt = 2; }else if(pad && pad != ship_pad){ ship_pad = ship_pbk; if(ship_cnt) ship_cnt--; else ship_pbk = pad; }else if(!pad){ ship_pad = 0; ship_pbk = 0; ship_cnt = 0; } /* 速度&方向設定 */ if(ship_lock == 0){ if(ship_pad) TskBuf[id].rot = ship_move[ship_pad][0]; }else{ TskBuf[id].rot = getTargetDirection(id); } TskBuf[id].ax = ship_move[ship_pad][1]; TskBuf[id].ay = ship_move[ship_pad][2]; TskBuf[id].nx = ship_move[ship_pad][3]; TskBuf[id].ny = ship_move[ship_pad][4]; if((pad_dat & PAD_SHOT) || BombTSTexec()){ TskBuf[id].ax *= 1.5f; TskBuf[id].ay *= 1.5f; } /* 加減速 */ acc = ACC_RATE; if(TskBuf[id].ax != 0.0f){ if(TskBuf[id].vx < TskBuf[id].ax){ TskBuf[id].vx += TskBuf[id].nx / acc; if(TskBuf[id].vx > TskBuf[id].ax) TskBuf[id].vx = TskBuf[id].ax; } if(TskBuf[id].vx > TskBuf[id].ax){ TskBuf[id].vx -= TskBuf[id].nx / acc; if(TskBuf[id].vx < TskBuf[id].ax) TskBuf[id].vx = TskBuf[id].ax; } }else{ TskBuf[id].vx -= TskBuf[id].vx / (acc * 2.0f); } if(TskBuf[id].ay != 0.0f){ if(TskBuf[id].vy < TskBuf[id].ay){ TskBuf[id].vy += TskBuf[id].ny / acc; if(TskBuf[id].vy > TskBuf[id].ay) TskBuf[id].vy = TskBuf[id].ay; } if(TskBuf[id].vy > TskBuf[id].ay){ TskBuf[id].vy -= TskBuf[id].ny / acc; if(TskBuf[id].vy < TskBuf[id].ay) TskBuf[id].vy = TskBuf[id].ay; } }else{ TskBuf[id].vy -= TskBuf[id].vy / (acc * 2.0f); } /* 座標更新 */ TskBuf[id].px += TskBuf[id].vx; TskBuf[id].py += TskBuf[id].vy; if(TskBuf[id].px < -SHIP_AREAMAX){ TskBuf[id].px = -SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].px > +SHIP_AREAMAX){ TskBuf[id].px = +SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].py < -SHIP_AREAMAX){ TskBuf[id].py = -SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } if(TskBuf[id].py > +SHIP_AREAMAX){ TskBuf[id].py = +SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } ship_px = TskBuf[id].px; ship_py = TskBuf[id].py; TskBuf[id].tx = TskBuf[id].px + sin(TskBuf[id].rot) * 1.0f; TskBuf[id].ty = TskBuf[id].py + cos(TskBuf[id].rot) * 1.0f; /* ボム */ if(!enemy_stg) BombOFF(); if(TskBuf[id].step == 2){ if(bomb && BombTST() && (trg_dat & PAD_BOMB)){ setTSK(GROUP_08,&TSKbomb); BombEXEC(); } } /* ショット */ if(BombTSTwait()){ cmd.vanish(); BombSTOP(); } if(ship_bomb_wait){ ship_bomb_wait--; if(!ship_bomb_wait){ playSNDse(SND_VOICE_CHARGE); BombON(); } } if(!BombTSTexec()){ if((pad_dat & PAD_SHOT)){ if(!cmd.isEnd()) cmd.run(); else cmd.set(id, BULLET_SHIP01); }else{ cmd.vanish(); } }else{ if((pad_dat & PAD_BOMB)){ if(bomb) bomb -= BOMB_SUB; if(bomb < 0) bomb = 0; if(!cmd.isEnd()) cmd.run(); else cmd.set(id, BULLET_SHIP02); } } /* ボム溜め */ if(BombTST()){ if((pad_dat & PAD_SHOT)) BmbGaugeAdd(BOMB_ADD_MIN); else BmbGaugeAdd(BOMB_ADD_MAX); BombREMAINscore(); } /* 時間チェック */ if(time_flag && !time_left){ playSNDse(SND_SE_SDEST); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); if(cmd.isEnd()) cmd.vanish(); TskBuf[id].fp_int = null; TskBuf[id].alpha = 0.0f; left = 0; stg_ctrl = STG_GAMEOVER; TskBuf[id].step = 255; break; } /* クリアチェック */ if(!enemy_stg){ TskBuf[id].fp_int = null; TskBuf[id].tskid |= TSKID_MUTEKI; TskBuf[id].alpha = 0.5f; } break; case 3: TskBuf[id].wait--; if(!TskBuf[id].wait){ TskBuf[id].tskid |= TSKID_MUTEKI; TskBuf[id].px = START_X; TskBuf[id].py = START_Y; TskBuf[id].wait = 120; TskBuf[id].cnt = TskBuf[id].wait; TskBuf[id].step = 1; } break; case 100: TskBuf[id].alpha = 0.0f; TskBuf[id].fp_int = null; TskBuf[id].px = START_X; TskBuf[id].py = START_Y; TskBuf[id].vx = +0.0f; TskBuf[id].vy = +0.0f; TskBuf[id].ax = +0.0f; TskBuf[id].ay = +0.0f; TskBuf[id].rot = 0.0f; TskBuf[id].step++; case 101: BombOFF(); cmd.vanish(); TskBuf[id].step++; case 102: /* 座標更新 */ acc = ACC_RATE; TskBuf[id].vx -= TskBuf[id].vx / (acc * 2.0f); TskBuf[id].vy -= TskBuf[id].vy / (acc * 2.0f); TskBuf[id].px += TskBuf[id].vx; TskBuf[id].py += TskBuf[id].vy; if(TskBuf[id].px < -SHIP_AREAMAX){ TskBuf[id].px = -SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].px > +SHIP_AREAMAX){ TskBuf[id].px = +SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].py < -SHIP_AREAMAX){ TskBuf[id].py = -SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } if(TskBuf[id].py > +SHIP_AREAMAX){ TskBuf[id].py = +SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } ship_px = TskBuf[id].px; ship_py = TskBuf[id].py; TskBuf[id].tx = TskBuf[id].px + sin(TskBuf[id].rot) * 1.0f; TskBuf[id].ty = TskBuf[id].py + cos(TskBuf[id].rot) * 1.0f; break; case 110: acc = ACC_RATE; BombOFF(); TskBuf[id].alpha = 1.00f; /* 座標更新 */ TskBuf[id].vx -= TskBuf[id].vx / (acc * 2.0f); TskBuf[id].vy -= TskBuf[id].vy / (acc * 2.0f); TskBuf[id].px += TskBuf[id].vx; TskBuf[id].py += TskBuf[id].vy; if(TskBuf[id].px < -SHIP_AREAMAX){ TskBuf[id].px = -SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].px > +SHIP_AREAMAX){ TskBuf[id].px = +SHIP_AREAMAX; TskBuf[id].vx = -TskBuf[id].vx / 2; TskBuf[id].ax = +0.0f; } if(TskBuf[id].py < -SHIP_AREAMAX){ TskBuf[id].py = -SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } if(TskBuf[id].py > +SHIP_AREAMAX){ TskBuf[id].py = +SHIP_AREAMAX; TskBuf[id].vy = -TskBuf[id].vy / 2; TskBuf[id].ay = +0.0f; } TskBuf[id].tx = TskBuf[id].px + sin(TskBuf[id].rot) * 1.0f; TskBuf[id].ty = TskBuf[id].py + cos(TskBuf[id].rot) * 1.0f; break; case 255: break; default: if(cmd){ cmd.vanish(); delete cmd; TskBuf[id].bullet_command = null; } clrTSK(id); break; } BmbGaugeExec(); return; } void TSKshipInt(int id) { BulletCommand cmd = TskBuf[id].bullet_command; if(g_step == GSTEP_DEMO) return; playSNDse(SND_SE_SDEST); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); effSetBrokenLine(id, ship_line, 0, 10, 0.0f, 0.0f); if(cmd.isEnd()) cmd.vanish(); TskBuf[id].fp_int = null; TskBuf[id].alpha = 0.0f; ship_lock = 0; TskBuf[ship_id].trg_id = -1; BombOFF(); if(!left){ stg_ctrl = STG_GAMEOVER; TskBuf[id].step = 255; }else{ TskBuf[id].step = 3; TskBuf[id].wait = 60; TskBuf[id].rot = 0.0f; TskBuf[id].vx = +0.0f; TskBuf[id].vy = +0.0f; TskBuf[id].ax = +0.0f; TskBuf[id].ay = +0.0f; left--; BombON(); switch(game_level){ case GLEVEL_EASY: setRank(0.0f); break; case GLEVEL_NORMAL: addRank(-0.5f); bomb = BOMB_ONE; break; case GLEVEL_HARD: addRank(-0.25f); bomb = BOMB_ONE; break; default: break; } } return; } void TSKshipDraw(int id) { float[XYZ] pos; int bodyNumVertices = cast(int)(TskBuf[id].body_ang.length); GLfloat[] bodyVertices; bodyVertices.length = bodyNumVertices*XYZ; foreach(i; 0..bodyNumVertices){ pos[X] = sin(TskBuf[id].body_ang[i][X] + TskBuf[id].rot) * getPointX(TskBuf[id].body_ang[i][W] * 3.0f, TskBuf[id].pz); pos[Y] = cos(TskBuf[id].body_ang[i][Y] + TskBuf[id].rot) * getPointY(TskBuf[id].body_ang[i][W] * 3.0f, TskBuf[id].pz); pos[Z] = TskBuf[id].body_ang[i][Z]; bodyVertices[i*XYZ + X] = pos[X] - getPointX(TskBuf[id].px - scr_pos[X], TskBuf[id].pz); bodyVertices[i*XYZ + Y] = pos[Y] - getPointY(TskBuf[id].py - scr_pos[Y], TskBuf[id].pz); bodyVertices[i*XYZ + Z] = pos[Z]; } glEnableClientState(GL_VERTEX_ARRAY); glColor4f(0.4f,0.4f,0.8f,TskBuf[id].alpha); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_TRIANGLE_FAN, 0, bodyNumVertices); glColor4f(1.0f,1.0f,1.0f,TskBuf[id].alpha); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_LINE_LOOP, 0, bodyNumVertices); glDisableClientState(GL_VERTEX_ARRAY); bodyVertices.length = 0; /* if(TskBuf[id].fp_int && !(TskBuf[id].tskid & TSKID_MUTEKI)){ }else{ } */ } void TSKshipExit(int id) { BulletCommand cmd = TskBuf[id].bullet_command; TskBuf[id].body_list.length = 0; TskBuf[id].body_ang.length = 0; if(cmd){ delete cmd; TskBuf[id].bullet_command = null; } } float getShipShotDirection(int id) { float px,py; float dir; int tid; tid = TskBuf[id].tid; px = TskBuf[id].tx - TskBuf[tid].px; py = TskBuf[id].ty - TskBuf[tid].py; dir = atan2(px, py); return dir; } void TSKsshotSimple(int id) { double tpos[XY]; switch(TskBuf[id].step){ case 0: TskBuf[id].px = TskBuf[TskBuf[id].parent].px; TskBuf[id].py = TskBuf[TskBuf[id].parent].py; TskBuf[id].cx = 4.0f; TskBuf[id].cy = 4.0f; TskBuf[id].fp_int = &TSKsshotInt; TskBuf[id].fp_draw = &TSKsshotDraw; TskBuf[id].fp_exit = &TSKsshotExit; TskBuf[id].body_list.length = sshot_body.length / 2; TskBuf[id].body_ang.length = sshot_body.length / 2; for(int i = 0; i < TskBuf[id].body_list.length; i++){ tpos[X] = sshot_body[i*2+0]; tpos[Y] = sshot_body[i*2+1]; TskBuf[id].body_ang[i][X] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Y] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Z] = 0.0f; tpos[X] = fabs(tpos[X]); tpos[Y] = fabs(tpos[Y]); TskBuf[id].body_ang[i][W] = sqrt(pow(tpos[X],2.0) + pow(tpos[Y],2.0)); } TskBuf[id].alpha = 1.0f; TskBuf[id].energy = 1; TskBuf[id].step++; break; case 1: TskBuf[id].px += TskBuf[id].bullet_velx; TskBuf[id].py += TskBuf[id].bullet_vely; TskBuf[id].px += TskBuf[id].bullet_accx; TskBuf[id].py += TskBuf[id].bullet_accy; if(TskBuf[id].px < -SSHOT_AREAMAX || TskBuf[id].px > +SSHOT_AREAMAX || TskBuf[id].py > +SSHOT_AREAMAX || TskBuf[id].py < -SSHOT_AREAMAX){ TskBuf[id].step = -1; } break; default: clrTSK(id); break; } return; } void TSKsshotActive(int id) { double[XY] tpos; BulletCommand cmd = TskBuf[id].bullet_command; switch(TskBuf[id].step){ case 0: TskBuf[id].px = TskBuf[TskBuf[id].parent].px; TskBuf[id].py = TskBuf[TskBuf[id].parent].py; TskBuf[id].cx = 4.0f; TskBuf[id].cy = 4.0f; TskBuf[id].tid = ship_id; TskBuf[id].fp_int = &TSKsshotInt; TskBuf[id].fp_draw = &TSKsshotDraw; TskBuf[id].fp_exit = &TSKsshotExit; TskBuf[id].simple = &TSKsshotSimple; TskBuf[id].active = &TSKsshotActive; TskBuf[id].target = &getShipDirection; TskBuf[id].body_list.length = sshot_body.length / 2; TskBuf[id].body_ang.length = sshot_body.length / 2; for(int i = 0; i < TskBuf[id].body_list.length; i++){ tpos[X] = sshot_body[i*2+0]; tpos[Y] = sshot_body[i*2+1]; TskBuf[id].body_ang[i][X] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Y] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Z] = 0.0f; tpos[X] = fabs(tpos[X]); tpos[Y] = fabs(tpos[Y]); TskBuf[id].body_ang[i][W] = sqrt(pow(tpos[X],2.0) + pow(tpos[Y],2.0)); } cmd = new BulletCommand(); TskBuf[id].bullet_command = cmd; cmd.set(id, TskBuf[id].bullet_state); TskBuf[id].alpha = 1.0f; TskBuf[id].energy = 1; TskBuf[id].step++; break; case 1: TskBuf[id].bullet_velx = (sin(TskBuf[id].bullet_direction) * (+TskBuf[id].bullet_speed)); TskBuf[id].bullet_vely = (cos(TskBuf[id].bullet_direction) * (-TskBuf[id].bullet_speed)); TskBuf[id].px += TskBuf[id].bullet_velx; TskBuf[id].py += TskBuf[id].bullet_vely; TskBuf[id].px += TskBuf[id].bullet_accx; TskBuf[id].py += TskBuf[id].bullet_accy; TskBuf[id].tx = TskBuf[TskBuf[id].tid].px; TskBuf[id].ty = TskBuf[TskBuf[id].tid].py; if(TskBuf[id].px < -SSHOT_AREAMAX || TskBuf[id].px > +SSHOT_AREAMAX || TskBuf[id].py > +SSHOT_AREAMAX || TskBuf[id].py < -SSHOT_AREAMAX){ TskBuf[id].step = -1; } if(!cmd.isEnd()) cmd.run(); break; default: if(cmd){ cmd.vanish(); delete cmd; TskBuf[id].bullet_command = null; } clrTSK(id); break; } return; } void TSKsshotInt(int id) { TskBuf[id].step = -1; return; } void TSKsshotDraw(int id) { float[XYZ] pos; int bodyNumVertices = cast(int)(TskBuf[id].body_ang.length); GLfloat[] bodyVertices; bodyVertices.length = bodyNumVertices*XYZ; foreach(i; 0..bodyNumVertices){ pos[X] = sin(TskBuf[id].bullet_direction - TskBuf[id].body_ang[i][X]) * getPointX(TskBuf[id].body_ang[i][W], TskBuf[id].pz); pos[Y] = cos(TskBuf[id].bullet_direction - TskBuf[id].body_ang[i][Y]) * getPointY(TskBuf[id].body_ang[i][W], TskBuf[id].pz); pos[Z] = TskBuf[id].body_ang[i][Z]; bodyVertices[i*XYZ + X] = pos[X] - getPointX(TskBuf[id].px - scr_pos[X], TskBuf[id].pz); bodyVertices[i*XYZ + Y] = pos[Y] - getPointY(TskBuf[id].py - scr_pos[Y], TskBuf[id].pz); bodyVertices[i*XYZ + Z] = pos[Z]; } glEnableClientState(GL_VERTEX_ARRAY); glColor4f(0.6f,0.6f,0.6f,TskBuf[id].alpha); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_TRIANGLE_FAN, 0, bodyNumVertices); glColor4f(1.0f,1.0f,1.0f,TskBuf[id].alpha); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_LINE_LOOP, 0, bodyNumVertices); glDisableClientState(GL_VERTEX_ARRAY); bodyVertices.length = 0; } void TSKsshotExit(int id) { BulletCommand cmd = TskBuf[id].bullet_command; TskBuf[id].body_list.length = 0; TskBuf[id].body_ang.length = 0; if(cmd){ delete cmd; TskBuf[id].bullet_command = null; } } void TSKbomb(int id) { int eid; switch(TskBuf[id].step){ case 0: eid = setTSK(GROUP_08,&TSKbgZoom); TskBuf[eid].wait = 30; TskBuf[eid].tx = BASE_Z - 1.25f; TskBuf[eid].tx = BASE_Z - 1.50f; TskBuf[id].wait = 30; TskBuf[ship_id].tskid |= TSKID_MUTEKI; TskBuf[ship_id].fp_int = null; TskBuf[id].step++; break; case 1: if(!enemy_stg || TskBuf[ship_id].step != 2){ eid = setTSK(GROUP_08,&TSKbgZoom); TskBuf[eid].wait = 30; TskBuf[eid].tx = BASE_Z + cam_scr; TskBuf[id].wait = 30; TskBuf[id].step++; break; } if(TskBuf[id].wait){ TskBuf[id].wait--; }else{ if(!TskBuf[ship_id].fp_int){ TskBuf[ship_id].tskid &= ~TSKID_MUTEKI; TskBuf[ship_id].fp_int = &TSKshipInt; } if(!(pad_dat & PAD_BOMB) || !bomb || boss_flag == 2){ eid = setTSK(GROUP_08,&TSKbgZoom); TskBuf[eid].wait = 30; TskBuf[eid].tx = BASE_Z + cam_scr; TskBuf[id].wait = 30; TskBuf[id].step++; } } BombADDscore(BOMB_SCORE_ADD); addRank(RANK_ADD); break; case 2: if(TskBuf[id].wait){ TskBuf[id].wait--; }else{ TskBuf[id].step = -1; } break; default: BombWAIT(); clrTSK(id); break; } return; } void TSKbarrier(int id) { double[XY] tpos; switch(TskBuf[id].step){ case 0: TskBuf[id].fp_draw = null; TskBuf[id].alpha = 0.0f; TskBuf[id].rot = 0.0f; TskBuf[id].body_list.length = barrier_poly.length / 2; TskBuf[id].body_ang.length = barrier_poly.length / 2; for(int i = 0; i < TskBuf[id]. body_list.length; i++){ tpos[X] = barrier_poly[i*2+0]; tpos[Y] = barrier_poly[i*2+1]; TskBuf[id].body_ang[i][X] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Y] = atan2(tpos[X], tpos[Y]); TskBuf[id].body_ang[i][Z] = 0.0f; tpos[X] = fabs(tpos[X]); tpos[Y] = fabs(tpos[Y]); TskBuf[id].body_ang[i][W] = sqrt(pow(tpos[X],2.0) + pow(tpos[Y],2.0)); } TskBuf[id].step++; break; case 1: TskBuf[id].px = TskBuf[ship_id].px; TskBuf[id].py = TskBuf[ship_id].py; if(TskBuf[ship_id].step != 3 && !TskBuf[ship_id].fp_int || (TskBuf[ship_id].tskid & TSKID_MUTEKI) || boss_flag == 2){ TskBuf[id].fp_draw = &TSKbarrierDraw; TskBuf[id].step++; TskBuf[id].wait = 15; } TskBuf[id].rot -= PI / 60.0f; break; case 2: TskBuf[id].px = TskBuf[ship_id].px; TskBuf[id].py = TskBuf[ship_id].py; if(!TskBuf[id].wait){ TskBuf[id].alpha = 1.0f; TskBuf[id].step++; }else{ TskBuf[id].alpha += (1.0f / 15.0f); TskBuf[id].wait--; } TskBuf[id].rot -= PI / 60.0f; break; case 3: TskBuf[id].px = TskBuf[ship_id].px; TskBuf[id].py = TskBuf[ship_id].py; if(TskBuf[ship_id].fp_int && !(TskBuf[ship_id].tskid & TSKID_MUTEKI) && boss_flag != 2){ TskBuf[id].step++; TskBuf[id].wait = 15; } TskBuf[id].rot -= PI / 60.0f; break; case 4: TskBuf[id].px = TskBuf[ship_id].px; TskBuf[id].py = TskBuf[ship_id].py; if(!TskBuf[id].wait){ TskBuf[id].alpha = 0.0f; TskBuf[id].step = 1; TskBuf[id].fp_draw = null; }else{ TskBuf[id].alpha -= (1.0f / 15.0f); TskBuf[id].wait--; } TskBuf[id].rot -= PI / 60.0f; break; default: clrTSK(id); break; } return; } void TSKbarrierDraw(int id) { float[XYZ] pos; int bodyNumVertices = cast(int)(TskBuf[id].body_list.length); GLfloat[] bodyVertices; bodyVertices.length = bodyNumVertices*XYZ; foreach(i; 0..bodyNumVertices){ pos[X] = sin(TskBuf[id].body_ang[i][X] + TskBuf[id].rot) * getPointX(TskBuf[id].body_ang[i][W] * 3.0f, TskBuf[id].pz); pos[Y] = cos(TskBuf[id].body_ang[i][Y] + TskBuf[id].rot) * getPointY(TskBuf[id].body_ang[i][W] * 3.0f, TskBuf[id].pz); pos[Z] = TskBuf[id].body_ang[i][Z]; bodyVertices[i*XYZ + X] = pos[X] - getPointX(TskBuf[id].px - scr_pos[X], TskBuf[id].pz); bodyVertices[i*XYZ + Y] = pos[Y] - getPointY(TskBuf[id].py - scr_pos[Y], TskBuf[id].pz); bodyVertices[i*XYZ + Z] = pos[Z]; } glEnableClientState(GL_VERTEX_ARRAY); glColor4f(0.25f,0.25f,0.50f,(0.25f * TskBuf[id].alpha)); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_TRIANGLE_FAN, 0, bodyNumVertices); glColor4f(1.0f,1.0f,1.0f,(1.0f * TskBuf[id].alpha)); glVertexPointer(XYZ, GL_FLOAT, 0, cast(void *)(bodyVertices.ptr)); glDrawArrays(GL_LINE_LOOP, 0, bodyNumVertices); glDisableClientState(GL_VERTEX_ARRAY); bodyVertices.length = 0; } void BombOFF() { ship_bomb = 0; } void BombON() { ship_bomb_wait = 0; ship_bomb = 1; } void BombEXEC() { ship_bomb = 2; } void BombWAIT() { ship_bomb_wait = 60; ship_bomb = 3; } void BombSTOP() { ship_bomb = 4; } int BombTST() { return (ship_bomb == 1); } int BombTSTexec() { return (ship_bomb == 2); } int BombTSTwait() { return (ship_bomb == 3); } void BmbGaugeAdd(int add) { if(bomb_lv != BOMB_MAX){ bomb += add; if(bomb >= (BOMB_ONE * BOMB_MAX)) bomb = BOMB_ONE * BOMB_MAX; } } void BombADDscore(int add_score) { bomb_bonus += add_score; bomb_remain += BOMB_REMAIN_ADD; if(bomb_bonus > BOMB_SCORE_MAX) bomb_bonus = BOMB_SCORE_MAX; if(bomb_remain > BOMB_REMAIN_MAX) bomb_remain = BOMB_REMAIN_MAX; } void BombREMAINscore() { if(bomb_remain){ bomb_remain--; }else{ if(!(turn % 30)){ if(bomb_bonus){ bomb_bonus -= 10; } } } } void BmbGaugeExec() { bomb_lv = bomb / BOMB_ONE; } float getShipLength(float px,float py) { float len = 0; float lpx,lpy; lpx = fabs(TskBuf[ship_id].px - px); lpy = fabs(TskBuf[ship_id].py - py); lpx = pow(lpx, 2.0f); lpy = pow(lpy, 2.0f); len = sqrt(lpx + lpy); return len; } float getTargetDirection(int id) { float px,py; float dir; int tid; tid = TskBuf[id].trg_id; px = TskBuf[id].tx - TskBuf[tid].px; py = TskBuf[id].ty - TskBuf[tid].py; dir = atan2(px, py); return dir; } int getNearEnemy(int id,float length) { int eid = -1; int prev; float max = length; float tmp; for(int i = TskIndex[GROUP_02]; i != -1; i = prev){ prev = TskBuf[i].prev; if(TskBuf[i].tskid != 0 && (TskBuf[i].tskid & (TSKID_ZAKO+TSKID_BOSS)) && TskBuf[i].fp_int != null){ tmp = getShipLength(TskBuf[i].px,TskBuf[i].py); if(tmp < length && max > tmp){ eid = i; max = tmp; } } } return eid; } void shipLockOff(int id) { if(TskBuf[ship_id].trg_id == id){ ship_lock = 0; TskBuf[ship_id].trg_id = -1; } } int getAttractPadData(int id) { if(g_step != GSTEP_DEMO) return pads; int eid = getNearEnemy(id, 4096.0f); int pad = 0; /* 移動 */ if(eid != -1){ if(TskBuf[id].px > TskBuf[eid].px){ pad |= PAD_RIGHT; }else if(TskBuf[id].px < TskBuf[eid].px){ pad |= PAD_LEFT; } if(TskBuf[id].py > TskBuf[eid].py){ pad |= PAD_UP; }else if(TskBuf[id].py < TskBuf[eid].py){ pad |= PAD_DOWN; } } /* demo_move = 0; demo_fire = 0; */ eid = getNearEnemy(id, 512.0f); if(demo_eid != eid){ demo_fire = 0; demo_eid = eid; } /* ショット */ if(!demo_fire && eid != -1){ demo_fire = Rand() % 120 + 120; }else{ if(demo_fire){ demo_fire--; pad |= PAD_SHOT; } //pad = PAD_BOMB; } return pad; } int getAttractTrgData(int id, int pad, int old_pad) { if(g_step != GSTEP_DEMO) return trgs; return pad & ~old_pad; }
D
/Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/JSON.build/JSON+Serialize.swift.o : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/File.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Bytes.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Equatable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Node.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Parse.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Serialize.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSONRepresentable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/Sequence+Convertible.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Polymorphic.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Jay.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/JSON.build/JSON+Serialize~partial.swiftmodule : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/File.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Bytes.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Equatable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Node.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Parse.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Serialize.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSONRepresentable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/Sequence+Convertible.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Polymorphic.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Jay.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/JSON.build/JSON+Serialize~partial.swiftdoc : /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/File.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Bytes.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Equatable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Node.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Parse.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON+Serialize.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSON.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/JSONRepresentable.swift /Users/okasho/serverProject/tryswift/helloworld/swift/Packages/JSON-1.0.6/Sources/JSON/Sequence+Convertible.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Node.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/PathIndexable.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Polymorphic.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.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/okasho/serverProject/tryswift/helloworld/swift/.build/debug/libc.swiftmodule /Users/okasho/serverProject/tryswift/helloworld/swift/.build/debug/Jay.swiftmodule
D
/Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.build/Codable/URLEncodedFormDecoder.swift.o : /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormData.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormDataConvertible.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormDecoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormEncoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormParser.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormSerializer.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/URLEncodedFormError.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/Exports.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.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 /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.build/URLEncodedFormDecoder~partial.swiftmodule : /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormData.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormDataConvertible.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormDecoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormEncoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormParser.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormSerializer.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/URLEncodedFormError.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/Exports.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.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 /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/URLEncodedForm.build/URLEncodedFormDecoder~partial.swiftdoc : /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormData.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormDataConvertible.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormDecoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Codable/URLEncodedFormEncoder.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormParser.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Data/URLEncodedFormSerializer.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/URLEncodedFormError.swift /Users/nice/HelloWord/.build/checkouts/url-encoded-form.git-6880606379968884505/Sources/URLEncodedForm/Utilities/Exports.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIO.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Async.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Core.swiftmodule /Users/nice/HelloWord/.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 /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/COperatingSystem.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/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOConcurrencyHelpers.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/Bits.swiftmodule /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/NIOFoundationCompat.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/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/cpp_magic.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIODarwin/include/c_nio_darwin.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOAtomics/include/c-atomics.h /Users/nice/HelloWord/.build/checkouts/swift-nio.git-5005363973595484456/Sources/CNIOLinux/include/c_nio_linux.h /Users/nice/HelloWord/.build/checkouts/swift-nio-zlib-support.git--6556802241718767980/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOSHA1.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CCryptoOpenSSL.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOZlib.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIODarwin.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOHTTPParser.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOAtomics.build/module.modulemap /Users/nice/HelloWord/.build/x86_64-apple-macosx10.10/debug/CNIOLinux.build/module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
/** * Модуль содержит методы работы с ответом сервера базы данных * * Copyright: (c) 2017, Oleg Lelenkov. * License: MIT * Authors: Oleg Lelenkov */ module tarantool.response; private { } struct Response { }
D
instance VLK_585_Aleph(Npc_Default) { name[0] = "Aëåô"; npcType = npctype_main; guild = GIL_VLK; level = 5; voice = 5; id = 585; attribute[ATR_STRENGTH] = 25; attribute[ATR_DEXTERITY] = 15; attribute[ATR_MANA_MAX] = 0; attribute[ATR_MANA] = 0; attribute[ATR_HITPOINTS_MAX] = 100; attribute[ATR_HITPOINTS] = 100; Mdl_SetVisual(self,"HUMANS.MDS"); Mdl_ApplyOverlayMds(self,"Humans_Tired.mds"); Mdl_SetVisualBody(self,"hum_body_Naked0",3,1,"Hum_Head_Thief",71,0,vlk_armor_m); B_Scale(self); Mdl_SetModelFatness(self,0); fight_tactic = FAI_HUMAN_COWARD; Npc_SetTalentSkill(self,NPC_TALENT_1H,1); EquipItem(self,ItMw_1H_Nailmace_01); CreateInvItem(self,ItMwPickaxe); CreateInvItems(self,ItKe_OM_03,1); EquipItem(self,Staerkering); CreateInvItem(self,ItFoBeer); CreateInvItem(self,ItLsTorch); daily_routine = Rtn_start_585; }; func void Rtn_start_585() { TA_SitAround(4,0,16,0,"OM_PICKORE_05"); TA_SitAround(16,0,4,0,"OM_PICKORE_05"); }; func void Rtn_Busy_585() { TA_PickOre(16,0,4,0,"OM_PICKORE_05"); TA_PickOre(4,0,16,0,"OM_PICKORE_05"); };
D
/** * Annotated declarations */ module exlang.annotated.declaration; /** * Abstract annotated declaration */ abstract class AnnDeclaration { import exlang.symtab.symbol; /** * The identifier */ string ident; /** * The type identifier */ Type type; /** * Constructor * * Params: * ident = The identifier * type = The type */ this ( string ident, Type type ) { this.ident = ident; this.type = type; } } /** * Annotated function argument declaration */ class AnnArgDeclaration : AnnDeclaration { import exlang.symtab.symbol; /** * Constructor * * Params: * ident = The identifier * type = The type */ this ( string ident, Type type ) { super(ident, type); } } /** * Annotated function declaration */ class AnnFuncDeclaration : AnnDeclaration { import exlang.annotated.statement; import exlang.symtab.symbol; /** * The argument identifiers; */ AnnArgDeclaration[] args; /** * The statement list */ AnnStatement[] statements; /** * Constructor: * * Params: * ident = The identifier * type_id = The type identifier * args = The argument identifiers * statements = The statement list */ this ( string ident, Type type, AnnArgDeclaration[] args, AnnStatement[] statements ) { super(ident, type); this.args = args; this.statements = statements; } }
D
/** Central include for every vibe.d based application. This file provides the majority of the vibe API through a single import. Note that typical vibe.d applications will import 'vibe.d' instead to also get an implicit application entry point. Copyright: © 2012 RejectedSoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Sönke Ludwig */ module vibe.vibe; public import vibe.core.core; public import vibe.core.file; public import vibe.core.log; public import vibe.core.net; public import vibe.core.process; public import vibe.core.signal; public import vibe.crypto.md5; public import vibe.crypto.passwordhash; public import vibe.crypto.sha1; public import vibe.crypto.ssl; public import vibe.data.bson; public import vibe.data.json; public import vibe.db.mongo.mongo; public import vibe.db.redis.redis; public import vibe.http.auth.basic_auth; public import vibe.http.client; public import vibe.http.fileserver; public import vibe.http.proxy; public import vibe.http.rest; public import vibe.http.router; public import vibe.http.server; public import vibe.http.websockets; public import vibe.inet.url; public import vibe.inet.urltransfer; public import vibe.mail.smtp; //public import vibe.stream.base64; public import vibe.stream.counting; public import vibe.stream.memory; public import vibe.stream.stream; public import vibe.stream.ssl; public import vibe.stream.zlib; public import vibe.templ.diet; public import vibe.templ.utils; public import vibe.textfilter.html; public import vibe.textfilter.markdown; public import vibe.textfilter.urlencode; public import vibe.utils.string; // make some useful D standard library functions available public import std.functional : toDelegate; public import std.conv : to; public import std.datetime; public import std.exception : enforce;
D
instance grd_5011_gardist(Npc_Default) { name[0] = NAME_Gardist; npcType = NpcType_MINE_Guard; guild = GIL_GRD; level = 15; voice = 13; id = 5011; attribute[ATR_STRENGTH] = 80; attribute[ATR_DEXTERITY] = 60; attribute[ATR_MANA_MAX] = 0; attribute[ATR_MANA] = 0; attribute[ATR_HITPOINTS_MAX] = 190; attribute[ATR_HITPOINTS] = 190; Mdl_SetVisual(self,"HUMANS.MDS"); Mdl_ApplyOverlayMds(self,"Humans_Militia.mds"); Mdl_SetVisualBody(self,"hum_body_Naked0",0,1,"Hum_Head_Pony",13,2,grd_armor_l); B_Scale(self); Mdl_SetModelFatness(self,0); fight_tactic = FAI_HUMAN_Strong; Npc_SetTalentSkill(self,NPC_TALENT_1H,2); Npc_SetTalentSkill(self,NPC_TALENT_2H,1); Npc_SetTalentSkill(self,NPC_TALENT_CROSSBOW,1); CreateInvItem(self,ItMw_1H_Sword_02); CreateInvItem(self,ItRw_Crossbow_01); CreateInvItems(self,ItAmBolt,30); CreateInvItem(self,ItFoCheese); CreateInvItem(self,ItFoApple); CreateInvItems(self,ItMiNugget,10); CreateInvItem(self,ItLsTorch); daily_routine = rtn_start_5011; }; func void rtn_start_5011() { TA_Smalltalk(22,0,8,0,"OW_OM_ENTRANCE02_WHEEL_USE"); TA_Smalltalk(8,0,22,0,"OW_OM_ENTRANCE02_WHEEL_USE"); }; func void rtn_fmtaken_5011() { TA_Smalltalk(22,0,8,0,"OW_OM_ENTRANCE02_WHEEL_USE"); TA_Smalltalk(8,0,22,0,"OW_OM_ENTRANCE02_WHEEL_USE"); };
D
/** * Copyright © DiamondMVC 2018 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE) * Author: Jacob Jensen (bausshf) */ module diamond.database.mongo; import diamond.core.apptype; static if (isWeb) { import vibe.db.mongo.mongo; import vibe.db.mongo.client; /// The mongo db client. private static __gshared MongoClient _client; public { import MongoDb = diamond.database.mongo.operations; } package(diamond) { /** * Initializes the mongo db connection. * Params: * host = The host of the mongo db. * port = The port of the mongo db host. Only specify this the host is an ip address. */ void initializeMongo(string host, ushort port = 0) { if (port) { _client = connectMongoDB(host, port); } else { _client = connectMongoDB(host); } } /// Gets the raw vibe.d mongo client. @property MongoClient client() { return _client; } } }
D
int main(string[] args){ import std.stdio; import std.string; import std.conv; import std.algorithm; import std.array; import std.range; import shapefil; import dtriangulate.triangulate; immutable string usage = "stateTriangulator /path/to/shapefileFolder/fileNoPrefix [shape number [part number] ]"; if(args.length < 2){ writeln("usage: " ~ usage); return 1; } string prefix = args[1]; auto dbfHandle = DBFOpen(toStringz(prefix ~ ".dbf"), toStringz("rb")); if(args.length < 3){ auto nRecords = DBFGetRecordCount(dbfHandle); writefln("shape in file: "); foreach(i; 0..nRecords){ auto name =fromStringz( DBFReadStringAttribute(dbfHandle, i, 5)); writefln("shape %d: %s", i, name); } return 0; } int shapeNumber = to!int(args[2]); auto shpHandle = SHPOpen(toStringz(prefix ~ ".shp"), toStringz("rb")); auto shape = SHPReadObject(shpHandle, shapeNumber); auto nParts = shape.nParts; auto nVerts = shape.nVertices; if(args.length < 4){ writeln("parts in shape: "); foreach(i; 0..shape.nParts){ writefln("part %d has %d verts", i, (i < (nParts -1) ? shape.panPartStart[i + 1] : nVerts ) - shape.panPartStart[i]); } writefln("shape has %d parts and %d verts", nParts, nVerts); return 0; } int partNumber = to!int(args[3]); import gl3n.linalg : vec2; vec2[] points = new vec2[(partNumber < (nParts -1) ? shape.panPartStart[partNumber + 1] : nVerts ) - shape.panPartStart[partNumber]]; foreach(i; 0..points.length){ points[i].x = shape.padfX[i + shape.panPartStart[partNumber]]; points[i].y = shape.padfY[i + shape.panPartStart[partNumber]]; } // writeln(points); import std.algorithm.iteration : uniq; import std.array : array; auto sizeBefore = points.length; points = points.uniq.array; auto sizeAfter = points.length; if(sizeBefore != sizeAfter){ writeln("unique deleted ", sizeBefore - sizeAfter, " points"); } if(points[0] == points[$-1]){ writeln("deleted duplicate start/end point"); points = points[0..$-1]; } /* auto pointsCopy = points.dup; sort(pointsCopy); if(!pointsCopy.findAdjacent.empty){ writeln("duplicate points, oh shit!"); assert(0); }*/ // points ~= 0.5*(points[259] + points[260]); /* import std.algorithm.searching : findAdjacent; vec2[] rng = points[]; while((rng = rng.findAdjacent).length > 0){ write("duplicate: "); writeln(rng[0]); rng = rng[1..$]; }*/ writeln("number of unique points: ", points.length); //points = points[0..282]; // foreach( i, ref p; points[1412 .. 1419]){ // writefln("%d: vec2(%0.12f, %0.12f) ", i + 1412, p.x, p.y); // } auto triDB = delaunayTriangulate(points); // auto tris = triDB.getTriangles(); string svgFile = to!string(fromStringz(DBFReadStringAttribute(dbfHandle, shapeNumber, 5)) ~ ".svg"); writeSVG(svgFile, points, triDB); auto segments = iota(points.length).map!(i => Pair(to!int(i), to!int((i + 1)%points.length))).array; //make constrained delaunay next bool[Pair] segmentSet; foreach(seg; segments){ segmentSet[seg] = true; } // segmentSet.remove(Pair(259,260)); // segmentSet[Pair(259, 282)] = true; // segmentSet[Pair(282, 260)] = true; makeConstrainedDelaunay(points, triDB, segmentSet); string svgFileConstrained = to!string(svgFile[0..$-4] ~ "constrained.svg"); writeSVG(svgFileConstrained, points, triDB); cutOffScraps(points, triDB, segmentSet); string svgFileTrimmed = to!string(svgFile[0..$-4] ~ "trimmed.svg"); writeSVG(svgFileTrimmed, points, triDB); foreach(i; 0..10){ if(!refinementStep(points, triDB, segmentSet, .1, 30, .5)){ break; } writeln("mesh modified in iteration ", i); } string svgFileRefined = to!string(svgFile[0..$-4] ~ "refined.svg"); writeSVG(svgFileRefined, points, triDB); import dtriangulate.predicates; writeln("adaptive O2ds: ", extendedO2dCount); /* foreach(i; 0..points.length){ if(!triDB.edgeExists(cast(int)i, cast(int)((i+1)%points.length))){ writeln("clearing cavity: ", i, ' ', (i+1) % points.length); writeln("vertices for ", i); triDB.dumpVertex(to!int(i)); writeln(); writeln("vertices for ", (i +1) % points.length); triDB.dumpVertex(to!int( (i + 1) % points.length)); writeln(); clearCavity(points, triDB, Pair(cast(int)i, cast(int)((i+1)%points.length))); string filename = to!string("cleared" ~ to!string(i) ~ ".svg"); writeSVG(filename, points, triDB); } }*/ return 0; }
D
/************************************************************************** Лежит ли slf на полу (повержен): TRUE - лежит, FALSE - нет. ***************************************************************************/ func int C_NpcIsDown(var C_Npc slf) { //если меня вообще нет if (!Hlp_IsValidNpc(slf)) { return TRUE; // то я повержен }; // если я без сознания, усыплен или умер if(Npc_IsInState(slf,ZS_Unconscious) || Npc_IsInState(slf,ZS_MagicSleep) || Npc_IsInState(slf,ZS_MagicSleep_Short) || Npc_IsDead(slf)) { return TRUE; // то я повержен }; // иначе return FALSE; // НЕ повержен };
D
# FIXED uartstdio.obj: C:/ti/TivaWare/utils/uartstdio.c uartstdio.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdbool.h uartstdio.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdint.h uartstdio.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h uartstdio.obj: C:/ti/TivaWare/inc/hw_ints.h uartstdio.obj: C:/ti/TivaWare/inc/hw_memmap.h uartstdio.obj: C:/ti/TivaWare/inc/hw_types.h uartstdio.obj: C:/ti/TivaWare/inc/hw_uart.h uartstdio.obj: C:/ti/TivaWare/driverlib/debug.h uartstdio.obj: C:/ti/TivaWare/driverlib/interrupt.h uartstdio.obj: C:/ti/TivaWare/driverlib/rom.h uartstdio.obj: C:/ti/TivaWare/driverlib/rom_map.h uartstdio.obj: C:/ti/TivaWare/driverlib/sysctl.h uartstdio.obj: C:/ti/TivaWare/driverlib/uart.h uartstdio.obj: C:/ti/TivaWare/utils/uartstdio.h uartstdio.obj: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h C:/ti/TivaWare/utils/uartstdio.c: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdbool.h: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdint.h: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h: C:/ti/TivaWare/inc/hw_ints.h: C:/ti/TivaWare/inc/hw_memmap.h: C:/ti/TivaWare/inc/hw_types.h: C:/ti/TivaWare/inc/hw_uart.h: C:/ti/TivaWare/driverlib/debug.h: C:/ti/TivaWare/driverlib/interrupt.h: C:/ti/TivaWare/driverlib/rom.h: C:/ti/TivaWare/driverlib/rom_map.h: C:/ti/TivaWare/driverlib/sysctl.h: C:/ti/TivaWare/driverlib/uart.h: C:/ti/TivaWare/utils/uartstdio.h: C:/ti/ccsv7/tools/compiler/ti-cgt-arm_16.9.6.LTS/include/stdarg.h:
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.nv.geometry_program4; private { import derelict.opengl.gltypes; import derelict.opengl.gl; import derelict.opengl.extension.loader; import derelict.util.wrapper; } private bool enabled = false; struct NVGeometryProgram4 { static bool load(char[] extString) { if(extString.findStr("GL_NV_geometry_program4") == -1) return false; if(!glBindExtFunc(cast(void**)&glProgramVertexLimitNV, "glProgramVertexLimitNV")) return false; enabled = true; return true; } static bool isEnabled() { return enabled; } } version(DerelictGL_NoExtensionLoaders) { } else { static this() { DerelictGL.registerExtensionLoader(&NVGeometryProgram4.load); } } enum : GLenum { GL_GEOMETRY_PROGRAM_NV = 0x8C26, GL_MAX_PROGRAM_OUTPUT_VERTICES_NV = 0x8C27, GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV = 0x8C28, } extern(System) { void function(GLenum, GLint) glProgramVertexLimitNV; }
D
instance DIA_Mil_332_Stadtwache_EXIT(C_Info) { npc = Mil_332_Stadtwache; nr = 999; condition = DIA_Mil_332_Stadtwache_EXIT_Condition; information = DIA_Mil_332_Stadtwache_EXIT_Info; permanent = TRUE; description = Dialog_Ende; }; func int DIA_Mil_332_Stadtwache_EXIT_Condition() { return TRUE; }; func void DIA_Mil_332_Stadtwache_EXIT_Info() { AI_StopProcessInfos(self); }; instance DIA_Mil_332_Stadtwache_PERM(C_Info) { npc = Mil_332_Stadtwache; nr = 1; condition = DIA_Mil_332_Stadtwache_PERM_Condition; information = DIA_Mil_332_Stadtwache_PERM_Info; permanent = TRUE; description = "Как дела?"; }; func int DIA_Mil_332_Stadtwache_PERM_Condition() { return TRUE; }; func void DIA_Mil_332_Stadtwache_PERM_Info() { AI_Output(other,self,"DIA_Mil_332_Stadtwache_PERM_15_00"); //Как дела? AI_Output(self,other,"DIA_Mil_332_Stadtwache_PERM_04_01"); //Проходи! Я на посту! AI_StopProcessInfos(self); };
D
/Users/matsumur/Dropbox/Working/tekupico7(acm)/DerivedData/てくPico/Build/Intermediates/てくPico.build/Debug-iphoneos/てくPico.build/Objects-normal/arm64/Someaction.o : /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/AppDelegate.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialFirstlViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Someaction.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ThirdViewContoroller.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/MenuViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Tutorial2ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TabBarViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/FirstViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Extensions.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Darwin.swiftmodule /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko-Bridging-Header.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCrypto.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptor.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptoError.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonDigest.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonHMAC.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonKeyDerivation.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonSymmetricKeywrap.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreImage.swiftmodule /Users/matsumur/Dropbox/Working/tekupico7(acm)/DerivedData/てくPico/Build/Intermediates/てくPico.build/Debug-iphoneos/てくPico.build/Objects-normal/arm64/Someaction~partial.swiftmodule : /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/AppDelegate.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialFirstlViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Someaction.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ThirdViewContoroller.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/MenuViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Tutorial2ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TabBarViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/FirstViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Extensions.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Darwin.swiftmodule /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko-Bridging-Header.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCrypto.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptor.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptoError.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonDigest.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonHMAC.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonKeyDerivation.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonSymmetricKeywrap.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreImage.swiftmodule /Users/matsumur/Dropbox/Working/tekupico7(acm)/DerivedData/てくPico/Build/Intermediates/てくPico.build/Debug-iphoneos/てくPico.build/Objects-normal/arm64/Someaction~partial.swiftdoc : /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/AppDelegate.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TutorialFirstlViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Someaction.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/ThirdViewContoroller.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/MenuViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Tutorial2ViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/TabBarViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/FirstViewController.swift /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko/Extensions.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Darwin.swiftmodule /Users/matsumur/Dropbox/Working/tekupico7(acm)/wakapeko-Bridging-Header.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCrypto.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptor.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonCryptoError.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonDigest.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonHMAC.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonKeyDerivation.h /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.2.sdk/usr/include/CommonCrypto/CommonSymmetricKeywrap.h /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/Security.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/CoreImage.swiftmodule
D
/***********************************************************************\ * nb30.d * * * * Windows API header module * * * * Translated from MinGW Windows headers * * by Stewart Gordon * * * * Placed into public domain * \***********************************************************************/ module win32.nb30; version(Windows): private import win32.windef; const size_t NCBNAMSZ = 16, MAX_LANA = 254; // FIXME: are these really two sets of constants? enum : UCHAR { REGISTERING = 0, REGISTERED = 4, DEREGISTERED, DUPLICATE, DUPLICATE_DEREG, // = 7 UNIQUE_NAME = 0, GROUP_NAME = 0x80, NAME_FLAGS_MASK = 0x87 } enum : UCHAR { LISTEN_OUTSTANDING = 1, CALL_PENDING, SESSION_ESTABLISHED, HANGUP_PENDING, HANGUP_COMPLETE, SESSION_ABORTED // = 6 } const char[4] ALL_TRANSPORTS = "M\0\0\0", MS_NBF = "MNBF"; enum : UCHAR { NCBCALL = 0x10, NCBLISTEN, NCBHANGUP, // = 0x12 NCBSEND = 0x14, NCBRECV, NCBRECVANY, NCBCHAINSEND, // = 0x17 NCBDGSEND = 0x20, NCBDGRECV, NCBDGSENDBC, NCBDGRECVBC, // = 0x23, NCBADDNAME = 0x30, NCBDELNAME, NCBRESET, NCBASTAT, NCBSSTAT, NCBCANCEL, NCBADDGRNAME, NCBENUM, // = 0x37 NCBUNLINK = 0x70, NCBSENDNA, NCBCHAINSENDNA, NCBLANSTALERT, // = 0x73 NCBACTION = 0x77, NCBFINDNAME, NCBTRACE // = 0x79 } const UCHAR ASYNCH = 0x80; enum : UCHAR { NRC_GOODRET = 0x00, NRC_BUFLEN = 0x01, NRC_ILLCMD = 0x03, NRC_CMDTMO = 0x05, NRC_INCOMP, NRC_BADDR, NRC_SNUMOUT, NRC_NORES, NRC_SCLOSED, NRC_CMDCAN, // = 0x0b NRC_DUPNAME = 0x0d, NRC_NAMTFUL, NRC_ACTSES, // = 0x0f, NRC_LOCTFUL = 0x11, NRC_REMTFUL, NRC_ILLNN, NRC_NOCALL, NRC_NOWILD, NRC_INUSE, NRC_NAMERR, NRC_SABORT, NRC_NAMCONF, // = 0x19 NRC_IFBUSY = 0x21, NRC_TOOMANY, NRC_BRIDGE, NRC_CANOCCR, // = 0x24 NRC_CANCEL = 0x26, NRC_DUPENV = 0x30, NRC_ENVNOTDEF = 0x34, NRC_OSRESNOTAV, NRC_MAXAPPS, NRC_NOSAPS, NRC_NORESOURCES, NRC_INVADDRESS, // = 0x39 NRC_INVDDID = 0x3B, NRC_LOCKFAIL = 0x3C, NRC_OPENERR = 0x3f, NRC_SYSTEM = 0x40, NRC_PENDING = 0xff } struct ACTION_HEADER { union { /* transport_id is defined as a ULONG, but both the above constants * and the documented description suggest it should be a char[4] */ ULONG transport_id; char[4] c_transport_id; } USHORT action_code; USHORT reserved; } alias ACTION_HEADER* PACTION_HEADER; struct ADAPTER_STATUS { UCHAR[6] adapter_address; UCHAR rev_major; UCHAR reserved0; UCHAR adapter_type; UCHAR rev_minor; WORD duration; WORD frmr_recv; WORD frmr_xmit; WORD iframe_recv_err; WORD xmit_aborts; DWORD xmit_success; DWORD recv_success; WORD iframe_xmit_err; WORD recv_buff_unavail; WORD t1_timeouts; WORD ti_timeouts; DWORD reserved1; WORD free_ncbs; WORD max_cfg_ncbs; WORD max_ncbs; WORD xmit_buf_unavail; WORD max_dgram_size; WORD pending_sess; WORD max_cfg_sess; WORD max_sess; WORD max_sess_pkt_size; WORD name_count; } alias ADAPTER_STATUS* PADAPTER_STATUS; struct FIND_NAME_BUFFER { /* From Win32 API docs * * length * Specifies the length, in bytes, of the FIND_NAME_BUFFER * structure. Although this structure always occupies 33 bytes, * not all of the structure is necessarily valid. * * On this basis, should length be initialised? */ UCHAR length; UCHAR access_control; UCHAR frame_control; UCHAR[6] destination_addr; UCHAR[6] source_addr; UCHAR[18] routing_info; } alias FIND_NAME_BUFFER* PFIND_NAME_BUFFER; struct FIND_NAME_HEADER { WORD node_count; UCHAR reserved; UCHAR unique_group; } alias FIND_NAME_HEADER* PFIND_NAME_HEADER; struct LANA_ENUM { UCHAR length; UCHAR[MAX_LANA+1] lana; } alias LANA_ENUM* PLANA_ENUM; struct NAME_BUFFER { UCHAR[NCBNAMSZ] name; UCHAR name_num; UCHAR name_flags; } alias NAME_BUFFER* PNAME_BUFFER; struct NCB { UCHAR ncb_command; UCHAR ncb_retcode; UCHAR ncb_lsn; UCHAR ncb_num; PUCHAR ncb_buffer; WORD ncb_length; UCHAR[NCBNAMSZ] ncb_callname; UCHAR[NCBNAMSZ] ncb_name; UCHAR ncb_rto; UCHAR ncb_sto; extern (Windows) void function(NCB*) ncb_post; UCHAR ncb_lana_num; UCHAR ncb_cmd_cplt; UCHAR[10] ncb_reserve; HANDLE ncb_event; } alias NCB* PNCB; struct SESSION_BUFFER { UCHAR lsn; UCHAR state; UCHAR[NCBNAMSZ] local_name; UCHAR[NCBNAMSZ] remote_name; UCHAR rcvs_outstanding; UCHAR sends_outstanding; } alias SESSION_BUFFER* PSESSION_BUFFER; struct SESSION_HEADER { UCHAR sess_name; UCHAR num_sess; UCHAR rcv_dg_outstanding; UCHAR rcv_any_outstanding; } alias SESSION_HEADER* PSESSION_HEADER; extern (Windows) UCHAR Netbios(PNCB);
D
/Users/bilalshahid/Developer/Qaida/build/Qaida.build/Debug-iphoneos/Qaida.build/Objects-normal/arm64/GridViewController.o : /Users/bilalshahid/Developer/Qaida/Qaida/AppDelegate.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/lessonsCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaCollectionViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/LessonsViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/User.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaClass.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaDatatoArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/simd.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/MediaToolbox.framework/Headers/MediaToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/bilalshahid/Developer/Qaida/build/Qaida.build/Debug-iphoneos/Qaida.build/Objects-normal/arm64/GridViewController~partial.swiftmodule : /Users/bilalshahid/Developer/Qaida/Qaida/AppDelegate.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/lessonsCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaCollectionViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/LessonsViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/User.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaClass.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaDatatoArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/simd.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/MediaToolbox.framework/Headers/MediaToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/bilalshahid/Developer/Qaida/build/Qaida.build/Debug-iphoneos/Qaida.build/Objects-normal/arm64/GridViewController~partial.swiftdoc : /Users/bilalshahid/Developer/Qaida/Qaida/AppDelegate.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/lessonsCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaCollectionViewCell.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Takhti/GridViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/Lessons/LessonsViewController.swift /Users/bilalshahid/Developer/Qaida/Qaida/User.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaClass.swift /Users/bilalshahid/Developer/Qaida/Qaida/QaidaDatatoArray.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/simd.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Metal.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/SwiftOnoneSupport.swiftmodule /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/MediaToolbox.framework/Headers/MediaToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
# FIXED driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/xbar.c driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/xbar.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdbool.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/yvals.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdarg.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/linkage.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/_lock.h driverlib/xbar.obj: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdint.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_epwmxbar.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_inputxbar.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_outputxbar.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_trigxbar.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_xbar.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_memmap.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_types.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/cpu.h driverlib/xbar.obj: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/debug.h C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/xbar.c: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/xbar.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdbool.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/yvals.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdarg.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/linkage.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/_lock.h: C:/ti/ccsv6/tools/compiler/ti-cgt-c2000_6.4.4/include/stdint.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_epwmxbar.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_inputxbar.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_outputxbar.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_trigxbar.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_xbar.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_memmap.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/inc/hw_types.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/cpu.h: C:/Users/a0221343/Git/bootROM/f28004x_bootrom/F28004x_ROM_dev_PG2.0/F28004x_ROM/driverlib/debug.h:
D
/* * unary_expression_unit.d * */ module syntax.unary_expression_unit; import syntax.postfix_expression_unit; import syntax.cast_expression_unit; import syntax.new_expression_unit; import lex.lexer; import lex.token; import logger; /* UnaryExpr => & UnaryExpr | ++ UnaryExpr | -- UnaryExpr | * UnaryExpr | - UnaryExpr | + UnaryExpr | ! UnaryExpr | ~ UnaryExpr | ( Type ) . Identifier | NewExpression | delete UnaryExpression | CastExpression | PostfixExpression */ class UnaryExpressionUnit { private: Lexer _lexer; Logger _logger; int _state; public: this(Lexer lexer, Logger logger) { _lexer = lexer; _logger = logger; } char[] parse() { Token token; do { token = _lexer.pop(); } while (tokenFound(token)); return ""; } bool tokenFound(Token token) { if (token.type == Token.Type.Comment) { return true; } switch (token.type) { case Token.Type.Cast: auto cast_expr = (new CastExpressionUnit(_lexer, _logger)).parse; return false; // ComplementExpression: ~x case Token.Type.Cat: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // DereferenceExpression: *x case Token.Type.Mul: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // NegativeExpression: -x case Token.Type.Sub: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // NotExpression: !x case Token.Type.Bang: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // PositiveExpression: +x case Token.Type.Add: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // PreIncrementExpression: ++x case Token.Type.Increment: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // PreDecrementExpression: --x case Token.Type.Decrement: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // ReferenceExpression: &x case Token.Type.And: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // DeleteExpression: delete x case Token.Type.Delete: auto expr = (new UnaryExpressionUnit(_lexer, _logger)).parse; return false; // NewExpression: new x case Token.Type.New: auto expr = (new NewExpressionUnit(_lexer, _logger)).parse; return false; default: _lexer.push(token); auto expr = (new PostfixExpressionUnit(_lexer, _logger)).parse; break; } return false; } }
D
/Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/DerivedData/KeyNinjaShopping/Build/Intermediates.noindex/KeyNinjaShopping.build/Debug-iphonesimulator/KeyNinjaShopping.build/Objects-normal/x86_64/DataItems.o : /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/SceneDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/AppDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ShoppingItem.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/NavigationControllers/NavigationController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ShoppingViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ItemViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/CartViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ItemCells.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/DataItems.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.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.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/DerivedData/KeyNinjaShopping/Build/Intermediates.noindex/KeyNinjaShopping.build/Debug-iphonesimulator/KeyNinjaShopping.build/Objects-normal/x86_64/DataItems~partial.swiftmodule : /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/SceneDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/AppDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ShoppingItem.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/NavigationControllers/NavigationController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ShoppingViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ItemViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/CartViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ItemCells.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/DataItems.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.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.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/DerivedData/KeyNinjaShopping/Build/Intermediates.noindex/KeyNinjaShopping.build/Debug-iphonesimulator/KeyNinjaShopping.build/Objects-normal/x86_64/DataItems~partial.swiftdoc : /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/SceneDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Delegates/AppDelegate.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ShoppingItem.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/NavigationControllers/NavigationController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ShoppingViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/ItemViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/ViewControllers/CartViewController.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/ItemCells.swift /Users/nicholasglover/Documents/GitHub/KeyNinjaShopping/KeyNinjaShopping/Common/DataItems.swift /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/ObjectiveC.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreImage.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/QuartzCore.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Dispatch.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Metal.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Darwin.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Foundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreFoundation.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/CoreGraphics.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/UIKit.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/lib/swift/SwiftOnoneSupport.swiftmodule/x86_64.swiftinterface /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface /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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.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.2.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
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/doc.d, _doc.d) * Documentation: https://dlang.org/phobos/dmd_doc.html * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/doc.d */ module dmd.doc; import core.stdc.ctype; import core.stdc.stdlib; import core.stdc.stdio; import core.stdc.string; import core.stdc.time; import dmd.aggregate; import dmd.arraytypes; import dmd.attrib; import dmd.cond; import dmd.dclass; import dmd.declaration; import dmd.denum; import dmd.dmacro; import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem; import dmd.dtemplate; import dmd.errors; import dmd.func; import dmd.globals; import dmd.hdrgen; import dmd.id; import dmd.identifier; import dmd.lexer; import dmd.mtype; import dmd.root.array; import dmd.root.file; import dmd.root.filename; import dmd.root.outbuffer; import dmd.root.port; import dmd.root.rmem; import dmd.tokens; import dmd.utf; import dmd.utils; import dmd.visitor; struct Escape { const(char)[][char.max] strings; /*************************************** * Find character string to replace c with. */ const(char)[] escapeChar(char c) { version (all) { //printf("escapeChar('%c') => %p, %p\n", c, strings, strings[c].ptr); return strings[c]; } else { const(char)[] s; switch (c) { case '<': s = "&lt;"; break; case '>': s = "&gt;"; break; case '&': s = "&amp;"; break; default: s = null; break; } return s; } } } /*********************************************************** */ private class Section { const(char)* name; size_t namelen; const(char)* _body; size_t bodylen; int nooutput; void write(Loc loc, DocComment* dc, Scope* sc, Dsymbols* a, OutBuffer* buf) { assert(a.dim); if (namelen) { static immutable table = [ "AUTHORS", "BUGS", "COPYRIGHT", "DATE", "DEPRECATED", "EXAMPLES", "HISTORY", "LICENSE", "RETURNS", "SEE_ALSO", "STANDARDS", "THROWS", "VERSION", ]; foreach (entry; table) { if (iequals(entry, name[0 .. namelen])) { buf.printf("$(DDOC_%s ", entry.ptr); goto L1; } } buf.writestring("$(DDOC_SECTION "); // Replace _ characters with spaces buf.writestring("$(DDOC_SECTION_H "); size_t o = buf.offset; for (size_t u = 0; u < namelen; u++) { char c = name[u]; buf.writeByte((c == '_') ? ' ' : c); } escapeStrayParenthesis(loc, buf, o, false); buf.writestring(")"); } else { buf.writestring("$(DDOC_DESCRIPTION "); } L1: size_t o = buf.offset; buf.write(_body, bodylen); escapeStrayParenthesis(loc, buf, o, true); highlightText(sc, a, loc, buf, o); buf.writestring(")"); } } /*********************************************************** */ private final class ParamSection : Section { override void write(Loc loc, DocComment* dc, Scope* sc, Dsymbols* a, OutBuffer* buf) { assert(a.dim); Dsymbol s = (*a)[0]; // test const(char)* p = _body; size_t len = bodylen; const(char)* pend = p + len; const(char)* tempstart = null; size_t templen = 0; const(char)* namestart = null; size_t namelen = 0; // !=0 if line continuation const(char)* textstart = null; size_t textlen = 0; size_t paramcount = 0; buf.writestring("$(DDOC_PARAMS "); while (p < pend) { // Skip to start of macro while (1) { switch (*p) { case ' ': case '\t': p++; continue; case '\n': p++; goto Lcont; default: if (isIdStart(p) || isCVariadicArg(p[0 .. cast(size_t)(pend - p)])) break; if (namelen) goto Ltext; // continuation of prev macro goto Lskipline; } break; } tempstart = p; while (isIdTail(p)) p += utfStride(p); if (isCVariadicArg(p[0 .. cast(size_t)(pend - p)])) p += 3; templen = p - tempstart; while (*p == ' ' || *p == '\t') p++; if (*p != '=') { if (namelen) goto Ltext; // continuation of prev macro goto Lskipline; } p++; if (namelen) { // Output existing param L1: //printf("param '%.*s' = '%.*s'\n", cast(int)namelen, namestart, cast(int)textlen, textstart); ++paramcount; HdrGenState hgs; buf.writestring("$(DDOC_PARAM_ROW "); { buf.writestring("$(DDOC_PARAM_ID "); { size_t o = buf.offset; Parameter fparam = isFunctionParameter(a, namestart, namelen); if (!fparam) { // Comments on a template might refer to function parameters within. // Search the parameters of nested eponymous functions (with the same name.) fparam = isEponymousFunctionParameter(a, namestart, namelen); } bool isCVariadic = isCVariadicParameter(a, namestart[0 .. namelen]); if (isCVariadic) { buf.writestring("..."); } else if (fparam && fparam.type && fparam.ident) { .toCBuffer(fparam.type, buf, fparam.ident, &hgs); } else { if (isTemplateParameter(a, namestart, namelen)) { // 10236: Don't count template parameters for params check --paramcount; } else if (!fparam) { warning(s.loc, "Ddoc: function declaration has no parameter '%.*s'", cast(int)namelen, namestart); } buf.write(namestart, namelen); } escapeStrayParenthesis(loc, buf, o, true); highlightCode(sc, a, buf, o); } buf.writestring(")"); buf.writestring("$(DDOC_PARAM_DESC "); { size_t o = buf.offset; buf.write(textstart, textlen); escapeStrayParenthesis(loc, buf, o, true); highlightText(sc, a, loc, buf, o); } buf.writestring(")"); } buf.writestring(")"); namelen = 0; if (p >= pend) break; } namestart = tempstart; namelen = templen; while (*p == ' ' || *p == '\t') p++; textstart = p; Ltext: while (*p != '\n') p++; textlen = p - textstart; p++; Lcont: continue; Lskipline: // Ignore this line while (*p++ != '\n') { } } if (namelen) goto L1; // write out last one buf.writestring(")"); TypeFunction tf = a.dim == 1 ? isTypeFunction(s) : null; if (tf) { size_t pcount = (tf.parameterList.parameters ? tf.parameterList.parameters.dim : 0) + cast(int)(tf.parameterList.varargs == VarArg.variadic); if (pcount != paramcount) { warning(s.loc, "Ddoc: parameter count mismatch, expected %d, got %d", pcount, paramcount); if (paramcount == 0) { // Chances are someone messed up the format warningSupplemental(s.loc, "Note that the format is `param = description`"); } } } } } /*********************************************************** */ private final class MacroSection : Section { override void write(Loc loc, DocComment* dc, Scope* sc, Dsymbols* a, OutBuffer* buf) { //printf("MacroSection::write()\n"); DocComment.parseMacros(dc.escapetable, dc.pmacrotable, _body, bodylen); } } private alias Sections = Array!(Section); // Workaround for missing Parameter instance for variadic params. (it's unnecessary to instantiate one). private bool isCVariadicParameter(Dsymbols* a, const(char)[] p) { foreach (member; *a) { TypeFunction tf = isTypeFunction(member); if (tf && tf.parameterList.varargs == VarArg.variadic && p == "...") return true; } return false; } private Dsymbol getEponymousMember(TemplateDeclaration td) { if (!td.onemember) return null; if (AggregateDeclaration ad = td.onemember.isAggregateDeclaration()) return ad; if (FuncDeclaration fd = td.onemember.isFuncDeclaration()) return fd; if (auto em = td.onemember.isEnumMember()) return null; // Keep backward compatibility. See compilable/ddoc9.d if (VarDeclaration vd = td.onemember.isVarDeclaration()) return td.constraint ? null : vd; return null; } private TemplateDeclaration getEponymousParent(Dsymbol s) { if (!s.parent) return null; TemplateDeclaration td = s.parent.isTemplateDeclaration(); return (td && getEponymousMember(td)) ? td : null; } private immutable ddoc_default = import("default_ddoc_theme.ddoc"); private immutable ddoc_decl_s = "$(DDOC_DECL "; private immutable ddoc_decl_e = ")\n"; private immutable ddoc_decl_dd_s = "$(DDOC_DECL_DD "; private immutable ddoc_decl_dd_e = ")\n"; /**************************************************** */ extern(C++) void gendocfile(Module m) { __gshared OutBuffer mbuf; __gshared int mbuf_done; OutBuffer buf; //printf("Module::gendocfile()\n"); if (!mbuf_done) // if not already read the ddoc files { mbuf_done = 1; // Use our internal default mbuf.writestring(ddoc_default); // Override with DDOCFILE specified in the sc.ini file char* p = getenv("DDOCFILE"); if (p) global.params.ddocfiles.shift(p); // Override with the ddoc macro files from the command line for (size_t i = 0; i < global.params.ddocfiles.dim; i++) { auto file = File(global.params.ddocfiles[i].toDString()); readFile(m.loc, &file); // BUG: convert file contents to UTF-8 before use //printf("file: '%.*s'\n", cast(int)file.len, file.buffer); mbuf.write(file.buffer, file.len); } } DocComment.parseMacros(&m.escapetable, &m.macrotable, mbuf.peekSlice().ptr, mbuf.peekSlice().length); Scope* sc = Scope.createGlobal(m); // create root scope DocComment* dc = DocComment.parse(m, m.comment); dc.pmacrotable = &m.macrotable; dc.escapetable = &m.escapetable; sc.lastdc = dc; // Generate predefined macros // Set the title to be the name of the module { const p = m.toPrettyChars().toDString; Macro.define(&m.macrotable, "TITLE", p); } // Set time macros { time_t t; time(&t); char* p = ctime(&t); p = mem.xstrdup(p); Macro.define(&m.macrotable, "DATETIME", p[0 .. strlen(p)]); Macro.define(&m.macrotable, "YEAR", p[20 .. 20 + 4]); } const srcfilename = m.srcfile.toString(); Macro.define(&m.macrotable, "SRCFILENAME", srcfilename); const docfilename = m.docfile.toString(); Macro.define(&m.macrotable, "DOCFILENAME", docfilename); if (dc.copyright) { dc.copyright.nooutput = 1; Macro.define(&m.macrotable, "COPYRIGHT", dc.copyright._body[0 .. dc.copyright.bodylen]); } if (m.isDocFile) { Loc loc = m.md ? m.md.loc : m.loc; if (!loc.filename) loc.filename = srcfilename.ptr; size_t commentlen = strlen(cast(char*)m.comment); Dsymbols a; // https://issues.dlang.org/show_bug.cgi?id=9764 // Don't push m in a, to prevent emphasize ddoc file name. if (dc.macros) { commentlen = dc.macros.name - m.comment; dc.macros.write(loc, dc, sc, &a, &buf); } buf.write(m.comment, commentlen); highlightText(sc, &a, loc, &buf, 0); } else { Dsymbols a; a.push(m); dc.writeSections(sc, &a, &buf); emitMemberComments(m, &buf, sc); } //printf("BODY= '%.*s'\n", cast(int)buf.offset, buf.data); Macro.define(&m.macrotable, "BODY", buf.peekSlice()); OutBuffer buf2; buf2.writestring("$(DDOC)"); size_t end = buf2.offset; m.macrotable.expand(&buf2, 0, &end, null); version (all) { /* Remove all the escape sequences from buf2, * and make CR-LF the newline. */ { const slice = buf2.peekSlice(); buf.setsize(0); buf.reserve(slice.length); auto p = slice.ptr; for (size_t j = 0; j < slice.length; j++) { char c = p[j]; if (c == 0xFF && j + 1 < slice.length) { j++; continue; } if (c == '\n') buf.writeByte('\r'); else if (c == '\r') { buf.writestring("\r\n"); if (j + 1 < slice.length && p[j + 1] == '\n') { j++; } continue; } buf.writeByte(c); } } // Transfer image to file assert(m.docfile); m.docfile.setbuffer(cast(void*)buf.peekSlice().ptr, buf.peekSlice().length); m.docfile._ref = 1; ensurePathToNameExists(Loc.initial, m.docfile.toChars()); writeFile(m.loc, m.docfile); } else { /* Remove all the escape sequences from buf2 */ { size_t i = 0; char* p = buf2.data; for (size_t j = 0; j < buf2.offset; j++) { if (p[j] == 0xFF && j + 1 < buf2.offset) { j++; continue; } p[i] = p[j]; i++; } buf2.setsize(i); } // Transfer image to file m.docfile.setbuffer(buf2.data, buf2.offset); m.docfile._ref = 1; ensurePathToNameExists(Loc.initial, m.docfile.toChars()); writeFile(m.loc, m.docfile); } } /**************************************************** * Having unmatched parentheses can hose the output of Ddoc, * as the macros depend on properly nested parentheses. * This function replaces all ( with $(LPAREN) and ) with $(RPAREN) * to preserve text literally. This also means macros in the * text won't be expanded. */ void escapeDdocString(OutBuffer* buf, size_t start) { for (size_t u = start; u < buf.offset; u++) { char c = buf.data[u]; switch (c) { case '$': buf.remove(u, 1); buf.insert(u, "$(DOLLAR)"); u += 8; break; case '(': buf.remove(u, 1); //remove the ( buf.insert(u, "$(LPAREN)"); //insert this instead u += 8; //skip over newly inserted macro break; case ')': buf.remove(u, 1); //remove the ) buf.insert(u, "$(RPAREN)"); //insert this instead u += 8; //skip over newly inserted macro break; default: break; } } } /**************************************************** * Having unmatched parentheses can hose the output of Ddoc, * as the macros depend on properly nested parentheses. * * Fix by replacing unmatched ( with $(LPAREN) and unmatched ) with $(RPAREN). * * Params: * loc = source location of start of text. It is a mutable copy to allow incrementing its linenum, for printing the correct line number when an error is encountered in a multiline block of ddoc. * buf = an OutBuffer containing the DDoc * start = the index within buf to start replacing unmatched parentheses * respectBackslashEscapes = if true, always replace parentheses that are * directly preceeded by a backslash with $(LPAREN) or $(RPAREN) instead of * counting them as stray parentheses */ private void escapeStrayParenthesis(Loc loc, OutBuffer* buf, size_t start, bool respectBackslashEscapes) { uint par_open = 0; char inCode = 0; bool atLineStart = true; for (size_t u = start; u < buf.offset; u++) { char c = buf.data[u]; switch (c) { case '(': if (!inCode) par_open++; atLineStart = false; break; case ')': if (!inCode) { if (par_open == 0) { //stray ')' warning(loc, "Ddoc: Stray ')'. This may cause incorrect Ddoc output. Use $(RPAREN) instead for unpaired right parentheses."); buf.remove(u, 1); //remove the ) buf.insert(u, "$(RPAREN)"); //insert this instead u += 8; //skip over newly inserted macro } else par_open--; } atLineStart = false; break; case '\n': atLineStart = true; version (none) { // For this to work, loc must be set to the beginning of the passed // text which is currently not possible // (loc is set to the Loc of the Dsymbol) loc.linnum++; } break; case ' ': case '\r': case '\t': break; case '-': case '`': // Issue 15465: don't try to escape unbalanced parens inside code // blocks. int numdash = 1; for (++u; u < buf.offset && buf.data[u] == '-'; ++u) ++numdash; --u; if (c == '`' || (atLineStart && numdash >= 3)) { if (inCode == c) inCode = 0; else if (!inCode) inCode = c; } atLineStart = false; break; case '\\': // replace backslash-escaped parens with their macros if (!inCode && respectBackslashEscapes && u+1 < buf.offset && global.params.markdown) { if (buf.data[u+1] == '(' || buf.data[u+1] == ')') { const paren = buf.data[u+1] == '(' ? "$(LPAREN)" : "$(RPAREN)"; buf.remove(u, 2); //remove the \) buf.insert(u, paren); //insert this instead u += 8; //skip over newly inserted macro } else if (buf.data[u+1] == '\\') ++u; } break; default: atLineStart = false; break; } } if (par_open) // if any unmatched lparens { par_open = 0; for (size_t u = buf.offset; u > start;) { u--; char c = buf.data[u]; switch (c) { case ')': par_open++; break; case '(': if (par_open == 0) { //stray '(' warning(loc, "Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses."); buf.remove(u, 1); //remove the ( buf.insert(u, "$(LPAREN)"); //insert this instead } else par_open--; break; default: break; } } } } // Basically, this is to skip over things like private{} blocks in a struct or // class definition that don't add any components to the qualified name. private Scope* skipNonQualScopes(Scope* sc) { while (sc && !sc.scopesym) sc = sc.enclosing; return sc; } private bool emitAnchorName(OutBuffer* buf, Dsymbol s, Scope* sc, bool includeParent) { if (!s || s.isPackage() || s.isModule()) return false; // Add parent names first bool dot = false; auto eponymousParent = getEponymousParent(s); if (includeParent && s.parent || eponymousParent) dot = emitAnchorName(buf, s.parent, sc, includeParent); else if (includeParent && sc) dot = emitAnchorName(buf, sc.scopesym, skipNonQualScopes(sc.enclosing), includeParent); // Eponymous template members can share the parent anchor name if (eponymousParent) return dot; if (dot) buf.writeByte('.'); // Use "this" not "__ctor" TemplateDeclaration td; if (s.isCtorDeclaration() || ((td = s.isTemplateDeclaration()) !is null && td.onemember && td.onemember.isCtorDeclaration())) { buf.writestring("this"); } else { /* We just want the identifier, not overloads like TemplateDeclaration::toChars. * We don't want the template parameter list and constraints. */ buf.writestring(s.Dsymbol.toChars()); } return true; } private void emitAnchor(OutBuffer* buf, Dsymbol s, Scope* sc, bool forHeader = false) { Identifier ident; { OutBuffer anc; emitAnchorName(&anc, s, skipNonQualScopes(sc), true); ident = Identifier.idPool(anc.peekSlice()); } auto pcount = cast(void*)ident in sc.anchorCounts; typeof(*pcount) count; if (!forHeader) { if (pcount) { // Existing anchor, // don't write an anchor for matching consecutive ditto symbols TemplateDeclaration td = getEponymousParent(s); if (sc.prevAnchor == ident && sc.lastdc && (isDitto(s.comment) || (td && isDitto(td.comment)))) return; count = ++*pcount; } else { sc.anchorCounts[cast(void*)ident] = 1; count = 1; } } // cache anchor name sc.prevAnchor = ident; auto macroName = forHeader ? "DDOC_HEADER_ANCHOR" : "DDOC_ANCHOR"; auto symbolName = ident.toString(); buf.printf("$(%.*s %.*s", cast(int) macroName.length, macroName.ptr, cast(int) symbolName.length, symbolName.ptr); // only append count once there's a duplicate if (count > 1) buf.printf(".%u", count); if (forHeader) { Identifier shortIdent; { OutBuffer anc; emitAnchorName(&anc, s, skipNonQualScopes(sc), false); shortIdent = Identifier.idPool(anc.peekSlice()); } auto shortName = shortIdent.toString(); buf.printf(", %.*s", cast(int) shortName.length, shortName.ptr); } buf.writeByte(')'); } /******************************* emitComment **********************************/ /** Get leading indentation from 'src' which represents lines of code. */ private size_t getCodeIndent(const(char)* src) { while (src && (*src == '\r' || *src == '\n')) ++src; // skip until we find the first non-empty line size_t codeIndent = 0; while (src && (*src == ' ' || *src == '\t')) { codeIndent++; src++; } return codeIndent; } /** Recursively expand template mixin member docs into the scope. */ private void expandTemplateMixinComments(TemplateMixin tm, OutBuffer* buf, Scope* sc) { if (!tm.semanticRun) tm.dsymbolSemantic(sc); TemplateDeclaration td = (tm && tm.tempdecl) ? tm.tempdecl.isTemplateDeclaration() : null; if (td && td.members) { for (size_t i = 0; i < td.members.dim; i++) { Dsymbol sm = (*td.members)[i]; TemplateMixin tmc = sm.isTemplateMixin(); if (tmc && tmc.comment) expandTemplateMixinComments(tmc, buf, sc); else emitComment(sm, buf, sc); } } } private void emitMemberComments(ScopeDsymbol sds, OutBuffer* buf, Scope* sc) { if (!sds.members) return; //printf("ScopeDsymbol::emitMemberComments() %s\n", toChars()); const(char)[] m = "$(DDOC_MEMBERS "; if (sds.isTemplateDeclaration()) m = "$(DDOC_TEMPLATE_MEMBERS "; else if (sds.isClassDeclaration()) m = "$(DDOC_CLASS_MEMBERS "; else if (sds.isStructDeclaration()) m = "$(DDOC_STRUCT_MEMBERS "; else if (sds.isEnumDeclaration()) m = "$(DDOC_ENUM_MEMBERS "; else if (sds.isModule()) m = "$(DDOC_MODULE_MEMBERS "; size_t offset1 = buf.offset; // save starting offset buf.writestring(m); size_t offset2 = buf.offset; // to see if we write anything sc = sc.push(sds); for (size_t i = 0; i < sds.members.dim; i++) { Dsymbol s = (*sds.members)[i]; //printf("\ts = '%s'\n", s.toChars()); // only expand if parent is a non-template (semantic won't work) if (s.comment && s.isTemplateMixin() && s.parent && !s.parent.isTemplateDeclaration()) expandTemplateMixinComments(cast(TemplateMixin)s, buf, sc); emitComment(s, buf, sc); } emitComment(null, buf, sc); sc.pop(); if (buf.offset == offset2) { /* Didn't write out any members, so back out last write */ buf.offset = offset1; } else buf.writestring(")"); } private void emitProtection(OutBuffer* buf, Prot prot) { if (prot.kind != Prot.Kind.undefined && prot.kind != Prot.Kind.public_) { protectionToBuffer(buf, prot); buf.writeByte(' '); } } private void emitComment(Dsymbol s, OutBuffer* buf, Scope* sc) { extern (C++) final class EmitComment : Visitor { alias visit = Visitor.visit; public: OutBuffer* buf; Scope* sc; extern (D) this(OutBuffer* buf, Scope* sc) { this.buf = buf; this.sc = sc; } override void visit(Dsymbol) { } override void visit(InvariantDeclaration) { } override void visit(UnitTestDeclaration) { } override void visit(PostBlitDeclaration) { } override void visit(DtorDeclaration) { } override void visit(StaticCtorDeclaration) { } override void visit(StaticDtorDeclaration) { } override void visit(TypeInfoDeclaration) { } void emit(Scope* sc, Dsymbol s, const(char)* com) { if (s && sc.lastdc && isDitto(com)) { sc.lastdc.a.push(s); return; } // Put previous doc comment if exists if (DocComment* dc = sc.lastdc) { assert(dc.a.dim > 0, "Expects at least one declaration for a" ~ "documentation comment"); auto symbol = dc.a[0]; buf.writestring("$(DDOC_MEMBER"); buf.writestring("$(DDOC_MEMBER_HEADER"); emitAnchor(buf, symbol, sc, true); buf.writeByte(')'); // Put the declaration signatures as the document 'title' buf.writestring(ddoc_decl_s); for (size_t i = 0; i < dc.a.dim; i++) { Dsymbol sx = dc.a[i]; // the added linebreaks in here make looking at multiple // signatures more appealing if (i == 0) { size_t o = buf.offset; toDocBuffer(sx, buf, sc); highlightCode(sc, sx, buf, o); buf.writestring("$(DDOC_OVERLOAD_SEPARATOR)"); continue; } buf.writestring("$(DDOC_DITTO "); { size_t o = buf.offset; toDocBuffer(sx, buf, sc); highlightCode(sc, sx, buf, o); } buf.writestring("$(DDOC_OVERLOAD_SEPARATOR)"); buf.writeByte(')'); } buf.writestring(ddoc_decl_e); // Put the ddoc comment as the document 'description' buf.writestring(ddoc_decl_dd_s); { dc.writeSections(sc, &dc.a, buf); if (ScopeDsymbol sds = dc.a[0].isScopeDsymbol()) emitMemberComments(sds, buf, sc); } buf.writestring(ddoc_decl_dd_e); buf.writeByte(')'); //printf("buf.2 = [[%.*s]]\n", cast(int)(buf.offset - o0), buf.data + o0); } if (s) { DocComment* dc = DocComment.parse(s, com); dc.pmacrotable = &sc._module.macrotable; sc.lastdc = dc; } } override void visit(Declaration d) { //printf("Declaration::emitComment(%p '%s'), comment = '%s'\n", d, d.toChars(), d.comment); //printf("type = %p\n", d.type); const(char)* com = d.comment; if (TemplateDeclaration td = getEponymousParent(d)) { if (isDitto(td.comment)) com = td.comment; else com = Lexer.combineComments(td.comment, com, true); } else { if (!d.ident) return; if (!d.type) { if (!d.isCtorDeclaration() && !d.isAliasDeclaration() && !d.isVarDeclaration()) { return; } } if (d.protection.kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_) return; } if (!com) return; emit(sc, d, com); } override void visit(AggregateDeclaration ad) { //printf("AggregateDeclaration::emitComment() '%s'\n", ad.toChars()); const(char)* com = ad.comment; if (TemplateDeclaration td = getEponymousParent(ad)) { if (isDitto(td.comment)) com = td.comment; else com = Lexer.combineComments(td.comment, com, true); } else { if (ad.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_) return; if (!ad.comment) return; } if (!com) return; emit(sc, ad, com); } override void visit(TemplateDeclaration td) { //printf("TemplateDeclaration::emitComment() '%s', kind = %s\n", td.toChars(), td.kind()); if (td.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_) return; if (!td.comment) return; if (Dsymbol ss = getEponymousMember(td)) { ss.accept(this); return; } emit(sc, td, td.comment); } override void visit(EnumDeclaration ed) { if (ed.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_) return; if (ed.isAnonymous() && ed.members) { for (size_t i = 0; i < ed.members.dim; i++) { Dsymbol s = (*ed.members)[i]; emitComment(s, buf, sc); } return; } if (!ed.comment) return; if (ed.isAnonymous()) return; emit(sc, ed, ed.comment); } override void visit(EnumMember em) { //printf("EnumMember::emitComment(%p '%s'), comment = '%s'\n", em, em.toChars(), em.comment); if (em.prot().kind == Prot.Kind.private_ || sc.protection.kind == Prot.Kind.private_) return; if (!em.comment) return; emit(sc, em, em.comment); } override void visit(AttribDeclaration ad) { //printf("AttribDeclaration::emitComment(sc = %p)\n", sc); /* A general problem with this, * illustrated by https://issues.dlang.org/show_bug.cgi?id=2516 * is that attributes are not transmitted through to the underlying * member declarations for template bodies, because semantic analysis * is not done for template declaration bodies * (only template instantiations). * Hence, Ddoc omits attributes from template members. */ Dsymbols* d = ad.include(null); if (d) { for (size_t i = 0; i < d.dim; i++) { Dsymbol s = (*d)[i]; //printf("AttribDeclaration::emitComment %s\n", s.toChars()); emitComment(s, buf, sc); } } } override void visit(ProtDeclaration pd) { if (pd.decl) { Scope* scx = sc; sc = sc.copy(); sc.protection = pd.protection; visit(cast(AttribDeclaration)pd); scx.lastdc = sc.lastdc; sc = sc.pop(); } } override void visit(ConditionalDeclaration cd) { //printf("ConditionalDeclaration::emitComment(sc = %p)\n", sc); if (cd.condition.inc != Include.notComputed) { visit(cast(AttribDeclaration)cd); return; } /* If generating doc comment, be careful because if we're inside * a template, then include(null) will fail. */ Dsymbols* d = cd.decl ? cd.decl : cd.elsedecl; for (size_t i = 0; i < d.dim; i++) { Dsymbol s = (*d)[i]; emitComment(s, buf, sc); } } } scope EmitComment v = new EmitComment(buf, sc); if (!s) v.emit(sc, null, null); else s.accept(v); } private void toDocBuffer(Dsymbol s, OutBuffer* buf, Scope* sc) { extern (C++) final class ToDocBuffer : Visitor { alias visit = Visitor.visit; public: OutBuffer* buf; Scope* sc; extern (D) this(OutBuffer* buf, Scope* sc) { this.buf = buf; this.sc = sc; } override void visit(Dsymbol s) { //printf("Dsymbol::toDocbuffer() %s\n", s.toChars()); HdrGenState hgs; hgs.ddoc = true; .toCBuffer(s, buf, &hgs); } void prefix(Dsymbol s) { if (s.isDeprecated()) buf.writestring("deprecated "); if (Declaration d = s.isDeclaration()) { emitProtection(buf, d.protection); if (d.isStatic()) buf.writestring("static "); else if (d.isFinal()) buf.writestring("final "); else if (d.isAbstract()) buf.writestring("abstract "); if (d.isFuncDeclaration()) // functionToBufferFull handles this return; if (d.isImmutable()) buf.writestring("immutable "); if (d.storage_class & STC.shared_) buf.writestring("shared "); if (d.isWild()) buf.writestring("inout "); if (d.isConst()) buf.writestring("const "); if (d.isSynchronized()) buf.writestring("synchronized "); if (d.storage_class & STC.manifest) buf.writestring("enum "); // Add "auto" for the untyped variable in template members if (!d.type && d.isVarDeclaration() && !d.isImmutable() && !(d.storage_class & STC.shared_) && !d.isWild() && !d.isConst() && !d.isSynchronized()) { buf.writestring("auto "); } } } override void visit(Declaration d) { if (!d.ident) return; TemplateDeclaration td = getEponymousParent(d); //printf("Declaration::toDocbuffer() %s, originalType = %s, td = %s\n", d.toChars(), d.originalType ? d.originalType.toChars() : "--", td ? td.toChars() : "--"); HdrGenState hgs; hgs.ddoc = true; if (d.isDeprecated()) buf.writestring("$(DEPRECATED "); prefix(d); if (d.type) { Type origType = d.originalType ? d.originalType : d.type; if (origType.ty == Tfunction) { functionToBufferFull(cast(TypeFunction)origType, buf, d.ident, &hgs, td); } else .toCBuffer(origType, buf, d.ident, &hgs); } else buf.writestring(d.ident.toChars()); if (d.isVarDeclaration() && td) { buf.writeByte('('); if (td.origParameters && td.origParameters.dim) { for (size_t i = 0; i < td.origParameters.dim; i++) { if (i) buf.writestring(", "); toCBuffer((*td.origParameters)[i], buf, &hgs); } } buf.writeByte(')'); } // emit constraints if declaration is a templated declaration if (td && td.constraint) { bool noFuncDecl = td.isFuncDeclaration() is null; if (noFuncDecl) { buf.writestring("$(DDOC_CONSTRAINT "); } .toCBuffer(td.constraint, buf, &hgs); if (noFuncDecl) { buf.writestring(")"); } } if (d.isDeprecated()) buf.writestring(")"); buf.writestring(";\n"); } override void visit(AliasDeclaration ad) { //printf("AliasDeclaration::toDocbuffer() %s\n", ad.toChars()); if (!ad.ident) return; if (ad.isDeprecated()) buf.writestring("deprecated "); emitProtection(buf, ad.protection); buf.printf("alias %s = ", ad.toChars()); if (Dsymbol s = ad.aliassym) // ident alias { prettyPrintDsymbol(s, ad.parent); } else if (Type type = ad.getType()) // type alias { if (type.ty == Tclass || type.ty == Tstruct || type.ty == Tenum) { if (Dsymbol s = type.toDsymbol(null)) // elaborate type prettyPrintDsymbol(s, ad.parent); else buf.writestring(type.toChars()); } else { // simple type buf.writestring(type.toChars()); } } buf.writestring(";\n"); } void parentToBuffer(Dsymbol s) { if (s && !s.isPackage() && !s.isModule()) { parentToBuffer(s.parent); buf.writestring(s.toChars()); buf.writestring("."); } } static bool inSameModule(Dsymbol s, Dsymbol p) { for (; s; s = s.parent) { if (s.isModule()) break; } for (; p; p = p.parent) { if (p.isModule()) break; } return s == p; } void prettyPrintDsymbol(Dsymbol s, Dsymbol parent) { if (s.parent && (s.parent == parent)) // in current scope -> naked name { buf.writestring(s.toChars()); } else if (!inSameModule(s, parent)) // in another module -> full name { buf.writestring(s.toPrettyChars()); } else // nested in a type in this module -> full name w/o module name { // if alias is nested in a user-type use module-scope lookup if (!parent.isModule() && !parent.isPackage()) buf.writestring("."); parentToBuffer(s.parent); buf.writestring(s.toChars()); } } override void visit(AggregateDeclaration ad) { if (!ad.ident) return; version (none) { emitProtection(buf, ad.protection); } buf.printf("%s %s", ad.kind(), ad.toChars()); buf.writestring(";\n"); } override void visit(StructDeclaration sd) { //printf("StructDeclaration::toDocbuffer() %s\n", sd.toChars()); if (!sd.ident) return; version (none) { emitProtection(buf, sd.protection); } if (TemplateDeclaration td = getEponymousParent(sd)) { toDocBuffer(td, buf, sc); } else { buf.printf("%s %s", sd.kind(), sd.toChars()); } buf.writestring(";\n"); } override void visit(ClassDeclaration cd) { //printf("ClassDeclaration::toDocbuffer() %s\n", cd.toChars()); if (!cd.ident) return; version (none) { emitProtection(buf, cd.protection); } if (TemplateDeclaration td = getEponymousParent(cd)) { toDocBuffer(td, buf, sc); } else { if (!cd.isInterfaceDeclaration() && cd.isAbstract()) buf.writestring("abstract "); buf.printf("%s %s", cd.kind(), cd.toChars()); } int any = 0; for (size_t i = 0; i < cd.baseclasses.dim; i++) { BaseClass* bc = (*cd.baseclasses)[i]; if (bc.sym && bc.sym.ident == Id.Object) continue; if (any) buf.writestring(", "); else { buf.writestring(": "); any = 1; } emitProtection(buf, Prot(Prot.Kind.public_)); if (bc.sym) { buf.printf("$(DDOC_PSUPER_SYMBOL %s)", bc.sym.toPrettyChars()); } else { HdrGenState hgs; .toCBuffer(bc.type, buf, null, &hgs); } } buf.writestring(";\n"); } override void visit(EnumDeclaration ed) { if (!ed.ident) return; buf.printf("%s %s", ed.kind(), ed.toChars()); if (ed.memtype) { buf.writestring(": $(DDOC_ENUM_BASETYPE "); HdrGenState hgs; .toCBuffer(ed.memtype, buf, null, &hgs); buf.writestring(")"); } buf.writestring(";\n"); } override void visit(EnumMember em) { if (!em.ident) return; buf.writestring(em.toChars()); } } scope ToDocBuffer v = new ToDocBuffer(buf, sc); s.accept(v); } /*********************************************************** */ struct DocComment { Sections sections; // Section*[] Section summary; Section copyright; Section macros; Macro** pmacrotable; Escape* escapetable; Dsymbols a; static DocComment* parse(Dsymbol s, const(char)* comment) { //printf("parse(%s): '%s'\n", s.toChars(), comment); auto dc = new DocComment(); dc.a.push(s); if (!comment) return dc; dc.parseSections(comment); for (size_t i = 0; i < dc.sections.dim; i++) { Section sec = dc.sections[i]; if (iequals("copyright", sec.name[0 .. sec.namelen])) { dc.copyright = sec; } if (iequals("macros", sec.name[0 .. sec.namelen])) { dc.macros = sec; } } return dc; } /************************************************ * Parse macros out of Macros: section. * Macros are of the form: * name1 = value1 * * name2 = value2 */ static void parseMacros(Escape* escapetable, Macro** pmacrotable, const(char)* m, size_t mlen) { const(char)* p = m; size_t len = mlen; const(char)* pend = p + len; const(char)* tempstart = null; size_t templen = 0; const(char)* namestart = null; size_t namelen = 0; // !=0 if line continuation const(char)* textstart = null; size_t textlen = 0; while (p < pend) { // Skip to start of macro while (1) { if (p >= pend) goto Ldone; switch (*p) { case ' ': case '\t': p++; continue; case '\r': case '\n': p++; goto Lcont; default: if (isIdStart(p)) break; if (namelen) goto Ltext; // continuation of prev macro goto Lskipline; } break; } tempstart = p; while (1) { if (p >= pend) goto Ldone; if (!isIdTail(p)) break; p += utfStride(p); } templen = p - tempstart; while (1) { if (p >= pend) goto Ldone; if (!(*p == ' ' || *p == '\t')) break; p++; } if (*p != '=') { if (namelen) goto Ltext; // continuation of prev macro goto Lskipline; } p++; if (p >= pend) goto Ldone; if (namelen) { // Output existing macro L1: //printf("macro '%.*s' = '%.*s'\n", cast(int)namelen, namestart, cast(int)textlen, textstart); if (iequals("ESCAPES", namestart[0 .. namelen])) parseEscapes(escapetable, textstart, textlen); else Macro.define(pmacrotable, namestart[0 ..namelen], textstart[0 .. textlen]); namelen = 0; if (p >= pend) break; } namestart = tempstart; namelen = templen; while (p < pend && (*p == ' ' || *p == '\t')) p++; textstart = p; Ltext: while (p < pend && *p != '\r' && *p != '\n') p++; textlen = p - textstart; p++; //printf("p = %p, pend = %p\n", p, pend); Lcont: continue; Lskipline: // Ignore this line while (p < pend && *p != '\r' && *p != '\n') p++; } Ldone: if (namelen) goto L1; // write out last one } /************************************** * Parse escapes of the form: * /c/string/ * where c is a single character. * Multiple escapes can be separated * by whitespace and/or commas. */ static void parseEscapes(Escape* escapetable, const(char)* textstart, size_t textlen) { if (!escapetable) { escapetable = new Escape(); memset(escapetable, 0, Escape.sizeof); } //printf("parseEscapes('%.*s') pescapetable = %p\n", cast(int)textlen, textstart, pescapetable); const(char)* p = textstart; const(char)* pend = p + textlen; while (1) { while (1) { if (p + 4 >= pend) return; if (!(*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n' || *p == ',')) break; p++; } if (p[0] != '/' || p[2] != '/') return; char c = p[1]; p += 3; const(char)* start = p; while (1) { if (p >= pend) return; if (*p == '/') break; p++; } size_t len = p - start; char* s = cast(char*)memcpy(mem.xmalloc(len + 1), start, len); s[len] = 0; escapetable.strings[c] = s[0 .. len]; //printf("\t%c = '%s'\n", c, s); p++; } } /***************************************** * Parse next paragraph out of *pcomment. * Update *pcomment to point past paragraph. * Returns NULL if no more paragraphs. * If paragraph ends in 'identifier:', * then (*pcomment)[0 .. idlen] is the identifier. */ void parseSections(const(char)* comment) { const(char)* p; const(char)* pstart; const(char)* pend; const(char)* idstart = null; // dead-store to prevent spurious warning size_t idlen; const(char)* name = null; size_t namelen = 0; //printf("parseSections('%s')\n", comment); p = comment; while (*p) { const(char)* pstart0 = p; p = skipwhitespace(p); pstart = p; pend = p; // Undo indent if starting with a list item if ((*p == '-' || *p == '+' || *p == '*') && (*(p+1) == ' ' || *(p+1) == '\t')) pstart = pstart0; else { const(char)* pitem = p; while (*pitem >= '0' && *pitem <= '9') ++pitem; if (pitem > p && *pitem == '.' && (*(pitem+1) == ' ' || *(pitem+1) == '\t')) pstart = pstart0; } /* Find end of section, which is ended by one of: * 'identifier:' (but not inside a code section) * '\0' */ idlen = 0; int inCode = 0; while (1) { // Check for start/end of a code section if (*p == '-') { if (!inCode) { // restore leading indentation while (pstart0 < pstart && isIndentWS(pstart - 1)) --pstart; } int numdash = 0; while (*p == '-') { ++numdash; p++; } // BUG: handle UTF PS and LS too if ((!*p || *p == '\r' || *p == '\n') && numdash >= 3) inCode ^= 1; pend = p; } if (!inCode && isIdStart(p)) { const(char)* q = p + utfStride(p); while (isIdTail(q)) q += utfStride(q); // Detected tag ends it if (*q == ':' && isupper(*p) && (isspace(q[1]) || q[1] == 0)) { idlen = q - p; idstart = p; for (pend = p; pend > pstart; pend--) { if (pend[-1] == '\n') break; } p = q + 1; break; } } while (1) { if (!*p) goto L1; if (*p == '\n') { p++; if (*p == '\n' && !summary && !namelen && !inCode) { pend = p; p++; goto L1; } break; } p++; pend = p; } p = skipwhitespace(p); } L1: if (namelen || pstart < pend) { Section s; if (iequals("Params", name[0 .. namelen])) s = new ParamSection(); else if (iequals("Macros", name[0 .. namelen])) s = new MacroSection(); else s = new Section(); s.name = name; s.namelen = namelen; s._body = pstart; s.bodylen = pend - pstart; s.nooutput = 0; //printf("Section: '%.*s' = '%.*s'\n", cast(int)s.namelen, s.name, cast(int)s.bodylen, s.body); sections.push(s); if (!summary && !namelen) summary = s; } if (idlen) { name = idstart; namelen = idlen; } else { name = null; namelen = 0; if (!*p) break; } } } void writeSections(Scope* sc, Dsymbols* a, OutBuffer* buf) { assert(a.dim); //printf("DocComment::writeSections()\n"); Loc loc = (*a)[0].loc; if (Module m = (*a)[0].isModule()) { if (m.md) loc = m.md.loc; } size_t offset1 = buf.offset; buf.writestring("$(DDOC_SECTIONS "); size_t offset2 = buf.offset; for (size_t i = 0; i < sections.dim; i++) { Section sec = sections[i]; if (sec.nooutput) continue; //printf("Section: '%.*s' = '%.*s'\n", cast(int)sec.namelen, sec.name, cast(int)sec.bodylen, sec.body); if (!sec.namelen && i == 0) { buf.writestring("$(DDOC_SUMMARY "); size_t o = buf.offset; buf.write(sec._body, sec.bodylen); escapeStrayParenthesis(loc, buf, o, true); highlightText(sc, a, loc, buf, o); buf.writestring(")"); } else sec.write(loc, &this, sc, a, buf); } for (size_t i = 0; i < a.dim; i++) { Dsymbol s = (*a)[i]; if (Dsymbol td = getEponymousParent(s)) s = td; for (UnitTestDeclaration utd = s.ddocUnittest; utd; utd = utd.ddocUnittest) { if (utd.protection.kind == Prot.Kind.private_ || !utd.comment || !utd.fbody) continue; // Strip whitespaces to avoid showing empty summary const(char)* c = utd.comment; while (*c == ' ' || *c == '\t' || *c == '\n' || *c == '\r') ++c; buf.writestring("$(DDOC_EXAMPLES "); size_t o = buf.offset; buf.writestring(cast(char*)c); if (utd.codedoc) { auto codedoc = utd.codedoc.stripLeadingNewlines; size_t n = getCodeIndent(codedoc); while (n--) buf.writeByte(' '); buf.writestring("----\n"); buf.writestring(codedoc); buf.writestring("----\n"); highlightText(sc, a, loc, buf, o); } buf.writestring(")"); } } if (buf.offset == offset2) { /* Didn't write out any sections, so back out last write */ buf.offset = offset1; buf.writestring("\n"); } else buf.writestring(")"); } } /***************************************** * Return true if comment consists entirely of "ditto". */ private bool isDitto(const(char)* comment) { if (comment) { const(char)* p = skipwhitespace(comment); if (Port.memicmp(p, "ditto", 5) == 0 && *skipwhitespace(p + 5) == 0) return true; } return false; } /********************************************** * Skip white space. */ private const(char)* skipwhitespace(const(char)* p) { return skipwhitespace(p.toDString).ptr; } /// Ditto private const(char)[] skipwhitespace(const(char)[] p) { foreach (idx, char c; p) { switch (c) { case ' ': case '\t': case '\n': continue; default: return p[idx .. $]; } } return p[$ .. $]; } /************************************************ * Scan past all instances of the given characters. * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to start scanning from * chars = the characters to skip; order is unimportant * Returns: the index after skipping characters. */ private size_t skipChars(OutBuffer* buf, size_t i, string chars) { Outer: foreach (j, c; buf.peekSlice()[i..$]) { foreach (d; chars) { if (d == c) continue Outer; } return i + j; } return buf.offset; } unittest { OutBuffer buf; string data = "test ---\r\n\r\nend"; buf.write(data.ptr, data.length); assert(skipChars(&buf, 0, "-") == 0); assert(skipChars(&buf, 4, "-") == 4); assert(skipChars(&buf, 4, " -") == 8); assert(skipChars(&buf, 8, "\r\n") == 12); assert(skipChars(&buf, 12, "dne") == 15); } /**************************************************** * Replace all instances of `c` with `r` in the given string * Params: * s = the string to do replacements in * c = the character to look for * r = the string to replace `c` with * Returns: `s` with `c` replaced with `r` */ private inout(char)[] replaceChar(inout(char)[] s, char c, string r) pure { int count = 0; foreach (char sc; s) if (sc == c) ++count; if (count == 0) return s; char[] result; result.reserve(s.length - count + (r.length * count)); size_t start = 0; foreach (i, char sc; s) { if (sc == c) { result ~= s[start..i]; result ~= r; start = i+1; } } result ~= s[start..$]; return result; } /// unittest { assert("".replaceChar(',', "$(COMMA)") == ""); assert("ab".replaceChar(',', "$(COMMA)") == "ab"); assert("a,b".replaceChar(',', "$(COMMA)") == "a$(COMMA)b"); assert("a,,b".replaceChar(',', "$(COMMA)") == "a$(COMMA)$(COMMA)b"); assert(",ab".replaceChar(',', "$(COMMA)") == "$(COMMA)ab"); assert("ab,".replaceChar(',', "$(COMMA)") == "ab$(COMMA)"); } /** * Return a lowercased copy of a string. * Params: * s = the string to lowercase * Returns: the lowercase version of the string or the original if already lowercase */ private string toLowercase(string s) pure { string lower; foreach (size_t i; 0..s.length) { char c = s[i]; // TODO: maybe unicode lowercase, somehow if (c >= 'A' && c <= 'Z') { if (!lower.length) { lower.reserve(s.length); } lower ~= s[lower.length..i]; c += 'a' - 'A'; lower ~= c; } } if (lower.length) lower ~= s[lower.length..$]; else lower = s; return lower; } /// unittest { assert("".toLowercase == ""); assert("abc".toLowercase == "abc"); assert("ABC".toLowercase == "abc"); assert("aBc".toLowercase == "abc"); } /************************************************ * Get the indent from one index to another, counting tab stops as four spaces wide * per the Markdown spec. * Params: * buf = an OutBuffer containing the DDoc * from = the index within `buf` to start counting from, inclusive * to = the index within `buf` to stop counting at, exclusive * Returns: the indent */ private int getMarkdownIndent(OutBuffer* buf, size_t from, size_t to) { const slice = buf.peekSlice(); if (to > slice.length) to = slice.length; int indent = 0; foreach (const c; slice[from..to]) indent += (c == '\t') ? 4 - (indent % 4) : 1; return indent; } /************************************************ * Scan forward to one of: * start of identifier * beginning of next line * end of buf */ size_t skiptoident(OutBuffer* buf, size_t i) { const slice = buf.peekSlice(); while (i < slice.length) { dchar c; size_t oi = i; if (utf_decodeChar(slice.ptr, slice.length, i, c)) { /* Ignore UTF errors, but still consume input */ break; } if (c >= 0x80) { if (!isUniAlpha(c)) continue; } else if (!(isalpha(c) || c == '_' || c == '\n')) continue; i = oi; break; } return i; } /************************************************ * Scan forward past end of identifier. */ private size_t skippastident(OutBuffer* buf, size_t i) { const slice = buf.peekSlice(); while (i < slice.length) { dchar c; size_t oi = i; if (utf_decodeChar(slice.ptr, slice.length, i, c)) { /* Ignore UTF errors, but still consume input */ break; } if (c >= 0x80) { if (isUniAlpha(c)) continue; } else if (isalnum(c) || c == '_') continue; i = oi; break; } return i; } /************************************************ * Scan forward past URL starting at i. * We don't want to highlight parts of a URL. * Returns: * i if not a URL * index just past it if it is a URL */ private size_t skippastURL(OutBuffer* buf, size_t i) { const slice = buf.peekSlice()[i .. $]; size_t j; bool sawdot = false; if (slice.length > 7 && Port.memicmp(slice.ptr, "http://", 7) == 0) { j = 7; } else if (slice.length > 8 && Port.memicmp(slice.ptr, "https://", 8) == 0) { j = 8; } else goto Lno; for (; j < slice.length; j++) { const c = slice[j]; if (isalnum(c)) continue; if (c == '-' || c == '_' || c == '?' || c == '=' || c == '%' || c == '&' || c == '/' || c == '+' || c == '#' || c == '~') continue; if (c == '.') { sawdot = true; continue; } break; } if (sawdot) return i + j; Lno: return i; } /**************************************************** * Remove a previously-inserted blank line macro. * Params: * buf = an OutBuffer containing the DDoc * iAt = the index within `buf` of the start of the `$(DDOC_BLANKLINE)` * macro. Upon function return its value is set to `0`. * i = an index within `buf`. If `i` is after `iAt` then it gets * reduced by the length of the removed macro. */ private void removeBlankLineMacro(OutBuffer* buf, ref size_t iAt, ref size_t i) { if (!iAt) return; enum macroLength = "$(DDOC_BLANKLINE)".length; buf.remove(iAt, macroLength); if (i > iAt) i -= macroLength; iAt = 0; } /**************************************************** * Attempt to detect and replace a Markdown thematic break (HR). These are three * or more of the same delimiter, optionally with spaces or tabs between any of * them, e.g. `\n- - -\n` becomes `\n$(HR)\n` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` of the first character of a potential * thematic break. If the replacement is made `i` changes to * point to the closing parenthesis of the `$(HR)` macro. * iLineStart = the index within `buf` that the thematic break's line starts at * loc = the current location within the file * Returns: whether a thematic break was replaced */ private bool replaceMarkdownThematicBreak(OutBuffer* buf, ref size_t i, size_t iLineStart, const ref Loc loc) { if (!global.params.markdown) return false; const slice = buf.peekSlice(); const c = buf.data[i]; size_t j = i + 1; int repeat = 1; for (; j < slice.length; j++) { if (buf.data[j] == c) ++repeat; else if (buf.data[j] != ' ' && buf.data[j] != '\t') break; } if (repeat >= 3) { if (j >= buf.offset || buf.data[j] == '\n' || buf.data[j] == '\r') { if (global.params.vmarkdown) { const s = buf.peekSlice()[i..j]; message(loc, "Ddoc: converted '%.*s' to a thematic break", cast(int)s.length, s.ptr); } buf.remove(iLineStart, j - iLineStart); i = buf.insert(iLineStart, "$(HR)") - 1; return true; } } return false; } /**************************************************** * Detect the level of an ATX-style heading, e.g. `## This is a heading` would * have a level of `2`. * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` of the first `#` character * Returns: * the detected heading level from 1 to 6, or * 0 if not at an ATX heading */ private int detectAtxHeadingLevel(OutBuffer* buf, const size_t i) { if (!global.params.markdown) return 0; const iHeadingStart = i; const iAfterHashes = skipChars(buf, i, "#"); const headingLevel = cast(int) (iAfterHashes - iHeadingStart); if (headingLevel > 6) return 0; const iTextStart = skipChars(buf, iAfterHashes, " \t"); const emptyHeading = buf.data[iTextStart] == '\r' || buf.data[iTextStart] == '\n'; // require whitespace if (!emptyHeading && iTextStart == iAfterHashes) return 0; return headingLevel; } /**************************************************** * Remove any trailing `##` suffix from an ATX-style heading. * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to start looking for a suffix at */ private void removeAnyAtxHeadingSuffix(OutBuffer* buf, size_t i) { size_t j = i; size_t iSuffixStart = 0; size_t iWhitespaceStart = j; const slice = buf.peekSlice(); for (; j < slice.length; j++) { switch (slice[j]) { case '#': if (iWhitespaceStart && !iSuffixStart) iSuffixStart = j; continue; case ' ': case '\t': if (!iWhitespaceStart) iWhitespaceStart = j; continue; case '\r': case '\n': break; default: iSuffixStart = 0; iWhitespaceStart = 0; continue; } break; } if (iSuffixStart) buf.remove(iWhitespaceStart, j - iWhitespaceStart); } /**************************************************** * Wrap text in a Markdown heading macro, e.g. `$(H2 heading text`). * Params: * buf = an OutBuffer containing the DDoc * iStart = the index within `buf` that the Markdown heading starts at * iEnd = the index within `buf` of the character after the last * heading character. Is incremented by the length of the * inserted heading macro when this function ends. * loc = the location of the Ddoc within the file * headingLevel = the level (1-6) of heading to end. Is set to `0` when this * function ends. */ private void endMarkdownHeading(OutBuffer* buf, size_t iStart, ref size_t iEnd, const ref Loc loc, ref int headingLevel) { if (!global.params.markdown) return; if (global.params.vmarkdown) { const s = buf.peekSlice()[iStart..iEnd]; message(loc, "Ddoc: added heading '%.*s'", cast(int)s.length, s.ptr); } char[5] heading = "$(H0 "; heading[3] = cast(char) ('0' + headingLevel); buf.insert(iStart, heading); iEnd += 5; size_t iBeforeNewline = iEnd; while (buf.data[iBeforeNewline-1] == '\r' || buf.data[iBeforeNewline-1] == '\n') --iBeforeNewline; buf.insert(iBeforeNewline, ")"); headingLevel = 0; } /**************************************************** * Replace Markdown emphasis with the appropriate macro, * e.g. `*very* **nice**` becomes `$(EM very) $(STRONG nice)`. * Params: * buf = an OutBuffer containing the DDoc * loc = the current location within the file * inlineDelimiters = the collection of delimiters found within a paragraph. When this function returns its length will be reduced to `downToLevel`. * downToLevel = the length within `inlineDelimiters`` to reduce emphasis to * Returns: the number of characters added to the buffer by the replacements */ private size_t replaceMarkdownEmphasis(OutBuffer* buf, const ref Loc loc, ref MarkdownDelimiter[] inlineDelimiters, int downToLevel = 0) { if (!global.params.markdown) return 0; size_t replaceEmphasisPair(ref MarkdownDelimiter start, ref MarkdownDelimiter end) { immutable count = start.count == 1 || end.count == 1 ? 1 : 2; size_t iStart = start.iStart; size_t iEnd = end.iStart; end.count -= count; start.count -= count; iStart += start.count; if (!start.count) start.type = 0; if (!end.count) end.type = 0; if (global.params.vmarkdown) { const s = buf.peekSlice()[iStart + count..iEnd]; message(loc, "Ddoc: emphasized text '%.*s'", cast(int)s.length, s.ptr); } buf.remove(iStart, count); iEnd -= count; buf.remove(iEnd, count); string macroName = count >= 2 ? "$(STRONG " : "$(EM "; buf.insert(iEnd, ")"); buf.insert(iStart, macroName); const delta = 1 + macroName.length - (count + count); end.iStart += count; return delta; } size_t delta = 0; int start = (cast(int) inlineDelimiters.length) - 1; while (start >= downToLevel) { // find start emphasis while (start >= downToLevel && (inlineDelimiters[start].type != '*' || !inlineDelimiters[start].leftFlanking)) --start; if (start < downToLevel) break; // find the nearest end emphasis int end = start + 1; while (end < inlineDelimiters.length && (inlineDelimiters[end].type != inlineDelimiters[start].type || inlineDelimiters[end].macroLevel != inlineDelimiters[start].macroLevel || !inlineDelimiters[end].rightFlanking)) ++end; if (end == inlineDelimiters.length) { // the start emphasis has no matching end; if it isn't an end itself then kill it if (!inlineDelimiters[start].rightFlanking) inlineDelimiters[start].type = 0; --start; continue; } // multiple-of-3 rule if (((inlineDelimiters[start].leftFlanking && inlineDelimiters[start].rightFlanking) || (inlineDelimiters[end].leftFlanking && inlineDelimiters[end].rightFlanking)) && (inlineDelimiters[start].count + inlineDelimiters[end].count) % 3 == 0) { --start; continue; } immutable delta0 = replaceEmphasisPair(inlineDelimiters[start], inlineDelimiters[end]); for (; end < inlineDelimiters.length; ++end) inlineDelimiters[end].iStart += delta0; delta += delta0; } inlineDelimiters.length = downToLevel; return delta; } /**************************************************** */ private bool isIdentifier(Dsymbols* a, const(char)* p, size_t len) { foreach (member; *a) { if (p[0 .. len] == member.ident.toString()) return true; } return false; } /**************************************************** */ private bool isKeyword(const(char)* p, size_t len) { immutable string[3] table = ["true", "false", "null"]; foreach (s; table) { if (p[0 .. len] == s) return true; } return false; } /**************************************************** */ private TypeFunction isTypeFunction(Dsymbol s) { FuncDeclaration f = s.isFuncDeclaration(); /* f.type may be NULL for template members. */ if (f && f.type) { Type t = f.originalType ? f.originalType : f.type; if (t.ty == Tfunction) return cast(TypeFunction)t; } return null; } /**************************************************** */ private Parameter isFunctionParameter(Dsymbol s, const(char)* p, size_t len) { TypeFunction tf = isTypeFunction(s); if (tf && tf.parameterList.parameters) { foreach (fparam; *tf.parameterList.parameters) { if (fparam.ident && p[0 .. len] == fparam.ident.toString()) { return fparam; } } } return null; } /**************************************************** */ private Parameter isFunctionParameter(Dsymbols* a, const(char)* p, size_t len) { for (size_t i = 0; i < a.dim; i++) { Parameter fparam = isFunctionParameter((*a)[i], p, len); if (fparam) { return fparam; } } return null; } /**************************************************** */ private Parameter isEponymousFunctionParameter(Dsymbols *a, const(char) *p, size_t len) { for (size_t i = 0; i < a.dim; i++) { TemplateDeclaration td = (*a)[i].isTemplateDeclaration(); if (td && td.onemember) { /* Case 1: we refer to a template declaration inside the template /// ...ddoc... template case1(T) { void case1(R)() {} } */ td = td.onemember.isTemplateDeclaration(); } if (!td) { /* Case 2: we're an alias to a template declaration /// ...ddoc... alias case2 = case1!int; */ AliasDeclaration ad = (*a)[i].isAliasDeclaration(); if (ad && ad.aliassym) { td = ad.aliassym.isTemplateDeclaration(); } } while (td) { Dsymbol sym = getEponymousMember(td); if (sym) { Parameter fparam = isFunctionParameter(sym, p, len); if (fparam) { return fparam; } } td = td.overnext; } } return null; } /**************************************************** */ private TemplateParameter isTemplateParameter(Dsymbols* a, const(char)* p, size_t len) { for (size_t i = 0; i < a.dim; i++) { TemplateDeclaration td = (*a)[i].isTemplateDeclaration(); // Check for the parent, if the current symbol is not a template declaration. if (!td) td = getEponymousParent((*a)[i]); if (td && td.origParameters) { foreach (tp; *td.origParameters) { if (tp.ident && p[0 .. len] == tp.ident.toString()) { return tp; } } } } return null; } /**************************************************** * Return true if str is a reserved symbol name * that starts with a double underscore. */ private bool isReservedName(const(char)[] str) { immutable string[] table = [ "__ctor", "__dtor", "__postblit", "__invariant", "__unitTest", "__require", "__ensure", "__dollar", "__ctfe", "__withSym", "__result", "__returnLabel", "__vptr", "__monitor", "__gate", "__xopEquals", "__xopCmp", "__LINE__", "__FILE__", "__MODULE__", "__FUNCTION__", "__PRETTY_FUNCTION__", "__DATE__", "__TIME__", "__TIMESTAMP__", "__VENDOR__", "__VERSION__", "__EOF__", "__CXXLIB__", "__LOCAL_SIZE", "___tls_get_addr", "__entrypoint", ]; foreach (s; table) { if (str == s) return true; } return false; } /**************************************************** * A delimiter for Markdown inline content like emphasis and links. */ private struct MarkdownDelimiter { size_t iStart; /// the index where this delimiter starts int count; /// the length of this delimeter's start sequence int macroLevel; /// the count of nested DDoc macros when the delimiter is started bool leftFlanking; /// whether the delimiter is left-flanking, as defined by the CommonMark spec bool rightFlanking; /// whether the delimiter is right-flanking, as defined by the CommonMark spec bool atParagraphStart; /// whether the delimiter is at the start of a paragraph char type; /// the type of delimiter, defined by its starting character /// whether this describes a valid delimiter @property bool isValid() const { return count != 0; } /// flag this delimiter as invalid void invalidate() { count = 0; } } /**************************************************** * Info about a Markdown list. */ private struct MarkdownList { string orderedStart; /// an optional start number--if present then the list starts at this number size_t iStart; /// the index where the list item starts size_t iContentStart; /// the index where the content starts after the list delimiter int delimiterIndent; /// the level of indent the list delimiter starts at int contentIndent; /// the level of indent the content starts at int macroLevel; /// the count of nested DDoc macros when the list is started char type; /// the type of list, defined by its starting character /// whether this describes a valid list @property bool isValid() const { return type != type.init; } /**************************************************** * Try to parse a list item, returning whether successful. * Params: * buf = an OutBuffer containing the DDoc * iLineStart = the index within `buf` of the first character of the line * i = the index within `buf` of the potential list item * Returns: the parsed list item. Its `isValid` property describes whether parsing succeeded. */ static MarkdownList parseItem(OutBuffer* buf, size_t iLineStart, size_t i) { if (!global.params.markdown) return MarkdownList(); if (buf.data[i] == '+' || buf.data[i] == '-' || buf.data[i] == '*') return parseUnorderedListItem(buf, iLineStart, i); else return parseOrderedListItem(buf, iLineStart, i); } /**************************************************** * Return whether the context is at a list item of the same type as this list. * Params: * buf = an OutBuffer containing the DDoc * iLineStart = the index within `buf` of the first character of the line * i = the index within `buf` of the list item * Returns: whether `i` is at a list item of the same type as this list */ private bool isAtItemInThisList(OutBuffer* buf, size_t iLineStart, size_t i) { MarkdownList item = (type == '.' || type == ')') ? parseOrderedListItem(buf, iLineStart, i) : parseUnorderedListItem(buf, iLineStart, i); if (item.type == type) return item.delimiterIndent < contentIndent && item.contentIndent > delimiterIndent; return false; } /**************************************************** * Start a Markdown list item by creating/deleting nested lists and starting the item. * Params: * buf = an OutBuffer containing the DDoc * iLineStart = the index within `buf` of the first character of the line. If this function succeeds it will be adjuested to equal `i`. * i = the index within `buf` of the list item. If this function succeeds `i` will be adjusted to fit the inserted macro. * iPrecedingBlankLine = the index within `buf` of the preceeding blank line. If non-zero and a new list was started, the preceeding blank line is removed and this value is set to `0`. * nestedLists = a set of nested lists. If this function succeeds it may contain a new nested list. * loc = the location of the Ddoc within the file * Returns: `true` if a list was created */ bool startItem(OutBuffer* buf, ref size_t iLineStart, ref size_t i, ref size_t iPrecedingBlankLine, ref MarkdownList[] nestedLists, const ref Loc loc) { buf.remove(iStart, iContentStart - iStart); if (!nestedLists.length || delimiterIndent >= nestedLists[$-1].contentIndent || buf.data[iLineStart - 4..iLineStart] == "$(LI") { // start a list macro nestedLists ~= this; if (type == '.') { if (orderedStart.length) { iStart = buf.insert(iStart, "$(OL_START "); iStart = buf.insert(iStart, orderedStart); iStart = buf.insert(iStart, ",\n"); } else iStart = buf.insert(iStart, "$(OL\n"); } else iStart = buf.insert(iStart, "$(UL\n"); removeBlankLineMacro(buf, iPrecedingBlankLine, iStart); } else if (nestedLists.length) { nestedLists[$-1].delimiterIndent = delimiterIndent; nestedLists[$-1].contentIndent = contentIndent; } iStart = buf.insert(iStart, "$(LI\n"); i = iStart - 1; iLineStart = i; if (global.params.vmarkdown) { size_t iEnd = iStart; while (iEnd < buf.offset && buf.data[iEnd] != '\r' && buf.data[iEnd] != '\n') ++iEnd; const s = buf.peekSlice()[iStart..iEnd]; message(loc, "Ddoc: starting list item '%.*s'", cast(int)s.length, s.ptr); } return true; } /**************************************************** * End all nested Markdown lists. * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to end lists at. If there were lists `i` will be adjusted to fit the macro endings. * nestedLists = a set of nested lists. Upon return it will be empty. * Returns: the amount that `i` changed */ static size_t endAllNestedLists(OutBuffer* buf, ref size_t i, ref MarkdownList[] nestedLists) { const iStart = i; for (; nestedLists.length; --nestedLists.length) i = buf.insert(i, ")\n)"); return i - iStart; } /**************************************************** * Look for a sibling list item or the end of nested list(s). * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to end lists at. If there was a sibling or ending lists `i` will be adjusted to fit the macro endings. * iParagraphStart = the index within `buf` to start the next paragraph at at. May be adjusted upon return. * nestedLists = a set of nested lists. Some nested lists may have been removed from it upon return. */ static void handleSiblingOrEndingList(OutBuffer* buf, ref size_t i, ref size_t iParagraphStart, ref MarkdownList[] nestedLists) { size_t iAfterSpaces = skipChars(buf, i + 1, " \t"); if (nestedLists[$-1].isAtItemInThisList(buf, i + 1, iAfterSpaces)) { // end a sibling list item i = buf.insert(i, ")"); iParagraphStart = skipChars(buf, i, " \t\r\n"); } else if (iAfterSpaces >= buf.offset || (buf.data[iAfterSpaces] != '\r' && buf.data[iAfterSpaces] != '\n')) { // end nested lists that are indented more than this content const indent = getMarkdownIndent(buf, i + 1, iAfterSpaces); while (nestedLists.length && nestedLists[$-1].contentIndent > indent) { i = buf.insert(i, ")\n)"); --nestedLists.length; iParagraphStart = skipChars(buf, i, " \t\r\n"); if (nestedLists.length && nestedLists[$-1].isAtItemInThisList(buf, i + 1, iParagraphStart)) { i = buf.insert(i, ")"); ++iParagraphStart; break; } } } } /**************************************************** * Parse an unordered list item at the current position * Params: * buf = an OutBuffer containing the DDoc * iLineStart = the index within `buf` of the first character of the line * i = the index within `buf` of the list item * Returns: the parsed list item, or a list item with type `.init` if no list item is available */ private static MarkdownList parseUnorderedListItem(OutBuffer* buf, size_t iLineStart, size_t i) { if (i+1 < buf.offset && (buf.data[i] == '-' || buf.data[i] == '*' || buf.data[i] == '+') && (buf.data[i+1] == ' ' || buf.data[i+1] == '\t' || buf.data[i+1] == '\r' || buf.data[i+1] == '\n')) { const iContentStart = skipChars(buf, i + 1, " \t"); const delimiterIndent = getMarkdownIndent(buf, iLineStart, i); const contentIndent = getMarkdownIndent(buf, iLineStart, iContentStart); auto list = MarkdownList(null, iLineStart, iContentStart, delimiterIndent, contentIndent, 0, buf.data[i]); return list; } return MarkdownList(); } /**************************************************** * Parse an ordered list item at the current position * Params: * buf = an OutBuffer containing the DDoc * iLineStart = the index within `buf` of the first character of the line * i = the index within `buf` of the list item * Returns: the parsed list item, or a list item with type `.init` if no list item is available */ private static MarkdownList parseOrderedListItem(OutBuffer* buf, size_t iLineStart, size_t i) { size_t iAfterNumbers = skipChars(buf, i, "0123456789"); if (iAfterNumbers - i > 0 && iAfterNumbers - i <= 9 && iAfterNumbers + 1 < buf.offset && buf.data[iAfterNumbers] == '.' && (buf.data[iAfterNumbers+1] == ' ' || buf.data[iAfterNumbers+1] == '\t' || buf.data[iAfterNumbers+1] == '\r' || buf.data[iAfterNumbers+1] == '\n')) { const iContentStart = skipChars(buf, iAfterNumbers + 1, " \t"); const delimiterIndent = getMarkdownIndent(buf, iLineStart, i); const contentIndent = getMarkdownIndent(buf, iLineStart, iContentStart); size_t iNumberStart = skipChars(buf, i, "0"); if (iNumberStart == iAfterNumbers) --iNumberStart; auto orderedStart = buf.peekSlice()[iNumberStart .. iAfterNumbers]; if (orderedStart == "1") orderedStart = null; return MarkdownList(orderedStart.idup, iLineStart, iContentStart, delimiterIndent, contentIndent, 0, buf.data[iAfterNumbers]); } return MarkdownList(); } } /**************************************************** * A Markdown link. */ private struct MarkdownLink { string href; /// the link destination string title; /// an optional title for the link string label; /// an optional label for the link Dsymbol symbol; /// an optional symbol to link to /**************************************************** * Replace a Markdown link or link definition in the form of: * - Inline link: `[foo](url/ 'optional title')` * - Reference link: `[foo][bar]`, `[foo][]` or `[foo]` * - Link reference definition: `[bar]: url/ 'optional title'` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the potential link. * If this function succeeds it will be adjusted to fit the inserted link macro. * loc = the current location within the file * inlineDelimiters = previously parsed Markdown delimiters, including emphasis and link/image starts * delimiterIndex = the index within `inlineDelimiters` of the nearest link/image starting delimiter * linkReferences = previously parsed link references. When this function returns it may contain * additional previously unparsed references. * Returns: whether a reference link was found and replaced at `i` */ static bool replaceLink(OutBuffer* buf, ref size_t i, const ref Loc loc, ref MarkdownDelimiter[] inlineDelimiters, int delimiterIndex, ref MarkdownLinkReferences linkReferences) { const delimiter = inlineDelimiters[delimiterIndex]; MarkdownLink link; size_t iEnd = link.parseReferenceDefinition(buf, i, delimiter); if (iEnd > i) { i = delimiter.iStart; link.storeAndReplaceDefinition(buf, i, iEnd, linkReferences, loc); inlineDelimiters.length = delimiterIndex; return true; } iEnd = link.parseInlineLink(buf, i); if (iEnd == i) { iEnd = link.parseReferenceLink(buf, i, delimiter); if (iEnd > i) { const label = link.label; link = linkReferences.lookupReference(label, buf, i, loc); // check rightFlanking to avoid replacing things like int[string] if (!link.href.length && !delimiter.rightFlanking) link = linkReferences.lookupSymbol(label); if (!link.href.length) return false; } } if (iEnd == i) return false; immutable delta = replaceMarkdownEmphasis(buf, loc, inlineDelimiters, delimiterIndex); iEnd += delta; i += delta; if (global.params.vmarkdown) { const s = buf.peekSlice()[delimiter.iStart..iEnd]; message(loc, "Ddoc: linking '%.*s' to '%.*s'", cast(int)s.length, s.ptr, cast(int)link.href.length, link.href.ptr); } link.replaceLink(buf, i, iEnd, delimiter); return true; } /**************************************************** * Replace a Markdown link definition in the form of `[bar]: url/ 'optional title'` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the potential link. * If this function succeeds it will be adjusted to fit the inserted link macro. * inlineDelimiters = previously parsed Markdown delimiters, including emphasis and link/image starts * delimiterIndex = the index within `inlineDelimiters` of the nearest link/image starting delimiter * linkReferences = previously parsed link references. When this function returns it may contain * additional previously unparsed references. * loc = the current location in the file * Returns: whether a reference link was found and replaced at `i` */ static bool replaceReferenceDefinition(OutBuffer* buf, ref size_t i, ref MarkdownDelimiter[] inlineDelimiters, int delimiterIndex, ref MarkdownLinkReferences linkReferences, const ref Loc loc) { const delimiter = inlineDelimiters[delimiterIndex]; MarkdownLink link; size_t iEnd = link.parseReferenceDefinition(buf, i, delimiter); if (iEnd == i) return false; i = delimiter.iStart; link.storeAndReplaceDefinition(buf, i, iEnd, linkReferences, loc); inlineDelimiters.length = delimiterIndex; return true; } /**************************************************** * Parse a Markdown inline link in the form of `[foo](url/ 'optional title')` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the inline link. * Returns: the index at the end of parsing the link, or `i` if parsing failed. */ private size_t parseInlineLink(OutBuffer* buf, size_t i) { size_t iEnd = i + 1; if (iEnd >= buf.offset || buf.data[iEnd] != '(') return i; ++iEnd; if (!parseHref(buf, iEnd)) return i; iEnd = skipChars(buf, iEnd, " \t\r\n"); if (buf.data[iEnd] != ')') { if (parseTitle(buf, iEnd)) iEnd = skipChars(buf, iEnd, " \t\r\n"); } if (buf.data[iEnd] != ')') return i; return iEnd + 1; } /**************************************************** * Parse a Markdown reference link in the form of `[foo][bar]`, `[foo][]` or `[foo]` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the inline link. * delimiter = the delimiter that starts this link * Returns: the index at the end of parsing the link, or `i` if parsing failed. */ private size_t parseReferenceLink(OutBuffer* buf, size_t i, MarkdownDelimiter delimiter) { size_t iStart = i + 1; size_t iEnd = iStart; if (iEnd >= buf.offset || buf.data[iEnd] != '[' || (iEnd+1 < buf.offset && buf.data[iEnd+1] == ']')) { // collapsed reference [foo][] or shortcut reference [foo] iStart = delimiter.iStart + delimiter.count - 1; if (buf.data[iEnd] == '[') iEnd += 2; } parseLabel(buf, iStart); if (!label.length) return i; if (iEnd < iStart) iEnd = iStart; return iEnd; } /**************************************************** * Parse a Markdown reference definition in the form of `[bar]: url/ 'optional title'` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the inline link. * delimiter = the delimiter that starts this link * Returns: the index at the end of parsing the link, or `i` if parsing failed. */ private size_t parseReferenceDefinition(OutBuffer* buf, size_t i, MarkdownDelimiter delimiter) { if (!delimiter.atParagraphStart || delimiter.type != '[' || i+1 >= buf.offset || buf.data[i+1] != ':') return i; size_t iEnd = delimiter.iStart; parseLabel(buf, iEnd); if (label.length == 0 || iEnd != i + 1) return i; ++iEnd; iEnd = skipChars(buf, iEnd, " \t"); skipOneNewline(buf, iEnd); if (!parseHref(buf, iEnd) || href.length == 0) return i; iEnd = skipChars(buf, iEnd, " \t"); const requireNewline = !skipOneNewline(buf, iEnd); const iBeforeTitle = iEnd; if (parseTitle(buf, iEnd)) { iEnd = skipChars(buf, iEnd, " \t"); if (iEnd < buf.offset && buf.data[iEnd] != '\r' && buf.data[iEnd] != '\n') { // the title must end with a newline title.length = 0; iEnd = iBeforeTitle; } } iEnd = skipChars(buf, iEnd, " \t"); if (requireNewline && iEnd < buf.offset-1 && buf.data[iEnd] != '\r' && buf.data[iEnd] != '\n') return i; return iEnd; } /**************************************************** * Parse and normalize a Markdown reference label * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `[` character at the start of the label. * If this function returns a non-empty label then `i` will point just after the ']' at the end of the label. * Returns: the parsed and normalized label, possibly empty */ private bool parseLabel(OutBuffer* buf, ref size_t i) { if (buf.data[i] != '[') return false; const slice = buf.peekSlice(); size_t j = i + 1; // Some labels have already been en-symboled; handle that const inSymbol = j+15 < slice.length && slice[j..j+15] == "$(DDOC_PSYMBOL "; if (inSymbol) j += 15; for (; j < slice.length; ++j) { const c = slice[j]; switch (c) { case ' ': case '\t': case '\r': case '\n': if (label.length && label[$-1] != ' ') label ~= ' '; break; case ')': if (inSymbol && j+1 < slice.length && slice[j+1] == ']') { ++j; goto case ']'; } goto default; case '[': if (slice[j-1] != '\\') { label.length = 0; return false; } break; case ']': if (label.length && label[$-1] == ' ') --label.length; if (label.length) { i = j + 1; return true; } return false; default: label ~= c; break; } } label.length = 0; return false; } /**************************************************** * Parse and store a Markdown link URL, optionally enclosed in `<>` brackets * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the first character of the URL. * If this function succeeds `i` will point just after the the end of the URL. * Returns: whether a URL was found and parsed */ private bool parseHref(OutBuffer* buf, ref size_t i) { size_t j = skipChars(buf, i, " \t"); size_t iHrefStart = j; size_t parenDepth = 1; bool inPointy = false; const slice = buf.peekSlice(); for (; j < slice.length; j++) { switch (slice[j]) { case '<': if (!inPointy && j == iHrefStart) { inPointy = true; ++iHrefStart; } break; case '>': if (inPointy && slice[j-1] != '\\') goto LReturnHref; break; case '(': if (!inPointy && slice[j-1] != '\\') ++parenDepth; break; case ')': if (!inPointy && slice[j-1] != '\\') { --parenDepth; if (!parenDepth) goto LReturnHref; } break; case ' ': case '\t': case '\r': case '\n': if (inPointy) { // invalid link return false; } goto LReturnHref; default: break; } } if (inPointy) return false; LReturnHref: auto href = slice[iHrefStart .. j].dup; this.href = cast(string) percentEncode(removeEscapeBackslashes(href)).replaceChar(',', "$(COMMA)"); i = j; if (inPointy) ++i; return true; } /**************************************************** * Parse and store a Markdown link title, enclosed in parentheses or `'` or `"` quotes * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the first character of the title. * If this function succeeds `i` will point just after the the end of the title. * Returns: whether a title was found and parsed */ private bool parseTitle(OutBuffer* buf, ref size_t i) { size_t j = skipChars(buf, i, " \t"); if (j >= buf.offset) return false; char type = buf.data[j]; if (type != '"' && type != '\'' && type != '(') return false; if (type == '(') type = ')'; const iTitleStart = j + 1; size_t iNewline = 0; const slice = buf.peekSlice(); for (j = iTitleStart; j < slice.length; j++) { const c = slice[j]; switch (c) { case ')': case '"': case '\'': if (type == c && slice[j-1] != '\\') goto LEndTitle; iNewline = 0; break; case ' ': case '\t': case '\r': break; case '\n': if (iNewline) { // no blank lines in titles return false; } iNewline = j; break; default: iNewline = 0; break; } } return false; LEndTitle: auto title = slice[iTitleStart .. j].dup; this.title = cast(string) removeEscapeBackslashes(title). replaceChar(',', "$(COMMA)"). replaceChar('"', "$(QUOTE)"); i = j + 1; return true; } /**************************************************** * Replace a Markdown link or image with the appropriate macro * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `]` character of the inline link. * When this function returns it will be adjusted to the end of the inserted macro. * iLinkEnd = the index within `buf` that points just after the last character of the link * delimiter = the Markdown delimiter that started the link or image */ private void replaceLink(OutBuffer* buf, ref size_t i, size_t iLinkEnd, MarkdownDelimiter delimiter) { size_t iAfterLink = i - delimiter.count; string macroName; if (symbol) { macroName = "$(SYMBOL_LINK "; } else if (title.length) { if (delimiter.type == '[') macroName = "$(LINK_TITLE "; else macroName = "$(IMAGE_TITLE "; } else { if (delimiter.type == '[') macroName = "$(LINK2 "; else macroName = "$(IMAGE "; } buf.remove(delimiter.iStart, delimiter.count); buf.remove(i - delimiter.count, iLinkEnd - i); iLinkEnd = buf.insert(delimiter.iStart, macroName); iLinkEnd = buf.insert(iLinkEnd, href); iLinkEnd = buf.insert(iLinkEnd, ", "); iAfterLink += macroName.length + href.length + 2; if (title.length) { iLinkEnd = buf.insert(iLinkEnd, title); iLinkEnd = buf.insert(iLinkEnd, ", "); iAfterLink += title.length + 2; // Link macros with titles require escaping commas for (size_t j = iLinkEnd; j < iAfterLink; ++j) if (buf.data[j] == ',') { buf.remove(j, 1); j = buf.insert(j, "$(COMMA)") - 1; iAfterLink += 7; } } // TODO: if image, remove internal macros, leaving only text buf.insert(iAfterLink, ")"); i = iAfterLink; } /**************************************************** * Store the Markdown link definition and remove it from `buf` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` that points to the `[` character at the start of the link definition. * When this function returns it will be adjusted to exclude the link definition. * iEnd = the index within `buf` that points just after the end of the definition * linkReferences = previously parsed link references. When this function returns it may contain * an additional reference. * loc = the current location in the file */ private void storeAndReplaceDefinition(OutBuffer* buf, ref size_t i, size_t iEnd, ref MarkdownLinkReferences linkReferences, const ref Loc loc) { if (global.params.vmarkdown) message(loc, "Ddoc: found link reference '%.*s' to '%.*s'", cast(int)label.length, label.ptr, cast(int)href.length, href.ptr); // Remove the definition and trailing whitespace iEnd = skipChars(buf, iEnd, " \t\r\n"); buf.remove(i, iEnd - i); i -= 2; string lowercaseLabel = label.toLowercase(); if (lowercaseLabel !in linkReferences.references) linkReferences.references[lowercaseLabel] = this; } /**************************************************** * Remove Markdown escaping backslashes from the given string * Params: * s = the string to remove escaping backslashes from * Returns: `s` without escaping backslashes in it */ private static char[] removeEscapeBackslashes(char[] s) { if (!s.length) return s; // avoid doing anything if there isn't anything to escape size_t i; for (i = 0; i < s.length-1; ++i) if (s[i] == '\\' && ispunct(s[i+1])) break; if (i == s.length-1) return s; // copy characters backwards, then truncate size_t j = i + 1; s[i] = s[j]; for (++i, ++j; j < s.length; ++i, ++j) { if (j < s.length-1 && s[j] == '\\' && ispunct(s[j+1])) ++j; s[i] = s[j]; } s.length -= (j - i); return s; } /// unittest { assert(removeEscapeBackslashes("".dup) == ""); assert(removeEscapeBackslashes(`\a`.dup) == `\a`); assert(removeEscapeBackslashes(`.\`.dup) == `.\`); assert(removeEscapeBackslashes(`\.\`.dup) == `.\`); assert(removeEscapeBackslashes(`\.`.dup) == `.`); assert(removeEscapeBackslashes(`\.\.`.dup) == `..`); assert(removeEscapeBackslashes(`a\.b\.c`.dup) == `a.b.c`); } /**************************************************** * Percent-encode (AKA URL-encode) the given string * Params: * s = the string to percent-encode * Returns: `s` with special characters percent-encoded */ private static inout(char)[] percentEncode(inout(char)[] s) pure { static bool shouldEncode(char c) { return ((c < '0' && c != '!' && c != '#' && c != '$' && c != '%' && c != '&' && c != '\'' && c != '(' && c != ')' && c != '*' && c != '+' && c != ',' && c != '-' && c != '.' && c != '/') || (c > '9' && c < 'A' && c != ':' && c != ';' && c != '=' && c != '?' && c != '@') || (c > 'Z' && c < 'a' && c != '[' && c != ']' && c != '_') || (c > 'z' && c != '~')); } for (size_t i = 0; i < s.length; ++i) { if (shouldEncode(s[i])) { immutable static hexDigits = "0123456789ABCDEF"; immutable encoded1 = hexDigits[s[i] >> 4]; immutable encoded2 = hexDigits[s[i] & 0x0F]; s = s[0..i] ~ '%' ~ encoded1 ~ encoded2 ~ s[i+1..$]; i += 2; } } return s; } /// unittest { assert(percentEncode("") == ""); assert(percentEncode("aB12-._~/?") == "aB12-._~/?"); assert(percentEncode("<\n>") == "%3C%0A%3E"); } /************************************************** * Skip a single newline at `i` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to start looking at. * If this function succeeds `i` will point after the newline. * Returns: whether a newline was skipped */ private static bool skipOneNewline(OutBuffer* buf, ref size_t i) pure { if (i < buf.offset && buf.data[i] == '\r') ++i; if (i < buf.offset && buf.data[i] == '\n') { ++i; return true; } return false; } } /************************************************** * A set of Markdown link references. */ private struct MarkdownLinkReferences { MarkdownLink[string] references; // link references keyed by normalized label MarkdownLink[string] symbols; // link symbols keyed by name Scope* _scope; // the current scope bool extractedAll; // the index into the buffer of the last-parsed reference /************************************************** * Look up a reference by label, searching through the rest of the buffer if needed. * Symbols in the current scope are searched for if the DDoc doesn't define the reference. * Params: * label = the label to find the reference for * buf = an OutBuffer containing the DDoc * i = the index within `buf` to start searching for references at * loc = the current location in the file * Returns: a link. If the `href` member has a value then the reference is valid. */ MarkdownLink lookupReference(string label, OutBuffer* buf, size_t i, const ref Loc loc) { const lowercaseLabel = label.toLowercase(); if (lowercaseLabel !in references) extractReferences(buf, i, loc); if (lowercaseLabel in references) return references[lowercaseLabel]; return MarkdownLink(); } /** * Look up the link for the D symbol with the given name. * If found, the link is cached in the `symbols` member. * Params: * name = the name of the symbol * Returns: the link for the symbol or a link with a `null` href */ MarkdownLink lookupSymbol(string name) { if (name in symbols) return symbols[name]; const ids = split(name, '.'); MarkdownLink link; auto id = Identifier.lookup(ids[0].ptr, ids[0].length); if (id) { auto loc = Loc(); auto symbol = _scope.search(loc, id, null, IgnoreErrors); for (size_t i = 1; symbol && i < ids.length; ++i) { id = Identifier.lookup(ids[i].ptr, ids[i].length); symbol = id !is null ? symbol.search(loc, id, IgnoreErrors) : null; } if (symbol) link = MarkdownLink(createHref(symbol), null, name, symbol); } symbols[name] = link; return link; } /************************************************** * Remove and store all link references from the document, in the form of * `[label]: href "optional title"` * Params: * buf = an OutBuffer containing the DDoc * i = the index within `buf` to start looking at * loc = the current location in the file * Returns: whether a reference was extracted */ private void extractReferences(OutBuffer* buf, size_t i, const ref Loc loc) { static bool isFollowedBySpace(OutBuffer* buf, size_t i) { return i+1 < buf.offset && (buf.data[i+1] == ' ' || buf.data[i+1] == '\t'); } if (extractedAll) return; bool leadingBlank = false; int inCode = false; bool newParagraph = true; MarkdownDelimiter[] delimiters; for (; i < buf.offset; ++i) { const c = buf.data[i]; switch (c) { case ' ': case '\t': break; case '\n': if (leadingBlank && !inCode) newParagraph = true; leadingBlank = true; break; case '\\': ++i; break; case '#': if (leadingBlank && !inCode) newParagraph = true; leadingBlank = false; break; case '+': if (leadingBlank && !inCode && isFollowedBySpace(buf, i)) newParagraph = true; else leadingBlank = false; break; case '0': .. case '9': if (leadingBlank && !inCode) { i = skipChars(buf, i, "0123456789"); if (i < buf.offset && (buf.data[i] == '.' || buf.data[i] == ')') && isFollowedBySpace(buf, i)) newParagraph = true; else leadingBlank = false; } break; case '*': if (leadingBlank && !inCode) { newParagraph = true; if (!isFollowedBySpace(buf, i)) leadingBlank = false; } break; case '-': if (leadingBlank && !inCode && isFollowedBySpace(buf, i)) goto case '+'; else if (leadingBlank && i+2 < buf.offset && buf.data[i+1] == c && buf.data[i+2] == c) { inCode = inCode == c ? false : c; i = skipChars(buf, i, [c]) - 1; newParagraph = true; } leadingBlank = false; break; case '[': if (leadingBlank && !inCode && newParagraph) delimiters ~= MarkdownDelimiter(i, 1, 0, false, false, true, c); break; case ']': if (delimiters.length && !inCode && MarkdownLink.replaceReferenceDefinition(buf, i, delimiters, cast(int) delimiters.length - 1, this, loc)) --i; break; default: if (leadingBlank) newParagraph = false; leadingBlank = false; break; } } extractedAll = true; } /** * Split a string by a delimiter, excluding the delimiter. * Params: * s = the string to split * delimiter = the character to split by * Returns: the resulting array of strings */ private static string[] split(string s, char delimiter) pure { string[] result; size_t iStart = 0; foreach (size_t i; 0..s.length) if (s[i] == delimiter) { result ~= s[iStart..i]; iStart = i + 1; } result ~= s[iStart..$]; return result; } /// unittest { assert(split("", ',') == [""]); assert(split("ab", ',') == ["ab"]); assert(split("a,b", ',') == ["a", "b"]); assert(split("a,,b", ',') == ["a", "", "b"]); assert(split(",ab", ',') == ["", "ab"]); assert(split("ab,", ',') == ["ab", ""]); } /** * Create a HREF for the given D symbol. * The HREF is relative to the current location if possible. * Params: * symbol = the symbol to create a HREF for. * Returns: the resulting href */ private string createHref(Dsymbol symbol) { Dsymbol root = symbol; const(char)[] lref; while (symbol && symbol.ident && !symbol.isModule()) { if (lref.length) lref = '.' ~ lref; lref = symbol.ident.toString() ~ lref; symbol = symbol.parent; } const(char)[] path; if (symbol && symbol.ident && symbol.isModule() != _scope._module) { do { root = symbol; // If the module has a file name, we're done if (symbol.isModule() && symbol.isModule().docfile) { const docfilename = symbol.isModule().docfile.toChars(); path = docfilename[0..strlen(docfilename)]; break; } if (path.length) path = '_' ~ path; path = symbol.ident.toString() ~ path; symbol = symbol.parent; } while (symbol && symbol.ident); if (!symbol && path.length) path ~= "$(DOC_EXTENSION)"; } // Attempt an absolute URL if not in the same package while (root.parent) root = root.parent; Dsymbol scopeRoot = _scope._module; while (scopeRoot.parent) scopeRoot = scopeRoot.parent; if (scopeRoot != root) { path = "$(DOC_ROOT_" ~ root.ident.toString() ~ ')' ~ path; lref = '.' ~ lref; // remote URIs like Phobos and Mir use .prefixes } return cast(string) (path ~ '#' ~ lref); } } /************************************************** * Highlight text section. * * Params: * scope = the current parse scope * a = an array of D symbols at the current scope * loc = source location of start of text. It is a mutable copy to allow incrementing its linenum, for printing the correct line number when an error is encountered in a multiline block of ddoc. * buf = an OutBuffer containing the DDoc * offset = the index within buf to start highlighting */ private void highlightText(Scope* sc, Dsymbols* a, Loc loc, OutBuffer* buf, size_t offset) { const incrementLoc = loc.linnum == 0 ? 1 : 0; loc.linnum += incrementLoc; loc.charnum = 0; //printf("highlightText()\n"); bool leadingBlank = true; size_t iParagraphStart = offset; size_t iPrecedingBlankLine = 0; int headingLevel = 0; int headingMacroLevel = 0; MarkdownList[] nestedLists; MarkdownDelimiter[] inlineDelimiters; MarkdownLinkReferences linkReferences; int inCode = 0; int inBacktick = 0; int macroLevel = 0; int parenLevel = 0; size_t iCodeStart = 0; // start of code section size_t codeIndent = 0; size_t iLineStart = offset; linkReferences._scope = sc; for (size_t i = offset; i < buf.offset; i++) { char c = buf.data[i]; Lcont: switch (c) { case ' ': case '\t': break; case '\n': if (inBacktick) { // `inline code` is only valid if contained on a single line // otherwise, the backticks should be output literally. // // This lets things like `output from the linker' display // unmolested while keeping the feature consistent with GitHub. inBacktick = false; inCode = false; // the backtick also assumes we're in code // Nothing else is necessary since the DDOC_BACKQUOTED macro is // inserted lazily at the close quote, meaning the rest of the // text is already OK. } if (headingLevel) { i += replaceMarkdownEmphasis(buf, loc, inlineDelimiters); endMarkdownHeading(buf, iParagraphStart, i, loc, headingLevel); removeBlankLineMacro(buf, iPrecedingBlankLine, i); ++i; iParagraphStart = skipChars(buf, i, " \t\r\n"); } if (!inCode && nestedLists.length) { MarkdownList.handleSiblingOrEndingList(buf, i, iParagraphStart, nestedLists); } iPrecedingBlankLine = 0; if (!inCode && i == iLineStart && i + 1 < buf.offset) // if "\n\n" { i += replaceMarkdownEmphasis(buf, loc, inlineDelimiters); // if we don't already know about this paragraph break then // insert a blank line and record the paragraph break if (iParagraphStart <= i) { iPrecedingBlankLine = i; i = buf.insert(i, "$(DDOC_BLANKLINE)"); iParagraphStart = i + 1; } } leadingBlank = true; iLineStart = i + 1; loc.linnum += incrementLoc; break; case '<': { leadingBlank = false; if (inCode) break; const slice = buf.peekSlice(); auto p = &slice[i]; const se = sc._module.escapetable.escapeChar('<'); if (se == "&lt;") { // Generating HTML // Skip over comments if (p[1] == '!' && p[2] == '-' && p[3] == '-') { size_t j = i + 4; p += 4; while (1) { if (j == slice.length) goto L1; if (p[0] == '-' && p[1] == '-' && p[2] == '>') { i = j + 2; // place on closing '>' break; } j++; p++; } break; } // Skip over HTML tag if (isalpha(p[1]) || (p[1] == '/' && isalpha(p[2]))) { size_t j = i + 2; p += 2; while (1) { if (j == slice.length) break; if (p[0] == '>') { i = j; // place on closing '>' break; } j++; p++; } break; } } L1: // Replace '<' with '&lt;' character entity if (se.length) { buf.remove(i, 1); i = buf.insert(i, se); i--; // point to ';' } break; } case '>': { leadingBlank = false; if (inCode) break; // Replace '>' with '&gt;' character entity const se = sc._module.escapetable.escapeChar('>'); if (se.length) { buf.remove(i, 1); i = buf.insert(i, se); i--; // point to ';' } break; } case '&': { leadingBlank = false; if (inCode) break; char* p = cast(char*)&buf.data[i]; if (p[1] == '#' || isalpha(p[1])) break; // already a character entity // Replace '&' with '&amp;' character entity const se = sc._module.escapetable.escapeChar('&'); if (se) { buf.remove(i, 1); i = buf.insert(i, se); i--; // point to ';' } break; } case '`': { if (inBacktick) { inBacktick = 0; inCode = 0; OutBuffer codebuf; codebuf.write(buf.peekSlice().ptr + iCodeStart + 1, i - (iCodeStart + 1)); // escape the contents, but do not perform highlighting except for DDOC_PSYMBOL highlightCode(sc, a, &codebuf, 0); escapeStrayParenthesis(loc, &codebuf, 0, false); buf.remove(iCodeStart, i - iCodeStart + 1); // also trimming off the current ` immutable pre = "$(DDOC_BACKQUOTED "; i = buf.insert(iCodeStart, pre); i = buf.insert(i, codebuf.peekSlice()); i = buf.insert(i, ")"); i--; // point to the ending ) so when the for loop does i++, it will see the next character break; } if (inCode) break; inCode = 1; inBacktick = 1; codeIndent = 0; // inline code is not indented // All we do here is set the code flags and record // the location. The macro will be inserted lazily // so we can easily cancel the inBacktick if we come // across a newline character. iCodeStart = i; break; } case '#': { /* A line beginning with # indicates an ATX-style heading. */ if (leadingBlank && !inCode) { leadingBlank = false; headingLevel = detectAtxHeadingLevel(buf, i); if (!headingLevel) break; // remove the ### prefix, including whitespace i = skipChars(buf, i + headingLevel, " \t"); buf.remove(iLineStart, i - iLineStart); i = iParagraphStart = iLineStart; removeAnyAtxHeadingSuffix(buf, i); --i; headingMacroLevel = macroLevel; } break; } case '-': /* A line beginning with --- delimits a code section. * inCode tells us if it is start or end of a code section. */ if (leadingBlank) { if (!inCode) { const list = MarkdownList.parseItem(buf, iLineStart, i); if (list.isValid) { if (replaceMarkdownThematicBreak(buf, i, iLineStart, loc)) { removeBlankLineMacro(buf, iPrecedingBlankLine, i); iParagraphStart = skipChars(buf, i+1, " \t\r\n"); break; } else goto case '+'; } } size_t istart = i; size_t eollen = 0; leadingBlank = false; while (1) { ++i; if (i >= buf.offset) break; c = buf.data[i]; if (c == '\n') { eollen = 1; break; } if (c == '\r') { eollen = 1; if (i + 1 >= buf.offset) break; if (buf.data[i + 1] == '\n') { eollen = 2; break; } } // BUG: handle UTF PS and LS too if (c != '-') goto Lcont; } if (i - istart < 3) goto Lcont; // We have the start/end of a code section // Remove the entire --- line, including blanks and \n buf.remove(iLineStart, i - iLineStart + eollen); i = iLineStart; if (inCode && (i <= iCodeStart)) { // Empty code section, just remove it completely. inCode = 0; break; } if (inCode) { inCode = 0; // The code section is from iCodeStart to i OutBuffer codebuf; codebuf.write(buf.data + iCodeStart, i - iCodeStart); codebuf.writeByte(0); // Remove leading indentations from all lines bool lineStart = true; char* endp = cast(char*)codebuf.data + codebuf.offset; for (char* p = cast(char*)codebuf.data; p < endp;) { if (lineStart) { size_t j = codeIndent; char* q = p; while (j-- > 0 && q < endp && isIndentWS(q)) ++q; codebuf.remove(p - cast(char*)codebuf.data, q - p); assert(cast(char*)codebuf.data <= p); assert(p < cast(char*)codebuf.data + codebuf.offset); lineStart = false; endp = cast(char*)codebuf.data + codebuf.offset; // update continue; } if (*p == '\n') lineStart = true; ++p; } highlightCode2(sc, a, &codebuf, 0); escapeStrayParenthesis(loc, &codebuf, 0, false); buf.remove(iCodeStart, i - iCodeStart); i = buf.insert(iCodeStart, codebuf.peekSlice()); i = buf.insert(i, ")\n"); i -= 2; // in next loop, c should be '\n' } else { __gshared const(char)* d_code = "$(D_CODE "; inCode = 1; codeIndent = istart - iLineStart; // save indent count i = buf.insert(i, d_code, strlen(d_code)); iCodeStart = i; i--; // place i on > leadingBlank = true; } } break; case '_': { if (leadingBlank && !inCode && replaceMarkdownThematicBreak(buf, i, iLineStart, loc)) { removeBlankLineMacro(buf, iPrecedingBlankLine, i); iParagraphStart = skipChars(buf, i+1, " \t\r\n"); break; } goto default; } case '+': case '0': .. case '9': { if (leadingBlank && !inCode) { MarkdownList list = MarkdownList.parseItem(buf, iLineStart, i); if (list.isValid) { // Avoid starting a numbered list in the middle of a paragraph if (!nestedLists.length && list.orderedStart.length && iParagraphStart < iLineStart) { i += list.orderedStart.length - 1; break; } list.macroLevel = macroLevel; list.startItem(buf, iLineStart, i, iPrecedingBlankLine, nestedLists, loc); break; } } leadingBlank = false; break; } case '*': { if (inCode || inBacktick || !global.params.markdown) break; if (leadingBlank) { // Check for a thematic break if (replaceMarkdownThematicBreak(buf, i, iLineStart, loc)) { removeBlankLineMacro(buf, iPrecedingBlankLine, i); iParagraphStart = skipChars(buf, i+1, " \t\r\n"); break; } // An initial * indicates a Markdown list item const list = MarkdownList.parseItem(buf, iLineStart, i); if (list.isValid) goto case '+'; } // Markdown emphasis const leftC = i > offset ? buf.data[i-1] : '\0'; size_t iAfterEmphasis = skipChars(buf, i+1, "*"); const rightC = iAfterEmphasis < buf.offset ? buf.data[iAfterEmphasis] : '\0'; int count = cast(int) (iAfterEmphasis - i); const leftFlanking = (rightC != '\0' && !isspace(rightC)) && (!ispunct(rightC) || leftC == '\0' || isspace(leftC) || ispunct(leftC)); const rightFlanking = (leftC != '\0' && !isspace(leftC)) && (!ispunct(leftC) || rightC == '\0' || isspace(rightC) || ispunct(rightC)); auto emphasis = MarkdownDelimiter(i, count, macroLevel, leftFlanking, rightFlanking, false, c); if (!emphasis.leftFlanking && !emphasis.rightFlanking) { i = iAfterEmphasis - 1; break; } inlineDelimiters ~= emphasis; i += emphasis.count; --i; break; } case '!': { leadingBlank = false; if (inCode || !global.params.markdown) break; if (i < buf.offset-1 && buf.data[i+1] == '[') { const imageStart = MarkdownDelimiter(i, 2, macroLevel, false, false, false, c); inlineDelimiters ~= imageStart; ++i; } break; } case '[': { if (inCode || !global.params.markdown) { leadingBlank = false; break; } const leftC = i > offset ? buf.data[i-1] : '\0'; const rightFlanking = leftC != '\0' && !isspace(leftC) && !ispunct(leftC); const atParagraphStart = leadingBlank && iParagraphStart >= iLineStart; const linkStart = MarkdownDelimiter(i, 1, macroLevel, false, rightFlanking, atParagraphStart, c); inlineDelimiters ~= linkStart; leadingBlank = false; break; } case ']': { leadingBlank = false; if (inCode || !global.params.markdown) break; for (int d = cast(int) inlineDelimiters.length - 1; d >= 0; --d) { const delimiter = inlineDelimiters[d]; if (delimiter.type == '[' || delimiter.type == '!') { if (delimiter.isValid && MarkdownLink.replaceLink(buf, i, loc, inlineDelimiters, d, linkReferences)) { // don't nest links if (delimiter.type == '[') for (--d; d >= 0; --d) if (inlineDelimiters[d].type == '[') inlineDelimiters[d].invalidate(); } else { // nothing found, so kill the delimiter inlineDelimiters = inlineDelimiters[0..d] ~ inlineDelimiters[d+1..$]; } break; } } break; } case '\\': { leadingBlank = false; if (inCode || i+1 >= buf.offset || !global.params.markdown) break; /* Escape Markdown special characters */ char c1 = buf.data[i+1]; if (ispunct(c1)) { if (global.params.vmarkdown) message(loc, "Ddoc: backslash-escaped %c", c1); buf.remove(i, 1); auto se = sc._module.escapetable.escapeChar(c1); if (!se) se = c1 == '$' ? "$(DOLLAR)" : c1 == ',' ? "$(COMMA)" : null; if (se) { buf.remove(i, 1); i = buf.insert(i, se); i--; // point to escaped char } } break; } case '$': { /* Look for the start of a macro, '$(Identifier' */ leadingBlank = false; if (inCode || inBacktick) break; const slice = buf.peekSlice(); auto p = &slice[i]; if (p[1] == '(' && isIdStart(&p[2])) ++macroLevel; break; } case '(': { if (!inCode && i > offset && buf.data[i-1] != '$') ++parenLevel; break; } case ')': { /* End of macro */ leadingBlank = false; if (inCode || inBacktick) break; if (parenLevel > 0) --parenLevel; else if (macroLevel) { int downToLevel = cast(int) inlineDelimiters.length; while (downToLevel > 0 && inlineDelimiters[downToLevel - 1].macroLevel >= macroLevel) --downToLevel; i += replaceMarkdownEmphasis(buf, loc, inlineDelimiters, downToLevel); if (headingLevel && headingMacroLevel >= macroLevel) { endMarkdownHeading(buf, iParagraphStart, i, loc, headingLevel); removeBlankLineMacro(buf, iPrecedingBlankLine, i); } while (nestedLists.length && nestedLists[$-1].macroLevel >= macroLevel) { i = buf.insert(i, ")\n)"); --nestedLists.length; } --macroLevel; } break; } default: leadingBlank = false; if (sc._module.isDocFile || inCode) break; const start = cast(char*)buf.data + i; if (isIdStart(start)) { size_t j = skippastident(buf, i); if (i < j) { size_t k = skippastURL(buf, i); if (i < k) { /* The URL is buf[i..k] */ if (macroLevel) /* Leave alone if already in a macro */ i = k - 1; else { /* Replace URL with '$(DDOC_LINK_AUTODETECT URL)' */ i = buf.bracket(i, "$(DDOC_LINK_AUTODETECT ", k, ")") - 1; } break; } } else break; size_t len = j - i; // leading '_' means no highlight unless it's a reserved symbol name if (c == '_' && (i == 0 || !isdigit(*(start - 1))) && (i == buf.offset - 1 || !isReservedName(start[0 .. len]))) { buf.remove(i, 1); i = buf.bracket(i, "$(DDOC_AUTO_PSYMBOL_SUPPRESS ", j - 1, ")") - 1; break; } if (isIdentifier(a, start, len)) { i = buf.bracket(i, "$(DDOC_AUTO_PSYMBOL ", j, ")") - 1; break; } if (isKeyword(start, len)) { i = buf.bracket(i, "$(DDOC_AUTO_KEYWORD ", j, ")") - 1; break; } if (isFunctionParameter(a, start, len)) { //printf("highlighting arg '%s', i = %d, j = %d\n", arg.ident.toChars(), i, j); i = buf.bracket(i, "$(DDOC_AUTO_PARAM ", j, ")") - 1; break; } i = j - 1; } break; } } if (inCode) error(loc, "unmatched `---` in DDoc comment"); size_t i = buf.offset; i += replaceMarkdownEmphasis(buf, loc, inlineDelimiters); if (headingLevel) { endMarkdownHeading(buf, iParagraphStart, i, loc, headingLevel); removeBlankLineMacro(buf, iPrecedingBlankLine, i); } MarkdownList.endAllNestedLists(buf, i, nestedLists); } /************************************************** * Highlight code for DDOC section. */ private void highlightCode(Scope* sc, Dsymbol s, OutBuffer* buf, size_t offset) { //printf("highlightCode(s = %s '%s')\n", s.kind(), s.toChars()); OutBuffer ancbuf; emitAnchor(&ancbuf, s, sc); buf.insert(offset, ancbuf.peekSlice()); offset += ancbuf.offset; Dsymbols a; a.push(s); highlightCode(sc, &a, buf, offset); } /**************************************************** */ private void highlightCode(Scope* sc, Dsymbols* a, OutBuffer* buf, size_t offset) { //printf("highlightCode(a = '%s')\n", a.toChars()); bool resolvedTemplateParameters = false; for (size_t i = offset; i < buf.offset; i++) { char c = buf.data[i]; const se = sc._module.escapetable.escapeChar(c); if (se.length) { buf.remove(i, 1); i = buf.insert(i, se); i--; // point to ';' continue; } char* start = cast(char*)buf.data + i; if (isIdStart(start)) { size_t j = skippastident(buf, i); if (i < j) { size_t len = j - i; if (isIdentifier(a, start, len)) { i = buf.bracket(i, "$(DDOC_PSYMBOL ", j, ")") - 1; continue; } if (isFunctionParameter(a, start, len)) { //printf("highlighting arg '%s', i = %d, j = %d\n", arg.ident.toChars(), i, j); i = buf.bracket(i, "$(DDOC_PARAM ", j, ")") - 1; continue; } i = j - 1; } } else if (!resolvedTemplateParameters) { size_t previ = i; // hunt for template declarations: foreach (symi; 0 .. a.dim) { FuncDeclaration fd = (*a)[symi].isFuncDeclaration(); if (!fd || !fd.parent || !fd.parent.isTemplateDeclaration()) { continue; } TemplateDeclaration td = fd.parent.isTemplateDeclaration(); // build the template parameters Array!(size_t) paramLens; paramLens.reserve(td.parameters.dim); OutBuffer parametersBuf; HdrGenState hgs; parametersBuf.writeByte('('); foreach (parami; 0 .. td.parameters.dim) { TemplateParameter tp = (*td.parameters)[parami]; if (parami) parametersBuf.writestring(", "); size_t lastOffset = parametersBuf.offset; .toCBuffer(tp, &parametersBuf, &hgs); paramLens[parami] = parametersBuf.offset - lastOffset; } parametersBuf.writeByte(')'); const templateParams = parametersBuf.peekSlice(); //printf("templateDecl: %s\ntemplateParams: %s\nstart: %s\n", td.toChars(), templateParams, start); if (start[0 .. templateParams.length] == templateParams) { immutable templateParamListMacro = "$(DDOC_TEMPLATE_PARAM_LIST "; buf.bracket(i, templateParamListMacro.ptr, i + templateParams.length, ")"); // We have the parameter list. While we're here we might // as well wrap the parameters themselves as well // + 1 here to take into account the opening paren of the // template param list i += templateParamListMacro.length + 1; foreach (const len; paramLens) { i = buf.bracket(i, "$(DDOC_TEMPLATE_PARAM ", i + len, ")"); // increment two here for space + comma i += 2; } resolvedTemplateParameters = true; // reset i to be positioned back before we found the template // param list this assures that anything within the template // param list that needs to be escaped or otherwise altered // has an opportunity for that to happen outside of this context i = previ; continue; } } } } } /**************************************** */ private void highlightCode3(Scope* sc, OutBuffer* buf, const(char)* p, const(char)* pend) { for (; p < pend; p++) { const se = sc._module.escapetable.escapeChar(*p); if (se.length) buf.writestring(se); else buf.writeByte(*p); } } /************************************************** * Highlight code for CODE section. */ private void highlightCode2(Scope* sc, Dsymbols* a, OutBuffer* buf, size_t offset) { uint errorsave = global.startGagging(); scope diagnosticReporter = new StderrDiagnosticReporter(global.params.useDeprecated); scope Lexer lex = new Lexer(null, cast(char*)buf.data, 0, buf.offset - 1, 0, 1, diagnosticReporter); OutBuffer res; const(char)* lastp = cast(char*)buf.data; //printf("highlightCode2('%.*s')\n", cast(int)(buf.offset - 1), buf.data); res.reserve(buf.offset); while (1) { Token tok; lex.scan(&tok); highlightCode3(sc, &res, lastp, tok.ptr); const(char)* highlight = null; switch (tok.value) { case TOK.identifier: { if (!sc) break; size_t len = lex.p - tok.ptr; if (isIdentifier(a, tok.ptr, len)) { highlight = "$(D_PSYMBOL "; break; } if (isFunctionParameter(a, tok.ptr, len)) { //printf("highlighting arg '%s', i = %d, j = %d\n", arg.ident.toChars(), i, j); highlight = "$(D_PARAM "; break; } break; } case TOK.comment: highlight = "$(D_COMMENT "; break; case TOK.string_: highlight = "$(D_STRING "; break; default: if (tok.isKeyword()) highlight = "$(D_KEYWORD "; break; } if (highlight) { res.writestring(highlight); size_t o = res.offset; highlightCode3(sc, &res, tok.ptr, lex.p); if (tok.value == TOK.comment || tok.value == TOK.string_) /* https://issues.dlang.org/show_bug.cgi?id=7656 * https://issues.dlang.org/show_bug.cgi?id=7715 * https://issues.dlang.org/show_bug.cgi?id=10519 */ escapeDdocString(&res, o); res.writeByte(')'); } else highlightCode3(sc, &res, tok.ptr, lex.p); if (tok.value == TOK.endOfFile) break; lastp = lex.p; } buf.setsize(offset); buf.write(&res); global.endGagging(errorsave); } /**************************************** * Determine if p points to the start of a "..." parameter identifier. */ private bool isCVariadicArg(const(char)[] p) { return p.length >= 3 && p[0 .. 3] == "..."; } /**************************************** * Determine if p points to the start of an identifier. */ bool isIdStart(const(char)* p) { dchar c = *p; if (isalpha(c) || c == '_') return true; if (c >= 0x80) { size_t i = 0; if (utf_decodeChar(p, 4, i, c)) return false; // ignore errors if (isUniAlpha(c)) return true; } return false; } /**************************************** * Determine if p points to the rest of an identifier. */ bool isIdTail(const(char)* p) { dchar c = *p; if (isalnum(c) || c == '_') return true; if (c >= 0x80) { size_t i = 0; if (utf_decodeChar(p, 4, i, c)) return false; // ignore errors if (isUniAlpha(c)) return true; } return false; } /**************************************** * Determine if p points to the indentation space. */ private bool isIndentWS(const(char)* p) { return (*p == ' ') || (*p == '\t'); } /***************************************** * Return number of bytes in UTF character. */ int utfStride(const(char)* p) { dchar c = *p; if (c < 0x80) return 1; size_t i = 0; utf_decodeChar(p, 4, i, c); // ignore errors, but still consume input return cast(int)i; } private inout(char)* stripLeadingNewlines(inout(char)* s) { while (s && *s == '\n' || *s == '\r') s++; return s; }
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 <benoit@tionex.de> *******************************************************************************/ module org.eclipse.swt.custom.StyledTextListener; import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.internal.SWTEventListener; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.TypedListener; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.ExtendedModifyEvent; import org.eclipse.swt.custom.ExtendedModifyListener; import org.eclipse.swt.custom.StyledTextEvent; import org.eclipse.swt.custom.LineBackgroundEvent; import org.eclipse.swt.custom.BidiSegmentEvent; import org.eclipse.swt.custom.LineStyleEvent; import org.eclipse.swt.custom.PaintObjectEvent; import org.eclipse.swt.custom.MovementEvent; import org.eclipse.swt.custom.TextChangedEvent; import org.eclipse.swt.custom.TextChangingEvent; import org.eclipse.swt.custom.LineBackgroundListener; import org.eclipse.swt.custom.BidiSegmentListener; import org.eclipse.swt.custom.LineStyleListener; import org.eclipse.swt.custom.PaintObjectListener; import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.custom.StyledTextContent; import org.eclipse.swt.custom.TextChangeListener; import org.eclipse.swt.custom.MovementListener; class StyledTextListener : TypedListener { /** */ this(SWTEventListener listener) { super(listener); } /** * Process StyledText events by invoking the event's handler. * * @param e the event to handle */ public override void handleEvent(Event e) { switch (e.type) { case StyledText.ExtendedModify: ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent( cast(StyledTextEvent) e); (cast(ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent); break; case StyledText.LineGetBackground: LineBackgroundEvent lineBgEvent = new LineBackgroundEvent(cast(StyledTextEvent) e); (cast(LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent); (cast(StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground; break; case StyledText.LineGetSegments: BidiSegmentEvent segmentEvent = new BidiSegmentEvent(cast(StyledTextEvent) e); (cast(BidiSegmentListener) eventListener).lineGetSegments(segmentEvent); (cast(StyledTextEvent) e).segments = segmentEvent.segments; break; case StyledText.LineGetStyle: LineStyleEvent lineStyleEvent = new LineStyleEvent(cast(StyledTextEvent) e); (cast(LineStyleListener) eventListener).lineGetStyle(lineStyleEvent); (cast(StyledTextEvent) e).ranges = lineStyleEvent.ranges; (cast(StyledTextEvent) e).styles = lineStyleEvent.styles; (cast(StyledTextEvent) e).alignment = lineStyleEvent.alignment; (cast(StyledTextEvent) e).indent = lineStyleEvent.indent; (cast(StyledTextEvent) e).justify = lineStyleEvent.justify; (cast(StyledTextEvent) e).bullet = lineStyleEvent.bullet; (cast(StyledTextEvent) e).bulletIndex = lineStyleEvent.bulletIndex; break; case StyledText.PaintObject: PaintObjectEvent paintObjectEvent = new PaintObjectEvent(cast(StyledTextEvent) e); (cast(PaintObjectListener) eventListener).paintObject(paintObjectEvent); break; case StyledText.VerifyKey: VerifyEvent verifyEvent = new VerifyEvent(e); (cast(VerifyKeyListener) eventListener).verifyKey(verifyEvent); e.doit = verifyEvent.doit; break; case StyledText.TextChanged: { TextChangedEvent textChangedEvent = new TextChangedEvent( cast(StyledTextContent) e.data); (cast(TextChangeListener) eventListener).textChanged(textChangedEvent); break; } case StyledText.TextChanging: TextChangingEvent textChangingEvent = new TextChangingEvent( cast(StyledTextContent) e.data, cast(StyledTextEvent) e); (cast(TextChangeListener) eventListener).textChanging(textChangingEvent); break; case StyledText.TextSet: { TextChangedEvent textChangedEvent = new TextChangedEvent( cast(StyledTextContent) e.data); (cast(TextChangeListener) eventListener).textSet(textChangedEvent); break; } case StyledText.WordNext: { MovementEvent wordBoundaryEvent = new MovementEvent(cast(StyledTextEvent) e); (cast(MovementListener) eventListener).getNextOffset(wordBoundaryEvent); (cast(StyledTextEvent) e).end = wordBoundaryEvent.newOffset; break; } case StyledText.WordPrevious: { MovementEvent wordBoundaryEvent = new MovementEvent(cast(StyledTextEvent) e); (cast(MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent); (cast(StyledTextEvent) e).end = wordBoundaryEvent.newOffset; break; } default: } } }
D
/** Contains definitions for customizing DDOX behavior. Copyright: © 2012 RejectedSoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Sönke Ludwig */ module ddox.settings; import vibe.inet.url; enum SortMode { None, Name } enum NavigationType { ModuleList, ModuleTree, DeclarationTree, } class DdoxSettings { NavigationType navigationType = NavigationType.ModuleTree; SortMode moduleSort = SortMode.Name; SortMode declSort = SortMode.None; string[] packageOrder; bool inheritDocumentation = true; bool mergeEponymousTemplates = true; bool oldJsonFormat; // DMD <= 2.061 } class GeneratorSettings { NavigationType navigationType = NavigationType.ModuleTree; // used for sitemap generation and for determining the URL prefix in registerApiDocs() Url siteUrl = Url.parse("http://localhost:8080/"); }
D
import std....stdio; import std.algorithm.iteration; import std.exception; double beta1(double[] x, double[] y, double x_bar, double y_bar) { /** Calculates the slope parameter for the linear regression of 'y' wrt 'x' */ enforce(x.length==y.length, "x and y should be the same length!"); double num=0, denom=0; int whilectr = 0; while (whilectr < x.length) { num += (x[whilectr] - x_bar) * (y[whilectr] - y_bar); whilectr++; } foreach (xval; x) denom += ((xval-x_bar)*(xval-x_bar)); return num / denom; } void main() { /+ Everything is done, so sit back and enjoy! /+ Nested comments should be supported, no matter what's inside /*//*/ +/ +/ double[] x = [0b1, 2, 3, 4, 5, 6.5, 7, 7.5, 8_000/1.0e+03, 8.5]; double[] y = [1, 2, 3, 3.2, 3.4, 40e-1, 4.2, 4.3, 4.35, 4.37]; double x_bar, y_bar, b1, _0; //Mean and regression parameters calculation x_bar = sum(x)/(cast(double)x.length); y_bar = sum(y)/(cast(double)y.length); b1 = beta1(x, y, x_bar, y_bar); _0 = y_bar - (b1*x_bar); /**/ /* Print result */ /**/ writefln("\"Slope\": %f", b1); writefln("\"Intercept\": %f", _0); ///Parsing tests. Comment to compile a = /+ // +/ 1; a = /+ "+/" +/ 1"; a = /+ /* +/ *2/ 3; }
D
/Users/pacmac/Documents/GitHub/Blockchain/substarte_blockchain/substrate-node-template/target/debug/deps/libref_cast_impl-b19b5e79d8ffa8ce.dylib: /Users/pacmac/.cargo/registry/src/github.com-1ecc6299db9ec823/ref-cast-impl-1.0.6/src/lib.rs /Users/pacmac/Documents/GitHub/Blockchain/substarte_blockchain/substrate-node-template/target/debug/deps/ref_cast_impl-b19b5e79d8ffa8ce.d: /Users/pacmac/.cargo/registry/src/github.com-1ecc6299db9ec823/ref-cast-impl-1.0.6/src/lib.rs /Users/pacmac/.cargo/registry/src/github.com-1ecc6299db9ec823/ref-cast-impl-1.0.6/src/lib.rs:
D
/** * Other global optimizations * * Copyright: Copyright (C) 1986-1998 by Symantec * Copyright (C) 2000-2021 by The D Language Foundation, All Rights Reserved * Authors: $(LINK2 https://www.digitalmars.com, Walter Bright) * License: Distributed under the Boost Software License, Version 1.0. * https://www.boost.org/LICENSE_1_0.txt * Source: https://github.com/dlang/dmd/blob/master/src/dmd/backend/gother.d * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/backend/gother.d * Documentation: https://dlang.org/phobos/dmd_backend_gother.html */ module dmd.backend.gother; version (SCPP) version = COMPILE; version (MARS) version = COMPILE; version (COMPILE) { import core.stdc.stdio; import core.stdc.stdlib; import core.stdc.time; import dmd.backend.cc; import dmd.backend.cdef; import dmd.backend.code_x86; import dmd.backend.oper; import dmd.backend.global; import dmd.backend.goh; import dmd.backend.el; import dmd.backend.symtab; import dmd.backend.ty; import dmd.backend.type; import dmd.backend.barray; import dmd.backend.dlist; import dmd.backend.dvec; nothrow: @safe: @trusted char symbol_isintab(const Symbol *s) { return sytab[s.Sclass] & SCSS; } extern (C++): version (SCPP) import parser; version (MARS) import dmd.backend.errors; /**********************************************************************/ alias Elemdatas = Rarray!(Elemdata); // Lists to help identify ranges of variables struct Elemdata { nothrow: elem *pelem; // the elem in question block *pblock; // which block it's in Barray!(elem*) rdlist; // list of definition elems for *pelem /*************************** * Reset memory so this allocation can be re-used. */ @trusted void reset() { rdlist.reset(); } /****************** * Initialize instance at ed. */ void emplace(elem *e,block *b) { this.pelem = e; this.pblock = b; } } /******************************** * Find `e` in Elemdata list. * Params: * e = elem to find * Returns: * Elemdata entry if found, * null if not */ @trusted Elemdata* find(ref Elemdatas eds, elem *e) { foreach (ref edl; eds) { if (edl.pelem == e) return &edl; } return null; } /***************** * Free list of Elemdata's. */ private void elemdatafree(ref Elemdatas eds) { foreach (ref ed; eds) ed.reset(); eds.reset(); } private __gshared { Elemdatas eqeqlist; // array of Elemdata's of OPeqeq & OPne elems Elemdatas rellist; // array of Elemdata's of relop elems Elemdatas inclist; // array of Elemdata's of increment elems } /*************************** Constant Propagation ***************************/ /************************** * Constant propagation. * Also detects use of variable before any possible def. */ @trusted void constprop() { rd_compute(); intranges(rellist, inclist); // compute integer ranges eqeqranges(eqeqlist); // see if we can eliminate some relationals elemdatafree(eqeqlist); elemdatafree(rellist); elemdatafree(inclist); } /************************************ * Compute reaching definitions. * Note: RD vectors are destroyed by this. */ private __gshared block *thisblock; @trusted private void rd_compute() { if (debugc) printf("constprop()\n"); assert(dfo); flowrd(); /* compute reaching definitions (rd) */ if (go.defnod.length == 0) /* if no reaching defs */ return; assert(rellist.length == 0 && inclist.length == 0 && eqeqlist.length == 0); block_clearvisit(); foreach (b; dfo[]) // for each block { switch (b.BC) { case BCjcatch: case BC_finally: case BC_lpad: case BCasm: case BCcatch: block_visit(b); break; default: break; } } foreach (i, b; dfo[]) // for each block { thisblock = b; //printf("block %d Bin ",i); vec_println(b.Binrd); //printf(" Bout "); vec_println(b.Boutrd); if (b.Bflags & BFLvisited) continue; // not reliable for this block if (b.Belem) { conpropwalk(b.Belem,b.Binrd); debug if (!(vec_equal(b.Binrd,b.Boutrd))) { int j; printf("block %d Binrd ", cast(int) i); vec_println(b.Binrd); printf(" Boutrd "); vec_println(b.Boutrd); WReqn(b.Belem); printf("\n"); vec_xorass(b.Binrd,b.Boutrd); j = cast(int)vec_index(0,b.Binrd); WReqn(go.defnod[j].DNelem); printf("\n"); } assert(vec_equal(b.Binrd,b.Boutrd)); } } } /*************************** * Support routine for constprop(). * Visit each elem in order * If elem is a reference to a variable, and * all the reaching defs of that variable are * defining it to be a specific constant, * Replace reference with that constant. * Generate warning if no reaching defs for a * variable, and the variable is on the stack * or in a register. * If elem is an assignment or function call or OPasm * Modify vector of reaching defs. */ @trusted private void conpropwalk(elem *n,vec_t IN) { vec_t L,R; elem *t; assert(n && IN); //printf("conpropwalk()\n"),elem_print(n); const op = n.Eoper; if (op == OPcolon || op == OPcolon2) { L = vec_clone(IN); switch (el_returns(n.EV.E1) * 2 | el_returns(n.EV.E2)) { case 3: // E1 and E2 return conpropwalk(n.EV.E1,L); conpropwalk(n.EV.E2,IN); vec_orass(IN,L); // IN = L | R break; case 2: // E1 returns conpropwalk(n.EV.E1,IN); conpropwalk(n.EV.E2,L); break; case 1: // E2 returns conpropwalk(n.EV.E1,L); conpropwalk(n.EV.E2,IN); break; case 0: // neither returns conpropwalk(n.EV.E1,L); vec_copy(L,IN); conpropwalk(n.EV.E2,L); break; default: break; } vec_free(L); } else if (op == OPandand || op == OPoror) { conpropwalk(n.EV.E1,IN); R = vec_clone(IN); conpropwalk(n.EV.E2,R); if (el_returns(n.EV.E2)) vec_orass(IN,R); // IN |= R vec_free(R); } else if (OTunary(op)) goto L3; else if (ERTOL(n)) { conpropwalk(n.EV.E2,IN); L3: t = n.EV.E1; if (OTassign(op)) { if (t.Eoper == OPvar) { // Note that the following ignores OPnegass if (OTopeq(op) && sytab[t.EV.Vsym.Sclass] & SCRD) { Barray!(elem*) rdl; listrds(IN,t,null,&rdl); if (!(config.flags & CFGnowarning)) // if warnings are enabled chkrd(t,rdl); if (auto e = chkprop(t,rdl)) { // Replace (t op= exp) with (t = e op exp) e = el_copytree(e); e.Ety = t.Ety; n.EV.E2 = el_bin(opeqtoop(op),n.Ety,e,n.EV.E2); n.Eoper = OPeq; } rdl.dtor(); } } else conpropwalk(t,IN); } else conpropwalk(t,IN); } else if (OTbinary(op)) { if (OTassign(op)) { t = n.EV.E1; if (t.Eoper != OPvar) conpropwalk(t,IN); } else conpropwalk(n.EV.E1,IN); conpropwalk(n.EV.E2,IN); } // Collect data for subsequent optimizations if (OTbinary(op) && n.EV.E1.Eoper == OPvar && n.EV.E2.Eoper == OPconst) { switch (op) { case OPlt: case OPgt: case OPle: case OPge: // Collect compare elems and their rd's in the rellist list if (tyintegral(n.EV.E1.Ety) && tyintegral(n.EV.E2.Ety) ) { //printf("appending to rellist\n"); elem_print(n); //printf("\trellist IN: "); vec_print(IN); printf("\n"); auto pdata = rellist.push(); pdata.emplace(n,thisblock); listrds(IN, n.EV.E1, null, &pdata.rdlist); } break; case OPaddass: case OPminass: case OPpostinc: case OPpostdec: // Collect increment elems and their rd's in the inclist list if (tyintegral(n.EV.E1.Ety)) { //printf("appending to inclist\n"); elem_print(n); //printf("\tinclist IN: "); vec_print(IN); printf("\n"); auto pdata = inclist.push(); pdata.emplace(n,thisblock); listrds(IN, n.EV.E1, null, &pdata.rdlist); } break; case OPne: case OPeqeq: // Collect compare elems and their rd's in the rellist list if (tyintegral(n.EV.E1.Ety)) { //printf("appending to eqeqlist\n"); elem_print(n); auto pdata = eqeqlist.push(); pdata.emplace(n,thisblock); listrds(IN, n.EV.E1, null, &pdata.rdlist); } break; default: break; } } if (OTdef(op)) /* if definition elem */ updaterd(n,IN,null); /* then update IN vector */ /* now we get to the part that checks to see if we can */ /* propagate a constant. */ if (op == OPvar && sytab[n.EV.Vsym.Sclass] & SCRD) { //printf("const prop: %s\n", n.EV.Vsym.Sident); Barray!(elem*) rdl; listrds(IN,n,null,&rdl); if (!(config.flags & CFGnowarning)) // if warnings are enabled chkrd(n,rdl); elem *e = chkprop(n,rdl); if (e) { tym_t nty; nty = n.Ety; el_copy(n,e); n.Ety = nty; // retain original type } rdl.dtor(); } } /****************************** * Give error if there are no reaching defs for variable v. */ @trusted private void chkrd(elem *n, Barray!(elem*) rdlist) { Symbol *sv; int unambig; sv = n.EV.Vsym; assert(sytab[sv.Sclass] & SCRD); if (sv.Sflags & SFLnord) // if already printed a warning return; if (sv.ty() & (mTYvolatile | mTYshared)) return; unambig = sv.Sflags & SFLunambig; foreach (d; rdlist) { elem_debug(d); if (d.Eoper == OPasm) /* OPasm elems ruin everything */ return; if (OTassign(d.Eoper)) { if (d.EV.E1.Eoper == OPvar) { if (d.EV.E1.EV.Vsym == sv) return; } else if (!unambig) return; } else { if (!unambig) return; } } // If there are any asm blocks, don't print the message foreach (b; dfo[]) if (b.BC == BCasm) return; // If variable contains bit fields, don't print message (because if // bit field is the first set, then we get a spurious warning). // STL uses 0 sized structs to transmit type information, so // don't complain about them being used before set. if (type_struct(sv.Stype)) { if (sv.Stype.Ttag.Sstruct.Sflags & (STRbitfields | STR0size)) return; } static if (0) { // If variable is zero length static array, don't print message. // BUG: Suppress error even if variable is initialized with void. if (sv.Stype.Tty == TYarray && sv.Stype.Tdim == 0) { printf("sv.Sident = %s\n", sv.Sident); return; } } version (SCPP) { { OutBuffer buf; char *p2; type_tostring(&buf, sv.Stype); buf.writeByte(' '); buf.write(sv.Sident.ptr); p2 = buf.toString(); warerr(WM.WM_used_b4_set, p2); // variable used before set } } //version (MARS) version(none) { /* Watch out for: void test() { void[0] x; auto y = x; } */ if (type_size(sv.Stype) != 0) { error(n.Esrcpos.Sfilename, n.Esrcpos.Slinnum, n.Esrcpos.Scharnum, "variable %s used before set", sv.Sident.ptr); } } sv.Sflags |= SFLnord; // no redundant messages //elem_print(n); } /********************************** * Look through the vector of reaching defs (IN) to see * if all defs of n are of the same constant. If so, replace * n with that constant. * Bit fields are gross, so don't propagate anything with assignments * to a bit field. * Note the flaw in the reaching def vector. There is currently no way * to detect RDs from when the function is invoked, i.e. RDs for parameters, * statics and globals. This could be fixed by adding dummy defs for * them before startblock, but we just kludge it and don't propagate * stuff for them. * Returns: * null do not propagate constant * e constant elem that we should replace n with */ @trusted private elem * chkprop(elem *n, Barray!(elem*) rdlist) { elem *foundelem = null; int unambig; Symbol *sv; tym_t nty; uint nsize; targ_size_t noff; //printf("checkprop: "); WReqn(n); printf("\n"); assert(n && n.Eoper == OPvar); elem_debug(n); sv = n.EV.Vsym; assert(sytab[sv.Sclass] & SCRD); nty = n.Ety; if (!tyscalar(nty)) goto noprop; nsize = cast(uint)size(nty); noff = n.EV.Voffset; unambig = sv.Sflags & SFLunambig; foreach (d; rdlist) { elem_debug(d); //printf("\trd: "); WReqn(d); printf("\n"); if (d.Eoper == OPasm) /* OPasm elems ruin everything */ goto noprop; // Runs afoul of Buzilla 4506 /*if (OTassign(d.Eoper) && EBIN(d))*/ // if assignment elem if (OTassign(d.Eoper)) // if assignment elem { elem *t = d.EV.E1; if (t.Eoper == OPvar) { assert(t.EV.Vsym == sv); if (d.Eoper == OPstreq || !tyscalar(t.Ety)) goto noprop; // not worth bothering with these cases if (d.Eoper == OPnegass) goto noprop; // don't bother with this case, either /* Everything must match or we must skip this variable */ /* (in case of assigning to overlapping unions, etc.) */ if (t.EV.Voffset != noff || /* If sizes match, we are ok */ size(t.Ety) != nsize && !(d.EV.E2.Eoper == OPconst && size(t.Ety) > nsize && !tyfloating(d.EV.E2.Ety))) goto noprop; } else { if (unambig) /* unambiguous assignments only */ continue; goto noprop; } if (d.Eoper != OPeq) goto noprop; } else /* must be a call elem */ { if (unambig) continue; else goto noprop; /* could be affected */ } if (d.EV.E2.Eoper == OPconst || d.EV.E2.Eoper == OPrelconst) { if (foundelem) /* already found one */ { /* then they must be the same */ if (!el_match(foundelem,d.EV.E2)) goto noprop; } else /* else this is it */ foundelem = d.EV.E2; } else goto noprop; } if (foundelem) /* if we got one */ { /* replace n with foundelem */ debug if (debugc) { printf("const prop ("); WReqn(n); printf(" replaced by "); WReqn(foundelem); printf("), %p to %p\n",foundelem,n); } go.changes++; return foundelem; } noprop: return null; } /*********************************** * Find all the reaching defs of OPvar e. * Params: * IN = vector of definition nodes * e = OPvar * f = if not null, set RD bits in it * rdlist = if not null, append reaching defs to it */ @trusted void listrds(vec_t IN,elem *e,vec_t f, Barray!(elem*)* rdlist) { uint i; uint unambig; Symbol *s; uint nsize; targ_size_t noff; tym_t ty; //printf("listrds: "); WReqn(e); printf("\n"); assert(IN); assert(e.Eoper == OPvar); s = e.EV.Vsym; ty = e.Ety; if (tyscalar(ty)) nsize = cast(uint)size(ty); noff = e.EV.Voffset; unambig = s.Sflags & SFLunambig; if (f) vec_clear(f); for (i = 0; (i = cast(uint) vec_index(i, IN)) < go.defnod.length; ++i) { elem *d = go.defnod[i].DNelem; //printf("\tlooking at "); WReqn(d); printf("\n"); const op = d.Eoper; if (op == OPasm) // assume ASM elems define everything goto listit; if (OTassign(op)) { elem *t = d.EV.E1; if (t.Eoper == OPvar && t.EV.Vsym == s) { if (op == OPstreq) goto listit; if (!tyscalar(ty) || !tyscalar(t.Ety)) goto listit; // If t does not overlap e, then it doesn't affect things if (noff + nsize > t.EV.Voffset && t.EV.Voffset + size(t.Ety) > noff) goto listit; // it's an assignment to s } else if (t.Eoper != OPvar && !unambig) goto listit; /* assignment through pointer */ } else if (!unambig) goto listit; /* probably a function call */ continue; listit: //printf("\tlisting "); WReqn(d); printf("\n"); if (f) vec_setbit(i,f); else (*rdlist).push(d); // add the definition node } } /******************************************** * Look at reaching defs for expressions of the form (v == c) and (v != c). * If all definitions of v are c or are not c, then we can replace the * expression with 1 or 0. * Params: * eqeqlist = array of == and != expressions */ @trusted private void eqeqranges(ref Elemdatas eqeqlist) { Symbol *v; int sz; elem *e; targ_llong c; int result; foreach (ref rel; eqeqlist) { e = rel.pelem; v = e.EV.E1.EV.Vsym; if (!(sytab[v.Sclass] & SCRD)) continue; sz = tysize(e.EV.E1.Ety); c = el_tolong(e.EV.E2); result = -1; // result not known yet foreach (erd; rel.rdlist) { elem *erd1; int szrd; int tmp; elem_debug(erd); if (erd.Eoper != OPeq || (erd1 = erd.EV.E1).Eoper != OPvar || erd.EV.E2.Eoper != OPconst ) goto L1; szrd = tysize(erd1.Ety); if (erd1.EV.Voffset + szrd <= e.EV.E1.EV.Voffset || e.EV.E1.EV.Voffset + sz <= erd1.EV.Voffset) continue; // doesn't affect us, skip it if (szrd != sz || e.EV.E1.EV.Voffset != erd1.EV.Voffset) goto L1; // overlapping - forget it tmp = (c == el_tolong(erd.EV.E2)); if (result == -1) result = tmp; else if (result != tmp) goto L1; } if (result >= 0) { //printf("replacing with %d\n",result); el_free(e.EV.E1); el_free(e.EV.E2); e.EV.Vint = (e.Eoper == OPeqeq) ? result : result ^ 1; e.Eoper = OPconst; } L1: } } /****************************** * Examine rellist and inclist to determine if any of the signed compare * elems in rellist can be replace by unsigned compares. * Params: * rellist = array of relationals in function * inclist = array of increment elems in function */ @trusted private void intranges(ref Elemdatas rellist, ref Elemdatas inclist) { block *rb; block *ib; Symbol *v; elem *rdeq; elem *rdinc; uint incop,relatop; targ_llong initial,increment,final_; if (debugc) printf("intranges()\n"); static if (0) { foreach (int i, ref rel; rellist) { printf("[%d] rel.pelem: ", i); WReqn(rel.pelem); printf("\n"); } } foreach (ref rel; rellist) { rb = rel.pblock; //printf("rel.pelem: "); WReqn(rel.pelem); printf("\n"); assert(rel.pelem.EV.E1.Eoper == OPvar); v = rel.pelem.EV.E1.EV.Vsym; // RD info is only reliable for registers and autos if (!(sytab[v.Sclass] & SCRD)) continue; /* Look for two rd's: an = and an increment */ if (rel.rdlist.length != 2) continue; rdeq = rel.rdlist[1]; if (rdeq.Eoper != OPeq) { rdinc = rdeq; rdeq = rel.rdlist[0]; if (rdeq.Eoper != OPeq) continue; } else rdinc = rel.rdlist[0]; static if (0) { printf("\neq: "); WReqn(rdeq); printf("\n"); printf("rel: "); WReqn(rel.pelem); printf("\n"); printf("inc: "); WReqn(rdinc); printf("\n"); } incop = rdinc.Eoper; if (!OTpost(incop) && incop != OPaddass && incop != OPminass) continue; /* lvalues should be unambiguous defs */ if (rdeq.EV.E1.Eoper != OPvar || rdinc.EV.E1.Eoper != OPvar) continue; /* rvalues should be constants */ if (rdeq.EV.E2.Eoper != OPconst || rdinc.EV.E2.Eoper != OPconst) continue; /* Ensure that the only defs reaching the increment elem (rdinc) */ /* are rdeq and rdinc. */ foreach (ref iel; inclist) { elem *rd1; elem *rd2; ib = iel.pblock; if (iel.pelem != rdinc) continue; /* not our increment elem */ if (iel.rdlist.length != 2) { //printf("!= 2\n"); break; } rd1 = iel.rdlist[0]; rd2 = iel.rdlist[1]; /* The rd's for the relational elem (rdeq,rdinc) must be */ /* the same as the rd's for tne increment elem (rd1,rd2). */ if (rd1 == rdeq && rd2 == rdinc || rd1 == rdinc && rd2 == rdeq) goto found; } goto nextrel; found: // Check that all paths from rdinc to rdinc must pass through rdrel { int i; // ib: block of increment // rb: block of relational i = loopcheck(ib,ib,rb); block_clearvisit(); if (i) continue; } /* Gather initial, increment, and final values for loop */ initial = el_tolong(rdeq.EV.E2); increment = el_tolong(rdinc.EV.E2); if (incop == OPpostdec || incop == OPminass) increment = -increment; relatop = rel.pelem.Eoper; final_ = el_tolong(rel.pelem.EV.E2); //printf("initial = %d, increment = %d, final_ = %d\n",initial,increment,final_); /* Determine if we can make the relational an unsigned */ if (initial >= 0) { if (final_ == 0 && relatop == OPge) { /* if the relation is (i >= 0) there is likely some dependency * on switching sign, so do not make it unsigned */ } else if (final_ >= initial) { if (increment > 0 && ((final_ - initial) % increment) == 0) goto makeuns; } else if (final_ >= 0) { /* 0 <= final_ < initial */ if (increment < 0 && ((final_ - initial) % increment) == 0 && !(final_ + increment < 0 && (relatop == OPge || relatop == OPlt) ) ) { makeuns: if (!tyuns(rel.pelem.EV.E2.Ety)) { rel.pelem.EV.E2.Ety = touns(rel.pelem.EV.E2.Ety); rel.pelem.Nflags |= NFLtouns; debug if (debugc) { WReqn(rel.pelem); printf(" made unsigned, initial = %lld, increment = %lld," ~ " final_ = %lld\n",cast(long)initial,cast(long)increment,cast(long)final_); } go.changes++; } static if (0) { // Eliminate loop if it is empty if (relatop == OPlt && rb.BC == BCiftrue && list_block(rb.Bsucc) == rb && rb.Belem.Eoper == OPcomma && rb.Belem.EV.E1 == rdinc && rb.Belem.EV.E2 == rel.pelem ) { rel.pelem.Eoper = OPeq; rel.pelem.Ety = rel.pelem.EV.E1.Ety; rb.BC = BCgoto; list_subtract(&rb.Bsucc,rb); list_subtract(&rb.Bpred,rb); debug if (debugc) { WReqn(rel.pelem); printf(" eliminated loop\n"); } go.changes++; } } } } } nextrel: } } /****************************** * Look for initialization and increment expressions in loop. * Very similar to intranges(). * Params: * rellist = list of relationals in function * inclist = list of increment elems in function. * erel = loop compare expression of the form (v < c) * rdeq = set to loop initialization of v * rdinc = set to loop increment of v * Returns: * false if cannot find rdeq or rdinc */ @trusted private bool returnResult(bool result) { elemdatafree(eqeqlist); elemdatafree(rellist); elemdatafree(inclist); return result; } @trusted bool findloopparameters(elem* erel, ref elem* rdeq, ref elem* rdinc) { if (debugc) printf("findloopparameters()\n"); const bool log = false; assert(erel.EV.E1.Eoper == OPvar); Symbol* v = erel.EV.E1.EV.Vsym; // RD info is only reliable for registers and autos if (!(sytab[v.Sclass] & SCRD)) return false; rd_compute(); // compute rellist, inclist, eqeqlist /* Find `erel` in `rellist` */ Elemdata* rel = rellist.find(erel); if (!rel) { if (log) printf("\trel not found\n"); return returnResult(false); } block* rb = rel.pblock; //printf("rel.pelem: "); WReqn(rel.pelem); printf("\n"); // Look for one reaching definition: an increment if (rel.rdlist.length != 1) { if (log) printf("\tnitems = %d\n", cast(int)rel.rdlist.length); return returnResult(false); } rdinc = rel.rdlist[0]; static if (0) { printf("\neq: "); WReqn(rdeq); printf("\n"); printf("rel: "); WReqn(rel.pelem); printf("\n"); printf("inc: "); WReqn(rdinc); printf("\n"); } uint incop = rdinc.Eoper; if (!OTpost(incop) && incop != OPaddass && incop != OPminass) { if (log) printf("\tnot += or -=\n"); return returnResult(false); } Elemdata* iel = inclist.find(rdinc); if (!iel) { if (log) printf("\trdinc not found\n"); return returnResult(false); } /* The increment should have two reaching definitions: * the initialization * the increment itself * We already have the increment (as rdinc), but need the initialization (rdeq) */ if (iel.rdlist.length != 2) { if (log) printf("nitems != 2\n"); return returnResult(false); } elem *rd1 = iel.rdlist[0]; elem *rd2 = iel.rdlist[1]; if (rd1 == rdinc) rdeq = rd2; else if (rd2 == rdinc) rdeq = rd1; else { if (log) printf("\tnot (rdeq,rdinc)\n"); return returnResult(false); } // lvalues should be unambiguous defs if (rdeq.Eoper != OPeq || rdeq.EV.E1.Eoper != OPvar || rdinc.EV.E1.Eoper != OPvar) { if (log) printf("\tnot OPvar\n"); return returnResult(false); } // rvalues should be constants if (rdeq.EV.E2.Eoper != OPconst || rdinc.EV.E2.Eoper != OPconst) { if (log) printf("\tnot OPconst\n"); return returnResult(false); } /* Check that all paths from rdinc to rdinc must pass through rdrel * iel.pblock = block of increment * rel.pblock = block of relational */ int i = loopcheck(iel.pblock,iel.pblock,rel.pblock); block_clearvisit(); if (i) { if (log) printf("\tnot loopcheck()\n"); return returnResult(false); } return returnResult(true); } /*********************** * Return true if there is a path from start to inc without * passing through rel. */ @trusted private int loopcheck(block *start,block *inc,block *rel) { if (!(start.Bflags & BFLvisited)) { start.Bflags |= BFLvisited; /* guarantee eventual termination */ foreach (list; ListRange(start.Bsucc)) { block *b = cast(block *) list_ptr(list); if (b != rel && (b == inc || loopcheck(b,inc,rel))) return true; } } return false; } /**************************** * Do copy propagation. * Copy propagation elems are of the form OPvar=OPvar, and they are * in go.expnod[]. */ @trusted void copyprop() { out_regcand(&globsym); if (debugc) printf("copyprop()\n"); assert(dfo); Louter: while (1) { flowcp(); /* compute available copy statements */ if (go.exptop <= 1) return; // none available static if (0) { foreach (i; 1 .. go.exptop) { printf("go.expnod[%d] = (",i); WReqn(go.expnod[i]); printf(");\n"); } } foreach (i, b; dfo[]) // for each block { if (b.Belem) { bool recalc; static if (0) { printf("B%d, elem (",i); WReqn(b.Belem); printf(")\nBin "); vec_println(b.Bin); recalc = copyPropWalk(b.Belem,b.Bin); printf("Bino "); vec_println(b.Bin); printf("Bout "); vec_println(b.Bout); } else { recalc = copyPropWalk(b.Belem,b.Bin); } /*assert(vec_equal(b.Bin,b.Bout)); */ /* The previous assert() is correct except */ /* for the following case: */ /* a=b; d=a; a=b; */ /* The vectors don't match because the */ /* equations changed to: */ /* a=b; d=b; a=b; */ /* and the d=b copy elem now reaches the end */ /* of the block (the d=a elem didn't). */ if (recalc) continue Louter; } } return; } } /***************************** * Walk tree n, doing copy propagation as we go. * Keep IN up to date. * Params: * n = tree to walk & do copy propagation in * IN = vector of live copy expressions, updated as progress is made * Returns: * true if need to recalculate data flow equations and try again */ @trusted private bool copyPropWalk(elem *n,vec_t IN) { bool recalc = false; int nocp = 0; void cpwalk(elem* n, vec_t IN) { assert(n && IN); /*chkvecdim(go.exptop,0);*/ if (recalc) return; elem *t; const op = n.Eoper; if (op == OPcolon || op == OPcolon2) { vec_t L = vec_clone(IN); cpwalk(n.EV.E1,L); cpwalk(n.EV.E2,IN); vec_andass(IN,L); // IN = L & R vec_free(L); } else if (op == OPandand || op == OPoror) { cpwalk(n.EV.E1,IN); vec_t L = vec_clone(IN); cpwalk(n.EV.E2,L); vec_andass(IN,L); // IN = L & R vec_free(L); } else if (OTunary(op)) { t = n.EV.E1; if (OTassign(op)) { if (t.Eoper == OPind) cpwalk(t.EV.E1,IN); } else if (op == OPctor || op == OPdtor) { /* This kludge is necessary because in except_pop() * an el_match is done on the lvalue. If copy propagation * changes the OPctor but not the corresponding OPdtor, * then the match won't happen and except_pop() * will fail. */ nocp++; cpwalk(t,IN); nocp--; } else cpwalk(t,IN); } else if (OTassign(op)) { cpwalk(n.EV.E2,IN); t = n.EV.E1; if (t.Eoper == OPind) cpwalk(t,IN); else { debug if (t.Eoper != OPvar) elem_print(n); assert(t.Eoper == OPvar); } } else if (ERTOL(n)) { cpwalk(n.EV.E2,IN); cpwalk(n.EV.E1,IN); } else if (OTbinary(op)) { cpwalk(n.EV.E1,IN); cpwalk(n.EV.E2,IN); } if (OTdef(op)) // if definition elem { int ambig; /* true if ambiguous def */ ambig = !OTassign(op) || t.Eoper == OPind; uint i; for (i = 0; (i = cast(uint) vec_index(i, IN)) < go.exptop; ++i) // for each active copy elem { Symbol *v; if (op == OPasm) goto clr; /* If this elem could kill the lvalue or the rvalue, */ /* Clear bit in IN. */ v = go.expnod[i].EV.E1.EV.Vsym; if (ambig) { if (!(v.Sflags & SFLunambig)) goto clr; } else { if (v == t.EV.Vsym) goto clr; } v = go.expnod[i].EV.E2.EV.Vsym; if (ambig) { if (!(v.Sflags & SFLunambig)) goto clr; } else { if (v == t.EV.Vsym) goto clr; } continue; clr: /* this copy elem is not available */ vec_clearbit(i,IN); /* so remove it from the vector */ } /* foreach */ /* If this is a copy elem in go.expnod[] */ /* Set bit in IN. */ if ((op == OPeq || op == OPstreq) && n.EV.E1.Eoper == OPvar && n.EV.E2.Eoper == OPvar && n.Eexp) vec_setbit(n.Eexp,IN); } else if (op == OPvar && !nocp) // if reference to variable v { Symbol *v = n.EV.Vsym; //printf("Checking copyprop for '%s', ty=x%x\n", v.Sident.ptr,n.Ety); symbol_debug(v); const ty = n.Ety; uint sz = tysize(n.Ety); if (sz == -1 && !tyfunc(n.Ety)) sz = cast(uint)type_size(v.Stype); elem *foundelem = null; Symbol *f; for (uint i = 0; (i = cast(uint) vec_index(i, IN)) < go.exptop; ++i) // for all active copy elems { elem* c = go.expnod[i]; assert(c); uint csz = tysize(c.EV.E1.Ety); if (c.Eoper == OPstreq) csz = cast(uint)type_size(c.ET); assert(cast(int)csz >= 0); //printf(" looking at: ("); WReqn(c); printf("), ty=x%x\n",c.EV.E1.Ety); /* Not only must symbol numbers match, but */ /* offsets too (in case of arrays) and sizes */ /* (in case of unions). */ if (v == c.EV.E1.EV.Vsym && n.EV.Voffset >= c.EV.E1.EV.Voffset && n.EV.Voffset + sz <= c.EV.E1.EV.Voffset + csz) { if (foundelem) { if (c.EV.E2.EV.Vsym != f) goto noprop; } else { foundelem = c; f = foundelem.EV.E2.EV.Vsym; } } } if (foundelem) /* if we can do the copy prop */ { debug if (debugc) { printf("Copyprop, '%s'(%d) replaced with '%s'(%d)\n", (v.Sident[0]) ? cast(char *)v.Sident.ptr : "temp".ptr, cast(int) v.Ssymnum, (f.Sident[0]) ? cast(char *)f.Sident.ptr : "temp".ptr, cast(int) f.Ssymnum); } type *nt = n.ET; targ_size_t noffset = n.EV.Voffset; el_copy(n,foundelem.EV.E2); n.Ety = ty; // retain original type n.ET = nt; n.EV.Voffset += noffset - foundelem.EV.E1.EV.Voffset; /* original => rewrite * v = f * g = v => g = f * f = x * d = g => d = f !!error * Therefore, if n appears as an rvalue in go.expnod[], then recalc */ for (size_t j = 1; j < go.exptop; ++j) { //printf("go.expnod[%d]: ", j); elem_print(go.expnod[j]); if (go.expnod[j].EV.E2 == n) { recalc = true; break; } } go.changes++; } //else printf("not found\n"); noprop: { } } } cpwalk(n, IN); return recalc; } /******************************** * Remove dead assignments. Those are assignments to a variable v * for which there are no subsequent uses of v. */ private __gshared { Barray!(elem*) assnod; /* array of pointers to asg elems */ vec_t ambigref; /* vector of assignment elems that */ /* are referenced when an ambiguous */ /* reference is done (as in *p or call) */ } @trusted void rmdeadass() { if (debugc) printf("rmdeadass()\n"); flowlv(); /* compute live variables */ foreach (b; dfo[]) // for each block b { if (!b.Belem) /* if no elems at all */ continue; if (b.Btry) // if in try-block guarded body continue; const assnum = numasg(b.Belem); // # of assignment elems if (assnum == 0) // if no assignment elems continue; assnod.setLength(assnum); // pre-allocate sufficient room vec_t DEAD = vec_calloc(assnum); vec_t POSS = vec_calloc(assnum); ambigref = vec_calloc(assnum); assnod.setLength(0); accumda(b.Belem,DEAD,POSS); // fill assnod[], compute DEAD and POSS assert(assnum == assnod.length); vec_free(ambigref); vec_orass(POSS,DEAD); /* POSS |= DEAD */ for (uint j = 0; (j = cast(uint) vec_index(j, POSS)) < assnum; ++j) // for each possible dead asg. { Symbol *v; /* v = target of assignment */ elem *n; elem *nv; n = assnod[j]; nv = n.EV.E1; v = nv.EV.Vsym; if (!symbol_isintab(v)) // not considered continue; //printf("assnod[%d]: ",j); WReqn(n); printf("\n"); //printf("\tPOSS\n"); /* If not positively dead but v is live on a */ /* successor to b, then v is live. */ //printf("\tDEAD=%d, live=%d\n",vec_testbit(j,DEAD),vec_testbit(v.Ssymnum,b.Boutlv)); if (!vec_testbit(j,DEAD) && vec_testbit(v.Ssymnum,b.Boutlv)) continue; /* volatile/shared variables are not dead */ if ((v.ty() | nv.Ety) & (mTYvolatile | mTYshared)) continue; /* Do not mix up floating and integer variables * https://issues.dlang.org/show_bug.cgi?id=20363 */ if (OTbinary(n.Eoper)) { elem* e2 = n.EV.E2; if (e2.Eoper == OPvar && config.fpxmmregs && !tyfloating(v.Stype.Tty) != !tyfloating(e2.EV.Vsym.Stype.Tty) ) continue; } debug if (debugc) { printf("dead assignment ("); WReqn(n); if (vec_testbit(j,DEAD)) printf(") DEAD\n"); else printf(") Boutlv\n"); } elimass(n); go.changes++; } /* foreach */ vec_free(DEAD); vec_free(POSS); } /* for */ } /*************************** * Remove side effect of assignment elem. */ @trusted void elimass(elem *n) { elem *e1; switch (n.Eoper) { case OPvecsto: n.EV.E2.Eoper = OPcomma; goto case OPeq; case OPeq: case OPstreq: /* (V=e) => (random constant,e) */ /* Watch out for (a=b=c) stuff! */ /* Don't screw up assnod[]. */ n.Eoper = OPcomma; n.Ety |= n.EV.E2.Ety & (mTYconst | mTYvolatile | mTYimmutable | mTYshared | mTYfar ); n.EV.E1.Eoper = OPconst; break; /* Convert (V op= e) to (V op e) */ case OPaddass: case OPminass: case OPmulass: case OPdivass: case OPorass: case OPandass: case OPxorass: case OPmodass: case OPshlass: case OPshrass: case OPashrass: n.Eoper = cast(ubyte)opeqtoop(n.Eoper); break; case OPpostinc: /* (V i++ c) => V */ case OPpostdec: /* (V i-- c) => V */ e1 = n.EV.E1; el_free(n.EV.E2); el_copy(n,e1); el_free(e1); break; case OPnegass: n.Eoper = OPneg; break; case OPbtc: case OPbtr: case OPbts: n.Eoper = OPbt; break; case OPcmpxchg: n.Eoper = OPcomma; n.EV.E2.Eoper = OPcomma; break; default: assert(0); } } /************************ * Compute number of =,op=,i++,i--,--i,++i elems. * (Unambiguous assignments only. Ambiguous ones would always be live.) * Some compilers generate better code for ?: than if-then-else. */ @trusted private uint numasg(elem *e) { assert(e); if (OTassign(e.Eoper) && e.EV.E1.Eoper == OPvar) { e.Nflags |= NFLassign; return 1 + numasg(e.EV.E1) + (OTbinary(e.Eoper) ? numasg(e.EV.E2) : 0); } e.Nflags &= ~NFLassign; return OTunary(e.Eoper) ? numasg(e.EV.E1) : OTbinary(e.Eoper) ? numasg(e.EV.E1) + numasg(e.EV.E2) : 0; } /****************************** * Tree walk routine for rmdeadass(). * DEAD = assignments which are dead * POSS = assignments which are possibly dead * The algorithm is basically: * if we have an assignment to v, * for all defs of v in POSS * set corresponding bits in DEAD * set bit for this def in POSS * if we have a reference to v, * clear all bits in POSS that are refs of v */ @trusted private void accumda(elem *n,vec_t DEAD, vec_t POSS) { LtailRecurse: assert(n && DEAD && POSS); const op = n.Eoper; switch (op) { case OPcolon: case OPcolon2: { vec_t Pl = vec_clone(POSS); vec_t Pr = vec_clone(POSS); vec_t Dl = vec_calloc(vec_numbits(POSS)); vec_t Dr = vec_calloc(vec_numbits(POSS)); accumda(n.EV.E1,Dl,Pl); accumda(n.EV.E2,Dr,Pr); /* D |= P & (Dl & Dr) | ~P & (Dl | Dr) */ /* P = P & (Pl & Pr) | ~P & (Pl | Pr) */ /* = Pl & Pr | ~P & (Pl | Pr) */ const vecdim = cast(uint)vec_dim(DEAD); for (uint i = 0; i < vecdim; i++) { DEAD[i] |= (POSS[i] & Dl[i] & Dr[i]) | (~POSS[i] & (Dl[i] | Dr[i])); POSS[i] = (Pl[i] & Pr[i]) | (~POSS[i] & (Pl[i] | Pr[i])); } vec_free(Pl); vec_free(Pr); vec_free(Dl); vec_free(Dr); break; } case OPandand: case OPoror: { accumda(n.EV.E1,DEAD,POSS); // Substituting into the above equations Pl=P and Dl=0: // D |= Dr - P // P = Pr vec_t Pr = vec_clone(POSS); vec_t Dr = vec_calloc(vec_numbits(POSS)); accumda(n.EV.E2,Dr,Pr); vec_subass(Dr,POSS); vec_orass(DEAD,Dr); vec_copy(POSS,Pr); vec_free(Pr); vec_free(Dr); break; } case OPvar: { Symbol *v = n.EV.Vsym; targ_size_t voff = n.EV.Voffset; uint vsize = tysize(n.Ety); // We have a reference. Clear all bits in POSS that // could be referenced. foreach (const i; 0 .. cast(uint)assnod.length) { elem *ti = assnod[i].EV.E1; if (v == ti.EV.Vsym && ((vsize == -1 || tysize(ti.Ety) == -1) || // If symbol references overlap (voff + vsize > ti.EV.Voffset && ti.EV.Voffset + tysize(ti.Ety) > voff) ) ) { vec_clearbit(i,POSS); } } break; } case OPasm: // reference everything foreach (const i; 0 .. cast(uint)assnod.length) vec_clearbit(i,POSS); break; case OPbt: accumda(n.EV.E1,DEAD,POSS); accumda(n.EV.E2,DEAD,POSS); vec_subass(POSS,ambigref); // remove possibly refed break; case OPind: case OPucall: case OPucallns: case OPvp_fp: accumda(n.EV.E1,DEAD,POSS); vec_subass(POSS,ambigref); // remove possibly refed // assignments from list // of possibly dead ones break; case OPconst: break; case OPcall: case OPcallns: case OPmemcpy: case OPstrcpy: case OPmemset: accumda(n.EV.E2,DEAD,POSS); goto case OPstrlen; case OPstrlen: accumda(n.EV.E1,DEAD,POSS); vec_subass(POSS,ambigref); // remove possibly refed // assignments from list // of possibly dead ones break; case OPstrcat: case OPstrcmp: case OPmemcmp: accumda(n.EV.E1,DEAD,POSS); accumda(n.EV.E2,DEAD,POSS); vec_subass(POSS,ambigref); // remove possibly refed // assignments from list // of possibly dead ones break; default: if (OTassign(op)) { elem *t; if (ERTOL(n)) accumda(n.EV.E2,DEAD,POSS); t = n.EV.E1; // if not (v = expression) then gen refs of left tree if (op != OPeq && op != OPstreq) accumda(n.EV.E1,DEAD,POSS); else if (OTunary(t.Eoper)) // if (*e = expression) accumda(t.EV.E1,DEAD,POSS); else if (OTbinary(t.Eoper)) { accumda(t.EV.E1,DEAD,POSS); accumda(t.EV.E2,DEAD,POSS); } if (!ERTOL(n) && op != OPnegass) accumda(n.EV.E2,DEAD,POSS); // if unambiguous assignment, post all possibilities // to DEAD if ((op == OPeq || op == OPstreq) && t.Eoper == OPvar) { uint tsz = tysize(t.Ety); if (n.Eoper == OPstreq) tsz = cast(uint)type_size(n.ET); foreach (const i; 0 .. cast(uint)assnod.length) { elem *ti = assnod[i].EV.E1; uint tisz = tysize(ti.Ety); if (assnod[i].Eoper == OPstreq) tisz = cast(uint)type_size(assnod[i].ET); // There may be some problem with this next // statement with unions. if (ti.EV.Vsym == t.EV.Vsym && ti.EV.Voffset == t.EV.Voffset && tisz == tsz && !(t.Ety & (mTYvolatile | mTYshared)) && //t.EV.Vsym.Sflags & SFLunambig && vec_testbit(i,POSS)) { vec_setbit(i,DEAD); } } } // if assignment operator, post this def to POSS if (n.Nflags & NFLassign) { const i = cast(uint)assnod.length; vec_setbit(i,POSS); // if variable could be referenced by a pointer // or a function call, mark the assignment in // ambigref if (!(t.EV.Vsym.Sflags & SFLunambig)) { vec_setbit(i,ambigref); debug if (debugc) { printf("ambiguous lvalue: "); WReqn(n); printf("\n"); } } assnod.push(n); } } else if (OTrtol(op)) { accumda(n.EV.E2,DEAD,POSS); n = n.EV.E1; goto LtailRecurse; // accumda(n.EV.E1,DEAD,POSS); } else if (OTbinary(op)) { accumda(n.EV.E1,DEAD,POSS); n = n.EV.E2; goto LtailRecurse; // accumda(n.EV.E2,DEAD,POSS); } else if (OTunary(op)) { n = n.EV.E1; goto LtailRecurse; // accumda(n.EV.E1,DEAD,POSS); } break; } } /*************************** * Mark all dead variables. Only worry about register candidates. * Compute live ranges for register candidates. * Be careful not to compute live ranges for members of structures (CLMOS). */ @trusted void deadvar() { assert(dfo); /* First, mark each candidate as dead. */ /* Initialize vectors for live ranges. */ for (SYMIDX i = 0; i < globsym.length; i++) { Symbol *s = globsym[i]; if (s.Sflags & SFLunambig) { s.Sflags |= SFLdead; if (s.Sflags & GTregcand) { s.Srange = vec_realloc(s.Srange, dfo.length); vec_clear(s.Srange); } } } /* Go through trees and "liven" each one we see. */ foreach (i, b; dfo[]) if (b.Belem) dvwalk(b.Belem,cast(uint)i); /* Compute live variables. Set bit for block in live range */ /* if variable is in the IN set for that block. */ flowlv(); /* compute live variables */ for (SYMIDX i = 0; i < globsym.length; i++) { if (globsym[i].Srange /*&& globsym[i].Sclass != CLMOS*/) foreach (j, b; dfo[]) if (vec_testbit(i,b.Binlv)) vec_setbit(cast(uint)j,globsym[i].Srange); } /* Print results */ for (SYMIDX i = 0; i < globsym.length; i++) { char *p; Symbol *s = globsym[i]; if (s.Sflags & SFLdead && s.Sclass != SCparameter && s.Sclass != SCregpar) s.Sflags &= ~GTregcand; // do not put dead variables in registers debug { p = cast(char *) s.Sident.ptr ; if (s.Sflags & SFLdead) if (debugc) printf("Symbol %d '%s' is dead\n",cast(int) i,p); if (debugc && s.Srange /*&& s.Sclass != CLMOS*/) { printf("Live range for %d '%s': ",cast(int) i,p); vec_println(s.Srange); } } } } /***************************** * Tree walk support routine for deadvar(). * Input: * n = elem to look at * i = block index */ @trusted private void dvwalk(elem *n,uint i) { for (; true; n = n.EV.E1) { assert(n); if (n.Eoper == OPvar || n.Eoper == OPrelconst) { Symbol *s = n.EV.Vsym; s.Sflags &= ~SFLdead; if (s.Srange) vec_setbit(i,s.Srange); } else if (!OTleaf(n.Eoper)) { if (OTbinary(n.Eoper)) dvwalk(n.EV.E2,i); continue; } break; } } /********************************* * Optimize very busy expressions (VBEs). */ private __gshared vec_t blockseen; /* which blocks we have visited */ @trusted void verybusyexp() { elem **pn; uint j,l; if (debugc) printf("verybusyexp()\n"); flowvbe(); /* compute VBEs */ if (go.exptop <= 1) return; /* if no VBEs */ assert(go.expblk.length); if (blockinit()) return; // can't handle ASM blocks compdom(); /* compute dominators */ /*setvecdim(go.exptop);*/ genkillae(); /* compute Bgen and Bkill for */ /* AEs */ /*chkvecdim(go.exptop,0);*/ blockseen = vec_calloc(dfo.length); /* Go backwards through dfo so that VBEs are evaluated as */ /* close as possible to where they are used. */ foreach_reverse (i, b; dfo[]) // for each block { int done; /* Do not hoist things to blocks that do not */ /* divide the flow of control. */ switch (b.BC) { case BCiftrue: case BCswitch: break; default: continue; } /* Find pointer to last statement in current elem */ pn = &(b.Belem); if (*pn) { while ((*pn).Eoper == OPcomma) pn = &((*pn).EV.E2); /* If last statement has side effects, */ /* don't do these VBEs. Potentially we */ /* could by assigning the result to */ /* a temporary, and rewriting the tree */ /* from (n) to (T=n,T) and installing */ /* the VBE as (T=n,VBE,T). This */ /* may not buy us very much, so we will */ /* just skip it for now. */ /*if (sideeffect(*pn))*/ if (!(*pn).Eexp) continue; } /* Eliminate all elems that have already been */ /* hoisted (indicated by go.expnod[] == 0). */ /* Constants are not useful as VBEs. */ /* Eliminate all elems from Bout that are not in blocks */ /* that are dominated by b. */ static if (0) { printf("block %d Bout = ",i); vec_println(b.Bout); } done = true; for (j = 0; (j = cast(uint) vec_index(j, b.Bout)) < go.exptop; ++j) { if (go.expnod[j] == null || !!OTleaf(go.expnod[j].Eoper) || !dom(b,go.expblk[j])) vec_clearbit(j,b.Bout); else done = false; } if (done) continue; /* Eliminate from Bout all elems that are killed by */ /* a block between b and that elem. */ static if (0) { printf("block %d Bout = ",i); vec_println(b.Bout); } for (j = 0; (j = cast(uint) vec_index(j, b.Bout)) < go.exptop; ++j) { vec_clear(blockseen); foreach (bl; ListRange(go.expblk[j].Bpred)) { if (killed(j,list_block(bl),b)) { vec_clearbit(j,b.Bout); break; } } } /* For each elem still left, make sure that there */ /* exists a path from b to j along which there is */ /* no other use of j (else it would be a CSE, and */ /* it would be a waste of time to hoist it). */ static if (0) { printf("block %d Bout = ",i); vec_println(b.Bout); } for (j = 0; (j = cast(uint) vec_index(j, b.Bout)) < go.exptop; ++j) { vec_clear(blockseen); foreach (bl; ListRange(go.expblk[j].Bpred)) { if (ispath(j,list_block(bl),b)) goto L2; } vec_clearbit(j,b.Bout); /* thar ain't no path */ L2: } /* For each elem that appears more than once in Bout */ /* We have a VBE. */ static if (0) { printf("block %d Bout = ",i); vec_println(b.Bout); } for (j = 0; (j = cast(uint) vec_index(j, b.Bout)) < go.exptop; ++j) { uint k; for (k = j + 1; k < go.exptop; k++) { if (vec_testbit(k,b.Bout) && el_match(go.expnod[j],go.expnod[k])) goto foundvbe; } continue; /* no VBE here */ foundvbe: /* we got one */ debug { if (debugc) { printf("VBE %d,%d, block %d (",j,k, cast(int) i); WReqn(go.expnod[j]); printf(");\n"); } } *pn = el_bin(OPcomma,(*pn).Ety, el_copytree(go.expnod[j]),*pn); /* Mark all the vbe elems found but one (the */ /* go.expnod[j] one) so that the expression will */ /* only be hoisted again if other occurrences */ /* of the expression are found later. This */ /* will substitute for the fact that the */ /* el_copytree() expression does not appear in go.expnod[]. */ l = k; do { if (k == l || (vec_testbit(k,b.Bout) && el_match(go.expnod[j],go.expnod[k]))) { /* Fix so nobody else will */ /* vbe this elem */ go.expnod[k] = null; vec_clearbit(k,b.Bout); } } while (++k < go.exptop); go.changes++; } /* foreach */ } /* for */ vec_free(blockseen); } /**************************** * Return true if elem j is killed somewhere * between b and bp. */ @trusted private int killed(uint j,block *bp,block *b) { if (bp == b || vec_testbit(bp.Bdfoidx,blockseen)) return false; if (vec_testbit(j,bp.Bkill)) return true; vec_setbit(bp.Bdfoidx,blockseen); /* mark as visited */ foreach (bl; ListRange(bp.Bpred)) if (killed(j,list_block(bl),b)) return true; return false; } /*************************** * Return true if there is a path from b to bp along which * elem j is not used. * Input: * b . block where we want to put the VBE * bp . block somewhere between b and block containing j * j = VBE expression elem candidate (index into go.expnod[]) */ @trusted private int ispath(uint j,block *bp,block *b) { /*chkvecdim(go.exptop,0);*/ if (bp == b) return true; /* the trivial case */ if (vec_testbit(bp.Bdfoidx,blockseen)) return false; /* already seen this block */ vec_setbit(bp.Bdfoidx,blockseen); /* we've visited this block */ /* false if elem j is used in block bp (and reaches the end */ /* of bp, indicated by it being an AE in Bgen) */ uint i; for (i = 0; (i = cast(uint) vec_index(i, bp.Bgen)) < go.exptop; ++i) // look thru used expressions { if (i != j && go.expnod[i] && el_match(go.expnod[i],go.expnod[j])) return false; } /* Not used in bp, see if there is a path through a predecessor */ /* of bp */ foreach (bl; ListRange(bp.Bpred)) if (ispath(j,list_block(bl),b)) return true; return false; /* j is used along all paths */ } }
D
/Users/chris/projects/rust_examples/macros/target/debug/deps/demo-2643b749f71bf7fc.rmeta: demo/src/main.rs /Users/chris/projects/rust_examples/macros/target/debug/deps/demo-2643b749f71bf7fc.d: demo/src/main.rs demo/src/main.rs:
D
template bsearch(alias pred) { import std.range.primitives; import std.range : isRandomAccessRange; size_t bsearch(Range)(Range r) if (isRandomAccessRange!Range) { import std.functional : unaryFun; alias _pred = unaryFun!pred; alias _ret = typeof(_pred(r.front)); static if (is(_ret == bool)) { size_t left = 0; auto right = r.length; while (left < right) { auto mid = left + (right - left) / 2; // avoid overflow. if (_pred(r[mid])) right = mid; else left = mid + 1; } return left; } else static assert(false, "Invalid predicate passed to bsearch."); } } unittest { auto arr = [1, 2, 3]; assert(arr.bsearch!(a => a > 2) == 2); assert(arr.bsearch!(a => a >= 1) == 0); assert(arr.bsearch!(a => a == 2) == 1); assert(arr.bsearch!"a == 4" == 3); // got arr.length if pred == false. }
D
/* Copyright (c) 2016-2020 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. */ /** * General-purpose non-allocating lexical analyzer. * * Description: * Breaks the input string to a stream of lexemes according to a given delimiter dictionary. * Delimiters are symbols that separate sequences of characters (e.g. operators). * Lexemes are slices of the input string. * Assumes UTF-8 input. * Treats \r\n as a single \n. * * Copyright: Timur Gafarov 2016-2020. * License: $(LINK2 boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Timur Gafarov, Eugene Wissner, Roman Chistokhodov, ijet */ module dlib.text.lexer; import std.ascii; import std.range.interfaces; import dlib.text.utf8; /** * Lexical analyzer class */ class Lexer: InputRange!string { protected: string input; string[] delims; UTF8Decoder dec; uint index; dchar current; uint currentSize; public: bool ignoreWhitespaces = false; bool ignoreNewlines = false; this(string input, string[] delims) { this.input = input; this.delims = delims; this.dec.input = this.input; this.index = 0; advance(); } uint position() @property { return pos(); } string getLexeme() { string res = ""; int tStart = -1; while(true) { dchar c = current; if (c == UTF8_END || c == UTF8_ERROR) { if (tStart > -1) { res = input[tStart..pos]; tStart = -1; break; } else { res = ""; break; } } if (isNewline(c)) { if (tStart > -1) { res = input[tStart..pos]; tStart = -1; break; } else { if (c == '\r') { advance(); c = current; if (c == '\n') advance(); } else { advance(); } if (ignoreNewlines) { continue; } else { res = "\n"; break; } } } if (isWhitespace(c)) { if (tStart > -1) { res = input[tStart..pos]; tStart = -1; break; } else { advance(); if (ignoreWhitespaces) { continue; } else { res = " "; break; } } } string d = consumeDelimiter(); if (d.length) { if (tStart > -1) { res = input[tStart..pos]; } else { res = d; forwardJump(d.length); } break; } else { if (tStart == -1) { tStart = pos; } advance(); } } return res; } protected: uint pos() { return index-currentSize; } void advance() { current = dec.decodeNext(); currentSize = cast(uint)dec.index - index; index += currentSize; } void forwardJump(size_t numChars) { for(size_t i = 0; i < numChars; i++) { advance(); } } bool forwardCompare(string str) { UTF8Decoder dec2 = UTF8Decoder(str); size_t oldIndex = dec.index; bool res = true; int c1 = current; int c2 = dec2.decodeNext(); do { if (c2 == UTF8_END || c2 == UTF8_ERROR) break; if (c1 == UTF8_END && c2 == UTF8_END) { res = true; break; } if (c1 != UTF8_END && c1 != UTF8_ERROR && c2 != UTF8_END && c2 != UTF8_ERROR) { if (c1 != c2) { res = false; break; } } else { res = false; break; } c1 = dec.decodeNext(); c2 = dec2.decodeNext(); } while(c2 != UTF8_END && c2 != UTF8_ERROR); dec.index = oldIndex; return res; } bool isWhitespace(dchar c) { foreach(w; std.ascii.whitespace) { if (c == w) { return true; } } return false; } bool isNewline(dchar c) { return (c == '\n' || c == '\r'); } string consumeDelimiter() { size_t bestLen = 0; string bestStr = ""; foreach(d; delims) { if (forwardCompare(d)) { if (d.length > bestLen) { bestLen = d.length; bestStr = input[pos..pos+d.length]; } } } return bestStr; } // Range interface private: string _front; public: bool empty() { return _front.length == 0; } string front() { return _front; } void popFront() { _front = getLexeme(); } string moveFront() { _front = getLexeme(); return _front; } int opApply(scope int delegate(string) dg) { int result = 0; while(true) { string lexeme = getLexeme(); if (!lexeme.length) break; result = dg(lexeme); if (result) break; } return result; } int opApply(scope int delegate(size_t, string) dg) { int result = 0; size_t i = 0; while(true) { string lexeme = getLexeme(); if (!lexeme.length) break; result = dg(i, lexeme); if (result) break; i++; } return result; } } /// unittest { string[] delims = ["(", ")", ";", " ", "{", "}", ".", "\n", "\r", "=", "++", "<"]; auto input = "for (int i=0; i<arr.length; ++i)\r\n{doThing();}\n"; auto lexer = new Lexer(input, delims); string[] arr; while(true) { auto lexeme = lexer.getLexeme(); if(lexeme.length == 0) { break; } arr ~= lexeme; } assert(arr == [ "for", " ", "(", "int", " ", "i", "=", "0", ";", " ", "i", "<", "arr", ".", "length", ";", " ", "++", "i", ")", "\n", "{", "doThing", "(", ")", ";", "}", "\n" ]); input = ""; lexer = new Lexer(input, delims); assert(lexer.getLexeme().length == 0); }
D
a sea nymph (part woman and part bird) supposed to lure sailors to destruction on the rocks where the nymphs lived a woman who is considered to be dangerously seductive a warning signal that is a loud wailing sound an acoustic device producing a loud often wailing sound as a signal or warning eellike aquatic North American salamander with small forelimbs and no hind limbs
D
/+ Copyright (c) 2006 Eric Anderton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/ module enki.library.d.Operator; private import enki.types; private import enki.library.d.Token; Tok operatorToken[String]; String operatorXref[Tok]; static this(){ operatorToken["/="] = Tok.DivAssign; operatorToken["/"] = Tok.Div; operatorToken["..."] = Tok.Elipsis; operatorToken[".."] = Tok.Slice; operatorToken["."] = Tok.Dot; operatorToken["&="] = Tok.AndAssign; operatorToken["&&"] = Tok.AndAnd; operatorToken["&"] = Tok.And; operatorToken["|="] = Tok.OrAssign; operatorToken["||"] = Tok.OrOr; operatorToken["|"] = Tok.Or; operatorToken["--"] = Tok.MinusMinus; operatorToken["-="] = Tok.MinusAssign; operatorToken["-"] = Tok.Minus; operatorToken["++"] = Tok.PlusPlus; operatorToken["+="] = Tok.PlusAssign; operatorToken["+"] = Tok.Plus; operatorToken["<="] = Tok.LessEquals; operatorToken["<<"] = Tok.LessLess; operatorToken["<<="] = Tok.LessLessEquals; operatorToken["<>"] = Tok.LessGreater; operatorToken["<>="] = Tok.LessGreaterEquals; operatorToken["<"] = Tok.Less; operatorToken[">>>"] = Tok.GreaterGreaterGreater; operatorToken[">>>="] = Tok.GreaterGreaterGreaterEquals; operatorToken[">>="] = Tok.GreaterGreaterEquals; operatorToken[">>"] = Tok.GreaterGreater; operatorToken[">="] = Tok.GreaterEquals; operatorToken[">"] = Tok.Greater; operatorToken["!=="] = Tok.NotEqualsEquals; operatorToken["!="] = Tok.NotEquals; operatorToken["!<>"] = Tok.NotGreaterLess; operatorToken["!<>="] = Tok.NotGreaterLessEquals; operatorToken["!<"] = Tok.NotLess; operatorToken["!<="] = Tok.NotLessEquals; operatorToken["!>"] = Tok.NotGreater; operatorToken["!>="] = Tok.NotGreaterEquals; operatorToken["!~"] = Tok.NotCat; operatorToken["!"] = Tok.Not; operatorToken["("] = Tok.OpenParen; operatorToken[")"] = Tok.CloseParen; operatorToken["["] = Tok.OpenBracket; operatorToken["]"] = Tok.CloseBracket; operatorToken["{"] = Tok.OpenCurl; operatorToken["}"] = Tok.CloseCurl; operatorToken["?"] = Tok.Question; operatorToken[","] = Tok.Comma; operatorToken[";"] = Tok.Semi; operatorToken[":"] = Tok.Colon; operatorToken["$"] = Tok.Dollar; operatorToken["==="] = Tok.EqualsEqualsEquals; operatorToken["=="] = Tok.EqualsEquals; operatorToken["="] = Tok.Equals; operatorToken["*="] = Tok.StarEquals; operatorToken["*"] = Tok.Star; operatorToken["%="] = Tok.ModEquals; operatorToken["%"] = Tok.Mod; operatorToken["^="] = Tok.InverseEquals; operatorToken["^"] = Tok.Inverse; operatorToken["~="] = Tok.CatEquals; operatorToken["~~"] = Tok.CatCat; operatorToken["~"] = Tok.Cat; foreach(key,value; operatorToken){ operatorXref[value] = key; } }
D
///////////////////////// ГРИБЫ ////////////////////////////// const int FLAG_MR = 161616; prototype Proto_Mushroom(C_Item) { description = "Гриб"; name = ""; weight = FLAG_MR; mainflag = ITEM_KAT_FOOD; flags = ITEM_MULTI | ITEM_Mushroom; scemeName = "FOOD"; material = MAT_LEATHER; }; //------------------------------------------- var int Hero_Knows_MR_Stone; instance ItMr_Stone(Proto_Mushroom) { description = "Каменка"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Stone.3DS"; value = Value_Mr_Stone; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Stone) { text[2] = NAME_Bonus_HP; count[2] = HP_Mr_Stone; text[3] = NAME_Bonus_Mana; count[3] = Mana_Mr_Stone; } else { text[2] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Stone; }; func void Use_Mushroom_Stone() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mr_Stone); Npc_ChangeAttribute(self,ATR_MANA, Mana_Mr_Stone); if(Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Stone) { Hero_Knows_MR_Stone = TRUE; AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(HP_Mr_Stone)),-1,55,FONT_ScreenSmall,3); AI_PrintScreen(CS3(NAME_Bonus_Mana, " ", IntToString(Mana_Mr_Stone)),-1,58,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_Stone); Npc_RemoveInvItems(self, ItMr_Stone,cnt); CreateInvItems(self, ItMr_Stone,cnt); }; MR_Eaten[MR_Stone] += 1; if(MR_Eaten[MR_Stone] % 30 == 0) { if (self.attribute[ATR_STRENGTH] > -AntiBonus_STR_Mr_Stone) { Npc_ChangeAttribute(self,ATR_STRENGTH,AntiBonus_STR_Mr_Stone); } else { self.attribute[ATR_STRENGTH] = 1; }; if (self.aivar[AIV_Gender] == MALE) { AI_PrintScreen("Мой желудок! Как будто камень проглотил!",-1,-1,FONT_Screen,2); } else { AI_PrintScreen("Мой желудок! Как будто камень проглотила!",-1,-1,FONT_Screen,2); }; AI_PrintScreen(CS3(NAME_Bonus_Str, " ", IntToString(AntiBonus_STR_Mr_Stone)),-1,61,FONT_ScreenSmall,3); }; }; }; //------------------------------------------- var int Hero_Knows_MR_Sunrise; instance ItMr_Sunrise(Proto_Mushroom) { description = "Зорьник"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Sunrise.3DS"; value = Value_Mr_Sunrise; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Sunrise) { text[2] = NAME_Bonus_HP; count[2] = HP_Mr_Sunrise; } else { text[2] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Sunrise; }; func void Use_Mushroom_Sunrise() { //обычно снижают здоровье if (self.attribute[ATR_HITPOINTS] > -HP_Mr_Sunrise) { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mr_Sunrise); } else { self.attribute[ATR_HITPOINTS] = 1; }; //но постепенно повышают ловкость if(Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Sunrise) { Hero_Knows_MR_Sunrise = TRUE; AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(HP_Mr_Sunrise)),-1,55,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_Sunrise); Npc_RemoveInvItems(self, ItMr_Sunrise,cnt); CreateInvItems(self, ItMr_Sunrise,cnt); }; MR_Eaten[MR_Sunrise] += 1; if (MR_Eaten[MR_Sunrise] % 12 == 0) { B_RaiseAttribute(self,ATR_DEXTERITY,Bonus_DEX_Mr_Sunrise); AI_PrintScreen(CS3(NAME_Bonus_Dex, " ", IntToString(Bonus_DEX_Mr_Sunrise)),-1,61,FONT_ScreenSmall,3); }; }; }; //------------------------------------------- var int Hero_Knows_MR_Foggy; instance ItMr_Foggy(Proto_Mushroom) { description = "Туманник"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Foggy.3DS"; if (Hero_Knows_MR_Foggy) { text[2] = "Галюциногенный."; text[3] = TEXT_DoNotEat; } else { text[3] = TEXT_UnknownEffect; }; text[5] = NAME_NoValue; on_state[0] = Use_Mushroom_Foggy; }; func void Use_Mushroom_Foggy() { if (self.attribute[ATR_HITPOINTS] > self.attribute[ATR_HITPOINTS_MAX] / 2) { self.attribute[ATR_HITPOINTS] = self.attribute[ATR_HITPOINTS_MAX] / 2; }; if(Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Foggy) { Hero_Knows_MR_Foggy = TRUE; var int cnt; cnt = Npc_HasItems(self, ItMr_Foggy); Npc_RemoveInvItems(self, ItMr_Foggy,cnt); CreateInvItems(self, ItMr_Foggy,cnt); }; B_Foggy_Templapse(); POISON_Foggy_Timer = Wld_GetFullTime() + POISON_Foggy_Duration + 1; MR_Eaten[MR_Foggy] += 1; B_LogNote_Poison(); B_LogNote(TOPIC_Poison,TOPIC_Poison_Foggy); } else { self.aivar[AIV_Timelapse_EndTime] = Wld_GetFullTime() + 15 + Hlp_Random(60); }; }; //------------------------------------------- var int Hero_Knows_MR_Piny; instance ItMr_Piny(Proto_Mushroom) { description = "Сосновик"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Piny.3DS"; value = Value_Mr_Piny; text[5] = NAME_Value; count[5] = value; text[2] = NAME_Bonus_HP; count[2] = Bonus_HP_Mr_Piny; on_state[0] = Use_Mushroom_Piny; }; func void Use_Mushroom_Piny() { Npc_ChangeAttribute(self,ATR_HITPOINTS,Bonus_HP_Mr_Piny); if(Npc_IsPlayer(self)) { Hero_Knows_MR_Piny = TRUE; MR_Eaten[MR_Piny] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_Red; instance ItMr_Red(Proto_Mushroom) { description = "Болтун"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Red.3DS"; value = Value_Mr_Red; text[5] = NAME_Value; count[5] = value; text[2] = "Не имеет эффекта."; on_state[0] = Use_Mushroom_Red; }; func void Use_Mushroom_Red() { PrintInInventory(PRINT_NoEffect); if(Npc_IsPlayer(self)) { Hero_Knows_MR_Red = TRUE; MR_Eaten[MR_Red] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_Bottle; instance ItMr_Bottle(Proto_Mushroom) { description = "Бутылочник"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Bottle.3DS"; value = Value_Mr_Bottle; text[5] = NAME_Value; count[5] = value; text[1] = "Похож на бутылку с пробкой."; text[2] = "Шляпка-пробка легко отделяется от ножки."; on_state[0] = Use_Mushroom_Bottle; }; //съесть шляпку (ядовита) FUNC VOID Use_Mushroom_Bottle_Top() { Npc_ChangeAttribute(self,ATR_HITPOINTS,AntiBonus_HP_Mr_Bottle); AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(AntiBonus_HP_Mr_Bottle)),-1,55,FONT_ScreenSmall,3); }; //съесть ножку (полезна) FUNC VOID Use_Mushroom_Bottle_Bottom() { Npc_ChangeAttribute(self,ATR_HITPOINTS,Bonus_HP_Mr_Bottle); AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(Bonus_HP_Mr_Bottle)),-1,58,FONT_ScreenSmall,3); }; //съесть целиком FUNC VOID Use_Mushroom_Bottle_All() { Use_Mushroom_Bottle_Top(); Use_Mushroom_Bottle_Bottom(); }; instance PC_MR_Bottle_End(DIA_Proto_End) { condition = PC_MR_Bottle_Cond; information = PC_MR_Bottle_End_Info; }; func int PC_MR_Bottle_Cond() { if (Hero_Dia_Bottle == TRUE) { return TRUE; }; }; func void PC_MR_Bottle_End_Info() { Hero_Dia_Bottle = FALSE; CreateInvItem(self, ItMr_Bottle); AI_StopProcessInfos(self); }; instance PC_MR_Bottle_Eat_Top(C_INFO) { nr = 1; condition = PC_MR_Bottle_Cond; information = PC_MR_Bottle_Eat_Top_Info; description = "съесть шляпку"; permanent = TRUE; }; func void PC_MR_Bottle_Eat_Top_Info() { Hero_Dia_Bottle = FALSE; Use_Mushroom_Bottle_Top(); AI_StopProcessInfos(self); }; instance PC_MR_Bottle_Eat_Bottom(C_INFO) { nr = 2; condition = PC_MR_Bottle_Cond; information = PC_MR_Bottle_Eat_Bottom_Info; description = "съесть ножку"; permanent = TRUE; }; func void PC_MR_Bottle_Eat_Bottom_Info() { Hero_Dia_Bottle = FALSE; Use_Mushroom_Bottle_Bottom(); AI_StopProcessInfos(self); }; instance PC_MR_Bottle_Eat_All(C_INFO) { nr = 3; condition = PC_MR_Bottle_Cond; information = PC_MR_Bottle_Eat_All_Info; description = "съесть целиком"; permanent = TRUE; }; func void PC_MR_Bottle_Eat_All_Info() { Hero_Dia_Bottle = FALSE; Use_Mushroom_Bottle_All(); AI_StopProcessInfos(self); }; func void Use_Mushroom_Bottle() { if (Npc_IsPlayer(self)) { MR_Eaten[MR_Bottle] += 1; if (Hero_Knows_Bottle == TRUE) { Use_Mushroom_Bottle_Bottom(); } else { PC_MR_Bottle_End.npc = Hlp_GetInstanceID(hero); PC_MR_Bottle_Eat_Top.npc = Hlp_GetInstanceID(hero); PC_MR_Bottle_Eat_Bottom.npc = Hlp_GetInstanceID(hero); PC_MR_Bottle_Eat_All.npc = Hlp_GetInstanceID(hero); Hero_Dia_Bottle = TRUE; AI_ProcessInfos(self); }; }; }; //------------------------------------------- var int Hero_Knows_MR_BrownOiler; instance ItMr_BrownOiler(Proto_Mushroom) { description = "Масляк"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_BrownOiler.3DS"; value = Value_Mr_BrownOiler; text[5] = NAME_Value; count[5] = value; text[2] = NAME_Bonus_Mana; count[2] = Mana_Mr_BrownOiler; on_state[0] = Use_Mushroom_BrownOiler; }; func void Use_Mushroom_BrownOiler() { Npc_ChangeAttribute(self,ATR_MANA,Mana_Mr_BrownOiler); if(Npc_IsPlayer(self)) { Hero_Knows_MR_BrownOiler = TRUE; MR_Eaten[MR_BrownOiler] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_Oyster; instance ItMr_Oyster(Proto_Mushroom) { description = "Ракушечник"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Oyster.3DS"; value = Value_Mr_Oyster; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Oyster) { text[2] = NAME_Bonus_HP; count[2] = HP_Mr_Oyster; text[3] = NAME_Bonus_Mana; count[3] = Mana_Mr_Oyster; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Oyster; }; func void Use_Mushroom_Oyster() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mr_Oyster); Npc_ChangeAttribute(self,ATR_MANA,Mana_Mr_Oyster); if(Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Oyster) { Hero_Knows_MR_Oyster = TRUE; AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(HP_Mr_Oyster)),-1,55,FONT_ScreenSmall,3); AI_PrintScreen(CS3(NAME_Bonus_Mana, " ", IntToString(Mana_Mr_Oyster)),-1,58,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_Oyster); Npc_RemoveInvItems(self, ItMr_Oyster,cnt); CreateInvItems(self, ItMr_Oyster,cnt); }; MR_Eaten[MR_Oyster] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_Governor; instance ItMr_Governor(Proto_Mushroom) { description = "Губернатор"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Governor.3DS"; value = Value_Mr_Governor; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Governor) { text[2] = NAME_Bonus_HP; count[2] = HP_Mr_Governor; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Governor; }; func void Use_Mushroom_Governor() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mr_Governor); if(Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Governor) { Hero_Knows_MR_Governor = TRUE; AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(HP_Mr_Governor)),-1,55,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_Governor); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_Governor,cnt); CreateInvItems(self, ItMr_Governor,cnt); }; }; MR_Eaten[MR_Governor] += 1; if (MR_Eaten[MR_Governor] % Bonus_HP_Mr_Governor_Cnt == 0) { B_RaiseAttribute(self,ATR_HITPOINTS_MAX,Bonus_HP_Mr_Governor); self.attribute[ATR_HITPOINTS] = self.attribute[ATR_HITPOINTS_MAX]; }; //UNFINISHED - призрак губернатора под кайфом if (MR_Eaten[MR_Governor] == 28) { Wld_SpawnNpcRange(self,PC_GovernorGhost,1,150); B_GiveAchievement_Governor(); }; }; }; //------------------------------------------- instance ItMr_KeilBig(Proto_Mushroom) { description = "Кабанчик (большой)"; //name = description; if (!OPT_HideMrNames) { name = "Кабанчик";}; visual = "ItMr_KeilBig.3DS"; scemeName = "MAP"; text[1] = "Большой как табуретка"; text[2] = "и твердый как камень."; text[5] = NAME_NoValue; on_state[0] = Use_Mushroom_KeilBig; }; func void Use_Mushroom_KeilBig() { PrintInInventory("Я не хочу сломать себе зубы!"); }; instance ItMr_KeilSmall(Proto_Mushroom) { description = "Кабанчик (маленький)"; //name = description; if (!OPT_HideMrNames) { name = "Кабанчик";}; visual = "ItMr_KeilSmall.3DS"; text[1] = "Шляпка еще не раскрылась"; value = Value_Mr_KeilSmall; text[5] = NAME_Value; count[5] = value; text[2] = NAME_Bonus_HP; count[2] = HP_Mr_KeilSmall; text[3] = "По слухам, может повысить силу."; on_state[0] = Use_Mushroom_KeilSmall; }; func void Use_Mushroom_KeilSmall() { Npc_ChangeAttribute(self, ATR_HITPOINTS, HP_Mr_KeilSmall); if (Npc_IsPlayer(self)) { MR_Eaten[MR_Keil] += 1; if (MR_Eaten[MR_Keil] % Bonus_STR_Mr_KeilSmall_Cnt == 0) { B_RaiseAttribute(self, ATR_STRENGTH, Bonus_STR_Mr_KeilSmall); }; }; }; //------------------------------------------- var int Hero_Knows_MR_Branch; instance ItMr_Branch(Proto_Mushroom) { description = "Веточник"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Branch.3DS"; value = Value_Mr_Branch; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Branch) { text[2] = NAME_Bonus_Mana; count[2] = Mana_Mr_Branch; text[3] = NAME_Bonus_ManaMax; count[3] = Bonus_Mana_Mr_Branch; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Branch; }; func void Use_Mushroom_Branch() { Npc_ChangeAttribute(self,ATR_MANA,Mana_Mr_Branch); Npc_ChangeAttribute(self,ATR_MANA_MAX,Bonus_Mana_Mr_Branch); if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Branch) { Hero_Knows_MR_Branch = TRUE; AI_PrintScreen(CS3(NAME_Bonus_Mana, " ", IntToString(Mana_Mr_Branch)),-1,55,FONT_ScreenSmall,3); AI_PrintScreen(CS3(NAME_Bonus_ManaMax, " ", IntToString(Bonus_Mana_Mr_Branch)),-1,58,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_Branch); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_Branch,cnt); CreateInvItems(self, ItMr_Branch,cnt); }; }; MR_Eaten[MR_Branch] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_LadysEar; instance ItMr_LadysEar(Proto_Mushroom) { description = "Дамское ушко"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_LadysEar.3DS"; value = Value_Mr_LadysEar; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_LadysEar) { text[2] = NAME_Bonus_HP; count[2] = HP_Mr_LadysEar; text[3] = NAME_Bonus_Mana; count[3] = Mana_Mr_LadysEar; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_LadysEar; }; func void Use_Mushroom_LadysEar() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mr_LadysEar); Npc_ChangeAttribute(self,ATR_MANA,Mana_Mr_LadysEar); if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_LadysEar) { Hero_Knows_MR_LadysEar = TRUE; AI_PrintScreen(CS3(NAME_Bonus_HP, " ", IntToString(HP_Mr_LadysEar)),-1,55,FONT_ScreenSmall,3); AI_PrintScreen(CS3(NAME_Bonus_Mana, " ", IntToString(Mana_Mr_LadysEar)),-1,58,FONT_ScreenSmall,3); var int cnt; cnt = Npc_HasItems(self, ItMr_LadysEar); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_LadysEar,cnt); CreateInvItems(self, ItMr_LadysEar,cnt); }; }; MR_Eaten[MR_LadysEar] += 1; }; }; //------------------------------------------- var int Hero_Knows_MR_Trident; instance ItMr_Trident(Proto_Mushroom) { description = "Трезубец"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Trident.3DS"; text[5] = NAME_NoValue; if (Hero_Knows_MR_Trident) { text[2] = "Вызывает сильную слабость."; text[3] = TEXT_DoNotEat; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Trident; }; func void Use_Mushroom_Trident() { if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Trident) { Hero_Knows_MR_Trident = TRUE; var int cnt; cnt = Npc_HasItems(self, ItMr_Trident); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_Trident,cnt); CreateInvItems(self, ItMr_Trident,cnt); }; }; MR_Eaten[MR_Trident] += 1; AI_PrintScreen("Я чувствую слабость", -1, -1, FONT_Screen,2); if (self.attribute[ATR_STRENGTH] > 10) { self.attribute[ATR_STRENGTH] -= 10; POISON_Trident_STR += 10; }; if (self.attribute[ATR_DEXTERITY] > 10) { self.attribute[ATR_DEXTERITY] -= 5; POISON_Trident_DEX += 5; }; Wld_PlayEffect("TREMBLE",self,self,1,0,0,0); B_LogNote_Poison(); B_LogNote(TOPIC_Poison,TOPIC_Poison_Trident); }; }; //------------------------------------------- var int Hero_Knows_MR_NightSparkles; instance ItMr_NightSparkles(Proto_Mushroom) { description = "Ночные искры"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_NightSparkles.3DS"; effect = "SPELLFX_HEALTHPOTION"; text[1] = "Здесь около дюжины маленьких грибочков."; text[5] = NAME_NoValue; if (Hero_Knows_MR_NightSparkles) { text[2] = "Защищают от огня."; text[3] = "На вкус жгучие."; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_NightSparkles; }; func void Use_Mushroom_NightSparkles() { if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_NightSparkles) { Hero_Knows_MR_NightSparkles = TRUE; var int cnt; cnt = Npc_HasItems(self, ItMr_NightSparkles); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_NightSparkles,cnt); CreateInvItems(self, ItMr_NightSparkles,cnt); }; }; MR_Eaten[MR_NightSparkles] += 1; if (TIMER_NightSparkles_Enabled == FALSE) { PrintInInventory("Чувствую странное покалывание..."); self.protection[PROT_FIRE] += ProtFire_Mr_NightSparkles; }; if (MIS_Cookery_AskSpices && !MIS_Cookery_SpicesGiven && !MIS_Cookery_NSparclesKnown) { B_LogEntry(TOPIC_Cookery,TOPIC_Cookery_NSparklesKnown); MIS_Cookery_NSparclesKnown = TRUE; }; TIMER_NightSparkles = TIMER_NightSparkles_Max; }; }; //------------------------------------------- var int Hero_Knows_MR_DragonTears; instance ItMr_DragonTears(Proto_Mushroom) { description = "Драконовы слезы"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_DragonTears.3DS"; text[5] = NAME_NoValue; if (Hero_Knows_MR_DragonTears) { text[3] = TEXT_DoNotEat; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_DragonTears; }; func void Use_Mushroom_DragonTears() { if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_DragonTears) { Hero_Knows_MR_DragonTears = TRUE; var int cnt; cnt = Npc_HasItems(self, ItMr_DragonTears); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_DragonTears,cnt); CreateInvItems(self, ItMr_DragonTears,cnt); }; }; MR_Eaten[MR_DragonTears] += 1; POISON_DrgTears_Timer = POISON_DrgTears_Time_Max; AI_PrintScreen("Жжется! ЖЖЕТСЯ!!! Внутри все горит!",-1,YPOS_InInventory,FONT_Screen,5); Wld_PlayEffect("POISON_DRGTEARS",self,self,1,0,0,FALSE); B_LogNote_Poison(); B_LogNote(TOPIC_Poison,TOPIC_Poison_DrgTears); }; }; //------------------------------------------- instance ItMr_Heart(Proto_Mushroom) { description = "Гриб-сердце"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Heart.3DS"; scemeName = "MAP"; text[5] = NAME_NoValue; text[3] = TEXT_UnknownEffect; on_state[0] = Use_Mushroom_Heart; }; func void Use_Mushroom_Heart() { PrintInInventory(PRINT_RefuseEat); }; //------------------------------------------- instance ItMr_Heart_Blessed(Proto_Mushroom) { description = "Гриб-сердце (благословленный)"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Heart.3DS"; effect = "SPELLFX_WEAKGLIMMER_RED"; text[2] = "Белиар наполнил этот сосуд своей силой."; text[5] = NAME_NoValue; on_state[0] = Use_Mushroom_Heart; }; func void Use_Mushroom_Heart_Blessed() { if (Npc_IsPlayer(self)) { MR_Eaten[MR_Heart] += 1; Wld_PlayEffect("SPELLFX_FEAR",self,self,1,0,0,0); B_Say_Overlay(self,self,"$AARGH_1"); self.attribute[ATR_HITPOINTS] = 1; self.attribute[ATR_MANA] = 1; self.protection[PROT_BLUNT] = Bonus_Prot_Mr_Heart; self.protection[PROT_EDGE] = Bonus_Prot_Mr_Heart; self.protection[PROT_POINT] = Bonus_Prot_Mr_Heart; self.protection[PROT_FIRE] = Bonus_Prot_Mr_Heart; self.protection[PROT_MAGIC] = Bonus_Prot2_Mr_Heart; B_RaiseAttribute(self,ATR_STRENGTH,Bonus_STR_Mr_Heart); B_RaiseAttribute(self,ATR_DEXTERITY,Bonus_DEX_Mr_Heart); }; }; //------------------------------------------- instance ItMr_GoldPlate(Proto_Mushroom) { description = "Золотая чаша"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_GoldPlate.3DS"; scemeName = "MAP"; text[5] = NAME_NoValue; text[3] = TEXT_UnknownEffect; on_state[0] = Use_Mushroom_GoldPlate; }; func void Use_Mushroom_GoldPlate() { PrintInInventory(PRINT_RefuseEat2); }; //------------------------------------------- instance ItMr_GoldPlate_Blessed(Proto_Mushroom) { description = "Золотая чаша (благословленная)"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_GoldPlate.3DS"; effect = "SPELLFX_WEAKGLIMMER_YELLOW"; text[2] = "Иннос благословил эту чашу."; text[5] = NAME_NoValue; on_state[0] = Use_Mushroom_GoldPlate_Blessed; }; func void Use_Mushroom_GoldPlate_Blessed() { if (Npc_IsPlayer(self)) { MR_Eaten[MR_GoldPlate] += 1; Wld_PlayEffect("SPELLFX_HEAL",self,self,1,0,0,0); B_RaiseAttribute(self,ATR_HITPOINTS_MAX,Bonus_HP_Mr_GoldPlate); B_RaiseAttribute(self,ATR_MANA_MAX,Bonus_Mana_Mr_GoldPlate); self.attribute[ATR_HITPOINTS] = self.attribute[ATR_HITPOINTS_MAX]; self.attribute[ATR_MANA] = self.attribute[ATR_MANA_MAX]; }; }; //------------------------------------------- instance PC_IvySleepStart(C_Info) { npc = PC_Hero; nr = 1; condition = PC_IvySleepStart_Condition; information = PC_IvySleepStart_Info; important = 1; permanent = 1; }; func int PC_IvySleepStart_Condition() { if(PLAYER_MOBSI_PRODUCTION == MOBSI_IvySleepStart) { return TRUE; }; return FALSE; }; func void PC_IvySleepStart_Info() { B_Say(self,self,"$AWAKE"); //ZS_MagicSleep_Short(); B_StopLookAt(self); AI_StopPointAt(self); if(!Npc_HasBodyFlag(self,BS_FLAG_INTERRUPTABLE)) { AI_Standup(self); } else { AI_StandupQuick(self); }; AI_PlayAniBS(self,"T_STAND_2_VICTIM_SLE",BS_LIE); if(C_NpcIsHero(self)) { HERO_IsSleeping = TRUE; }; AI_Wait(self,Sleep_Time_Ivyf); //B_StopMagicSleep(); AI_PlayAniBS(self,"T_VICTIM_SLE_2_STAND", BS_STAND); if(C_NpcIsHero(self)) { HERO_IsSleeping = FALSE; }; b_endproductiondialog(); }; var int Hero_Knows_MR_Ivy; instance ItMr_Ivy(Proto_Mushroom) { description = "Плющевик"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Ivy.3DS"; value = Value_Mr_Ivy; text[5] = NAME_Value; count[5] = value; if (Hero_Knows_MR_Ivy) { text[2] = "Вызывает сонливость."; } else { text[3] = TEXT_UnknownEffect; }; on_state[0] = Use_Mushroom_Ivy; }; func void Use_Mushroom_Ivy() { // B_ClearPerceptions(self); if (Npc_IsPlayer(self)) { if (!Hero_Knows_MR_Ivy) { Hero_Knows_MR_Ivy = TRUE; var int cnt; cnt = Npc_HasItems(self, ItMr_Ivy); if (cnt > 0) { Npc_RemoveInvItems(self, ItMr_Ivy,cnt); CreateInvItems(self, ItMr_Ivy,cnt); }; }; MR_Eaten[MR_Ivy] += 1; PC_IvySleepStart.npc = Hlp_GetInstanceID(self); PLAYER_MOBSI_PRODUCTION = MOBSI_IvySleepStart; AI_ProcessInfos(self); } else { AI_StartState(self,ZS_MagicSleep_Short,0,""); }; }; //------------------------------------------- var int Hero_Knows_MR_Violet; instance ItMr_Violet(Proto_Mushroom) { description = "Белиарова поганка"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItMr_Violet.3DS"; effect = "SPELLFX_WEAKGLIMMER_VIOLET"; text[5] = NAME_NoValue; text[3] = "Выглядит очень ядовитой!"; on_state[0] = Use_Mushroom_Violet; }; func void Use_Mushroom_Violet() { Npc_ChangeAttribute(self,ATR_HITPOINTS,-self.attribute[ATR_HITPOINTS]); if (Npc_IsPlayer(self)) { MR_Eaten[MR_Violet] += 1; }; }; //------------------------------------------- instance ItPl_Mushroom_01(Proto_Mushroom) { description = "Темный гриб"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItPl_Mushroom_01.3DS"; text[1] = NAME_Bonus_HP; count[1] = HP_Mushroom_01; value = Value_Mushroom_01; text[5] = NAME_Value; count[5] = value; on_state[0] = Use_Mushroom_01; }; func void Use_Mushroom_01() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mushroom_01); if(Npc_IsPlayer(self)) { MR_Eaten[MR_01] += 1; Dunkelpilz_Bonus = Dunkelpilz_Bonus + 1; if(Dunkelpilz_Bonus == 50) { B_RaiseAttribute(self,ATR_MANA_MAX,5); Npc_ChangeAttribute(self,ATR_MANA,5); Snd_Play("LevelUp"); Dunkelpilz_Bonus = 0; }; }; }; instance ItPl_Mushroom_02(Proto_Mushroom) { description = "Пища рудокопа"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItPl_Mushroom_02.3DS"; on_state[0] = Use_Mushroom_02; text[1] = NAME_Bonus_HP; count[1] = HP_Mushroom_02; text[3] = "Сытный мясной гриб"; value = Value_Mushroom_02; text[5] = NAME_Value; count[5] = value; }; func void Use_Mushroom_02() { Npc_ChangeAttribute(self,ATR_HITPOINTS,HP_Mushroom_02); if(Npc_IsPlayer(self)) { MR_Eaten[MR_02] += 1; }; }; //================================================ //является ли предмет грибом func int C_ItemIsMushroom(var C_ITEM itm) { if (Hlp_IsItem(itm,ItPl_Mushroom_01)) {return MR_01;} else if (Hlp_IsItem(itm,ItPl_Mushroom_02)) {return MR_02;} else if (Hlp_IsItem(itm,ItMr_Bottle)) {return MR_Bottle;} else if (Hlp_IsItem(itm,ItMr_Branch)) {return MR_Branch;} else if (Hlp_IsItem(itm,ItMr_BrownOiler)) {return MR_BrownOiler;} else if (Hlp_IsItem(itm,ItMr_DragonTears)) {return MR_DragonTears;} else if (Hlp_IsItem(itm,ItMr_Foggy)) {return MR_Foggy;} else if (Hlp_IsItem(itm,ItMr_GoldPlate)) {return MR_GoldPlate;} else if (Hlp_IsItem(itm,ItMr_Governor)) {return MR_Governor;} else if (Hlp_IsItem(itm,ItMr_Heart)) {return MR_Heart;} else if (Hlp_IsItem(itm,ItMr_Ivy)) {return MR_Ivy;} else if (Hlp_IsItem(itm,ItMr_KeilBig)) {return MR_Keil;} else if (Hlp_IsItem(itm,ItMr_KeilSmall)) {return MR_Keil;} else if (Hlp_IsItem(itm,ItMr_LadysEar)) {return MR_LadysEar;} else if (Hlp_IsItem(itm,ItMr_NightSparkles)) {return MR_NightSparkles;} else if (Hlp_IsItem(itm,ItMr_Oyster)) {return MR_Oyster;} else if (Hlp_IsItem(itm,ItMr_Piny)) {return MR_Piny;} else if (Hlp_IsItem(itm,ItMr_Red)) {return MR_Red;} else if (Hlp_IsItem(itm,ItMr_Stone)) {return MR_Stone;} else if (Hlp_IsItem(itm,ItMr_Sunrise)) {return MR_Sunrise;} else if (Hlp_IsItem(itm,ItMr_Trident)) {return MR_Trident;} else if (Hlp_IsItem(itm,ItMr_Violet)) {return MR_Violet;}; return -1; }; //---------------------------------------------- func int C_ItemIsNotMushroomByPtr(var int itmPtr) { var C_ITEM itm; itm = _^(itmPtr); MEM_Debug(itm.name); if (C_ItemIsMushroom(itm) == -1) { return TRUE; }; return FALSE; }; //---------------------------------------------- func int C_GetMushroomPrice(var C_ITEM itm) { var int MR_Index; MR_Index = C_ItemIsMushroom(itm); if (MR_Index >= 0) { return MEM_ReadStatArr(MR_Price, MR_Index); }; return itm.value; }; func int C_GetMushroomPriceByPtr(var int itmPtr) { var C_ITEM itm; itm = _^(itmPtr); return C_GetMushroomPrice(itm); }; func void C_SetMushroomPriceByPtr(var int itmPtr) { var C_ITEM itm; itm = _^(itmPtr); itm.value = C_GetMushroomPrice(itm); }; //=========================================== instance ItMr_YellowFun(Proto_Mushroom) { description = "2Khaos"; //name = description; if (!OPT_HideMrNames) { name = description;}; visual = "ItPl_YellowFun.3DS"; effect = "SPELLFX_WEAKGLIMMER_YELLOW"; text[5] = NAME_NoValue; text[3] = "Съешь меня!"; on_state[0] = Use_Mushroom_YellowFun; }; func void Use_Mushroom_YellowFun() { Npc_ChangeAttribute(self,ATR_HITPOINTS,-self.attribute[ATR_HITPOINTS]); };
D
import std.stdio; import std.string; void main() { int n; int count[6]; count[] = 0; string str = chomp(readln()); foreach (char c; str) { n = c - 'A'; if ( 0 <= n && n < 6) { count[n]++; } } for (uint i; i < 6; i++) { if (i == 5) { write(count[i],"\n"); } else { write(count[i]," "); } } }
D
/* THIS FILE GENERATED BY bcd.gen */ module bcd.fltk.Fl_JPEG_Image; public import bcd.bind; public import bcd.fltk.Fl_Image; public import bcd.fltk.Enumerations; extern (C) void _BCD_delete_13Fl_JPEG_Image(void *); extern (C) void *_BCD_new__ZN13Fl_JPEG_ImageC1EPKc(char *); extern (C) void _BCD_RI_13Fl_JPEG_Image(void *cd, void *dd); extern (C) void _BCD_delete_13Fl_JPEG_Image__Fl_JPEG_Image_R(void *This); extern (C) void *_BCD_new__ZN13Fl_JPEG_ImageC1EPKc_R(char *); class Fl_JPEG_Image : Fl_RGB_Image { this(ifloat ignore) { super(ignore); } this(ifloat ignore, void *x) { super(ignore); __C_data = x; __C_data_owned = false; } ~this() { if (__C_data && __C_data_owned) _BCD_delete_13Fl_JPEG_Image(__C_data); __C_data = null; } this(char * filename) { super(cast(ifloat) 0); __C_data = _BCD_new__ZN13Fl_JPEG_ImageC1EPKc(filename); __C_data_owned = true; } } class Fl_JPEG_Image_R : Fl_JPEG_Image { ~this() { if (__C_data && __C_data_owned) _BCD_delete_13Fl_JPEG_Image__Fl_JPEG_Image_R(__C_data); __C_data = null; } this(char * filename) { super(cast(ifloat) 0); __C_data = _BCD_new__ZN13Fl_JPEG_ImageC1EPKc_R(filename); __C_data_owned = true; _BCD_RI_13Fl_JPEG_Image(__C_data, cast(void *) this); } }
D
/** gl3n.linalg Special thanks to: $(UL $(LI Tomasz Stachowiak (h3r3tic): allowed me to use parts of $(LINK2 https://bitbucket.org/h3r3tic/boxen/src/default/src/xf/omg, omg).) $(LI Jakob Øvrum (jA_cOp): improved the code a lot!) $(LI Florian Boesch (___doc__): helps me to understand opengl/complex maths better, see: $(LINK http://codeflow.org/).) $(LI #D on freenode: answered general questions about D.) ) Authors: David Herberth License: MIT Note: All methods marked with pure are weakly pure since, they all access an instance member. All static methods are strongly pure. */ module gl3n.linalg; private { import std.math : isNaN, isInfinity; import std.conv : to; import std.traits : isFloatingPoint, isStaticArray, isDynamicArray, isImplicitlyConvertible, isArray; import std.string : format, rightJustify; import std.array : join; import std.algorithm : max, min, reduce; import gl3n.math : clamp, PI, sqrt, sin, cos, acos, tan, asin, atan2, almost_equal; import gl3n.util : is_vector, is_matrix, is_quaternion, TupleRange; } version(NoReciprocalMul) { private enum rmul = false; } else { private enum rmul = true; } /// Base template for all vector-types. /// Params: /// type = all values get stored as this type /// dimension = specifies the dimension of the vector, can be 1, 2, 3 or 4 /// Examples: /// --- /// alias Vector!(int, 3) vec3i; /// alias Vector!(float, 4) vec4; /// alias Vector!(real, 2) vec2r; /// --- struct Vector(type, int dimension_) { alias type vt; /// Holds the internal type of the vector. static const int dimension = dimension_; ///Holds the dimension of the vector. vt[dimension] vector; /// Holds all coordinates, length conforms dimension. /// Returns a pointer to the coordinates. @property auto value_ptr() { return vector.ptr; } /// Returns the current vector formatted as string, useful for printing the vector. @property string as_string() { return format("%s", vector); } alias as_string toString; /// ditto @safe pure nothrow: /// private @property ref inout(vt) get_(char coord)() inout { return vector[coord_to_index!coord]; } alias get_!'x' x; /// static properties to access the values. alias get_!'y' y; /// ditto alias x u; /// ditto alias y v; /// ditto alias x s; /// ditto alias y t; /// ditto alias x r; /// ditto alias y g; /// ditto static if(dimension >= 3) { alias get_!'z' z; /// ditto alias z b; /// ditto alias z p; /// ditto } static if(dimension >= 4) { alias get_!'w' w; /// ditto alias w a; /// ditto alias w q; /// ditto } static if(dimension == 2) { enum Vector e1 = Vector(1, 0); /// canonical basis for Euclidian space enum Vector e2 = Vector(0, 1); /// ditto } else static if(dimension == 3) { enum Vector e1 = Vector(1, 0, 0); /// canonical basis for Euclidian space enum Vector e2 = Vector(0, 1, 0); /// ditto enum Vector e3 = Vector(0, 0, 1); /// ditto } else static if(dimension == 4) { enum Vector e1 = Vector(1, 0, 0, 0); /// canonical basis for Euclidian space enum Vector e2 = Vector(0, 1, 0, 0); /// ditto enum Vector e3 = Vector(0, 0, 1, 0); /// ditto enum Vector e4 = Vector(0, 0, 0, 1); /// ditto } unittest { assert(vec2.e1.vector == [1.0, 0.0]); assert(vec2.e2.vector == [0.0, 1.0]); assert(vec3.e1.vector == [1.0, 0.0, 0.0]); assert(vec3.e2.vector == [0.0, 1.0, 0.0]); assert(vec3.e3.vector == [0.0, 0.0, 1.0]); assert(vec4.e1.vector == [1.0, 0.0, 0.0, 0.0]); assert(vec4.e2.vector == [0.0, 1.0, 0.0, 0.0]); assert(vec4.e3.vector == [0.0, 0.0, 1.0, 0.0]); assert(vec4.e4.vector == [0.0, 0.0, 0.0, 1.0]); } static void isCompatibleVectorImpl(int d)(Vector!(vt, d) vec) if(d <= dimension) { } template isCompatibleVector(T) { enum isCompatibleVector = is(typeof(isCompatibleVectorImpl(T.init))); } static void isCompatibleMatrixImpl(int r, int c)(Matrix!(vt, r, c) m) { } template isCompatibleMatrix(T) { enum isCompatibleMatrix = is(typeof(isCompatibleMatrixImpl(T.init))); } private void construct(int i, T, Tail...)(T head, Tail tail) { static if(i >= dimension) { static assert(false, "Too many arguments passed to constructor"); } else static if(is(T : vt)) { vector[i] = head; construct!(i + 1)(tail); } else static if(isDynamicArray!T) { static assert((Tail.length == 0) && (i == 0), "dynamic array can not be passed together with other arguments"); vector[] = head[]; } else static if(isStaticArray!T) { vector[i .. i + T.length] = head[]; construct!(i + T.length)(tail); } else static if(isCompatibleVector!T) { vector[i .. i + T.dimension] = head.vector[]; construct!(i + T.dimension)(tail); } else { static assert(false, "Vector constructor argument must be of type " ~ vt.stringof ~ " or Vector, not " ~ T.stringof); } } private void construct(int i)() { // terminate static assert(i == dimension, "Not enough arguments passed to constructor"); } /// Constructs the vector. /// If a single value is passed the vector, the vector will be cleared with this value. /// If a vector with a higher dimension is passed the vector will hold the first values up to its dimension. /// If mixed types are passed they will be joined together (allowed types: vector, static array, $(I vt)). /// Examples: /// --- /// vec4 v4 = vec4(1.0f, vec2(2.0f, 3.0f), 4.0f); /// vec3 v3 = vec3(v4); // v3 = vec3(1.0f, 2.0f, 3.0f); /// vec2 v2 = v3.xy; // swizzling returns a static array. /// vec3 v3_2 = vec3(1.0f); // vec3 v3_2 = vec3(1.0f, 1.0f, 1.0f); /// --- this(Args...)(Args args) { construct!(0)(args); } /// ditto this(T)(T vec) if(is_vector!T && is(T.vt : vt) && (T.dimension >= dimension)) { foreach(i; TupleRange!(0, dimension)) { vector[i] = vec.vector[i]; } } /// ditto this()(vt value) { clear(value); } /// Returns true if all values are not nan and finite, otherwise false. @property bool ok() const { foreach(v; vector) { if(isNaN(v) || isInfinity(v)) { return false; } } return true; } /// Sets all values of the vector to value. void clear(vt value) { foreach(i; TupleRange!(0, dimension)) { vector[i] = value; } } unittest { vec3 vec_clear; assert(!vec_clear.ok); vec_clear.clear(1.0f); assert(vec_clear.ok); assert(vec_clear.vector == [1.0f, 1.0f, 1.0f]); assert(vec_clear.vector == vec3(1.0f).vector); vec_clear.clear(float.infinity); assert(!vec_clear.ok); vec_clear.clear(float.nan); assert(!vec_clear.ok); vec_clear.clear(1.0f); assert(vec_clear.ok); vec4 b = vec4(1.0f, vec_clear); assert(b.ok); assert(b.vector == [1.0f, 1.0f, 1.0f, 1.0f]); assert(b.vector == vec4(1.0f).vector); vec2 v2_1 = vec2(vec2(0.0f, 1.0f)); assert(v2_1.vector == [0.0f, 1.0f]); vec2 v2_2 = vec2(1.0f, 1.0f); assert(v2_2.vector == [1.0f, 1.0f]); vec3 v3 = vec3(v2_1, 2.0f); assert(v3.vector == [0.0f, 1.0f, 2.0f]); vec4 v4_1 = vec4(1.0f, vec2(2.0f, 3.0f), 4.0f); assert(v4_1.vector == [1.0f, 2.0f, 3.0f, 4.0f]); assert(vec3(v4_1).vector == [1.0f, 2.0f, 3.0f]); assert(vec2(vec3(v4_1)).vector == [1.0f, 2.0f]); assert(vec2(vec3(v4_1)).vector == vec2(v4_1).vector); assert(v4_1.vector == vec4([1.0f, 2.0f, 3.0f, 4.0f]).vector); vec4 v4_2 = vec4(vec2(1.0f, 2.0f), vec2(3.0f, 4.0f)); assert(v4_2.vector == [1.0f, 2.0f, 3.0f, 4.0f]); assert(vec3(v4_2).vector == [1.0f, 2.0f, 3.0f]); assert(vec2(vec3(v4_2)).vector == [1.0f, 2.0f]); assert(vec2(vec3(v4_2)).vector == vec2(v4_2).vector); assert(v4_2.vector == vec4([1.0f, 2.0f, 3.0f, 4.0f]).vector); float[2] f2 = [1.0f, 2.0f]; float[3] f3 = [1.0f, 2.0f, 3.0f]; float[4] f4 = [1.0f, 2.0f, 3.0f, 4.0f]; assert(vec2(1.0f, 2.0f).vector == vec2(f2).vector); assert(vec3(1.0f, 2.0f, 3.0f).vector == vec3(f3).vector); assert(vec3(1.0f, 2.0f, 3.0f).vector == vec3(f2, 3.0f).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f).vector == vec4(f4).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f).vector == vec4(f3, 4.0f).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f).vector == vec4(f2, 3.0f, 4.0f).vector); // useful for: "vec4 v4 = […]" or "vec4 v4 = other_vector.rgba" assert(vec3(vec3i(1, 2, 3)) == vec3(1.0, 2.0, 3.0)); assert(vec3d(vec3(1.0, 2.0, 3.0)) == vec3d(1.0, 2.0, 3.0)); static assert(!__traits(compiles, vec3(0.0f, 0.0f))); static assert(!__traits(compiles, vec4(0.0f, 0.0f, 0.0f))); static assert(!__traits(compiles, vec4(0.0f, vec2(0.0f, 0.0f)))); static assert(!__traits(compiles, vec4(vec3(0.0f, 0.0f, 0.0f)))); } template coord_to_index(char c) { static if((c == 'x') || (c == 'r') || (c == 'u') || (c == 's')) { enum coord_to_index = 0; } else static if((c == 'y') || (c == 'g') || (c == 'v') || (c == 't')) { enum coord_to_index = 1; } else static if((c == 'z') || (c == 'b') || (c == 'p')) { static assert(dimension >= 3, "the " ~ c ~ " property is only available on vectors with a third dimension."); enum coord_to_index = 2; } else static if((c == 'w') || (c == 'a') || (c == 'q')) { static assert(dimension >= 4, "the " ~ c ~ " property is only available on vectors with a fourth dimension."); enum coord_to_index = 3; } else { static assert(false, "accepted coordinates are x, s, r, u, y, g, t, v, z, p, b, w, q and a not " ~ c ~ "."); } } static if(dimension == 2) { void set(vt x, vt y) { vector[0] = x; vector[1] = y; } } static if(dimension == 3) { void set(vt x, vt y, vt z) { vector[0] = x; vector[1] = y; vector[2] = z; } } static if(dimension == 4) { void set(vt x, vt y, vt z, vt w) { vector[0] = x; vector[1] = y; vector[2] = z; vector[3] = w; } } /// Updates the vector with the values from other. void update(Vector!(vt, dimension) other) { vector = other.vector; } unittest { vec2 v2 = vec2(1.0f, 2.0f); assert(v2.x == 1.0f); assert(v2.y == 2.0f); v2.x = 3.0f; v2.x += 1; v2.x -= 1; assert(v2.vector == [3.0f, 2.0f]); v2.y = 4.0f; v2.y += 1; v2.y -= 1; assert(v2.vector == [3.0f, 4.0f]); assert((v2.x == 3.0f) && (v2.x == v2.u) && (v2.x == v2.s) && (v2.x == v2.r)); assert(v2.y == 4.0f); assert((v2.y == 4.0f) && (v2.y == v2.v) && (v2.y == v2.t) && (v2.y == v2.g)); v2.set(0.0f, 1.0f); assert(v2.vector == [0.0f, 1.0f]); v2.update(vec2(3.0f, 4.0f)); assert(v2.vector == [3.0f, 4.0f]); vec3 v3 = vec3(1.0f, 2.0f, 3.0f); assert(v3.x == 1.0f); assert(v3.y == 2.0f); assert(v3.z == 3.0f); v3.x = 3.0f; v3.x += 1; v3.x -= 1; assert(v3.vector == [3.0f, 2.0f, 3.0f]); v3.y = 4.0f; v3.y += 1; v3.y -= 1; assert(v3.vector == [3.0f, 4.0f, 3.0f]); v3.z = 5.0f; v3.z += 1; v3.z -= 1; assert(v3.vector == [3.0f, 4.0f, 5.0f]); assert((v3.x == 3.0f) && (v3.x == v3.s) && (v3.x == v3.r)); assert((v3.y == 4.0f) && (v3.y == v3.t) && (v3.y == v3.g)); assert((v3.z == 5.0f) && (v3.z == v3.p) && (v3.z == v3.b)); v3.set(0.0f, 1.0f, 2.0f); assert(v3.vector == [0.0f, 1.0f, 2.0f]); v3.update(vec3(3.0f, 4.0f, 5.0f)); assert(v3.vector == [3.0f, 4.0f, 5.0f]); vec4 v4 = vec4(1.0f, 2.0f, vec2(3.0f, 4.0f)); assert(v4.x == 1.0f); assert(v4.y == 2.0f); assert(v4.z == 3.0f); assert(v4.w == 4.0f); v4.x = 3.0f; v4.x += 1; v4.x -= 1; assert(v4.vector == [3.0f, 2.0f, 3.0f, 4.0f]); v4.y = 4.0f; v4.y += 1; v4.y -= 1; assert(v4.vector == [3.0f, 4.0f, 3.0f, 4.0f]); v4.z = 5.0f; v4.z += 1; v4.z -= 1; assert(v4.vector == [3.0f, 4.0f, 5.0f, 4.0f]); v4.w = 6.0f; v4.w += 1; v4.w -= 1; assert(v4.vector == [3.0f, 4.0f, 5.0f, 6.0f]); assert((v4.x == 3.0f) && (v4.x == v4.s) && (v4.x == v4.r)); assert((v4.y == 4.0f) && (v4.y == v4.t) && (v4.y == v4.g)); assert((v4.z == 5.0f) && (v4.z == v4.p) && (v4.z == v4.b)); assert((v4.w == 6.0f) && (v4.w == v4.q) && (v4.w == v4.a)); v4.set(0.0f, 1.0f, 2.0f, 3.0f); assert(v4.vector == [0.0f, 1.0f, 2.0f, 3.0f]); v4.update(vec4(3.0f, 4.0f, 5.0f, 6.0f)); assert(v4.vector == [3.0f, 4.0f, 5.0f, 6.0f]); } private void dispatchImpl(int i, string s, int size)(ref vt[size] result) const { static if(s.length > 0) { result[i] = vector[coord_to_index!(s[0])]; dispatchImpl!(i + 1, s[1..$])(result); } } /// Implements dynamic swizzling. /// Returns: a Vector @property Vector!(vt, s.length) opDispatch(string s)() const { vt[s.length] ret; dispatchImpl!(0, s)(ret); Vector!(vt, s.length) ret_vec; ret_vec.vector = ret; return ret_vec; } unittest { vec2 v2 = vec2(1.0f, 2.0f); assert(v2.xytsy == [1.0f, 2.0f, 2.0f, 1.0f, 2.0f]); assert(vec3(1.0f, 2.0f, 3.0f).xybzyr == [1.0f, 2.0f, 3.0f, 3.0f, 2.0f, 1.0f]); assert(vec4(v2, 3.0f, 4.0f).xyzwrgbastpq == [1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f]); assert(vec4(v2, 3.0f, 4.0f).wgyzax == [4.0f, 2.0f, 2.0f, 3.0f, 4.0f, 1.0f]); assert(vec4(v2.xyst).vector == [1.0f, 2.0f, 1.0f, 2.0f]); } /// Returns the squared magnitude of the vector. @property real magnitude_squared() const { real temp = 0; foreach(index; TupleRange!(0, dimension)) { temp += vector[index]^^2; } return temp; } /// Returns the magnitude of the vector. @property real magnitude() const { return sqrt(magnitude_squared); } alias magnitude_squared length_squared; /// ditto alias magnitude length; /// ditto /// Normalizes the vector. void normalize() { real len = length; if(len != 0) { foreach(index; TupleRange!(0, dimension)) { vector[index] /= len; } } } /// Returns a normalized copy of the current vector. @property Vector normalized() const { Vector ret; ret.update(this); ret.normalize(); return ret; } Vector opUnary(string op : "-")() const { Vector ret; foreach(index; TupleRange!(0, dimension)) { ret.vector[index] = -vector[index]; } return ret; } unittest { assert(vec2(1.0f, 1.0f) == -vec2(-1.0f, -1.0f)); assert(vec2(-1.0f, 1.0f) == -vec2(1.0f, -1.0f)); assert(-vec3(1.0f, 1.0f, 1.0f) == vec3(-1.0f, -1.0f, -1.0f)); assert(-vec3(-1.0f, 1.0f, -1.0f) == vec3(1.0f, -1.0f, 1.0f)); assert(vec4(1.0f, 1.0f, 1.0f, 1.0f) == -vec4(-1.0f, -1.0f, -1.0f, -1.0f)); assert(vec4(-1.0f, 1.0f, -1.0f, 1.0f) == -vec4(1.0f, -1.0f, 1.0f, -1.0f)); } // let the math begin! Vector opBinary(string op : "*")(vt r) const { Vector ret; foreach(index; TupleRange!(0, dimension)) { ret.vector[index] = vector[index] * r; } return ret; } Vector opBinary(string op)(Vector r) const if((op == "+") || (op == "-")) { Vector ret; foreach(index; TupleRange!(0, dimension)) { ret.vector[index] = mixin("vector[index]" ~ op ~ "r.vector[index]"); } return ret; } vt opBinary(string op : "*")(Vector r) const { return dot(this, r); } Vector!(vt, T.rows) opBinary(string op : "*", T)(T inp) const if(isCompatibleMatrix!T && (T.cols == dimension)) { Vector!(vt, T.rows) ret; ret.clear(0); foreach(c; TupleRange!(0, T.cols)) { foreach(r; TupleRange!(0, T.rows)) { ret.vector[r] += vector[c] * inp.matrix[r][c]; } } return ret; } auto opBinaryRight(string op, T)(T inp) const if(!is_vector!T && !is_matrix!T && !is_quaternion!T) { return this.opBinary!(op)(inp); } unittest { vec2 v2 = vec2(1.0f, 3.0f); 2 * v2; assert((v2*2.5f).vector == [2.5f, 7.5f]); assert((v2+vec2(3.0f, 1.0f)).vector == [4.0f, 4.0f]); assert((v2-vec2(1.0f, 3.0f)).vector == [0.0f, 0.0f]); assert((v2*vec2(2.0f, 2.0f)) == 8.0f); vec3 v3 = vec3(1.0f, 3.0f, 5.0f); assert((v3*2.5f).vector == [2.5f, 7.5f, 12.5f]); assert((v3+vec3(3.0f, 1.0f, -1.0f)).vector == [4.0f, 4.0f, 4.0f]); assert((v3-vec3(1.0f, 3.0f, 5.0f)).vector == [0.0f, 0.0f, 0.0f]); assert((v3*vec3(2.0f, 2.0f, 2.0f)) == 18.0f); vec4 v4 = vec4(1.0f, 3.0f, 5.0f, 7.0f); assert((v4*2.5f).vector == [2.5f, 7.5f, 12.5f, 17.5]); assert((v4+vec4(3.0f, 1.0f, -1.0f, -3.0f)).vector == [4.0f, 4.0f, 4.0f, 4.0f]); assert((v4-vec4(1.0f, 3.0f, 5.0f, 7.0f)).vector == [0.0f, 0.0f, 0.0f, 0.0f]); assert((v4*vec4(2.0f, 2.0f, 2.0f, 2.0f)) == 32.0f); mat2 m2 = mat2(1.0f, 2.0f, 3.0f, 4.0f); vec2 v2_2 = vec2(2.0f, 2.0f); assert((v2_2*m2).vector == [6.0f, 14.0f]); mat3 m3 = mat3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); vec3 v3_2 = vec3(2.0f, 2.0f, 2.0f); assert((v3_2*m3).vector == [12.0f, 30.0f, 48.0f]); } void opOpAssign(string op : "*")(vt r) { foreach(index; TupleRange!(0, dimension)) { vector[index] *= r; } } void opOpAssign(string op)(Vector r) if((op == "+") || (op == "-")) { foreach(index; TupleRange!(0, dimension)) { mixin("vector[index]" ~ op ~ "= r.vector[index];"); } } unittest { vec2 v2 = vec2(1.0f, 3.0f); v2 *= 2.5f; assert(v2.vector == [2.5f, 7.5f]); v2 -= vec2(2.5f, 7.5f); assert(v2.vector == [0.0f, 0.0f]); v2 += vec2(1.0f, 3.0f); assert(v2.vector == [1.0f, 3.0f]); assert(v2.length == sqrt(10.0f)); assert(v2.length_squared == 10.0f); assert((v2.magnitude == v2.length) && (v2.magnitude_squared == v2.length_squared)); assert(almost_equal(v2.normalized, vec2(1.0f/sqrt(10.0f), 3.0f/sqrt(10.0f)))); vec3 v3 = vec3(1.0f, 3.0f, 5.0f); v3 *= 2.5f; assert(v3.vector == [2.5f, 7.5f, 12.5f]); v3 -= vec3(2.5f, 7.5f, 12.5f); assert(v3.vector == [0.0f, 0.0f, 0.0f]); v3 += vec3(1.0f, 3.0f, 5.0f); assert(v3.vector == [1.0f, 3.0f, 5.0f]); assert(v3.length == sqrt(35.0f)); assert(v3.length_squared == 35.0f); assert((v3.magnitude == v3.length) && (v3.magnitude_squared == v3.length_squared)); assert(almost_equal(v3.normalized, vec3(1.0f/sqrt(35.0f), 3.0f/sqrt(35.0f), 5.0f/sqrt(35.0f)))); vec4 v4 = vec4(1.0f, 3.0f, 5.0f, 7.0f); v4 *= 2.5f; assert(v4.vector == [2.5f, 7.5f, 12.5f, 17.5]); v4 -= vec4(2.5f, 7.5f, 12.5f, 17.5f); assert(v4.vector == [0.0f, 0.0f, 0.0f, 0.0f]); v4 += vec4(1.0f, 3.0f, 5.0f, 7.0f); assert(v4.vector == [1.0f, 3.0f, 5.0f, 7.0f]); assert(v4.length == sqrt(84.0f)); assert(v4.length_squared == 84.0f); assert((v4.magnitude == v4.length) && (v4.magnitude_squared == v4.length_squared)); assert(almost_equal(v4.normalized, vec4(1.0f/sqrt(84.0f), 3.0f/sqrt(84.0f), 5.0f/sqrt(84.0f), 7.0f/sqrt(84.0f)))); } const bool opEquals(T)(const T vec) if(!isArray!T && T.dimension == dimension) { return vector == vec.vector; } const bool opEquals(T)(const(T)[] array) if(!isArray!T && !is_vector!T) { if(array.length != dimension) { return false; } foreach(index; TupleRange!(0, dimension)) { if(vector[index] != array[index]) { return false; } } return true; } bool opCast(T : bool)() const { return ok; } unittest { assert(vec2(1.0f, 2.0f) == vec2(1.0f, 2.0f)); assert(vec2(1.0f, 2.0f) != vec2(1.0f, 1.0f)); assert(vec2(1.0f, 2.0f) == vec2d(1.0, 2.0)); assert(vec2(1.0f, 2.0f) != vec2d(1.0, 1.0)); assert(vec2(1.0f, 2.0f) == vec2(1.0f, 2.0f).vector); assert(vec2(1.0f, 2.0f) != vec2(1.0f, 1.0f).vector); assert(vec2(1.0f, 2.0f) == vec2d(1.0, 2.0).vector); assert(vec2(1.0f, 2.0f) != vec2d(1.0, 1.0).vector); assert(vec3(1.0f, 2.0f, 3.0f) == vec3(1.0f, 2.0f, 3.0f)); assert(vec3(1.0f, 2.0f, 3.0f) != vec3(1.0f, 2.0f, 2.0f)); assert(vec3(1.0f, 2.0f, 3.0f) == vec3d(1.0, 2.0, 3.0)); assert(vec3(1.0f, 2.0f, 3.0f) != vec3d(1.0, 2.0, 2.0)); assert(vec3(1.0f, 2.0f, 3.0f) == vec3(1.0f, 2.0f, 3.0f).vector); assert(vec3(1.0f, 2.0f, 3.0f) != vec3(1.0f, 2.0f, 2.0f).vector); assert(vec3(1.0f, 2.0f, 3.0f) == vec3d(1.0, 2.0, 3.0).vector); assert(vec3(1.0f, 2.0f, 3.0f) != vec3d(1.0, 2.0, 2.0).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) == vec4(1.0f, 2.0f, 3.0f, 4.0f)); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) != vec4(1.0f, 2.0f, 3.0f, 3.0f)); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) == vec4d(1.0, 2.0, 3.0, 4.0)); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) != vec4d(1.0, 2.0, 3.0, 3.0)); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) == vec4(1.0f, 2.0f, 3.0f, 4.0f).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) != vec4(1.0f, 2.0f, 3.0f, 3.0f).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) == vec4d(1.0, 2.0, 3.0, 4.0).vector); assert(vec4(1.0f, 2.0f, 3.0f, 4.0f) != vec4d(1.0, 2.0, 3.0, 3.0).vector); assert(!(vec4(float.nan))); if(vec4(1.0f)) { } else { assert(false); } } } /// Calculates the product between two vectors. @safe pure nothrow T.vt dot(T)(const T veca, const T vecb) if(is_vector!T) { T.vt temp = 0; foreach(index; TupleRange!(0, T.dimension)) { temp += veca.vector[index] * vecb.vector[index]; } return temp; } /// Calculates the cross product of two 3-dimensional vectors. @safe pure nothrow T cross(T)(const T veca, const T vecb) if(is_vector!T && (T.dimension == 3)) { return T(veca.y * vecb.z - vecb.y * veca.z, veca.z * vecb.x - vecb.z * veca.x, veca.x * vecb.y - vecb.x * veca.y); } /// Calculates the distance between two vectors. @safe pure nothrow T.vt distance(T)(const T veca, const T vecb) if(is_vector!T) { return (veca - vecb).length; } unittest { // dot is already tested in Vector.opBinary, so no need for testing with more vectors vec3 v1 = vec3(1.0f, 2.0f, -3.0f); vec3 v2 = vec3(1.0f, 3.0f, 2.0f); assert(dot(v1, v2) == 1.0f); assert(dot(v1, v2) == (v1 * v2)); assert(dot(v1, v2) == dot(v2, v1)); assert((v1 * v2) == (v1 * v2)); assert(cross(v1, v2).vector == [13.0f, -5.0f, 1.0f]); assert(cross(v2, v1).vector == [-13.0f, 5.0f, -1.0f]); assert(distance(vec2(0.0f, 0.0f), vec2(0.0f, 10.0f)) == 10.0); } /// Pre-defined vector types, the number represents the dimension and the last letter the type (none = float, d = double, i = int). alias Vector!(float, 2) vec2; alias Vector!(float, 3) vec3; /// ditto alias Vector!(float, 4) vec4; /// ditto alias Vector!(double, 2) vec2d; /// ditto alias Vector!(double, 3) vec3d; /// ditto alias Vector!(double, 4) vec4d; /// ditto alias Vector!(int, 2) vec2i; /// ditto alias Vector!(int, 3) vec3i; /// ditto alias Vector!(int, 4) vec4i; /// ditto /*alias Vector!(ubyte, 2) vec2ub; alias Vector!(ubyte, 3) vec3ub; alias Vector!(ubyte, 4) vec4ub;*/ /// Base template for all matrix-types. /// Params: /// type = all values get stored as this type /// rows_ = rows of the matrix /// cols_ = columns of the matrix /// Examples: /// --- /// alias Matrix!(float, 4, 4) mat4; /// alias Matrix!(double, 3, 4) mat34d; /// alias Matrix!(real, 2, 2) mat2r; /// --- struct Matrix(type, int rows_, int cols_) if((rows_ > 0) && (cols_ > 0)) { alias type mt; /// Holds the internal type of the matrix; static const int rows = rows_; /// Holds the number of rows; static const int cols = cols_; /// Holds the number of columns; /// Holds the matrix $(RED row-major) in memory. mt[cols][rows] matrix; // In C it would be mt[rows][cols], D does it like this: (mt[foo])[bar] alias matrix this; unittest { mat2 m2 = mat2(0.0f, 1.0f, 2.0f, 3.0f); assert(m2[0][0] == 0.0f); assert(m2[0][1] == 1.0f); assert(m2[1][0] == 2.0f); assert(m2[1][1] == 3.0f); m2[0..1] = [2.0f, 2.0f]; assert(m2 == [[2.0f, 2.0f], [2.0f, 3.0f]]); mat3 m3 = mat3(0.0f, 0.1f, 0.2f, 1.0f, 1.1f, 1.2f, 2.0f, 2.1f, 2.2f); assert(m3[0][1] == 0.1f); assert(m3[2][0] == 2.0f); assert(m3[1][2] == 1.2f); m3[0][0..$] = 0.0f; assert(m3 == [[0.0f, 0.0f, 0.0f], [1.0f, 1.1f, 1.2f], [2.0f, 2.1f, 2.2f]]); mat4 m4 = mat4(0.0f, 0.1f, 0.2f, 0.3f, 1.0f, 1.1f, 1.2f, 1.3f, 2.0f, 2.1f, 2.2f, 2.3f, 3.0f, 3.1f, 3.2f, 3.3f); assert(m4[0][3] == 0.3f); assert(m4[1][1] == 1.1f); assert(m4[2][0] == 2.0f); assert(m4[3][2] == 3.2f); m4[2][1..3] = [1.0f, 2.0f]; assert(m4 == [[0.0f, 0.1f, 0.2f, 0.3f], [1.0f, 1.1f, 1.2f, 1.3f], [2.0f, 1.0f, 2.0f, 2.3f], [3.0f, 3.1f, 3.2f, 3.3f]]); } /// Returns the pointer to the stored values as OpenGL requires it. /// Note this will return a pointer to a $(RED row-major) matrix, /// $(RED this means you've to set the transpose argument to GL_TRUE when passing it to OpenGL). /// Examples: /// --- /// // 3rd argument = GL_TRUE /// glUniformMatrix4fv(programs.main.model, 1, GL_TRUE, mat4.translation(-0.5f, -0.5f, 1.0f).value_ptr); /// --- @property auto value_ptr() { return matrix[0].ptr; } /// Returns the current matrix formatted as flat string. @property string as_string() { return format("%s", matrix); } alias as_string toString; /// ditto /// Returns the current matrix as pretty formatted string. @property string as_pretty_string() { string fmtr = "%s"; size_t rjust = max(format(fmtr, reduce!(max)(matrix[])).length, format(fmtr, reduce!(min)(matrix[])).length) - 1; string[] outer_parts; foreach(mt[] row; matrix) { string[] inner_parts; foreach(mt col; row) { inner_parts ~= rightJustify(format(fmtr, col), rjust); } outer_parts ~= " [" ~ join(inner_parts, ", ") ~ "]"; } return "[" ~ join(outer_parts, "\n")[1..$] ~ "]"; } alias as_pretty_string toPrettyString; /// ditto @safe pure nothrow: static void isCompatibleMatrixImpl(int r, int c)(Matrix!(mt, r, c) m) { } template isCompatibleMatrix(T) { enum isCompatibleMatrix = is(typeof(isCompatibleMatrixImpl(T.init))); } static void isCompatibleVectorImpl(int d)(Vector!(mt, d) vec) { } template isCompatibleVector(T) { enum isCompatibleVector = is(typeof(isCompatibleVectorImpl(T.init))); } private void construct(int i, T, Tail...)(T head, Tail tail) { static if(i >= rows*cols) { static assert(false, "Too many arguments passed to constructor"); } else static if(is(T : mt)) { matrix[i / cols][i % cols] = head; construct!(i + 1)(tail); } else static if(is(T == Vector!(mt, cols))) { static if(i % cols == 0) { matrix[i / cols] = head.vector; construct!(i + T.dimension)(tail); } else { static assert(false, "Can't convert Vector into the matrix. Maybe it doesn't align to the columns correctly or dimension doesn't fit"); } } else { static assert(false, "Matrix constructor argument must be of type " ~ mt.stringof ~ " or Vector, not " ~ T.stringof); } } private void construct(int i)() { // terminate static assert(i == rows*cols, "Not enough arguments passed to constructor"); } /// Constructs the matrix: /// If a single value is passed, the matrix will be cleared with this value (each column in each row will contain this value). /// If a matrix with more rows and columns is passed, the matrix will be the upper left nxm matrix. /// If a matrix with less rows and columns is passed, the passed matrix will be stored in the upper left of an identity matrix. /// It's also allowed to pass vectors and scalars at a time, but the vectors dimension must match the number of columns and align correctly. /// Examples: /// --- /// mat2 m2 = mat2(0.0f); // mat2 m2 = mat2(0.0f, 0.0f, 0.0f, 0.0f); /// mat3 m3 = mat3(m2); // mat3 m3 = mat3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); /// mat3 m3_2 = mat3(vec3(1.0f, 2.0f, 3.0f), 4.0f, 5.0f, 6.0f, vec3(7.0f, 8.0f, 9.0f)); /// mat4 m4 = mat4.identity; // just an identity matrix /// mat3 m3_3 = mat3(m4); // mat3 m3_3 = mat3.identity /// --- this(Args...)(Args args) { construct!(0)(args); } /// ditto this(T)(T mat) if(is_matrix!T && (T.cols >= cols) && (T.rows >= rows)) { foreach(r; TupleRange!(0, rows)) { foreach(c; TupleRange!(0, cols)) { matrix[r][c] = mat.matrix[r][c]; } } } /// ditto this(T)(T mat) if(is_matrix!T && (T.cols < cols) && (T.rows < rows)) { make_identity(); foreach(r; TupleRange!(0, T.rows)) { foreach(c; TupleRange!(0, T.cols)) { matrix[r][c] = mat.matrix[r][c]; } } } /// ditto this()(mt value) { clear(value); } /// Returns true if all values are not nan and finite, otherwise false. @property bool ok() const { foreach(row; matrix) { foreach(col; row) { if(isNaN(col) || isInfinity(col)) { return false; } } } return true; } /// Sets all values of the matrix to value (each column in each row will contain this value). void clear(mt value) { foreach(r; TupleRange!(0, rows)) { foreach(c; TupleRange!(0, cols)) { matrix[r][c] = value; } } } unittest { mat2 m2 = mat2(1.0f, 1.0f, vec2(2.0f, 2.0f)); assert(m2.matrix == [[1.0f, 1.0f], [2.0f, 2.0f]]); m2.clear(3.0f); assert(m2.matrix == [[3.0f, 3.0f], [3.0f, 3.0f]]); assert(m2.ok); m2.clear(float.nan); assert(!m2.ok); m2.clear(float.infinity); assert(!m2.ok); m2.clear(0.0f); assert(m2.ok); mat3 m3 = mat3(1.0f); assert(m3.matrix == [[1.0f, 1.0f, 1.0f], [1.0f, 1.0f, 1.0f], [1.0f, 1.0f, 1.0f]]); mat4 m4 = mat4(vec4(1.0f, 1.0f, 1.0f, 1.0f), 2.0f, 2.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f, 3.0f, vec4(4.0f, 4.0f, 4.0f, 4.0f)); assert(m4.matrix == [[1.0f, 1.0f, 1.0f, 1.0f], [2.0f, 2.0f, 2.0f, 2.0f], [3.0f, 3.0f, 3.0f, 3.0f], [4.0f, 4.0f, 4.0f, 4.0f]]); assert(mat3(m4).matrix == [[1.0f, 1.0f, 1.0f], [2.0f, 2.0f, 2.0f], [3.0f, 3.0f, 3.0f]]); assert(mat2(mat3(m4)).matrix == [[1.0f, 1.0f], [2.0f, 2.0f]]); assert(mat2(m4).matrix == mat2(mat3(m4)).matrix); assert(mat4(mat3(m4)).matrix == [[1.0f, 1.0f, 1.0f, 0.0f], [2.0f, 2.0f, 2.0f, 0.0f], [3.0f, 3.0f, 3.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); Matrix!(float, 2, 3) mt1 = Matrix!(float, 2, 3)(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f); Matrix!(float, 3, 2) mt2 = Matrix!(float, 3, 2)(6.0f, -1.0f, 3.0f, 2.0f, 0.0f, -3.0f); assert(mt1.matrix == [[1.0f, 2.0f, 3.0f], [4.0f, 5.0f, 6.0f]]); assert(mt2.matrix == [[6.0f, -1.0f], [3.0f, 2.0f], [0.0f, -3.0f]]); static assert(!__traits(compiles, mat2(1, 2, 1))); static assert(!__traits(compiles, mat3(1, 2, 3, 1, 2, 3, 1, 2))); static assert(!__traits(compiles, mat4(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3))); } static if(rows == cols) { /// Makes the current matrix an identity matrix. void make_identity() { clear(0); foreach(r; TupleRange!(0, rows)) { matrix[r][r] = 1; } } /// Returns a identity matrix. static @property Matrix identity() { Matrix ret; ret.clear(0); foreach(r; TupleRange!(0, rows)) { ret.matrix[r][r] = 1; } return ret; } /// Transposes the current matrix; void transpose() { matrix = transposed().matrix; } unittest { mat2 m2 = mat2(1.0f); m2.transpose(); assert(m2.matrix == mat2(1.0f).matrix); m2.make_identity(); assert(m2.matrix == [[1.0f, 0.0f], [0.0f, 1.0f]]); m2.transpose(); assert(m2.matrix == [[1.0f, 0.0f], [0.0f, 1.0f]]); assert(m2.matrix == m2.identity.matrix); mat3 m3 = mat3(1.1f, 1.2f, 1.3f, 2.1f, 2.2f, 2.3f, 3.1f, 3.2f, 3.3f); m3.transpose(); assert(m3.matrix == [[1.1f, 2.1f, 3.1f], [1.2f, 2.2f, 3.2f], [1.3f, 2.3f, 3.3f]]); mat4 m4 = mat4(2.0f); m4.transpose(); assert(m4.matrix == mat4(2.0f).matrix); m4.make_identity(); assert(m4.matrix == [[1.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, 1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(m4.matrix == m4.identity.matrix); } } /// Returns a transposed copy of the matrix. @property Matrix!(mt, cols, rows) transposed() const { typeof(return) ret; foreach(r; TupleRange!(0, rows)) { foreach(c; TupleRange!(0, cols)) { ret.matrix[c][r] = matrix[r][c]; } } return ret; } // transposed already tested in last unittest static if((rows == 2) && (cols == 2)) { @property mt det() const { return (matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]); } private Matrix invert(ref Matrix mat) const { static if(isFloatingPoint!mt && rmul) { mt d = 1 / det; mat.matrix = [[matrix[1][1]*d, -matrix[0][1]*d], [-matrix[1][0]*d, matrix[0][0]*d]]; } else { mt d = det; mat.matrix = [[matrix[1][1]/d, -matrix[0][1]/d], [-matrix[1][0]/d, matrix[0][0]/d]]; } return mat; } } else static if((rows == 3) && (cols == 3)) { @property mt det() const { return (matrix[0][0] * matrix[1][1] * matrix[2][2] + matrix[0][1] * matrix[1][2] * matrix[2][0] + matrix[0][2] * matrix[1][0] * matrix[2][1] - matrix[0][2] * matrix[1][1] * matrix[2][0] - matrix[0][1] * matrix[1][0] * matrix[2][2] - matrix[0][0] * matrix[1][2] * matrix[2][1]); } private Matrix invert(ref Matrix mat) const { static if(isFloatingPoint!mt && rmul) { mt d = 1 / det; enum op = "*"; } else { mt d = det; enum op = "/"; } mixin(` mat.matrix = [[(matrix[1][1] * matrix[2][2] - matrix[1][2] * matrix[2][1])`~op~`d, (matrix[0][2] * matrix[2][1] - matrix[0][1] * matrix[2][2])`~op~`d, (matrix[0][1] * matrix[1][2] - matrix[0][2] * matrix[1][1])`~op~`d], [(matrix[1][2] * matrix[2][0] - matrix[1][0] * matrix[2][2])`~op~`d, (matrix[0][0] * matrix[2][2] - matrix[0][2] * matrix[2][0])`~op~`d, (matrix[0][2] * matrix[1][0] - matrix[0][0] * matrix[1][2])`~op~`d], [(matrix[1][0] * matrix[2][1] - matrix[1][1] * matrix[2][0])`~op~`d, (matrix[0][1] * matrix[2][0] - matrix[0][0] * matrix[2][1])`~op~`d, (matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0])`~op~`d]]; `); return mat; } static Matrix translation(mt x, mt y) { Matrix ret = Matrix.identity; ret.matrix[0][2] = x; ret.matrix[1][2] = y; return ret; } Matrix translate(mt x, mt y) { this = Matrix.translation(x, y) * this; return this; } static Matrix scaling(mt x, mt y) { Matrix ret = Matrix.identity; ret.matrix[0][0] = x; ret.matrix[1][1] = y; return ret; } Matrix scale(mt x, mt y) { this = Matrix.scaling(x, y) * this; return this; } } else static if((rows == 4) && (cols == 4)) { /// Returns the determinant of the current matrix (2x2, 3x3 and 4x4 matrices). @property mt det() const { return (matrix[0][3] * matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[0][2] * matrix[1][3] * matrix[2][1] * matrix[3][0] - matrix[0][3] * matrix[1][1] * matrix[2][2] * matrix[3][0] + matrix[0][1] * matrix[1][3] * matrix[2][2] * matrix[3][0] + matrix[0][2] * matrix[1][1] * matrix[2][3] * matrix[3][0] - matrix[0][1] * matrix[1][2] * matrix[2][3] * matrix[3][0] - matrix[0][3] * matrix[1][2] * matrix[2][0] * matrix[3][1] + matrix[0][2] * matrix[1][3] * matrix[2][0] * matrix[3][1] + matrix[0][3] * matrix[1][0] * matrix[2][2] * matrix[3][1] - matrix[0][0] * matrix[1][3] * matrix[2][2] * matrix[3][1] - matrix[0][2] * matrix[1][0] * matrix[2][3] * matrix[3][1] + matrix[0][0] * matrix[1][2] * matrix[2][3] * matrix[3][1] + matrix[0][3] * matrix[1][1] * matrix[2][0] * matrix[3][2] - matrix[0][1] * matrix[1][3] * matrix[2][0] * matrix[3][2] - matrix[0][3] * matrix[1][0] * matrix[2][1] * matrix[3][2] + matrix[0][0] * matrix[1][3] * matrix[2][1] * matrix[3][2] + matrix[0][1] * matrix[1][0] * matrix[2][3] * matrix[3][2] - matrix[0][0] * matrix[1][1] * matrix[2][3] * matrix[3][2] - matrix[0][2] * matrix[1][1] * matrix[2][0] * matrix[3][3] + matrix[0][1] * matrix[1][2] * matrix[2][0] * matrix[3][3] + matrix[0][2] * matrix[1][0] * matrix[2][1] * matrix[3][3] - matrix[0][0] * matrix[1][2] * matrix[2][1] * matrix[3][3] - matrix[0][1] * matrix[1][0] * matrix[2][2] * matrix[3][3] + matrix[0][0] * matrix[1][1] * matrix[2][2] * matrix[3][3]); } private Matrix invert(ref Matrix mat) const { static if(isFloatingPoint!mt && rmul) { mt d = 1 / det; enum op = "*"; } else { mt d = det; enum op = "/"; } mixin(` mat.matrix = [[(matrix[1][1] * matrix[2][2] * matrix[3][3] + matrix[1][2] * matrix[2][3] * matrix[3][1] + matrix[1][3] * matrix[2][1] * matrix[3][2] - matrix[1][1] * matrix[2][3] * matrix[3][2] - matrix[1][2] * matrix[2][1] * matrix[3][3] - matrix[1][3] * matrix[2][2] * matrix[3][1])`~op~`d, (matrix[0][1] * matrix[2][3] * matrix[3][2] + matrix[0][2] * matrix[2][1] * matrix[3][3] + matrix[0][3] * matrix[2][2] * matrix[3][1] - matrix[0][1] * matrix[2][2] * matrix[3][3] - matrix[0][2] * matrix[2][3] * matrix[3][1] - matrix[0][3] * matrix[2][1] * matrix[3][2])`~op~`d, (matrix[0][1] * matrix[1][2] * matrix[3][3] + matrix[0][2] * matrix[1][3] * matrix[3][1] + matrix[0][3] * matrix[1][1] * matrix[3][2] - matrix[0][1] * matrix[1][3] * matrix[3][2] - matrix[0][2] * matrix[1][1] * matrix[3][3] - matrix[0][3] * matrix[1][2] * matrix[3][1])`~op~`d, (matrix[0][1] * matrix[1][3] * matrix[2][2] + matrix[0][2] * matrix[1][1] * matrix[2][3] + matrix[0][3] * matrix[1][2] * matrix[2][1] - matrix[0][1] * matrix[1][2] * matrix[2][3] - matrix[0][2] * matrix[1][3] * matrix[2][1] - matrix[0][3] * matrix[1][1] * matrix[2][2])`~op~`d], [(matrix[1][0] * matrix[2][3] * matrix[3][2] + matrix[1][2] * matrix[2][0] * matrix[3][3] + matrix[1][3] * matrix[2][2] * matrix[3][0] - matrix[1][0] * matrix[2][2] * matrix[3][3] - matrix[1][2] * matrix[2][3] * matrix[3][0] - matrix[1][3] * matrix[2][0] * matrix[3][2])`~op~`d, (matrix[0][0] * matrix[2][2] * matrix[3][3] + matrix[0][2] * matrix[2][3] * matrix[3][0] + matrix[0][3] * matrix[2][0] * matrix[3][2] - matrix[0][0] * matrix[2][3] * matrix[3][2] - matrix[0][2] * matrix[2][0] * matrix[3][3] - matrix[0][3] * matrix[2][2] * matrix[3][0])`~op~`d, (matrix[0][0] * matrix[1][3] * matrix[3][2] + matrix[0][2] * matrix[1][0] * matrix[3][3] + matrix[0][3] * matrix[1][2] * matrix[3][0] - matrix[0][0] * matrix[1][2] * matrix[3][3] - matrix[0][2] * matrix[1][3] * matrix[3][0] - matrix[0][3] * matrix[1][0] * matrix[3][2])`~op~`d, (matrix[0][0] * matrix[1][2] * matrix[2][3] + matrix[0][2] * matrix[1][3] * matrix[2][0] + matrix[0][3] * matrix[1][0] * matrix[2][2] - matrix[0][0] * matrix[1][3] * matrix[2][2] - matrix[0][2] * matrix[1][0] * matrix[2][3] - matrix[0][3] * matrix[1][2] * matrix[2][0])`~op~`d], [(matrix[1][0] * matrix[2][1] * matrix[3][3] + matrix[1][1] * matrix[2][3] * matrix[3][0] + matrix[1][3] * matrix[2][0] * matrix[3][1] - matrix[1][0] * matrix[2][3] * matrix[3][1] - matrix[1][1] * matrix[2][0] * matrix[3][3] - matrix[1][3] * matrix[2][1] * matrix[3][0])`~op~`d, (matrix[0][0] * matrix[2][3] * matrix[3][1] + matrix[0][1] * matrix[2][0] * matrix[3][3] + matrix[0][3] * matrix[2][1] * matrix[3][0] - matrix[0][0] * matrix[2][1] * matrix[3][3] - matrix[0][1] * matrix[2][3] * matrix[3][0] - matrix[0][3] * matrix[2][0] * matrix[3][1])`~op~`d, (matrix[0][0] * matrix[1][1] * matrix[3][3] + matrix[0][1] * matrix[1][3] * matrix[3][0] + matrix[0][3] * matrix[1][0] * matrix[3][1] - matrix[0][0] * matrix[1][3] * matrix[3][1] - matrix[0][1] * matrix[1][0] * matrix[3][3] - matrix[0][3] * matrix[1][1] * matrix[3][0])`~op~`d, (matrix[0][0] * matrix[1][3] * matrix[2][1] + matrix[0][1] * matrix[1][0] * matrix[2][3] + matrix[0][3] * matrix[1][1] * matrix[2][0] - matrix[0][0] * matrix[1][1] * matrix[2][3] - matrix[0][1] * matrix[1][3] * matrix[2][0] - matrix[0][3] * matrix[1][0] * matrix[2][1])`~op~`d], [(matrix[1][0] * matrix[2][2] * matrix[3][1] + matrix[1][1] * matrix[2][0] * matrix[3][2] + matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[1][0] * matrix[2][1] * matrix[3][2] - matrix[1][1] * matrix[2][2] * matrix[3][0] - matrix[1][2] * matrix[2][0] * matrix[3][1])`~op~`d, (matrix[0][0] * matrix[2][1] * matrix[3][2] + matrix[0][1] * matrix[2][2] * matrix[3][0] + matrix[0][2] * matrix[2][0] * matrix[3][1] - matrix[0][0] * matrix[2][2] * matrix[3][1] - matrix[0][1] * matrix[2][0] * matrix[3][2] - matrix[0][2] * matrix[2][1] * matrix[3][0])`~op~`d, (matrix[0][0] * matrix[1][2] * matrix[3][1] + matrix[0][1] * matrix[1][0] * matrix[3][2] + matrix[0][2] * matrix[1][1] * matrix[3][0] - matrix[0][0] * matrix[1][1] * matrix[3][2] - matrix[0][1] * matrix[1][2] * matrix[3][0] - matrix[0][2] * matrix[1][0] * matrix[3][1])`~op~`d, (matrix[0][0] * matrix[1][1] * matrix[2][2] + matrix[0][1] * matrix[1][2] * matrix[2][0] + matrix[0][2] * matrix[1][0] * matrix[2][1] - matrix[0][0] * matrix[1][2] * matrix[2][1] - matrix[0][1] * matrix[1][0] * matrix[2][2] - matrix[0][2] * matrix[1][1] * matrix[2][0])`~op~`d]]; `); return mat; } // some static fun ... // (1) glprogramming.com/red/appendixf.html - ortographic is broken! // (2) http://fly.cc.fer.hr/~unreal/theredbook/appendixg.html // (3) http://en.wikipedia.org/wiki/Orthographic_projection_(geometry) /// Returns a translation matrix (3x3 and 4x4 matrices). static Matrix translation(mt x, mt y, mt z) { Matrix ret = Matrix.identity; ret.matrix[0][3] = x; ret.matrix[1][3] = y; ret.matrix[2][3] = z; return ret; } /// Applys a translation on the current matrix and returns $(I this) (3x3 and 4x4 matrices). Matrix translate(mt x, mt y, mt z) { this = Matrix.translation(x, y, z) * this; return this; } /// Returns a scaling matrix (3x3 and 4x4 matrices); static Matrix scaling(mt x, mt y, mt z) { Matrix ret = Matrix.identity; ret.matrix[0][0] = x; ret.matrix[1][1] = y; ret.matrix[2][2] = z; return ret; } /// Applys a scale to the current matrix and returns $(I this) (3x3 and 4x4 matrices). Matrix scale(mt x, mt y, mt z) { this = Matrix.scaling(x, y, z) * this; return this; } unittest { mat4 m4 = mat4(1.0f); assert(m4.translation(1.0f, 2.0f, 3.0f).matrix == mat4.translation(1.0f, 2.0f, 3.0f).matrix); assert(mat4.translation(1.0f, 2.0f, 3.0f).matrix == [[1.0f, 0.0f, 0.0f, 1.0f], [0.0f, 1.0f, 0.0f, 2.0f], [0.0f, 0.0f, 1.0f, 3.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.identity.translate(0.0f, 1.0f, 2.0f).matrix == mat4.translation(0.0f, 1.0f, 2.0f).matrix); assert(m4.scaling(0.0f, 1.0f, 2.0f).matrix == mat4.scaling(0.0f, 1.0f, 2.0f).matrix); assert(mat4.scaling(0.0f, 1.0f, 2.0f).matrix == [[0.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, 2.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.identity.scale(0.0f, 1.0f, 2.0f).matrix == mat4.scaling(0.0f, 1.0f, 2.0f).matrix); } static if(isFloatingPoint!mt) { static private mt[6] cperspective(mt width, mt height, mt fov, mt near, mt far) in { assert(height != 0); } body { mt aspect = width/height; mt top = near * tan(fov*(PI/360.0)); mt bottom = -top; mt right = top * aspect; mt left = -right; return [left, right, bottom, top, near, far]; } /// Returns a perspective matrix (4x4 and floating-point matrices only). static Matrix perspective(mt width, mt height, mt fov, mt near, mt far) { mt[6] cdata = cperspective(width, height, fov, near, far); return perspective(cdata[0], cdata[1], cdata[2], cdata[3], cdata[4], cdata[5]); } /// ditto static Matrix perspective(mt left, mt right, mt bottom, mt top, mt near, mt far) in { assert(right-left != 0); assert(top-bottom != 0); assert(far-near != 0); } body { Matrix ret; ret.clear(0); ret.matrix[0][0] = (2*near)/(right-left); ret.matrix[0][2] = (right+left)/(right-left); ret.matrix[1][1] = (2*near)/(top-bottom); ret.matrix[1][2] = (top+bottom)/(top-bottom); ret.matrix[2][2] = -(far+near)/(far-near); ret.matrix[2][3] = -(2*far*near)/(far-near); ret.matrix[3][2] = -1; return ret; } /// Returns an inverse perspective matrix (4x4 and floating-point matrices only). static Matrix perspective_inverse(mt width, mt height, mt fov, mt near, mt far) { mt[6] cdata = cperspective(width, height, fov, near, far); return perspective_inverse(cdata[0], cdata[1], cdata[2], cdata[3], cdata[4], cdata[5]); } /// ditto static Matrix perspective_inverse(mt left, mt right, mt bottom, mt top, mt near, mt far) in { assert(near != 0); assert(far != 0); } body { Matrix ret; ret.clear(0); ret.matrix[0][0] = (right-left)/(2*near); ret.matrix[0][3] = (right+left)/(2*near); ret.matrix[1][1] = (top-bottom)/(2*near); ret.matrix[1][3] = (top+bottom)/(2*near); ret.matrix[2][3] = -1; ret.matrix[3][2] = -(far-near)/(2*far*near); ret.matrix[3][3] = (far+near)/(2*far*near); return ret; } // (2) and (3) say this one is correct /// Returns an orthographic matrix (4x4 and floating-point matrices only). static Matrix orthographic(mt left, mt right, mt bottom, mt top, mt near, mt far) in { assert(right-left != 0); assert(top-bottom != 0); assert(far-near != 0); } body { Matrix ret; ret.clear(0); ret.matrix[0][0] = 2/(right-left); ret.matrix[0][3] = -(right+left)/(right-left); ret.matrix[1][1] = 2/(top-bottom); ret.matrix[1][3] = -(top+bottom)/(top-bottom); ret.matrix[2][2] = -2/(far-near); ret.matrix[2][3] = -(far+near)/(far-near); ret.matrix[3][3] = 1; return ret; } // (1) and (2) say this one is correct /// Returns an inverse ortographic matrix (4x4 and floating-point matrices only). static Matrix orthographic_inverse(mt left, mt right, mt bottom, mt top, mt near, mt far) { Matrix ret; ret.clear(0); ret.matrix[0][0] = (right-left)/2; ret.matrix[0][3] = (right+left)/2; ret.matrix[1][1] = (top-bottom)/2; ret.matrix[1][3] = (top+bottom)/2; ret.matrix[2][2] = (far-near)/-2; ret.matrix[2][3] = (far+near)/2; ret.matrix[3][3] = 1; return ret; } /// Returns a look at matrix (4x4 and floating-point matrices only). static Matrix look_at(Vector!(mt, 3) eye, Vector!(mt, 3) target, Vector!(mt, 3) up) { alias Vector!(mt, 3) vec3mt; vec3mt look_dir = (target - eye).normalized; vec3mt up_dir = up.normalized; vec3mt right_dir = cross(look_dir, up_dir).normalized; vec3mt perp_up_dir = cross(right_dir, look_dir); Matrix ret = Matrix.identity; ret.matrix[0][0..3] = right_dir.vector[]; ret.matrix[1][0..3] = perp_up_dir.vector[]; ret.matrix[2][0..3] = (-look_dir).vector[]; ret.matrix[0][3] = -dot(eye, right_dir); ret.matrix[1][3] = -dot(eye, perp_up_dir); ret.matrix[2][3] = dot(eye, look_dir); return ret; } unittest { mt[6] cp = cperspective(600f, 900f, 60f, 1f, 100f); assert(cp[4] == 1.0f); assert(cp[5] == 100.0f); assert(cp[0] == -cp[1]); assert((cp[0] < -0.38489f) && (cp[0] > -0.38491f)); assert(cp[2] == -cp[3]); assert((cp[2] < -0.577349f) && (cp[2] > -0.577351f)); assert(mat4.perspective(600f, 900f, 60.0, 1.0, 100.0) == mat4.perspective(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5])); float[4][4] m4p = mat4.perspective(600f, 900f, 60.0, 1.0, 100.0).matrix; assert((m4p[0][0] < 2.598077f) && (m4p[0][0] > 2.598075f)); assert(m4p[0][2] == 0.0f); assert((m4p[1][1] < 1.732052) && (m4p[1][1] > 1.732050)); assert(m4p[1][2] == 0.0f); assert((m4p[2][2] < -1.020201) && (m4p[2][2] > -1.020203)); assert((m4p[2][3] < -2.020201) && (m4p[2][3] > -2.020203)); assert((m4p[3][2] < -0.9f) && (m4p[3][2] > -1.1f)); float[4][4] m4pi = mat4.perspective_inverse(600f, 900f, 60.0, 1.0, 100.0).matrix; assert((m4pi[0][0] < 0.384901) && (m4pi[0][0] > 0.384899)); assert(m4pi[0][3] == 0.0f); assert((m4pi[1][1] < 0.577351) && (m4pi[1][1] > 0.577349)); assert(m4pi[1][3] == 0.0f); assert(m4pi[2][3] == -1.0f); assert((m4pi[3][2] < -0.494999) && (m4pi[3][2] > -0.495001)); assert((m4pi[3][3] < 0.505001) && (m4pi[3][3] > 0.504999)); // maybe the next tests should be improved float[4][4] m4o = mat4.orthographic(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f).matrix; assert(m4o == [[1.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, -1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); float[4][4] m4oi = mat4.orthographic_inverse(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f).matrix; assert(m4oi == [[1.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, -1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); //TODO: look_at tests } } } static if((rows == cols) && (rows >= 3)) { /// Returns an identity matrix with an applied rotate_axis around an arbitrary axis (nxn matrices, n >= 3). static Matrix rotation(real alpha, Vector!(mt, 3) axis) { Matrix mult = Matrix.identity; if(axis.length != 1) { axis.normalize(); } real cosa = cos(alpha); real sina = sin(alpha); Vector!(mt, 3) temp = (1 - cosa)*axis; mult.matrix[0][0] = to!mt(cosa + temp.x * axis.x); mult.matrix[0][1] = to!mt( temp.x * axis.y + sina * axis.z); mult.matrix[0][2] = to!mt( temp.x * axis.z - sina * axis.y); mult.matrix[1][0] = to!mt( temp.y * axis.x - sina * axis.z); mult.matrix[1][1] = to!mt(cosa + temp.y * axis.y); mult.matrix[1][2] = to!mt( temp.y * axis.z + sina * axis.x); mult.matrix[2][0] = to!mt( temp.z * axis.x + sina * axis.y); mult.matrix[2][1] = to!mt( temp.z * axis.y - sina * axis.x); mult.matrix[2][2] = to!mt(cosa + temp.z * axis.z); return mult; } /// ditto static Matrix rotation(real alpha, mt x, mt y, mt z) { return Matrix.rotation(alpha, Vector!(mt, 3)(x, y, z)); } /// Returns an identity matrix with an applied rotation around the x-axis (nxn matrices, n >= 3). static Matrix xrotation(real alpha) { Matrix mult = Matrix.identity; mt cosamt = to!mt(cos(alpha)); mt sinamt = to!mt(sin(alpha)); mult.matrix[1][1] = cosamt; mult.matrix[1][2] = -sinamt; mult.matrix[2][1] = sinamt; mult.matrix[2][2] = cosamt; return mult; } /// Returns an identity matrix with an applied rotation around the y-axis (nxn matrices, n >= 3). static Matrix yrotation(real alpha) { Matrix mult = Matrix.identity; mt cosamt = to!mt(cos(alpha)); mt sinamt = to!mt(sin(alpha)); mult.matrix[0][0] = cosamt; mult.matrix[0][2] = sinamt; mult.matrix[2][0] = -sinamt; mult.matrix[2][2] = cosamt; return mult; } /// Returns an identity matrix with an applied rotation around the z-axis (nxn matrices, n >= 3). static Matrix zrotation(real alpha) { Matrix mult = Matrix.identity; mt cosamt = to!mt(cos(alpha)); mt sinamt = to!mt(sin(alpha)); mult.matrix[0][0] = cosamt; mult.matrix[0][1] = -sinamt; mult.matrix[1][0] = sinamt; mult.matrix[1][1] = cosamt; return mult; } Matrix rotate(real alpha, Vector!(mt, 3) axis) { this = rotation(alpha, axis) * this; return this; } /// Rotates the current matrix around the x-axis and returns $(I this) (nxn matrices, n >= 3). Matrix rotatex(real alpha) { this = xrotation(alpha) * this; return this; } /// Rotates the current matrix around the y-axis and returns $(I this) (nxn matrices, n >= 3). Matrix rotatey(real alpha) { this = yrotation(alpha) * this; return this; } /// Rotates the current matrix around the z-axis and returns $(I this) (nxn matrices, n >= 3). Matrix rotatez(real alpha) { this = zrotation(alpha) * this; return this; } unittest { assert(mat4.xrotation(0).matrix == [[1.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, -0.0f, 0.0f], [0.0f, 0.0f, 1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.yrotation(0).matrix == [[1.0f, 0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, 1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.zrotation(0).matrix == [[1.0f, -0.0f, 0.0f, 0.0f], [0.0f, 1.0f, 0.0f, 0.0f], [0.0f, 0.0f, 1.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); mat4 xro = mat4.identity; xro.rotatex(0); assert(mat4.xrotation(0).matrix == xro.matrix); assert(xro.matrix == mat4.identity.rotatex(0).matrix); assert(xro.matrix == mat4.rotation(0, vec3(1.0f, 0.0f, 0.0f)).matrix); mat4 yro = mat4.identity; yro.rotatey(0); assert(mat4.yrotation(0).matrix == yro.matrix); assert(yro.matrix == mat4.identity.rotatey(0).matrix); assert(yro.matrix == mat4.rotation(0, vec3(0.0f, 1.0f, 0.0f)).matrix); mat4 zro = mat4.identity; xro.rotatez(0); assert(mat4.zrotation(0).matrix == zro.matrix); assert(zro.matrix == mat4.identity.rotatez(0).matrix); assert(zro.matrix == mat4.rotation(0, vec3(0.0f, 0.0f, 1.0f)).matrix); } /// Sets the translation of the matrix (nxn matrices, n >= 3). void translation(mt[] values...) // intended to be a property in { assert(values.length >= (rows-1)); } body { foreach(r; TupleRange!(0, rows-1)) { matrix[r][rows-1] = values[r]; } } /// Copyies the translation from mat to the current matrix (nxn matrices, n >= 3). void translation(Matrix mat) { foreach(r; TupleRange!(0, rows-1)) { matrix[r][rows-1] = mat.matrix[r][rows-1]; } } /// Returns an identity matrix with the current translation applied (nxn matrices, n >= 3).. Matrix translation() { Matrix ret = Matrix.identity; foreach(r; TupleRange!(0, rows-1)) { ret.matrix[r][rows-1] = matrix[r][rows-1]; } return ret; } unittest { mat3 m3 = mat3(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 1.0f); assert(m3.translation.matrix == [[1.0f, 0.0f, 2.0f], [0.0f, 1.0f, 5.0f], [0.0f, 0.0f, 1.0f]]); m3.translation = mat3.identity; assert(mat3.identity.matrix == m3.translation.matrix); m3.translation = [2.0f, 5.0f]; assert(m3.translation.matrix == [[1.0f, 0.0f, 2.0f], [0.0f, 1.0f, 5.0f], [0.0f, 0.0f, 1.0f]]); assert(mat3.identity.matrix == mat3.identity.translation.matrix); mat4 m4 = mat4(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 1.0f); assert(m4.translation.matrix == [[1.0f, 0.0f, 0.0f, 3.0f], [0.0f, 1.0f, 0.0f, 7.0f], [0.0f, 0.0f, 1.0f, 11.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); m4.translation = mat4.identity; assert(mat4.identity.matrix == m4.translation.matrix); m4.translation = [3.0f, 7.0f, 11.0f]; assert(m4.translation.matrix == [[1.0f, 0.0f, 0.0f, 3.0f], [0.0f, 1.0f, 0.0f, 7.0f], [0.0f, 0.0f, 1.0f, 11.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.identity.matrix == mat4.identity.translation.matrix); } /// Sets the scale of the matrix (nxn matrices, n >= 3). void scale(mt[] values...) // intended to be a property in { assert(values.length >= (rows-1)); } body { foreach(r; TupleRange!(0, rows-1)) { matrix[r][r] = values[r]; } } /// Copyies the scale from mat to the current matrix (nxn matrices, n >= 3). void scale(Matrix mat) { foreach(r; TupleRange!(0, rows-1)) { matrix[r][r] = mat.matrix[r][r]; } } /// Returns an identity matrix with the current scale applied (nxn matrices, n >= 3). Matrix scale() { Matrix ret = Matrix.identity; foreach(r; TupleRange!(0, rows-1)) { ret.matrix[r][r] = matrix[r][r]; } return ret; } unittest { mat3 m3 = mat3(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 1.0f); assert(m3.scale.matrix == [[0.0f, 0.0f, 0.0f], [0.0f, 4.0f, 0.0f], [0.0f, 0.0f, 1.0f]]); m3.scale = mat3.identity; assert(mat3.identity.matrix == m3.scale.matrix); m3.scale = [0.0f, 4.0f]; assert(m3.scale.matrix == [[0.0f, 0.0f, 0.0f], [0.0f, 4.0f, 0.0f], [0.0f, 0.0f, 1.0f]]); assert(mat3.identity.matrix == mat3.identity.scale.matrix); mat4 m4 = mat4(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 1.0f); assert(m4.scale.matrix == [[0.0f, 0.0f, 0.0f, 0.0f], [0.0f, 5.0f, 0.0f, 0.0f], [0.0f, 0.0f, 10.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); m4.scale = mat4.identity; assert(mat4.identity.matrix == m4.scale.matrix); m4.scale = [0.0f, 5.0f, 10.0f]; assert(m4.scale.matrix == [[0.0f, 0.0f, 0.0f, 0.0f], [0.0f, 5.0f, 0.0f, 0.0f], [0.0f, 0.0f, 10.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(mat4.identity.matrix == mat4.identity.scale.matrix); } /// Copies rot into the upper left corner, the translation (nxn matrices, n >= 3). void rotation(Matrix!(mt, 3, 3) rot) { // intended to be a property foreach(r; TupleRange!(0, 3)) { foreach(c; TupleRange!(0, 3)) { matrix[r][c] = rot[r][c]; } } } /// Returns an identity matrix with the current rotation applied (nxn matrices, n >= 3). Matrix!(mt, 3, 3) rotation() { Matrix!(mt, 3, 3) ret = Matrix!(mt, 3, 3).identity; foreach(r; TupleRange!(0, 3)) { foreach(c; TupleRange!(0, 3)) { ret.matrix[r][c] = matrix[r][c]; } } return ret; } unittest { mat3 m3 = mat3(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 1.0f); assert(m3.rotation.matrix == [[0.0f, 1.0f, 2.0f], [3.0f, 4.0f, 5.0f], [6.0f, 7.0f, 1.0f]]); m3.rotation = mat3.identity; assert(mat3.identity.matrix == m3.rotation.matrix); m3.rotation = mat3(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 1.0f); assert(m3.rotation.matrix == [[0.0f, 1.0f, 2.0f], [3.0f, 4.0f, 5.0f], [6.0f, 7.0f, 1.0f]]); assert(mat3.identity.matrix == mat3.identity.rotation.matrix); mat4 m4 = mat4(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 1.0f); assert(m4.rotation.matrix == [[0.0f, 1.0f, 2.0f], [4.0f, 5.0f, 6.0f], [8.0f, 9.0f, 10.0f]]); m4.rotation = mat3.identity; assert(mat3.identity.matrix == m4.rotation.matrix); m4.rotation = mat3(0.0f, 1.0f, 2.0f, 4.0f, 5.0f, 6.0f, 8.0f, 9.0f, 10.0f); assert(m4.rotation.matrix == [[0.0f, 1.0f, 2.0f], [4.0f, 5.0f, 6.0f], [8.0f, 9.0f, 10.0f]]); assert(mat3.identity.matrix == mat4.identity.rotation.matrix); } } static if((rows == cols) && (rows <= 4)) { /// Returns an inverted copy of the current matrix (nxn matrices, n <= 4). @property Matrix inverse() const { Matrix mat; invert(mat); return mat; } /// Inverts the current matrix (nxn matrices, n <= 4). void invert() { // workaround Issue #11238 // uses a temporary instead of invert(this) Matrix temp; invert(temp); this.matrix = temp.matrix; } } unittest { mat2 m2 = mat2(1.0f, 2.0f, vec2(3.0f, 4.0f)); assert(m2.det == -2.0f); assert(m2.inverse.matrix == [[-2.0f, 1.0f], [1.5f, -0.5f]]); mat3 m3 = mat3(1.0f, -2.0f, 3.0f, 7.0f, -1.0f, 0.0f, 3.0f, 2.0f, -4.0f); assert(m3.det == -1.0f); assert(m3.inverse.matrix == [[-4.0f, 2.0f, -3.0f], [-28.0f, 13.0f, -21.0f], [-17.0f, 8.0f, -13.0f]]); mat4 m4 = mat4(1.0f, 2.0f, 3.0f, 4.0f, -2.0f, 1.0f, 5.0f, -2.0f, 2.0f, -1.0f, 7.0f, 1.0f, 3.0f, -3.0f, 2.0f, 0.0f); assert(m4.det == -8.0f); assert(m4.inverse.matrix == [[6.875f, 7.875f, -11.75f, 11.125f], [6.625f, 7.625f, -11.25f, 10.375f], [-0.375f, -0.375f, 0.75f, -0.625f], [-4.5f, -5.5f, 8.0f, -7.5f]]); } private void mms(mt inp, ref Matrix mat) const { // mat * scalar for(int r = 0; r < rows; r++) { for(int c = 0; c < cols; c++) { mat.matrix[r][c] = matrix[r][c] * inp; } } } private void masm(string op)(Matrix inp, ref Matrix mat) const { // mat + or - mat foreach(r; TupleRange!(0, rows)) { foreach(c; TupleRange!(0, cols)) { mat.matrix[r][c] = mixin("inp.matrix[r][c]" ~ op ~ "matrix[r][c]"); } } } Matrix!(mt, rows, T.cols) opBinary(string op : "*", T)(T inp) const if(isCompatibleMatrix!T && (T.rows == cols)) { Matrix!(mt, rows, T.cols) ret; foreach(r; TupleRange!(0, rows)) { foreach(c; TupleRange!(0, cols)) { ret.matrix[r][c] = 0; foreach(c2; TupleRange!(0, cols)) { ret.matrix[r][c] += matrix[r][c2] * inp.matrix[c2][c]; } } } return ret; } Vector!(mt, rows) opBinary(string op : "*", T : Vector!(mt, cols))(T inp) const { Vector!(mt, rows) ret; ret.clear(0); foreach(c; TupleRange!(0, cols)) { foreach(r; TupleRange!(0, rows)) { ret.vector[r] += matrix[r][c] * inp.vector[c]; } } return ret; } Matrix opBinary(string op : "*")(mt inp) const { Matrix ret; mms(inp, ret); return ret; } Matrix opBinaryRight(string op : "*")(mt inp) const { return this.opBinary!(op)(inp); } Matrix opBinary(string op)(Matrix inp) const if((op == "+") || (op == "-")) { Matrix ret; masm!(op)(inp, ret); return ret; } void opOpAssign(string op : "*")(mt inp) { mms(inp, this); } void opOpAssign(string op)(Matrix inp) if((op == "+") || (op == "-")) { masm!(op)(inp, this); } unittest { mat2 m2 = mat2(1.0f, 2.0f, 3.0f, 4.0f); vec2 v2 = vec2(2.0f, 2.0f); assert((m2*2).matrix == [[2.0f, 4.0f], [6.0f, 8.0f]]); assert((2*m2).matrix == (m2*2).matrix); m2 *= 2; assert(m2.matrix == [[2.0f, 4.0f], [6.0f, 8.0f]]); assert((m2*v2).vector == [12.0f, 28.0f]); assert((v2*m2).vector == (m2*v2).vector); assert((m2*m2).matrix == [[28.0f, 40.0f], [60.0f, 88.0f]]); assert((m2-m2).matrix == [[0.0f, 0.0f], [0.0f, 0.0f]]); assert((m2+m2).matrix == [[4.0f, 8.0f], [12.0f, 16.0f]]); m2 += m2; assert(m2.matrix == [[4.0f, 8.0f], [12.0f, 16.0f]]); m2 -= m2; assert(m2.matrix == [[0.0f, 0.0f], [0.0f, 0.0f]]); mat3 m3 = mat3(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f); vec3 v3 = vec3(2.0f, 2.0f, 2.0f); assert((m3*2).matrix == [[2.0f, 4.0f, 6.0f], [8.0f, 10.0f, 12.0f], [14.0f, 16.0f, 18.0f]]); assert((2*m3).matrix == (m3*2).matrix); m3 *= 2; assert(m3.matrix == [[2.0f, 4.0f, 6.0f], [8.0f, 10.0f, 12.0f], [14.0f, 16.0f, 18.0f]]); assert((m3*v3).vector == [24.0f, 60.0f, 96.0f]); assert((v3*m3).vector == (m3*v3).vector); assert((m3*m3).matrix == [[120.0f, 144.0f, 168.0f], [264.0f, 324.0f, 384.0f], [408.0f, 504.0f, 600.0f]]); assert((m3-m3).matrix == [[0.0f, 0.0f, 0.0f], [0.0f, 0.0f, 0.0f], [0.0f, 0.0f, 0.0f]]); assert((m3+m3).matrix == [[4.0f, 8.0f, 12.0f], [16.0f, 20.0f, 24.0f], [28.0f, 32.0f, 36.0f]]); m3 += m3; assert(m3.matrix == [[4.0f, 8.0f, 12.0f], [16.0f, 20.0f, 24.0f], [28.0f, 32.0f, 36.0f]]); m3 -= m3; assert(m3.matrix == [[0.0f, 0.0f, 0.0f], [0.0f, 0.0f, 0.0f], [0.0f, 0.0f, 0.0f]]); //TODO: tests for mat4, mat34 } // opEqual => "alias matrix this;" bool opCast(T : bool)() const { return ok; } unittest { assert(mat2(1.0f, 2.0f, 1.0f, 1.0f) == mat2(1.0f, 2.0f, 1.0f, 1.0f)); assert(mat2(1.0f, 2.0f, 1.0f, 1.0f) != mat2(1.0f, 1.0f, 1.0f, 1.0f)); assert(mat3(1.0f) == mat3(1.0f)); assert(mat3(1.0f) != mat3(2.0f)); assert(mat4(1.0f) == mat4(1.0f)); assert(mat4(1.0f) != mat4(2.0f)); assert(!(mat4(float.nan))); if(mat4(1.0f)) { } else { assert(false); } } } /// Pre-defined matrix types, the first number represents the number of rows /// and the second the number of columns, if there's just one it's a nxn matrix. /// All of these matrices are floating-point matrices. alias Matrix!(float, 2, 2) mat2; alias Matrix!(float, 3, 3) mat3; alias Matrix!(float, 3, 4) mat34; alias Matrix!(float, 4, 4) mat4; /// Base template for all quaternion-types. /// Params: /// type = all values get stored as this type struct Quaternion(type) { alias type qt; /// Holds the internal type of the quaternion. qt[4] quaternion; /// Holds the w, x, y and z coordinates. /// Returns a pointer to the quaternion in memory, it starts with the w coordinate. @property auto value_ptr() { return quaternion.ptr; } /// Returns the current vector formatted as string, useful for printing the quaternion. @property string as_string() { return format("%s", quaternion); } alias as_string toString; @safe pure nothrow: private @property qt get_(char coord)() const { return quaternion[coord_to_index!coord]; } private @property void set_(char coord)(qt value) { quaternion[coord_to_index!coord] = value; } alias get_!'w' w; /// static properties to access the values. alias set_!'w' w; alias get_!'x' x; /// ditto alias set_!'x' x; alias get_!'y' y; /// ditto alias set_!'y' y; alias get_!'z' z; /// ditto alias set_!'z' z; /// Constructs the quaternion. /// Takes a 4-dimensional vector, where vector.x = the quaternions w coordinate, /// or a w coordinate of type $(I qt) and a 3-dimensional vector representing the imaginary part, /// or 4 values of type $(I qt). this(qt w_, qt x_, qt y_, qt z_) { w = w_; x = x_; y = y_; z = z_; } /// ditto this(qt w_, Vector!(qt, 3) vec) { w = w_; quaternion[1..4] = vec.vector[]; } /// ditto this(Vector!(qt, 4) vec) { quaternion[] = vec.vector[]; } /// Returns true if all values are not nan and finite, otherwise false. @property bool ok() const { foreach(q; quaternion) { if(isNaN(q) || isInfinity(q)) { return false; } } return true; } unittest { quat q1 = quat(0.0f, 0.0f, 0.0f, 1.0f); assert(q1.quaternion == [0.0f, 0.0f, 0.0f, 1.0f]); assert(q1.quaternion == quat(0.0f, 0.0f, 0.0f, 1.0f).quaternion); assert(q1.quaternion == quat(0.0f, vec3(0.0f, 0.0f, 1.0f)).quaternion); assert(q1.quaternion == quat(vec4(0.0f, 0.0f, 0.0f, 1.0f)).quaternion); assert(q1.ok); q1.x = float.infinity; assert(!q1.ok); q1.x = float.nan; assert(!q1.ok); q1.x = 0.0f; assert(q1.ok); } template coord_to_index(char c) { static if(c == 'w') { enum coord_to_index = 0; } else static if(c == 'x') { enum coord_to_index = 1; } else static if(c == 'y') { enum coord_to_index = 2; } else static if(c == 'z') { enum coord_to_index = 3; } else { static assert(false, "accepted coordinates are x, y, z and w not " ~ c ~ "."); } } /// Returns the squared magnitude of the quaternion. @property real magnitude_squared() const { return to!real(w^^2 + x^^2 + y^^2 + z^^2); } /// Returns the magnitude of the quaternion. @property real magnitude() const { return sqrt(magnitude_squared); } /// Returns an identity quaternion (w=1, x=0, y=0, z=0). static @property Quaternion identity() { return Quaternion(1, 0, 0, 0); } /// Makes the current quaternion an identity quaternion. void make_identity() { w = 1; x = 0; y = 0; z = 0; } /// Inverts the quaternion. void invert() { x = -x; y = -y; z = -z; } alias invert conjugate; /// ditto /// Returns an inverted copy of the current quaternion. @property Quaternion inverse() const { return Quaternion(w, -x, -y, -z); } alias inverse conjugated; /// ditto unittest { quat q1 = quat(1.0f, 1.0f, 1.0f, 1.0f); assert(q1.magnitude == 2.0f); assert(q1.magnitude_squared == 4.0f); assert(q1.magnitude == quat(0.0f, 0.0f, 2.0f, 0.0f).magnitude); quat q2 = quat.identity; assert(q2.quaternion == [1.0f, 0.0f, 0.0f, 0.0f]); assert(q2.x == 0.0f); assert(q2.y == 0.0f); assert(q2.z == 0.0f); assert(q2.w == 1.0f); assert(q1.inverse.quaternion == [1.0f, -1.0f, -1.0f, -1.0f]); q1.invert(); assert(q1.quaternion == [1.0f, -1.0f, -1.0f, -1.0f]); q1.make_identity(); assert(q1.quaternion == q2.quaternion); } /// Creates a quaternion from a 3x3 matrix. /// Params: /// matrix = 3x3 matrix (rotation) /// Returns: A quaternion representing the rotation (3x3 matrix) static Quaternion from_matrix(Matrix!(qt, 3, 3) matrix) { Quaternion ret; auto mat = matrix.matrix; qt trace = mat[0][0] + mat[1][1] + mat[2][2]; if(trace > 0) { real s = 0.5 / sqrt(trace + 1.0); ret.w = to!qt(0.25 / s); ret.x = to!qt((mat[2][1] - mat[1][2]) * s); ret.y = to!qt((mat[0][2] - mat[2][0]) * s); ret.z = to!qt((mat[1][0] - mat[0][1]) * s); } else if((mat[0][0] > mat[1][2]) && (mat[0][0] > mat[2][2])) { real s = 2.0 * sqrt(1 + mat[0][0] - mat[1][1] - mat[2][2]); ret.w = to!qt((mat[2][1] - mat[1][2]) / s); ret.x = to!qt(0.25 * s); ret.y = to!qt((mat[0][1] - mat[1][0]) / s); ret.z = to!qt((mat[0][2] - mat[2][0]) / s); } else if(mat[1][1] > mat[2][2]) { real s = 2.0 * sqrt(1 + mat[1][1] - mat[0][0] - mat[2][2]); ret.w = to!qt((mat[0][2] - mat[2][0]) / s); ret.x = to!qt((mat[0][1] + mat[1][0]) / s); ret.y = to!qt(0.25f * s); ret.z = to!qt((mat[1][2] + mat[2][1]) / s); } else { real s = 2.0 * sqrt(1 + mat[2][2] - mat[0][0] - mat[1][1]); ret.w = to!qt((mat[1][0] - mat[0][1]) / s); ret.x = to!qt((mat[0][2] + mat[2][0]) / s); ret.y = to!qt((mat[1][2] + mat[2][1]) / s); ret.z = to!qt(0.25f * s); } return ret; } /// Returns the quaternion as matrix. /// Params: /// rows = number of rows of the resulting matrix (min 3) /// cols = number of columns of the resulting matrix (min 3) Matrix!(qt, rows, cols) to_matrix(int rows, int cols)() const if((rows >= 3) && (cols >= 3)) { static if((rows == 3) && (cols == 3)) { Matrix!(qt, rows, cols) ret; } else { Matrix!(qt, rows, cols) ret = Matrix!(qt, rows, cols).identity; } qt xx = x^^2; qt xy = x * y; qt xz = x * z; qt xw = x * w; qt yy = y^^2; qt yz = y * z; qt yw = y * w; qt zz = z^^2; qt zw = z * w; ret.matrix[0][0..3] = [1 - 2 * (yy + zz), 2 * (xy - zw), 2 * (xz + yw)]; ret.matrix[1][0..3] = [2 * (xy + zw), 1 - 2 * (xx + zz), 2 * (yz - xw)]; ret.matrix[2][0..3] = [2 * (xz - yw), 2 * (yz + xw), 1 - 2 * (xx + yy)]; return ret; } unittest { quat q1 = quat(4.0f, 1.0f, 2.0f, 3.0f); assert(q1.to_matrix!(3, 3).matrix == [[-25.0f, -20.0f, 22.0f], [28.0f, -19.0f, 4.0f], [-10.0f, 20.0f, -9.0f]]); assert(q1.to_matrix!(4, 4).matrix == [[-25.0f, -20.0f, 22.0f, 0.0f], [28.0f, -19.0f, 4.0f, 0.0f], [-10.0f, 20.0f, -9.0f, 0.0f], [0.0f, 0.0f, 0.0f, 1.0f]]); assert(quat.identity.to_matrix!(3, 3).matrix == Matrix!(qt, 3, 3).identity.matrix); assert(q1.quaternion == quat.from_matrix(q1.to_matrix!(3, 3)).quaternion); assert(quat(1.0f, 0.0f, 0.0f, 0.0f).quaternion == quat.from_matrix(mat3.identity).quaternion); quat q2 = quat.from_matrix(mat3(1.0f, 3.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f)); assert(q2.x == 0.0f); assert(almost_equal(q2.y, 0.7071067f)); assert(almost_equal(q2.z, -1.060660)); assert(almost_equal(q2.w, 0.7071067f)); } /// Normalizes the current quaternion. void normalize() { qt m = to!qt(magnitude); if(m != 0) { w = w / m; x = x / m; y = y / m; z = z / m; } } /// Returns a normalized copy of the current quaternion. Quaternion normalized() const { Quaternion ret; qt m = to!qt(magnitude); if(m != 0) { ret.w = w / m; ret.x = x / m; ret.y = y / m; ret.z = z / m; } else { ret = Quaternion(w, x, y, z); } return ret; } unittest { quat q1 = quat(1.0f, 2.0f, 3.0f, 4.0f); quat q2 = quat(1.0f, 2.0f, 3.0f, 4.0f); q1.normalize(); assert(q1.quaternion == q2.normalized.quaternion); //assert(q1.quaternion == q1.normalized.quaternion); assert(almost_equal(q1.magnitude, 1.0)); } /// Returns the yaw. @property real yaw() const { return atan2(to!real(2 * (w*y + x*z)), to!real(w^^2 - x^^2 - y^^2 + z^^2)); } /// Returns the pitch. @property real pitch() const { return asin(to!real(2 * (w*x - y*z))); } /// Returns the roll. @property real roll() const { return atan2(to!real(2 * (w*z + x*y)), to!real(w^^2 - x^^2 + y^^2 - z^^2)); } unittest { quat q1 = quat.identity; assert(q1.pitch == 0.0f); assert(q1.yaw == 0.0f); assert(q1.roll == 0.0f); quat q2 = quat(1.0f, 1.0f, 1.0f, 1.0f); assert(almost_equal(q2.yaw, q2.roll)); assert(almost_equal(q2.yaw, 1.570796f)); assert(q2.pitch == 0.0f); quat q3 = quat(0.1f, 1.9f, 2.1f, 1.3f); assert(almost_equal(q3.yaw, 2.4382f)); assert(isNaN(q3.pitch)); assert(almost_equal(q3.roll, 1.67719f)); } /// Returns a quaternion with applied rotation around the x-axis. static Quaternion xrotation(real alpha) { Quaternion ret; alpha /= 2; ret.w = to!qt(cos(alpha)); ret.x = to!qt(sin(alpha)); ret.y = 0; ret.z = 0; return ret; } /// Returns a quaternion with applied rotation around the y-axis. static Quaternion yrotation(real alpha) { Quaternion ret; alpha /= 2; ret.w = to!qt(cos(alpha)); ret.x = 0; ret.y = to!qt(sin(alpha)); ret.z = 0; return ret; } /// Returns a quaternion with applied rotation around the z-axis. static Quaternion zrotation(real alpha) { Quaternion ret; alpha /= 2; ret.w = to!qt(cos(alpha)); ret.x = 0; ret.y = 0; ret.z = to!qt(sin(alpha)); return ret; } /// Returns a quaternion with applied rotation around an axis. static Quaternion axis_rotation(real alpha, Vector!(qt, 3) axis) { if(alpha == 0) { return Quaternion.identity; } Quaternion ret; alpha /= 2; qt sinaqt = to!qt(sin(alpha)); ret.w = to!qt(cos(alpha)); ret.x = axis.x * sinaqt; ret.y = axis.y * sinaqt; ret.z = axis.z * sinaqt; return ret; } /// Creates a quaternion from an euler rotation. static Quaternion euler_rotation(real heading, real attitude, real bank) { Quaternion ret; real c1 = cos(heading / 2); real s1 = sin(heading / 2); real c2 = cos(attitude / 2); real s2 = sin(attitude / 2); real c3 = cos(bank / 2); real s3 = sin(bank / 2); ret.w = to!qt(c1 * c2 * c3 - s1 * s2 * s3); ret.x = to!qt(s1 * s2 * c3 + c1 * c2 * s3); ret.y = to!qt(s1 * c2 * c3 + c1 * s2 * s3); ret.z = to!qt(c1 * s2 * c3 - s1 * c2 * s3); return ret; } /// Rotates the current quaternion around the x-axis and returns $(I this). Quaternion rotatex(real alpha) { this = xrotation(alpha) * this; return this; } /// Rotates the current quaternion around the y-axis and returns $(I this). Quaternion rotatey(real alpha) { this = yrotation(alpha) * this; return this; } /// Rotates the current quaternion around the z-axis and returns $(I this). Quaternion rotatez(real alpha) { this = zrotation(alpha) * this; return this; } /// Rotates the current quaternion around an axis and returns $(I this). Quaternion rotate_axis(real alpha, Vector!(qt, 3) axis) { this = axis_rotation(alpha, axis) * this; return this; } /// Applies an euler rotation to the current quaternion and returns $(I this). Quaternion rotate_euler(real heading, real attitude, real bank) { this = euler_rotation(heading, attitude, bank) * this; return this; } unittest { assert(quat.xrotation(PI).quaternion[1..4] == [1.0f, 0.0f, 0.0f]); assert(quat.yrotation(PI).quaternion[1..4] == [0.0f, 1.0f, 0.0f]); assert(quat.zrotation(PI).quaternion[1..4] == [0.0f, 0.0f, 1.0f]); assert((quat.xrotation(PI).w == quat.yrotation(PI).w) && (quat.yrotation(PI).w == quat.zrotation(PI).w)); //assert(quat.rotatex(PI).w == to!(quat.qt)(cos(PI))); assert(quat.xrotation(PI).quaternion == quat.identity.rotatex(PI).quaternion); assert(quat.yrotation(PI).quaternion == quat.identity.rotatey(PI).quaternion); assert(quat.zrotation(PI).quaternion == quat.identity.rotatez(PI).quaternion); assert(quat.axis_rotation(PI, vec3(1.0f, 1.0f, 1.0f)).quaternion[1..4] == [1.0f, 1.0f, 1.0f]); assert(quat.axis_rotation(PI, vec3(1.0f, 1.0f, 1.0f)).w == quat.xrotation(PI).w); assert(quat.axis_rotation(PI, vec3(1.0f, 1.0f, 1.0f)).quaternion == quat.identity.rotate_axis(PI, vec3(1.0f, 1.0f, 1.0f)).quaternion); quat q1 = quat.euler_rotation(PI, PI, PI); assert((q1.x > -1e-16) && (q1.x < 1e-16)); assert((q1.y > -1e-16) && (q1.y < 1e-16)); assert((q1.z > -1e-16) && (q1.z < 1e-16)); assert(q1.w == -1.0f); assert(quat.euler_rotation(PI, PI, PI).quaternion == quat.identity.rotate_euler(PI, PI, PI).quaternion); } Quaternion opBinary(string op : "*")(Quaternion inp) const { Quaternion ret; ret.w = -x * inp.x - y * inp.y - z * inp.z + w * inp.w; ret.x = x * inp.w + y * inp.z - z * inp.y + w * inp.x; ret.y = -x * inp.z + y * inp.w + z * inp.x + w * inp.y; ret.z = x * inp.y - y * inp.x + z * inp.w + w * inp.z; return ret; } auto opBinaryRight(string op, T)(T inp) const if(!is_quaternion!T) { return this.opBinary!(op)(inp); } Quaternion opBinary(string op)(Quaternion inp) const if((op == "+") || (op == "-")) { Quaternion ret; mixin("ret.w = w" ~ op ~ "inp.w;"); mixin("ret.x = x" ~ op ~ "inp.x;"); mixin("ret.y = y" ~ op ~ "inp.y;"); mixin("ret.z = z" ~ op ~ "inp.z;"); return ret; } Vector!(qt, 3) opBinary(string op : "*")(Vector!(qt, 3) inp) const { Vector!(qt, 3) ret; qt ww = w^^2; qt w2 = w * 2; qt wx2 = w2 * x; qt wy2 = w2 * y; qt wz2 = w2 * z; qt xx = x^^2; qt x2 = x * 2; qt xy2 = x2 * y; qt xz2 = x2 * z; qt yy = y^^2; qt yz2 = 2 * y * z; qt zz = z * z; ret.vector = [ww * inp.x + wy2 * inp.z - wz2 * inp.y + xx * inp.x + xy2 * inp.y + xz2 * inp.z - zz * inp.x - yy * inp.x, xy2 * inp.x + yy * inp.y + yz2 * inp.z + wz2 * inp.x - zz * inp.y + ww * inp.y - wx2 * inp.z - xx * inp.y, xz2 * inp.x + yz2 * inp.y + zz * inp.z - wy2 * inp.x - yy * inp.z + wx2 * inp.y - xx * inp.z + ww * inp.z]; return ret; } Quaternion opBinary(string op : "*")(qt inp) const { return Quaternion(w*inp, x*inp, y*inp, z*inp); } void opOpAssign(string op : "*")(Quaternion inp) { qt w2 = -x * inp.x - y * inp.y - z * inp.z + w * inp.w; qt x2 = x * inp.w + y * inp.z - z * inp.y + w * inp.x; qt y2 = -x * inp.z + y * inp.w + z * inp.x + w * inp.y; qt z2 = x * inp.y - y * inp.x + z * inp.w + w * inp.z; w = w2; x = x2; y = y2; z = z2; } void opOpAssign(string op)(Quaternion inp) if((op == "+") || (op == "-")) { mixin("w = w" ~ op ~ "inp.w;"); mixin("x = x" ~ op ~ "inp.x;"); mixin("y = y" ~ op ~ "inp.y;"); mixin("z = z" ~ op ~ "inp.z;"); } void opOpAssign(string op : "*")(qt inp) { quaternion[0] *= inp; quaternion[1] *= inp; quaternion[2] *= inp; quaternion[3] *= inp; } unittest { quat q1 = quat.identity; quat q2 = quat(3.0f, 0.0f, 1.0f, 2.0f); quat q3 = quat(3.4f, 0.1f, 1.2f, 2.3f); assert((q1 * q1).quaternion == q1.quaternion); assert((q1 * q2).quaternion == q2.quaternion); assert((q2 * q1).quaternion == q2.quaternion); quat q4 = q3 * q2; assert((q2 * q3).quaternion != q4.quaternion); q3 *= q2; assert(q4.quaternion == q3.quaternion); assert(almost_equal(q4.x, 0.4f)); assert(almost_equal(q4.y, 6.8f)); assert(almost_equal(q4.z, 13.8f)); assert(almost_equal(q4.w, 4.4f)); quat q5 = quat(1.0f, 2.0f, 3.0f, 4.0f); quat q6 = quat(3.0f, 1.0f, 6.0f, 2.0f); assert((q5 - q6).quaternion == [-2.0f, 1.0f, -3.0f, 2.0f]); assert((q5 + q6).quaternion == [4.0f, 3.0f, 9.0f, 6.0f]); assert((q6 - q5).quaternion == [2.0f, -1.0f, 3.0f, -2.0f]); assert((q6 + q5).quaternion == [4.0f, 3.0f, 9.0f, 6.0f]); q5 += q6; assert(q5.quaternion == [4.0f, 3.0f, 9.0f, 6.0f]); q6 -= q6; assert(q6.quaternion == [0.0f, 0.0f, 0.0f, 0.0f]); quat q7 = quat(2.0f, 2.0f, 2.0f, 2.0f); assert((q7 * 2).quaternion == [4.0f, 4.0f, 4.0f, 4.0f]); assert((2 * q7).quaternion == (q7 * 2).quaternion); q7 *= 2; assert(q7.quaternion == [4.0f, 4.0f, 4.0f, 4.0f]); vec3 v1 = vec3(1.0f, 2.0f, 3.0f); assert((q1 * v1).vector == v1.vector); assert((v1 * q1).vector == (q1 * v1).vector); assert((q2 * v1).vector == [-2.0f, 36.0f, 38.0f]); } bool opEquals(const Quaternion qu) const { return quaternion == qu.quaternion; } bool opCast(T : bool)() const { return ok; } unittest { assert(quat(1.0f, 2.0f, 3.0f, 4.0f) == quat(1.0f, 2.0f, 3.0f, 4.0f)); assert(quat(1.0f, 2.0f, 3.0f, 4.0f) != quat(1.0f, 2.0f, 3.0f, 3.0f)); assert(!(quat(float.nan, float.nan, float.nan, float.nan))); if(quat(1.0f, 1.0f, 1.0f, 1.0f)) { } else { assert(false); } } } /// Pre-defined quaternion of type float. alias Quaternion!(float) quat;
D
module win32.directx.dinput8; //import tango.sys.win32.Types; //alias char CHAR; import win32.windows; enum { CLASS_E_NOAGGREGATION = cast(int) 0x80040110, } interface IUnknown { HRESULT QueryInterface(IID* riid, void** pvObject); ULONG AddRef(); ULONG Release(); } extern(C): struct DIDEVICEINSTANCEA { DWORD dwSize; GUID guidInstance; GUID guidProduct; DWORD dwDevType; CHAR[MAX_PATH] tszInstanceName; CHAR[MAX_PATH] tszProductName; GUID guidFFDriver; WORD wUsagePage; WORD wUsage; } alias DIDEVICEINSTANCEA DIDEVICEINSTANCE; struct DIDEVICEOBJECTINSTANCEA { DWORD dwSize; GUID guidType; DWORD dwOfs; DWORD dwType; DWORD dwFlags; CHAR[MAX_PATH] tszName; DWORD dwFFMaxForce; DWORD dwFFForceResolution; WORD wCollectionNumber; WORD wDesignatorIndex; WORD wUsagePage; WORD wUsage; DWORD dwDimension; WORD wExponent; WORD wReportId; } struct DIOBJECTDATAFORMAT { const GUID *pguid; DWORD dwOfs; DWORD dwType; DWORD dwFlags; } struct DIDATAFORMAT { DWORD dwSize; DWORD dwObjSize; DWORD dwFlags; DWORD dwDataSize; DWORD dwNumObjs; DIOBJECTDATAFORMAT* rgodf; } extern DIDATAFORMAT c_dfDIKeyboard; extern DIDATAFORMAT c_dfDIMouse2; extern DIDATAFORMAT c_dfDIJoystick; struct DIACTIONA { UINT* uAppData; DWORD dwSemantic; DWORD dwFlags; union { LPCSTR lptszActionName; UINT uResIdString; } GUID guidInstance; DWORD dwObjID; DWORD dwHow; } struct DIACTIONFORMATA { DWORD dwSize; DWORD dwActionSize; DWORD dwDataSize; DWORD dwNumActions; DIACTIONA* rgoAction; GUID guidActionMap; DWORD dwGenre; DWORD dwBufferSize; LONG lAxisMin; LONG lAxisMax; HINSTANCE hInstString; FILETIME ftTimeStamp; DWORD dwCRC; CHAR[MAX_PATH] tszActionMap; } struct DIDEVCAPS { DWORD dwSize; DWORD dwFlags; DWORD dwDevType; DWORD dwAxes; DWORD dwButtons; DWORD dwPOVs; DWORD dwFFSamplePeriod; DWORD dwFFMinTimeResolution; DWORD dwFirmwareRevision; DWORD dwHardwareRevision; DWORD dwFFDriverVersion; } struct DIPROPHEADER { DWORD dwSize; DWORD dwHeaderSize; DWORD dwObj; DWORD dwHow; } struct DIDEVICEOBJECTDATA { DWORD dwOfs; DWORD dwData; DWORD dwTimeStamp; DWORD dwSequence; UINT* uAppData; } struct DIENVELOPE { DWORD dwSize = DIENVELOPE.sizeof; DWORD dwAttackLevel; DWORD dwAttackTime; // Microseconds DWORD dwFadeLevel; DWORD dwFadeTime; // Microseconds } struct DIEFFECT { DWORD dwSize = DIEFFECT.sizeof; DWORD dwFlags; // DIEFF_* DWORD dwDuration; // Microseconds DWORD dwSamplePeriod; // Microseconds DWORD dwGain; DWORD dwTriggerButton; // or DIEB_NOTRIGGER DWORD dwTriggerRepeatInterval; // Microseconds DWORD cAxes; // Number of axes LPDWORD rgdwAxes; // Array of axes LPLONG rglDirection; // Array of directions DIENVELOPE* lpEnvelope; // Optional DWORD cbTypeSpecificParams; // Size of params LPVOID lpvTypeSpecificParams; // Pointer to params DWORD dwStartDelay; // Microseconds } struct DIEFFESCAPE { DWORD dwSize; DWORD dwCommand; LPVOID lpvInBuffer; DWORD cbInBuffer; LPVOID lpvOutBuffer; DWORD cbOutBuffer; } struct DIEFFECTINFOA { DWORD dwSize; GUID guid; DWORD dwEffType; DWORD dwStaticParams; DWORD dwDynamicParams; CHAR[MAX_PATH] tszName; } struct DIFILEEFFECT { DWORD dwSize; GUID GuidEffect; DIEFFECT* lpDiEffect; CHAR[MAX_PATH] szFriendlyName; } struct DIDEVICEIMAGEINFOA { CHAR[MAX_PATH] tszImagePath; DWORD dwFlags; // These are valid if DIDIFT_OVERLAY is present in dwFlags. DWORD dwViewID; RECT rcOverlay; DWORD dwObjID; DWORD dwcValidPts; POINT[5] rgptCalloutLine; RECT rcCalloutRect; DWORD dwTextAlign; } struct DIDEVICEIMAGEINFOHEADERA { DWORD dwSize; DWORD dwSizeImageInfo; DWORD dwcViews; DWORD dwcButtons; DWORD dwcAxes; DWORD dwcPOVs; DWORD dwBufferSize; DWORD dwBufferUsed; DIDEVICEIMAGEINFOA* lprgImageInfoArray; } struct DICONFIGUREDEVICESPARAMSA { DWORD dwSize; DWORD dwcUsers; LPSTR lptszUserNames; DWORD dwcFormats; DIACTIONFORMATA* lprgFormats; HWND hwnd; DICOLORSET dics; IUnknown lpUnkDDSTarget; } struct DICOLORSET { DWORD dwSize; DWORD cTextFore; DWORD cTextHighlight; DWORD cCalloutLine; DWORD cCalloutHighlight; DWORD cBorder; DWORD cControlFill; DWORD cHighlightFill; DWORD cAreaFill; } struct DIMOUSESTATE2 { LONG lX; LONG lY; LONG lZ; BYTE[8] rgbButtons; } struct DIJOYSTATE { LONG lX; /* x-axis position */ LONG lY; /* y-axis position */ LONG lZ; /* z-axis position */ LONG lRx; /* x-axis rotation */ LONG lRy; /* y-axis rotation */ LONG lRz; /* z-axis rotation */ LONG[2] rglSlider; /* extra axes positions */ DWORD[4]rgdwPOV; /* POV directions */ BYTE[32]rgbButtons; /* 32 buttons */ } struct DIPROPRANGE { DIPROPHEADER diph; LONG lMin; LONG lMax; } interface IDirectInputEffect : IUnknown { HRESULT Initialize(HINSTANCE, DWORD, GUID*); HRESULT GetEffectGuid(GUID*); HRESULT GetParameters(DIEFFECT*, DWORD); HRESULT SetParameters(DIEFFECT*, DWORD); HRESULT Start(DWORD, DWORD); HRESULT Stop(); HRESULT GetEffectStatus(LPDWORD); HRESULT Download(); HRESULT Unload(); HRESULT Escape(DIEFFESCAPE*); } extern(Windows) alias bool function(DIDEVICEINSTANCEA*, LPVOID) LPDIENUMDEVICESCALLBACKA; extern(Windows) alias bool function(DIDEVICEINSTANCEA*, IDirectInputDevice8A*, DWORD, DWORD, LPVOID) LPDIENUMDEVICESBYSEMANTICSCBA; extern(Windows) alias bool function(DIDEVICEOBJECTINSTANCEA *didoi, void* pContext) LPDIENUMDEVICEOBJECTSCALLBACKA; extern(Windows) alias bool function(DIEFFECTINFOA*, LPVOID) LPDIENUMEFFECTSCALLBACKA; extern(Windows) alias bool function(IDirectInputEffect, LPVOID) LPDIENUMCREATEDEFFECTOBJECTSCALLBACK; extern(Windows) alias bool function(DIFILEEFFECT* , LPVOID) LPDIENUMEFFECTSINFILECALLBACK; extern(Windows) alias bool function(IUnknown, LPVOID) LPDICONFIGUREDEVICESCALLBACK; interface IDirectInputDevice8A : IUnknown { HRESULT GetCapabilities(DIDEVCAPS*); HRESULT EnumObjects(LPDIENUMDEVICEOBJECTSCALLBACKA, VOID*, DWORD); HRESULT GetProperty(GUID*, DIPROPHEADER*); HRESULT SetProperty(GUID*, DIPROPHEADER*); HRESULT Acquire(); HRESULT Unacquire(); HRESULT GetDeviceState(DWORD, LPVOID); HRESULT GetDeviceData(DWORD, DIDEVICEOBJECTDATA*, LPDWORD, DWORD); HRESULT SetDataFormat(DIDATAFORMAT*); HRESULT SetEventNotification(HANDLE); HRESULT SetCooperativeLevel(HWND, DWORD); HRESULT GetObjectInfo(DIDEVICEOBJECTINSTANCEA*, DWORD, DWORD); HRESULT GetDeviceInfo(DIDEVICEINSTANCEA*); HRESULT RunControlPanel(HWND, DWORD); HRESULT Initialize(HINSTANCE, DWORD, GUID*); HRESULT CreateEffect(GUID*, DIEFFECT*, IDirectInputEffect*, IUnknown); HRESULT EnumEffects(LPDIENUMEFFECTSCALLBACKA, LPVOID, DWORD); HRESULT GetEffectInfo(DIEFFECTINFOA*, GUID*); HRESULT GetForceFeedbackState(LPDWORD); HRESULT SendForceFeedbackCommand(DWORD); HRESULT EnumCreatedEffectObjects(LPDIENUMCREATEDEFFECTOBJECTSCALLBACK, LPVOID, DWORD); HRESULT Escape(DIEFFESCAPE*); HRESULT Poll(); HRESULT SendDeviceData(DWORD, DIDEVICEOBJECTDATA*, LPDWORD, DWORD); HRESULT EnumEffectsInFile(LPCSTR, LPDIENUMEFFECTSINFILECALLBACK, LPVOID, DWORD); HRESULT WriteEffectToFile(LPCSTR, DWORD, DIFILEEFFECT*, DWORD); HRESULT BuildActionMap(DIACTIONFORMATA*, LPCSTR, DWORD); HRESULT SetActionMap(DIACTIONFORMATA*, LPCSTR, DWORD); HRESULT GetImageInfo(DIDEVICEIMAGEINFOHEADERA*); } alias IDirectInputDevice8A IDirectInputDevice8; interface IDirectInput8A : IUnknown { extern(Windows): HRESULT CreateDevice(GUID*, IDirectInputDevice8A*, IUnknown); HRESULT EnumDevices(DWORD, LPDIENUMDEVICESCALLBACKA, LPVOID, DWORD); HRESULT GetDeviceStatus(GUID*); HRESULT RunControlPanel(HWND, DWORD); HRESULT Initialize(HINSTANCE, DWORD); HRESULT FindDevice(GUID*, LPCSTR, GUID*); HRESULT EnumDevicesBySemantics(LPCSTR, DIACTIONFORMATA*, LPDIENUMDEVICESBYSEMANTICSCBA, LPVOID, DWORD); HRESULT ConfigureDevices(LPDICONFIGUREDEVICESCALLBACK, DICONFIGUREDEVICESPARAMSA*, DWORD, LPVOID); } alias IDirectInput8A IDirectInput8; extern(Windows) HRESULT DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, GUID* riidltf, void** ppvOut, IUnknown punkOuter); const GUID IID_IDirectInput8A={0xBF798030, 0x483A, 0x4DA2, [0xAA, 0x99, 0x5D, 0x64, 0xED, 0x36, 0x97, 0x00]}; alias IID_IDirectInput8A IID_IDirectInput8; const GUID GUID_SysKeyboard = {0x6F1D2B61, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_SysMouse = {0x6F1D2B60, 0xD5A0, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_XAxis = {0xA36D02E0, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_YAxis = {0xA36D02E1, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_ZAxis = {0xA36D02E2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_RxAxis = {0xA36D02F4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_RyAxis = {0xA36D02F5, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_RzAxis = {0xA36D02E3, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_Slider = {0xA36D02E4, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_Key = {0x55728220, 0xD33C, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; const GUID GUID_POV = {0xA36D02F2, 0xC9F3, 0x11CF, [0xBF, 0xC7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00]}; enum : uint { DISCL_EXCLUSIVE= 0x00000001, DISCL_NONEXCLUSIVE= 0x00000002, DISCL_FOREGROUND= 0x00000004, DISCL_BACKGROUND= 0x00000008, DISCL_NOWINKEY= 0x00000010, DIPH_DEVICE=0, DIPH_BYOFFSET=1, DI8DEVCLASS_GAMECTRL=4, DIEDFL_ATTACHEDONLY= 0x00000001, DIDFT_AXIS= 0x00000003 } enum { SEVERITY_SUCCESS= 0, SEVERITY_ERROR= 1, FACILITY_WIN32= 7, ERROR_READ_FAULT= 30L, DIENUM_CONTINUE= 1, DIPH_BYID= 2 } struct DIPROPDWORD { DIPROPHEADER diph; DWORD dwData; } template MAKE_HRESULT(uint sev, uint fac, uint code) { const HRESULT MAKE_HRESULT = cast(HRESULT)((sev << 31) | (fac << 16) | code); } const HRESULT DIERR_OLDDIRECTINPUTVERSION = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1150); const HRESULT DIERR_BETADIRECTINPUTVERSION = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1153); const HRESULT DIERR_BADDRIVERVER = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 119); const HRESULT DIERR_DEVICENOTREG = 0x80040154; const HRESULT DIERR_NOTFOUND = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND); const HRESULT DIERR_OBJECTNOTFOUND = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND); const HRESULT DIERR_INVALIDPARAM = E_INVALIDARG; const HRESULT DIERR_NOINTERFACE = E_NOINTERFACE; const HRESULT DIERR_GENERIC = E_FAIL; const HRESULT DIERR_OUTOFMEMORY = E_OUTOFMEMORY; const HRESULT DIERR_UNSUPPORTED = E_NOTIMPL; const HRESULT DIERR_NOTINITIALIZED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 21); const HRESULT DIERR_ALREADYINITIALIZED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 1247); const HRESULT DIERR_NOAGGREGATION = CLASS_E_NOAGGREGATION; const HRESULT DIERR_OTHERAPPHASPRIO = 0x80070005; const HRESULT DIERR_INPUTLOST = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT); const HRESULT DIERR_ACQUIRED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 170); const HRESULT DIERR_NOTACQUIRED = MAKE_HRESULT!(SEVERITY_ERROR, FACILITY_WIN32, 12); const HRESULT DIERR_READONLY = 0x80070005; const HRESULT DIERR_HANDLEEXISTS = 0x80070005; const HRESULT DIERR_INSUFFICIENTPRIVS = 0x80040200; const HRESULT DIERR_DEVICEFULL = 0x80040201; const HRESULT DIERR_MOREDATA = 0x80040202; const HRESULT DIERR_NOTDOWNLOADED = 0x80040203; const HRESULT DIERR_HASEFFECTS = 0x80040204; const HRESULT DIERR_NOTEXCLUSIVEACQUIRED = 0x80040205; const HRESULT DIERR_INCOMPLETEEFFECT = 0x80040206; const HRESULT DIERR_NOTBUFFERED = 0x80040207; const HRESULT DIERR_EFFECTPLAYING = 0x80040208; const HRESULT DIERR_UNPLUGGED = 0x80040209; const HRESULT DIERR_REPORTFULL = 0x8004020A; const HRESULT DIERR_MAPFILEFAIL = 0x8004020B;
D
/Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/Build/Intermediates.noindex/Alamofire.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Result+Alamofire.o : /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartFormData.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartUpload.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AlamofireExtended.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Protected.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPMethod.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Combine.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/OperationQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/StringEncoding+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Result+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLRequest+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Response.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/SessionDelegate.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoding.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Session.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Validation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ServerTrustEvaluation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ResponseSerialization.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestTaskMap.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLEncodedFormEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/NetworkReachabilityManager.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/CachedResponseHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RedirectHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AFError.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/EventMonitor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AuthenticationInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Notifications.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPHeaders.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Request.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/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/Dispatch.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/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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/usr/include/objc/ObjectiveC.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.5.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/Build/Intermediates.noindex/Alamofire.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Result+Alamofire~partial.swiftmodule : /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartFormData.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartUpload.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AlamofireExtended.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Protected.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPMethod.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Combine.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/OperationQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/StringEncoding+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Result+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLRequest+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Response.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/SessionDelegate.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoding.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Session.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Validation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ServerTrustEvaluation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ResponseSerialization.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestTaskMap.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLEncodedFormEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/NetworkReachabilityManager.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/CachedResponseHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RedirectHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AFError.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/EventMonitor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AuthenticationInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Notifications.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPHeaders.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Request.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/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/Dispatch.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/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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/usr/include/objc/ObjectiveC.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.5.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/Build/Intermediates.noindex/Alamofire.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Result+Alamofire~partial.swiftdoc : /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartFormData.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartUpload.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AlamofireExtended.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Protected.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPMethod.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Combine.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/OperationQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/StringEncoding+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Result+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLRequest+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Response.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/SessionDelegate.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoding.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Session.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Validation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ServerTrustEvaluation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ResponseSerialization.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestTaskMap.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLEncodedFormEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/NetworkReachabilityManager.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/CachedResponseHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RedirectHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AFError.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/EventMonitor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AuthenticationInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Notifications.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPHeaders.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Request.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/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/Dispatch.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/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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/usr/include/objc/ObjectiveC.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.5.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/Build/Intermediates.noindex/Alamofire.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Result+Alamofire~partial.swiftsourceinfo : /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartFormData.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/MultipartUpload.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AlamofireExtended.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Protected.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPMethod.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLConvertible+URLRequestConvertible.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Combine.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/OperationQueue+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/StringEncoding+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLSessionConfiguration+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Result+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLRequest+Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Alamofire.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Response.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/SessionDelegate.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoding.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Session.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Validation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ServerTrustEvaluation.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ResponseSerialization.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestTaskMap.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/URLEncodedFormEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/ParameterEncoder.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/NetworkReachabilityManager.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/CachedResponseHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RedirectHandler.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AFError.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/EventMonitor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/AuthenticationInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/RequestInterceptor.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Notifications.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/HTTPHeaders.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/Alamofire/Source/Request.swift /Users/olafgomez/Documents/PracticasCice/PokedexXYiOS/PokemonXYiOS/DerivedData/PokemonXYiOS/SourcePackages/checkouts/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/Dispatch.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/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 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/usr/include/objc/ObjectiveC.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.5.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.5.sdk/System/Library/Frameworks/Security.framework/Headers/Security.apinotes
D
module carb.base.controller; import vibe.d; import std.variant; import std.conv; import std.traits; import std.stdio; import carb.base.validator; import carb.utils.util; interface Dynamic { Variant __send__(string method,HTTPServerRequest req, HTTPServerResponse res); } enum DynamicallyAvailable; // we'll use this as a user-defined annotation to see if the method should be available enum Action; struct CarbPath{ string _path; } struct CarbMethod{ HTTPMethod _method; } // This sees if the above attribute is on the member bool isDynamicallyAvailable(alias member)() { // the way UDAs work in D is this trait gives you a list of them // they are identified by type and can also hold a value (though // we don't handle that case here) foreach(annotation; __traits(getAttributes, member)) static if(is(annotation == DynamicallyAvailable)) return true; return false; } bool isActionAvailable(alias member)() { // the way UDAs work in D is this trait gives you a list of them // they are identified by type and can also hold a value (though // we don't handle that case here) foreach(annotation; __traits(getAttributes, member)) static if(is(annotation == Action)) return true; return false; } bool isCarbMethodAvailable(alias member)() { // the way UDAs work in D is this trait gives you a list of them // they are identified by type and can also hold a value (though // we don't handle that case here) foreach(annotation; __traits(getAttributes, member)) static if(is(typeof(annotation) == CarbMethod)) return true; return false; } //alias Helper(alias T) T; // this is used just to help make code shorter when doing reflection // then the implementation is a mixin template. This won't get in the way of inheritance // and will run the template on the child class (putting the code straight in the interface or // base class will not be able to call new methods in the children. The reason is this code runs // at compile time, and at compile time it can only see what's there in the source - no child class methods.) // // Actually, I think there is a way to put a template like this in the interface that does know child classes, // but I don't remember how or if it would actually work for this kind of thing or not. But I know this way works. mixin template DynamicImplementation() { private { import vibe.data.json; import std.conv : to; string toRestString(Json value) { switch( value.type ){ default: return value.toString(); case Json.Type.Bool: return value.get!bool ? "true" : "false"; case Json.Type.Int: return to!string(value.get!long); case Json.Type.Float: return to!string(value.get!double); case Json.Type.String: return value.get!string; } } T fromRestString(T)(string value) { static if( is(T == bool) ) return value == "true"; else static if( is(T : int) ) return to!T(value); else static if( is(T : double) ) return to!T(value); // FIXME: formattedWrite(dst, "%.16g", json.get!double); else static if( is(T : string) ) return value; else static if( __traits(compiles, T.fromString("hello")) ) return T.fromString(value); else return deserializeJson!T(parseJson(value)); } } import std.traits : ParameterTypeTuple, ReturnType, ParameterDefaultValueTuple, ParameterIdentifierTuple; import std.string : format; import std.algorithm : startsWith; import std.exception : enforce; import vibe.http.server : HTTPServerRequest, HTTPServerResponse; import vibe.http.common : HTTPStatusException, HTTPStatus; import vibe.utils.string : sanitizeUTF8; import vibe.internal.meta.funcattr : IsAttributedParameter; import std.variant; import std.conv; import std.traits; override Variant __send__(string methodNameWanted,HTTPServerRequest req, HTTPServerResponse res) { template ValidationParamHandler(P,VPT ...){ void validationParamHandler(string resourceName,ref VPT vparams,int method,int depth=3){ enforce( depth > -1, format("Max depth exceeded") ); if(depth <= 0){ return; } enum Vnames = [ParameterIdentifierTuple!(__traits(getMember, P,"initWithArgs"))]; alias Vdefaults = ParameterDefaultValueTuple!(__traits(getMember, P,"initWithArgs")); // VPT vparams; foreach (n, Q; VPT) { if ((Vnames[n] in req.params)) { // legacy special case for :id, backwards-compatibility logDebug("id %s", req.params[Vnames[n]]); vparams[n] = fromRestString!Q(req.params[Vnames[n]]); } else{ alias VDefVal = Vdefaults[n]; static if(is(Q : IValidator)){ alias WPT = ParameterTypeTuple!(__traits(getMember, Q,"initWithArgs")); WPT qparams; ValidationParamHandler!(Q,WPT).validationParamHandler(resourceName,qparams,method,depth - 1); Q obj = new Q(); __traits(getMember, obj,"initWithArgs")(qparams); bool validate = __traits(getMember, obj,"validate")(); enforce( validate, format("Failed validation on query parameter '%s'. \n Error: %s\n Class: %s", Vnames[n],obj.getError(),obj) ); vparams[n] = obj; } else{ if(method == HTTPMethod.GET){ static if (is (VDefVal == void)) { enforce( Vnames[n] in req.query, format("Missing validation query parameter '%s' ", Vnames[n]) ); } else { if (Vnames[n] !in req.query) { vparams[n] = VDefVal; continue; } } vparams[n] = fromRestString!Q(req.query[Vnames[n]]); } else{ static if (is(VDefVal == void)) { enforce( req.json[Vnames[n]].type != Json.Type.Undefined, format("Missing parameter %s", Vnames[n]) ); } else { if (req.json[Vnames[n]].type == Json.Type.Undefined) { vparams[n] = VDefVal; continue; } } vparams[n] = deserializeJson!Q(req.json[Vnames[n]]); } } } } } } foreach(memberName; __traits(allMembers, typeof(this))) { // writeln(memberName); if(memberName != methodNameWanted) continue; // this static if filters out private members that we can see, but cannot access static if(__traits(compiles, __traits(getMember, this, memberName))) { // the helper from above is needed for this line to compile // otherwise it would complain that alias = __traits is bad syntax // but now we can use member instead of writing __traits(getMember) over and over again // alias member = Helper!(__traits(getMember, this, memberName)); // we're only interested in calling functions that are marked as available static if(is(typeof(__traits(getMember, this, memberName)) == function) && ( isActionAvailable!(__traits(getMember, this, memberName)) || isCarbMethodAvailable!(__traits(getMember, this, memberName)) )) { alias PT = ParameterTypeTuple!(__traits(getMember, this, memberName)); PT params; void jsonParamHandler(T, string method, alias Func)(T inst){ alias ParamDefaults = ParameterDefaultValueTuple!Func; enum ParamNames = [ ParameterIdentifierTuple!Func ]; string resourceName = T.classinfo.name.split(".")[$-1][0 .. $ - 10 ].toLower(); foreach (i, P; PT) { static assert ( ParamNames[i].length, format( "Parameter %s of %s has no name", i.stringof, method ) ); // will be re-written by UDA function anyway // static if (!IsAttributedParameter!(Func, ParamNames[i])) { if ((ParamNames[i] in req.params)) { // legacy special case for :id, backwards-compatibility logDebug("id %s", req.params[resourceName ~ "_id"]); params[i] = fromRestString!P(req.params[ParamNames[i]]); } else static if (ParamNames[i].startsWith("_")) { // URL parameter static if (ParamNames[i] != "_dummy") { enforce( ParamNames[i][1 .. $] in req.params, format("req.param[%s] was not set!", ParamNames[i][1 .. $]) ); logDebug("param %s %s", ParamNames[i], req.params[ParamNames[i][1 .. $]]); params[i] = fromRestString!P(req.params[ParamNames[i][1 .. $]]); } } else { // normal parameter alias DefVal = ParamDefaults[i]; if (req.method == HTTPMethod.GET) { logDebug("query %s of %s" ,ParamNames[i], req.query); static if (is (DefVal == void)) { enforce( ParamNames[i] in req.query, format("Missing query parameter '%s'", ParamNames[i]) ); } else { if (ParamNames[i] !in req.query) { params[i] = DefVal; continue; } } static if(is(P : IValidator)){ //not int, but check for validate UDA //if has validate //get validator for argname //run validator, set params to result alias VPT = ParameterTypeTuple!(__traits(getMember, P,"initWithArgs")); VPT vparams; ValidationParamHandler!(P,VPT).validationParamHandler(resourceName, vparams,req.method); P obj = new P(); __traits(getMember, obj,"initWithArgs")(vparams); bool validate = __traits(getMember, obj,"validate")(); enforce( validate, format("Failed validation on query parameter '%s'. \n Error: %s\n Class: %s", ParamNames[i],obj.getError(),obj) ); params[i] = obj; } //o.w. else{ params[i] = fromRestString!P(req.query[ParamNames[i]]); } } else { logDebug("%s %s", method, ParamNames[i]); enforce( req.contentType == "application/json", "The Content-Type header needs to be set to application/json." ); enforce( req.json.type != Json.Type.Undefined, "The request body does not contain a valid JSON value." ); enforce( req.json.type == Json.Type.Object, "The request body must contain a JSON object with an entry for each parameter." ); static if (is(DefVal == void)) { enforce( req.json[ParamNames[i]].type != Json.Type.Undefined, format("Missing parameter %s", ParamNames[i]) ); } else { if (req.json[ParamNames[i]].type == Json.Type.Undefined) { params[i] = DefVal; continue; } } static if(is(P : IValidator)){ //not int, but check for validate UDA //if has validate //get validator for argname //run validator, set params to result alias VPT = ParameterTypeTuple!(__traits(getMember, P,"initWithArgs")); VPT vparams; ValidationParamHandler!(P,VPT).validationParamHandler(resourceName,vparams,req.method); P obj = new P(); __traits(getMember, obj,"initWithArgs")(vparams); bool validate = __traits(getMember, obj,"validate")(); enforce( validate, format("Failed validation on query parameter '%s'. \n Error: %s", ParamNames[i],obj.getError()) ); params[i] = obj; } else{ params[i] = deserializeJson!P(req.json[ParamNames[i]]); } } } //} } } //Get JSON Params //alias member = (__traits(getMember, this, memberName); // now we have a function, so time to write the code to call it // gotta get our arguments converted to the right types. We get the // tuple of them, then loop over that, and extract it from our dynamic array. // We loop over the tuple because the compile time info is available there. jsonParamHandler!(typeof(this),memberName,__traits(getMember, this, memberName))(this); //writeln(functionArguments); // Note: This won't compile if the function takes fully immutable arguments! //foreach(index, ref arg; functionArguments) { // if(index >= arguments.length) // throw new Exception("Not enough arguments to call " ~ methodNameWanted); // // I did string arguments here, could be other things too // arg = to!(typeof(arg))(arguments[index]); // // if you did Variant[] arguments, the following code would work instead // // arg = arguments[index].get!(typeof(arg)); // // .coerce instead of .get tries to force a conversion if needed, so you might want that too //} Variant returnValue; // now, for calling the function and getting the return value, // we need to check if it returns void. If so, returnValue = void // won't compile, so we do two branches. static if(is(ReturnType!(__traits(getMember, this, memberName)) == void)) __traits(getMember, this, memberName)(params); else returnValue = __traits(getMember, this, memberName)(params); return returnValue; } } } throw new Exception("No such method " ~ methodNameWanted); } } class Controller : Dynamic { mixin DynamicImplementation!(); protected { HTTPServerRequest _request; HTTPServerResponse _response; } this(HTTPServerRequest req, HTTPServerResponse res) { this._request = req; this._response = res; } @property HTTPServerRequest request() { return _request; } @property HTTPServerResponse response() { return _response; } @property void request(HTTPServerRequest req) { _request = req; } @property void response(HTTPServerResponse res) { _response = res; } } unittest{ //Controller c = new Controller; //assert(!c); }
D
/** gl2platform.d Converted from 'gl2platform.h'. Version: 2.0 See_Also: http://www.khronos.org/opengles/2_X/ Authors: Koji Kishita */ module c.gles2.gl2platform; /* * This document is licensed under the SGI Free Software B License Version * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . */ public import c.khr.khrplatform;
D
/** * Stuff for working with narrow strings. * This module shouldn't be imported directly. * Use SafeUtf/UnsafeUtf modules instead. * * Authors: Denis Shelomovskij <verylonglogin.reg@gmail.com> */ module java.nonstandard.UtfBase; package const UtfBaseText = ` # line 11 "java\nonstandard\UtfBase.d" import java.lang.util; version(Tango){ static import tango.text.convert.Utf; } else { // Phobos static import std.utf; static import std.conv; } ///The Universal Character Set (UCS), defined by the International Standard ISO/IEC 10646 /*typedef*/alias ptrdiff_t UCSindex; alias UCSindex UCSshift; static if(UTFTypeCheck) { ///UTF-16 (16-bit Unicode Transformation Format) /*struct UTF16index { ptrdiff_t internalValue; alias internalValue val; private static UTF16index opCall(ptrdiff_t _val) { UTF16index t = { _val }; return t; } void opAddAssign(in UTF16shift di) { val += di; } void opSubAssign(in UTF16shift di) { val -= di; } mixin(constFuncs!(" UTF16index opAdd(in UTF16shift di) { return UTF16index(val + di); } UTF16index opSub(in UTF16shift di) { return UTF16index(val - di); } version(Windows) { UTF16index opAdd(in ptrdiff_t di) { return UTF16index(val + di); } UTF16index opSub(in ptrdiff_t di) { return UTF16index(val - di); } } int opCmp(in UTF16index i2) { return cast(int)(val - i2.val); } ")); }*/ alias ptrdiff_t UTF16index; alias ptrdiff_t UTF16shift; ///UTF-8 (UCS Transformation Format — 8-bit) //typedef ptrdiff_t UTF8index; //alias UTF8index UTF8shift; struct UTF8index { ptrdiff_t internalValue; alias internalValue val; private static UTF8index opCall(ptrdiff_t _val) { UTF8index t = { _val }; return t; } void opAddAssign(in UTF8shift di) { val += di.val; } void opSubAssign(in UTF8shift di) { val -= di.val; } mixin(constFuncs!(" UTF8index opAdd(in UTF8shift di) { return UTF8index(val + di.val); } UTF8index opSub(in UTF8shift di) { return UTF8index(val - di.val); } UTF8shift opSub(in UTF8index di) { return UTF8shift(val - di.val); } int opCmp(in UTF8index i2) { return cast(int)(val - i2.val); } ")); } private UTF8index newUTF8index(ptrdiff_t i) { return UTF8index(i); } private ptrdiff_t val(T)(T i) { static if(is(T : UTF16index)) return cast(ptrdiff_t) i; else return i.val; } private void dec(ref UTF8index i) { --i.val; } struct UTF8shift { ptrdiff_t internalValue; alias internalValue val; private static UTF8shift opCall(ptrdiff_t _val) { UTF8shift t = { _val }; return t; } void opAddAssign(in UTF8shift di) { val += di.val; } void opSubAssign(in UTF8shift di) { val -= di.val; } mixin(constFuncs!(" UTF8shift opAdd(in UTF8shift di) { return UTF8shift(val + di.val); } UTF8shift opSub(in UTF8shift di) { return UTF8shift(val - di.val); } int opCmp(in UTF8shift di2) { return cast(int)(val - di2.val); } ")); } UTF8index asUTF8index(ptrdiff_t i) { return UTF8index(i); } UTF8shift asUTF8shift(int i) { return UTF8shift(i); } } else { alias ptrdiff_t UTF16index; alias ptrdiff_t UTF16shift; alias ptrdiff_t UTF8index; alias ptrdiff_t UTF8shift; private ptrdiff_t val(ptrdiff_t i) { return i; } private void dec(ref UTF8index i) { --i; } } char charByteAt(in char[] s, in UTF8index i) { return s[val(i)]; } UTF8index preFirstIndex(in char[] s) { return cast(UTF8index) -1; } UTF8index firstIndex(in char[] s) { return cast(UTF8index) 0; } UTF8index endIndex(in char[] s) { return cast(UTF8index) cast(int)/*64bit*/s.length; } UTF8index beforeEndIndex(in char[] s) { return s.offsetBefore(s.endIndex()); } //These variables aren't in TLS so it can be used only for writing mixin(gshared!(" private UCSindex UCSdummyShift; private UTF8shift UTF8dummyShift; private UTF16shift UTF16dummyShift; ")); private const ubyte[256] p_UTF8stride = [ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF, ]; private String toUTF8infoString(in char[] s, UTF8index i) { return Format("i = {}, s[i] = {}, s = {}", val(i), cast(ubyte)s.charByteAt(i), cast(ubyte[])s); } class UTF8Exception : Exception { this( String msg, in char[] s, UTF8index i){ super( Format("{}:\n{}", msg, toUTF8infoString(s, i))); } } bool isUTF8sequenceStart( in char[] s, in UTF8index i ) { return p_UTF8stride[s.charByteAt(i)] != 0xFF; } void validateUTF8index( in char[] s, in UTF8index i ) { if(i != s.endIndex() && !s.isUTF8sequenceStart(i)) throw new UTF8Exception("Not a start of an UTF-8 sequence", s, i); } UTF8shift UTF8strideAt( in char[] s, in UTF8index i ) { s.validateUTF8index(i); version(Tango) { return cast(UTF8shift)p_UTF8stride[s.charByteAt(i)]; } else { // Phobos return cast(UTF8shift)std.utf.stride( s, val(i) ); } } UTF16shift UTF16strideAt( in wchar[] s, in UTF16index i ) { //s.validateUTF16index(i); version(Tango) { uint u = s[val(i)]; return cast(UTF16shift)(1 + (u >= 0xD800 && u <= 0xDBFF)); } else { // Phobos return cast(UTF16shift)std.utf.stride( s, val(i) ); } } UCSindex UCScount( in char[] s ){ version(Tango){ scope dchar[] buf = new dchar[]( s.length ); uint ate; dchar[] res = tango.text.convert.Utf.toString32( s, buf, &ate ); assert( ate is s.length ); return res.length; } else { // Phobos return cast(UCSindex)/*64bit*/std.utf.count(s); } } UTF8shift toUTF8shift( in char[] s, in UTF8index i, in UCSshift dn ) { s.validateUTF8index(i); UTF8index j = i; UCSshift tdn = dn; if(tdn > 0) { do { j += s.UTF8strideAt(j); if(j > s.endIndex()) { throw new UTF8Exception(Format("toUTF8shift (dn = {}): No end of the UTF-8 sequence", dn), s, i); } } while(--tdn); } else if(tdn < 0) { do { if(!val(j)) { if(tdn == -1) { j = s.preFirstIndex(); break; } else { throw new UTF8Exception(Format("toUTF8shift (dn = {}): Can only go down to -1, not {}", dn, tdn), s, i); } } int l = 0; do { if(!val(j)) { throw new UTF8Exception(Format("toUTF8shift (dn = {}): No start of the UTF-8 sequence before", dn), s, i); } ++l; dec(j); } while(!s.isUTF8sequenceStart(j)); l -= val(s.UTF8strideAt(j)); if(l > 0) { throw new UTF8Exception(Format("toUTF8shift (dn = {}): Overlong UTF-8 sequence before", dn), s, i); } else if(l < 0) { throw new UTF8Exception(Format("toUTF8shift (dn = {}): Too short UTF-8 sequence before", dn), s, i); } } while(++tdn); } return j - i; } UTF8index offsetBefore( in char[] s, in UTF8index i ) { return i + s.toUTF8shift(i, -1); } UTF8index offsetAfter( in char[] s, in UTF8index i ) { return i + s.toUTF8shift(i, 1); } /** If the index is in a midle of an UTF-8 byte sequence, it will return the position of the first byte of this sequence. */ void adjustUTF8index( in char[] s, ref UTF8index i ){ if(i == s.endIndex() || s.isUTF8sequenceStart(i)) return; int l = 0; alias i res; do { if(!val(res)) throw new UTF8Exception("adjustUTF8index: No start of the UTF-8 sequence", s, i); ++l; dec(res); } while(!s.isUTF8sequenceStart(res)); l -= val(s.UTF8strideAt(i)); if(l > 0) throw new UTF8Exception("adjustUTF8index: Overlong UTF-8 sequence", s, i); } UTF8index takeIndexArg(String F = __FILE__, uint L = __LINE__)(String s, int i_arg, String location) { UTF8index res = cast(UTF8index) i_arg; if(i_arg > 0 && i_arg < s.length) { auto t = res; s.adjustUTF8index(res); if(t != res) getDwtLogger().warn(F, L, Format("Fixed invalid UTF-8 index at {}:\nnew i = {}, {}", location, val(res), toUTF8infoString(s, t))); } return res; } version(Win64) dchar dcharAt( in char[] s, in UTF8index i, out int stride) { return dcharAt(s, i, stride); } dchar dcharAt( in char[] s, in UTF8index i, out UTF8shift stride = UTF8dummyShift ) { s.validateUTF8index(i); auto str = s[val(i) .. $]; version(Tango){ dchar[1] buf; uint ate; dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate ); assert( ate > 0 && res.length is 1 ); stride = cast(UTF8shift)ate; return res[0]; } else { // Phobos size_t ate = 0; dchar res = std.utf.decode(str, ate); stride = cast(UTF8shift)cast(int)/*64bit*/ate; return res; } } dchar dcharAt( in wchar[] s, in UTF16index i, out UTF16shift stride = UTF16dummyShift ) { //s.validateUTF16index(i); auto str = s[val(i) .. $]; version(Tango){ dchar[1] buf; uint ate; dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate ); assert( ate > 0 && res.length is 1 ); stride = cast(UTF16shift)ate; if( ate is 0 || res.length is 0 ){ getDwtLogger().trace( __FILE__, __LINE__, "str.length={} str={:X2}", str.length, cast(ubyte[])str ); } return res[0]; } else { // Phobos size_t ate = 0; dchar res = std.utf.decode(str, ate); stride = cast(UTF16shift)ate; return res; } } dchar dcharBefore( in char[] s, in UTF8index i ) { return s.dcharAt(s.offsetBefore(i)); } dchar dcharAfter( in char[] s, in UTF8index i ) { return s.dcharAt(i + s.toUTF8shift(i, 1)); } ///Get that String, that contains the next codepoint of a String. String dcharAsStringAt( in char[] s, in UTF8index i, out UTF8shift stride = UTF8dummyShift ) { s.validateUTF8index(i); auto str = s[val(i) .. $]; uint ate; version(Tango){ dchar[1] buf; dchar[] res = tango.text.convert.Utf.toString32( str, buf, &ate ); } else { // Phobos ate = std.utf.stride( str, 0 ); } stride = cast(UTF8shift)ate; return str[ 0 .. ate ]._idup(); } `;
D
/** * Authors: Frank Benoit <keinfarbton@googlemail.com> */ module java.io.File; import java.lang.all; version(Tango){ static import tango.io.model.IFile; static import tango.io.FilePath; static import tango.io.Path; static import tango.io.FileSystem; static import tango.sys.Environment; static import tango.sys.Common; static import tango.stdc.stringz; //for toStringz version(Posix) static import tango.stdc.posix.unistd; //for access } else { // Phobos static import std.file; static import std.path; static import std.string; //for toStringz version(Posix) static import core.sys.posix.unistd; //for access } // Implement this more efficient by using FilePath in Tango public class File { public static char separatorChar; public static String separator; public static char pathSeparatorChar; public static String pathSeparator; private String mFilePath; static this(){ version(Tango){ separator = tango.io.model.IFile.FileConst.PathSeparatorString; separatorChar = tango.io.model.IFile.FileConst.PathSeparatorChar; pathSeparator = tango.io.model.IFile.FileConst.SystemPathString; pathSeparatorChar = tango.io.model.IFile.FileConst.SystemPathChar; } else { // Phobos separator = std.path.sep; separatorChar = std.path.sep[0]; pathSeparator = std.path.pathsep; pathSeparatorChar = std.path.pathsep[0]; } } private static String toStd( String path ){ version(Tango){ return tango.io.Path.standard( path.dup ); } else { // Phobos return path; } } private static String join( String path, String file ){ version(Tango){ return tango.io.Path.join( toStd(path), toStd(file) ); } else { // Phobos return std.path.buildPath( toStd(path), toStd(file) ); } } public this ( String pathname ){ mFilePath = toStd( pathname ); } public this ( String parent, String child ){ mFilePath = join( parent, child ); } public this ( java.io.File.File parent, String child ){ version(Tango){ mFilePath = tango.io.Path.join( parent.mFilePath, toStd(child) ); } else { // Phobos mFilePath = std.path.buildPath( parent.mFilePath, toStd(child) ); } } public int getPrefixLength(){ implMissing( __FILE__, __LINE__ ); return 0; } public String getName(){ implMissing( __FILE__, __LINE__ ); return null; } public String getParent(){ implMissing( __FILE__, __LINE__ ); return null; } public java.io.File.File getParentFile(){ implMissing( __FILE__, __LINE__ ); return null; } public String getPath(){ implMissing( __FILE__, __LINE__ ); return null; } public bool isAbsolute(){ implMissing( __FILE__, __LINE__ ); return false; } public String getAbsolutePath(){ version(Tango){ return (new tango.io.FilePath.FilePath(mFilePath)).absolute(tango.sys.Environment.Environment.cwd).toString; } else { // Phobos return std.path.absolutePath(mFilePath); } } public java.io.File.File getAbsoluteFile(){ return new File( getAbsolutePath() ); } public String getCanonicalPath(){ implMissing( __FILE__, __LINE__ ); return null; } public java.io.File.File getCanonicalFile(){ implMissing( __FILE__, __LINE__ ); return null; } public bool canRead(){ implMissing( __FILE__, __LINE__ ); return false; } public bool canWrite(){ version(Windows) { //Windows's ACL isn't supported version(Tango) { return tango.io.Path.isWritable(mFilePath); } else { // Phobos return !(std.file.getAttributes(mFilePath) & 1); //FILE_ATTRIBUTE_READONLY = 1 } } else version(Posix) { //workaround Tango's bug (isWritable is always true) version(Tango) { return tango.stdc.posix.unistd.access (tango.stdc.stringz.toStringz(mFilePath), 2) is 0; //W_OK = 2 } else { // Phobos return core.sys.posix.unistd.access (std.string.toStringz(mFilePath), 2) is 0; //W_OK = 2 } } else static assert(0); } public bool exists(){ version(Tango){ return tango.io.Path.exists(mFilePath); } else { // Phobos return std.file.exists(mFilePath); } } public bool isDirectory(){ version(Tango){ return tango.io.Path.isFolder(mFilePath); } else { // Phobos return std.file.isDir(mFilePath); } } public bool isFile(){ implMissing( __FILE__, __LINE__ ); return false; } public bool isHidden(){ implMissing( __FILE__, __LINE__ ); return false; } public long lastModified(){ implMissing( __FILE__, __LINE__ ); return 0L; } public long length(){ implMissing( __FILE__, __LINE__ ); return 0L; } public bool createNewFile(){ implMissing( __FILE__, __LINE__ ); return false; } public bool delete_KEYWORDESCAPE(){ implMissing( __FILE__, __LINE__ ); return false; } public void deleteOnExit(){ implMissing( __FILE__, __LINE__ ); } public String[] list(){ implMissing( __FILE__, __LINE__ ); return null; } public java.io.File.File[] listFiles(){ implMissing( __FILE__, __LINE__ ); return null; } public bool mkdir(){ implMissing( __FILE__, __LINE__ ); return false; } public bool mkdirs(){ implMissing( __FILE__, __LINE__ ); return false; } public bool renameTo( java.io.File.File dest ){ implMissing( __FILE__, __LINE__ ); return false; } public bool setLastModified( long time ){ implMissing( __FILE__, __LINE__ ); return false; } public bool setReadOnly(){ implMissing( __FILE__, __LINE__ ); return false; } public static java.io.File.File[] listRoots(){ implMissing( __FILE__, __LINE__ ); return null; } public static java.io.File.File createTempFile( String prefix, String suffix, java.io.File.File directory ){ implMissing( __FILE__, __LINE__ ); return null; } public static java.io.File.File createTempFile( String prefix, String suffix ){ implMissing( __FILE__, __LINE__ ); return null; } public int compareTo( java.io.File.File pathname ){ implMissing( __FILE__, __LINE__ ); return 0; } public String toString(){ implMissing( __FILE__, __LINE__ ); return null; } }
D
assign too low a value to esteem lightly lose in value
D
module UnrealScript.TribesGame.GFxTrUI_LoadoutMenu; import ScriptClasses; import UnrealScript.Helpers; import UnrealScript.UTGame.UTGFxTweenableMoviePlayer; extern(C++) interface GFxTrUI_LoadoutMenu : UTGFxTweenableMoviePlayer { public extern(D): private static __gshared ScriptClass mStaticClass; @property final static ScriptClass StaticClass() { mixin(MGSCC("Class TribesGame.GFxTrUI_LoadoutMenu")); } private static __gshared GFxTrUI_LoadoutMenu mDefaultProperties; @property final static GFxTrUI_LoadoutMenu DefaultProperties() { mixin(MGDPC("GFxTrUI_LoadoutMenu", "GFxTrUI_LoadoutMenu TribesGame.Default__GFxTrUI_LoadoutMenu")); } }
D
/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module 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 QLINEEDIT_H #define QLINEEDIT_H public import qt.QtWidgets.qframe; public import qt.QtGui.qtextcursor; public import qt.QtCore.qstring; public import qt.QtCore.qmargins; QT_BEGIN_NAMESPACE #ifndef QT_NO_LINEEDIT class QValidator; class QMenu; class QLineEditPrivate; class QCompleter; class QStyleOptionFrame; class QAbstractSpinBox; class QDateTimeEdit; class QIcon; class QToolButton; class Q_WIDGETS_EXPORT QLineEdit : public QWidget { mixin Q_OBJECT; Q_ENUMS(ActionPosition EchoMode) mixin Q_PROPERTY!(QString, "inputMask", "READ", "inputMask", "WRITE", "setInputMask"); mixin Q_PROPERTY!(QString, "text", "READ", "text", "WRITE", "setText", "NOTIFY", "textChanged", "USER", "true"); mixin Q_PROPERTY!(int, "maxLength", "READ", "maxLength", "WRITE", "setMaxLength"); mixin Q_PROPERTY!(bool, "frame", "READ", "hasFrame", "WRITE", "setFrame"); mixin Q_PROPERTY!(EchoMode, "echoMode", "READ", "echoMode", "WRITE", "setEchoMode"); mixin Q_PROPERTY!(QString, "displayText", "READ", "displayText"); mixin Q_PROPERTY!(int, "cursorPosition", "READ", "cursorPosition", "WRITE", "setCursorPosition"); mixin Q_PROPERTY!(Qt.Alignment, "alignment", "READ", "alignment", "WRITE", "setAlignment"); mixin Q_PROPERTY!(bool, "modified", "READ", "isModified", "WRITE", "setModified", "DESIGNABLE", "false"); mixin Q_PROPERTY!(bool, "hasSelectedText", "READ", "hasSelectedText"); mixin Q_PROPERTY!(QString, "selectedText", "READ", "selectedText"); mixin Q_PROPERTY!(bool, "dragEnabled", "READ", "dragEnabled", "WRITE", "setDragEnabled"); mixin Q_PROPERTY!(bool, "readOnly", "READ", "isReadOnly", "WRITE", "setReadOnly"); mixin Q_PROPERTY!(bool, "undoAvailable", "READ", "isUndoAvailable"); mixin Q_PROPERTY!(bool, "redoAvailable", "READ", "isRedoAvailable"); mixin Q_PROPERTY!(bool, "acceptableInput", "READ", "hasAcceptableInput"); mixin Q_PROPERTY!(QString, "placeholderText", "READ", "placeholderText", "WRITE", "setPlaceholderText"); mixin Q_PROPERTY!(Qt.CursorMoveStyle, "cursorMoveStyle", "READ", "cursorMoveStyle", "WRITE", "setCursorMoveStyle"); mixin Q_PROPERTY!(bool, "clearButtonEnabled", "READ", "isClearButtonEnabled", "WRITE", "setClearButtonEnabled"); public: enum ActionPosition { LeadingPosition, TrailingPosition }; explicit QLineEdit(QWidget* parent=0); explicit QLineEdit(ref const(QString) , QWidget* parent=0); ~QLineEdit(); QString text() const; QString displayText() const; QString placeholderText() const; void setPlaceholderText(ref const(QString) ); int maxLength() const; void setMaxLength(int); void setFrame(bool); bool hasFrame() const; void setClearButtonEnabled(bool enable); bool isClearButtonEnabled() const; enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit }; EchoMode echoMode() const; void setEchoMode(EchoMode); bool isReadOnly() const; void setReadOnly(bool); #ifndef QT_NO_VALIDATOR void setValidator(const(QValidator)* ); const(QValidator)* validator() const; #endif #ifndef QT_NO_COMPLETER void setCompleter(QCompleter *completer); QCompleter *completer() const; #endif QSize sizeHint() const; QSize minimumSizeHint() const; int cursorPosition() const; void setCursorPosition(int); int cursorPositionAt(ref const(QPoint) pos); void setAlignment(Qt.Alignment flag); Qt.Alignment alignment() const; void cursorForward(bool mark, int steps = 1); void cursorBackward(bool mark, int steps = 1); void cursorWordForward(bool mark); void cursorWordBackward(bool mark); void backspace(); void del(); void home(bool mark); void end(bool mark); bool isModified() const; void setModified(bool); void setSelection(int, int); bool hasSelectedText() const; QString selectedText() const; int selectionStart() const; bool isUndoAvailable() const; bool isRedoAvailable() const; void setDragEnabled(bool b); bool dragEnabled() const; void setCursorMoveStyle(Qt.CursorMoveStyle style); Qt.CursorMoveStyle cursorMoveStyle() const; QString inputMask() const; void setInputMask(ref const(QString) inputMask); bool hasAcceptableInput() const; void setTextMargins(int left, int top, int right, int bottom); void setTextMargins(ref const(QMargins) margins); void getTextMargins(int *left, int *top, int *right, int *bottom) const; QMargins textMargins() const; #ifdef Q_NO_USING_KEYWORD /+inline+/ void addAction(QAction *action) { QWidget::addAction(action); } #else using QWidget::addAction; #endif void addAction(QAction *action, ActionPosition position); QAction *addAction(ref const(QIcon) icon, ActionPosition position); public Q_SLOTS: void setText(ref const(QString) ); void clear(); void selectAll(); void undo(); void redo(); #ifndef QT_NO_CLIPBOARD void cut(); void copy() const; void paste(); #endif public: void deselect(); void insert(ref const(QString) ); #ifndef QT_NO_CONTEXTMENU QMenu *createStandardContextMenu(); #endif Q_SIGNALS: void textChanged(ref const(QString) ); void textEdited(ref const(QString) ); void cursorPositionChanged(int, int); void returnPressed(); void editingFinished(); void selectionChanged(); protected: void mousePressEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void mouseDoubleClickEvent(QMouseEvent *); void keyPressEvent(QKeyEvent *); void focusInEvent(QFocusEvent *); void focusOutEvent(QFocusEvent *); void paintEvent(QPaintEvent *); #ifndef QT_NO_DRAGANDDROP void dragEnterEvent(QDragEnterEvent *); void dragMoveEvent(QDragMoveEvent *e); void dragLeaveEvent(QDragLeaveEvent *e); void dropEvent(QDropEvent *); #endif void changeEvent(QEvent *); #ifndef QT_NO_CONTEXTMENU void contextMenuEvent(QContextMenuEvent *); #endif void inputMethodEvent(QInputMethodEvent *); void initStyleOption(QStyleOptionFrame *option) const; public: QVariant inputMethodQuery(Qt.InputMethodQuery) const; bool event(QEvent *); protected: QRect cursorRect() const; public: private: friend class QAbstractSpinBox; friend class QAccessibleLineEdit; #ifdef QT_KEYPAD_NAVIGATION friend class QDateTimeEdit; #endif mixin Q_DISABLE_COPY; mixin Q_DECLARE_PRIVATE; Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) Q_PRIVATE_SLOT(d_func(), void _q_textEdited(ref const(QString) )) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int)) #ifndef QT_NO_COMPLETER Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString)) #endif #ifdef QT_KEYPAD_NAVIGATION Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool)) #endif Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged()) Q_PRIVATE_SLOT(d_func(), void _q_updateNeeded(ref const(QRect) )) Q_PRIVATE_SLOT(d_func(), void _q_textChanged(ref const(QString) )) Q_PRIVATE_SLOT(d_func(), void _q_clearButtonClicked()) }; #endif // QT_NO_LINEEDIT QT_END_NAMESPACE #endif // QLINEEDIT_H
D
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; void main() { int N; scanf("%d", &N); auto X = new int[](N); auto Y = new int[](N); auto T = new int[](N); auto R = new int[](N); foreach (i; 0..N) scanf("%d %d %d %d", &X[i], &Y[i], &T[i], &R[i]); auto adj = new real[][](N, N); foreach (i; 0..N) { foreach (j; 0..N) { if (i == j) { adj[i][j] = 0; continue; } auto d = sqrt(cast(real)((X[i]-X[j])^^2 + (Y[i]-Y[j])^^2)); adj[i][j] = d / min(T[i], R[j]); } } immutable real INF = 1L << 40; auto dist = new real[](N); fill(dist, INF); dist[0] = 0; auto used = new bool[](N); while(true) { int v = -1; foreach (u; 0..N) if (!used[u] && (v == -1 || dist[u] < dist[v])) v = u; if (v == -1) break; used[v] = true; foreach (u; 0..N) dist[u] = min(dist[u], dist[v] + adj[v][u]); } dist.sort(); foreach (i; 1..N) { dist[i] += N - 1 - i; } writefln("%.10f", dist.reduce!(max)); }
D
/Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/Objects-normal/x86_64/HeroTransition.o : /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroCompatible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier+HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UIViewControllerTransitioningDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UINavigationControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UITabBarControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroViewControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Animate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransitionState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTargetState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Complete.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Interactive.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+CustomTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CG+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/DispatchQueue+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CAMediaTimingFunction+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIViewController+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CALayer+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIKit+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIView+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/Array+HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroProgressRunner.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Parser.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Lexer.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/SourcePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/CascadePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/BasePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/MatchPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/ConditionalPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/DefaultAnimationPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/IgnoreSubviewModifiersPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroDefaultAnimator.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Nodes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTypes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Start.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroCoreAnimationViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroAnimatorViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroViewPropertyViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugView.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Regex.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/ModelIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/MetalKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/Hero/Hero-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/ModelIO.framework/Headers/ModelIO.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/MetalKit.framework/Headers/MetalKit.apinotes /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/Objects-normal/x86_64/HeroTransition~partial.swiftmodule : /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroCompatible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier+HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UIViewControllerTransitioningDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UINavigationControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UITabBarControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroViewControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Animate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransitionState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTargetState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Complete.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Interactive.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+CustomTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CG+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/DispatchQueue+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CAMediaTimingFunction+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIViewController+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CALayer+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIKit+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIView+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/Array+HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroProgressRunner.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Parser.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Lexer.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/SourcePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/CascadePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/BasePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/MatchPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/ConditionalPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/DefaultAnimationPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/IgnoreSubviewModifiersPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroDefaultAnimator.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Nodes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTypes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Start.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroCoreAnimationViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroAnimatorViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroViewPropertyViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugView.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Regex.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/ModelIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/MetalKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/Hero/Hero-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/ModelIO.framework/Headers/ModelIO.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/MetalKit.framework/Headers/MetalKit.apinotes /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/Objects-normal/x86_64/HeroTransition~partial.swiftdoc : /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroCompatible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier+HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/HeroStringConvertible.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UIViewControllerTransitioningDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UINavigationControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+UITabBarControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroViewControllerDelegate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Animate.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransitionState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTargetState.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Complete.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Interactive.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroPlugin.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+CustomTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CG+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/DispatchQueue+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CAMediaTimingFunction+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIViewController+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/CALayer+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIKit+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/UIView+Hero.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Extensions/Array+HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroModifier.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroProgressRunner.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Parser.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Lexer.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/SourcePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/CascadePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/BasePreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/MatchPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/ConditionalPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/DefaultAnimationPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Preprocessors/IgnoreSubviewModifiersPreprocessor.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroDefaultAnimator.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Nodes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroTypes.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Transition/HeroTransition+Start.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/HeroContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroCoreAnimationViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroAnimatorViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Animator/HeroViewPropertyViewContext.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Debug\ Plugin/HeroDebugView.swift /Users/benormos/Desktop/MyFutureBox/Pods/Hero/Sources/Parser/Regex.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/ModelIO.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/simd.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/MetalKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/SwiftOnoneSupport.swiftmodule /Users/benormos/Desktop/MyFutureBox/Pods/Target\ Support\ Files/Hero/Hero-umbrella.h /Users/benormos/Desktop/MyFutureBox/build/Pods.build/Debug-iphonesimulator/Hero.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/ModelIO.framework/Headers/ModelIO.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.0.sdk/System/Library/Frameworks/MetalKit.framework/Headers/MetalKit.apinotes
D
/**** * Generic ranges not found in Phobos. * Copyright: 2013 by Digital Mars * License: $(LINK2 http://boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Walter Bright */ module ranges; /************** * BitBucket is an OutputRange that throws away its output. */ struct BitBucket(E) { static void put(E e) { } } /***************************************** */ struct EmptyInputRange(E) { enum bool empty = true; enum E front = E.init; static void popFront() { assert(0); } } /***************************************** */ struct StaticArrayBuffer(E, size_t N) { size_t i; E[N] arr = void; void initialize() { i = 0; } void put(E e) { arr[i] = e; ++i; } void put(E[] e) { arr[i .. i + e.length] = e[]; i += e.length; } E[] opSlice() { return arr[0 .. i]; } @property size_t length() { return i; } } //import std.stdio; unittest { StaticArrayBuffer!(ubyte, 2) buf = void; buf.initialize(); buf.put('a'); buf.put('b'); //writefln("'%s'", buf.get()); assert(buf[] == "ab"); } unittest { ubyte[2] buf = void; size_t i; buf[i] = 'a'; ++i; buf[i] = 'b'; ++i; assert(buf[0 .. i] == "ab"); }
D
module webtank.security.auth.core.controller; import webtank.security.auth.iface.controller: IAuthController; /// Класс управляет выдачей билетов для доступа class AuthCoreController: IAuthController { import webtank.security.auth.iface.user_identity: IUserIdentity; import webtank.security.auth.common.exception: AuthException, AuthSystemException; import webtank.security.auth.common.user_identity: CoreUserIdentity; import webtank.security.auth.common.session_id: SessionId, sessionIdStrLength; import webtank.net.http.input: HTTPInput; import webtank.db: IDatabase, queryParams, IDatabaseFactory; import webtank.security.auth.core.consts: sessionLifetime; import webtank.security.auth.core.utils: getAuthDB; protected: IDatabaseFactory _dbFactory; public: import std.exception: enforce; this(IDatabaseFactory factory) { enforce!AuthSystemException(factory !is null, `Expected instance of IDatabaseFactory`); _dbFactory = factory; } /// Выполняет HTTP-запроса по идентификатору сессии /// Возвращает удостоверение пользователя override IUserIdentity authenticate(HTTPInput req) { import std.conv: text; import std.base64: Base64URL; import webtank.net.http.headers.consts: HTTPHeader, CookieName; import webtank.datctrl.record_format: RecordFormat, PrimaryKey; import webtank.db.datctrl: getRecord; auto authDB = _dbFactory.getAuthDB(); string SIDString = req.cookies.get(CookieName.SessionId, null); enforce!AuthException(SIDString.length > 0, `Empty sid string`); enforce!AuthException(SIDString.length == sessionIdStrLength, `Incorrect length of sid string`); SessionId sessionId; Base64URL.decode(SIDString, sessionId[]); enforce!AuthException(sessionId != SessionId.init, `Empty sid`); // По сессии узнаем информацию о пользователе auto userRec = authDB.queryParams( `select su.num, su.email, su.login, su.name, to_json(coalesce( ( select -- Роли пользователя array_agg(R.name) filter( where nullif(R.name, '') is not null ) from user_access_role UR join access_role R on R.num = UR.role_num where UR.user_num = su.num ), ARRAY[]::text[] )) "roles", ss.client_address, ss.user_agent from( -- Находим сессию и проверяем, что она не "протухла" select sss.site_user_num, sss.client_address, sss.user_agent from session sss where sss.sid = $1::text and sss.created > (current_timestamp at time zone 'UTC' - ($2::text || ' minutes')::interval) limit 1 ) ss join site_user su on su.num = ss.site_user_num limit 1`, Base64URL.encode(sessionId), sessionLifetime ).getRecord(RecordFormat!( PrimaryKey!(size_t, "num"), string, "email", string, "login", string, "name", string[], "roles", string, `client_address`, string, `user_agent` )()); //Проверяем адрес и клиентскую программу с имеющимися при создании сессии enforce!AuthException( req.headers.get(HTTPHeader.XRealIP, null) == userRec.getStr!`client_address`, `User IP-address mismatch`); enforce!AuthException( req.headers.get(HTTPHeader.UserAgent, null) == userRec.getStr!`user_agent`, `User agent mismatch`); string[string] userData = [ "userNum": userRec.getStr!"num", "email": userRec.getStr!"email" ]; import std.array: join; //Получаем информацию о пользователе из результата запроса return new CoreUserIdentity( userRec.getStr!"login", userRec.getStr!"name", userRec.get!"roles", userData, sessionId ); } void logout(IUserIdentity user) { import std.conv: to, ConvException; if( user is null ) { return; } scope(exit) { // В любом случае нужно вызвать инвалидацию удостоверения user.invalidate(); } size_t userNum; try { userNum = user.data.get(`userNum`, null).to!size_t; } catch(ConvException e) { return; } // Сносим все сессии пользователя из базы _dbFactory.getAuthDB().queryParams( `delete from session where "site_user_num" = $1`, userNum); } }
D
module android.java.org.w3c.dom.CDATASection_d_interface; import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers; static import arsd.jni; import import5 = android.java.org.w3c.dom.Document_d_interface; import import2 = android.java.org.w3c.dom.Node_d_interface; import import0 = android.java.java.lang.Class_d_interface; import import3 = android.java.org.w3c.dom.NodeList_d_interface; import import1 = android.java.org.w3c.dom.Text_d_interface; import import4 = android.java.org.w3c.dom.NamedNodeMap_d_interface; import import6 = android.java.org.w3c.dom.UserDataHandler_d_interface; final class CDATASection : IJavaObject { static immutable string[] _d_canCastTo = [ "org/w3c/dom/Text", ]; @Import import0.Class getClass(); @Import int hashCode(); @Import bool equals(IJavaObject); @Import @JavaName("toString") string toString_(); override string toString() { return arsd.jni.javaObjectToString(this); } @Import void notify(); @Import void notifyAll(); @Import void wait(long); @Import void wait(long, int); @Import void wait(); @Import import1.Text splitText(int); @Import bool isElementContentWhitespace(); @Import string getWholeText(); @Import import1.Text replaceWholeText(string); @Import string getData(); @Import void setData(string); @Import int getLength(); @Import string substringData(int, int); @Import void appendData(string); @Import void insertData(int, string); @Import void deleteData(int, int); @Import void replaceData(int, int, string); @Import string getNodeName(); @Import string getNodeValue(); @Import void setNodeValue(string); @Import short getNodeType(); @Import import2.Node getParentNode(); @Import import3.NodeList getChildNodes(); @Import import2.Node getFirstChild(); @Import import2.Node getLastChild(); @Import import2.Node getPreviousSibling(); @Import import2.Node getNextSibling(); @Import import4.NamedNodeMap getAttributes(); @Import import5.Document getOwnerDocument(); @Import import2.Node insertBefore(import2.Node, import2.Node); @Import import2.Node replaceChild(import2.Node, import2.Node); @Import import2.Node removeChild(import2.Node); @Import import2.Node appendChild(import2.Node); @Import bool hasChildNodes(); @Import import2.Node cloneNode(bool); @Import void normalize(); @Import bool isSupported(string, string); @Import string getNamespaceURI(); @Import string getPrefix(); @Import void setPrefix(string); @Import string getLocalName(); @Import bool hasAttributes(); @Import string getBaseURI(); @Import short compareDocumentPosition(import2.Node); @Import string getTextContent(); @Import void setTextContent(string); @Import bool isSameNode(import2.Node); @Import string lookupPrefix(string); @Import bool isDefaultNamespace(string); @Import string lookupNamespaceURI(string); @Import bool isEqualNode(import2.Node); @Import IJavaObject getFeature(string, string); @Import IJavaObject setUserData(string, IJavaObject, import6.UserDataHandler); @Import IJavaObject getUserData(string); mixin IJavaObjectImplementation!(false); public static immutable string _javaParameterString = "Lorg/w3c/dom/CDATASection;"; }
D
/Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/CandleChartDataProvider.o : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Legend.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Description.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/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/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/CandleChartDataProvider~partial.swiftmodule : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Legend.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Description.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/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/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/Objects-normal/x86_64/CandleChartDataProvider~partial.swiftdoc : /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator+N.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CombinedChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartData.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedViewPortJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/MoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedMoveViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/ZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Jobs/AnimatedZoomViewJob.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Legend.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerImage.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Range.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ChartLimitLine.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ChartDataRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/AxisRendererBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/AxisBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/ComponentBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieRadarChartViewBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntryBase.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/ChartAnimationEasing.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Fill.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Platform.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/Description.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CombinedChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarLineScatterCandleBubbleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/CandleChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/LineChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/BarChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Interfaces/ScatterChartDataProvider.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/IMarker.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ViewPortHandler.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/Transformer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Renderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LegendRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/IShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/XShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CircleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/TriangleShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/SquareShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronDownShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/ChevronUpShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/Scatter/CrossShapeRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineScatterCandleRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineRadarRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CombinedChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/PieChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/LineChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/HorizontalBarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/RadarChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/ScatterChartRenderer.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/IHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/CombinedHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/BarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/HorizontalBarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/RadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/PieRadarHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/ChartHighlighter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IndexAxisValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultValueFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/IFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Formatters/DefaultFillFormatter.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Animation/Animator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Filters/DataApproximator.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartColorTemplates.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/XAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/YAxis.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/ChartUtils.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/ChartBaseDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IPieChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarLineScatterCandleBubbleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ICandleChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IBarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineScatterCandleRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/LineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/ILineRadarChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Interfaces/IScatterChartDataSet.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Highlight/Highlight.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Utils/TransformerHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererHorizontalBarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/XAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Renderers/YAxisRendererRadarChart.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Components/MarkerView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CombinedChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/PieChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BubbleChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/LineChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/CandleStickChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/BarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/HorizontalBarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/RadarChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Charts/ScatterChartView.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/PieChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BubbleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/CandleChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/BarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Charts/Source/Charts/Data/Implementations/Standard/RadarChartDataEntry.swift /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/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/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/Pods/Target\ Support\ Files/Charts/Charts-umbrella.h /Users/justinlew/Documents/SFU/CMPT276/justinlew.mealify.io/DerivedData/mealify/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Charts.build/unextended-module.modulemap /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/objc/ObjectiveC.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/OpenGLES.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreImage.framework/Headers/CoreImage.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/include/Darwin.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CoreText.framework/Headers/CoreText.apinotes
D
module arrayfire.internal; import arrayfire.defines; extern ( C ){ //#if AF_API_VERSION >= 33 /+ \param[out] arr an af_array with specified offset, dimensions and strides. \param[in] data is the raw data pointer. \param[in] offset specifies the number of elements to skip. \param[in] ndims specifies the number of array dimensions. \param[in] dims specifies the dimensions for the region of interest. \param[in] strides specifies the distance between each element of a given dimension. \param[in] ty specifies the data type of \p data. \param[in] location specifies if the data is on host or the device. \note If \p location is `afHost`, a memory copy is performed. \ingroup internal_func_create +/ af_err af_create_strided_array(af_array *arr, const void *data, const dim_t offset, const uint ndims, const dim_t * dims, const dim_t * strides, const af_dtype ty, const af_source location); // #endif //#if AF_API_VERSION >= 33 /+ \param[in] arr An multi dimensional array. \param[out] s0 distance between each consecutive element along first dimension. \param[out] s1 distance between each consecutive element along second dimension. \param[out] s2 distance between each consecutive element along third dimension. \param[out] s3 distance between each consecutive element along fourth dimension. \ingroup internal_func_strides +/ af_err af_get_strides(dim_t *s0, dim_t *s1, dim_t *s2, dim_t *s3, const af_array arr); // #endif //#if AF_API_VERSION >= 33 /+ \param[in] arr An multi dimensional array. \param[out] offset: Offset from the starting location of data pointer specified in number of elements. distance between each consecutive element along first dimension. \ingroup internal_func_offset +/ af_err af_get_offset(dim_t *offset, const af_array arr); // #endif //#if AF_API_VERSION >= 33 /+ \param[in] arr An multi dimensional array. \param[out] ptr the raw pointer location to the array. \note This pointer may be shared with other arrays. Use this function with caution. \ingroup internal_func_rawptr +/ af_err af_get_raw_ptr(void **ptr, const af_array arr); // #endif //#if AF_API_VERSION >= 33 /+ \param[in] arr An multi dimensional array. \param[out] result: a boolean specifying if all elements in the array are contiguous. \ingroup internal_func_linear +/ af_err af_is_linear(bool *result, const af_array arr); // #endif //#if AF_API_VERSION >= 33 /+ \param[in] arr An multi dimensional array. \param[out] result: a boolean specifying if the array owns the raw pointer. It is false if it is a sub array. \ingroup internal_func_owner +/ af_err af_is_owner(bool *result, const af_array arr); // #endif }
D
/Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Intermediates/DanTangFromQuanzai.build/Debug-iphonesimulator/DanTangFromQuanzai.build/Objects-normal/x86_64/XZQLoginViewController.o : /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/ViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Me/Controller/XZQMeViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQNavigationController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQHomeItem.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshView.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQComment.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQHomeCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQTabBarController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProductDetail.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQNetWorkTool.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQLoginViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQGroup.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQConst.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQNewfeatureViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollectionPost.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Category/UIView+Extension.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDanTangViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQBaseViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Controller/XZQCategoryViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollection.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/View/XZQCollectionViewCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDetailViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshControl.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQSearchResult.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Controller/XZQProductViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/AppDelegate.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQChannel.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQTopicViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProduct.swift /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/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 /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVRadialGradientLayer.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVIndefiniteAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/Kingfisher.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/SnapKit.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/UINavigationController+FDFullscreenPopGesture.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/FDFullscreenPopGesture-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Intermediates/DanTangFromQuanzai.build/Debug-iphonesimulator/DanTangFromQuanzai.build/Objects-normal/x86_64/XZQLoginViewController~partial.swiftmodule : /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/ViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Me/Controller/XZQMeViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQNavigationController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQHomeItem.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshView.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQComment.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQHomeCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQTabBarController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProductDetail.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQNetWorkTool.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQLoginViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQGroup.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQConst.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQNewfeatureViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollectionPost.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Category/UIView+Extension.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDanTangViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQBaseViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Controller/XZQCategoryViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollection.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/View/XZQCollectionViewCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDetailViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshControl.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQSearchResult.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Controller/XZQProductViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/AppDelegate.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQChannel.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQTopicViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProduct.swift /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/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 /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVRadialGradientLayer.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVIndefiniteAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/Kingfisher.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/SnapKit.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/UINavigationController+FDFullscreenPopGesture.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/FDFullscreenPopGesture-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Intermediates/DanTangFromQuanzai.build/Debug-iphonesimulator/DanTangFromQuanzai.build/Objects-normal/x86_64/XZQLoginViewController~partial.swiftdoc : /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/ViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Me/Controller/XZQMeViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQNavigationController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQHomeItem.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshView.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQComment.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQHomeCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQTabBarController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProductDetail.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQNetWorkTool.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQLoginViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQGroup.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Tools/XZQConst.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Login&Register/Controller/XZQNewfeatureViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollectionPost.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Category/UIView+Extension.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDanTangViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Main/Controller/XZQBaseViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Controller/XZQCategoryViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Classify/Model/XZQCollection.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/View/XZQCollectionViewCell.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQDetailViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQRefreshControl.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQSearchResult.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Controller/XZQProductViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/AppDelegate.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Model/XZQChannel.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/DanTang/Controller/XZQTopicViewController.swift /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/DanTangFromQuanzai/Classes/Product/Model/XZQProduct.swift /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/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 /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVRadialGradientLayer.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVIndefiniteAnimatedView.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Headers/SVProgressHUD-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SVProgressHUD/SVProgressHUD.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/Kingfisher.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Headers/Kingfisher-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Kingfisher/Kingfisher.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Headers/Alamofire-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/Alamofire/Alamofire.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/SwiftyJSON.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Headers/SwiftyJSON-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SwiftyJSON/SwiftyJSON.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/SnapKit.swiftmodule/x86_64.swiftmodule /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-Swift.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Headers/SnapKit-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/SnapKit/SnapKit.framework/Modules/module.modulemap /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/UINavigationController+FDFullscreenPopGesture.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Headers/FDFullscreenPopGesture-umbrella.h /Users/atyun-monitor/Desktop/Swift/DanTangFromQuanzai/Build/Products/Debug-iphonesimulator/FDFullscreenPopGesture/FDFullscreenPopGesture.framework/Modules/module.modulemap
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range; void get(Args...)(ref Args args) { import std.traits, std.meta, std.typecons; static if (Args.length == 1) { alias Arg = Args[0]; static if (isArray!Arg) { static if (isSomeChar!(ElementType!Arg)) { args[0] = readln.chomp.to!Arg; } else { args[0] = readln.split.to!Arg; } } else static if (isTuple!Arg) { auto input = readln.split; static foreach (i; 0..Fields!Arg.length) { args[0][i] = input[i].to!(Fields!Arg[i]); } } else { args[0] = readln.chomp.to!Arg; } } else { auto input = readln.split; assert(input.length == Args.length); static foreach (i; 0..Args.length) { args[i] = input[i].to!(Args[i]); } } } void get_lines(Args...)(size_t N, ref Args args) { import std.traits, std.range; static foreach (i; 0..Args.length) { static assert(isArray!(Args[i])); args[i].length = N; } foreach (i; 0..N) { static if (Args.length == 1) { get(args[0][i]); } else { auto input = readln.split; static foreach (j; 0..Args.length) { args[j][i] = input[j].to!(ElementType!(Args[j])); } } } } void main() { int N; get(N); auto gs = new int[](2*N+1); auto os = new int[](2*N+1); auto ps = new int[](N+1); foreach (i; 1..N+1) { int A, B; get(A, B); if ((A != -1 && B != -1 && B <= A) || (A != -1 && gs[A] != 0) || (B != -1 && os[B] != 0)) { writeln("No"); return; } if (A != -1) gs[A] = i; if (B != -1) os[B] = i; ps[i] = A != -1 && B != -1 ? 3 : A != -1 ? 2 : B != -1 ? 1 : 0; } bool solve(int i, int j) { if (j <= 2*N-1 && solve(i, j+2)) return true; auto o = (j - i) / 2; foreach (k; i..i+o) { if (gs[k+o] != 0 || os[k] != 0) return false; if (gs[k] != 0 && os[k+o] != 0) { if (gs[k] != os[k+o]) return false; } else if (gs[k] != 0) { if (ps[gs[k]] != 2) return false; } else if (os[k+o] != 0) { if (ps[os[k+o]] != 1) return false; } } return j == 2*N+1 || solve(j, j+2); } writeln(solve(1, 3) ? "Yes" : "No"); } /* 3 1 -1 -1 4 -1 6 1 _ _ _ _ _ _ 2 _ _ _ 3 -> 後に載ってきた人よりも先に降りなければ行けないというルールx 幾つかのグループに分けて、グループ内で順番に乗る・同じ順番で降りる、とする 2 -1 -1 -1 3 _ _ _ _ _ 2 _ _ 2 -1 -1 -1 4 _ _ _ _ _ _ _ 2 3 -1 4 2 -1 3 6 _ _ 2 _ 3 _ _ 1 _ _ _ 3 3 4 -1 -1 5 -1 6 _ _ _ _ _ _ 1 _ _ 2 _ 3 */
D
/******************************************************************************* Distributed Message Queue Node Connection Handler copyright: Copyright (c) 2011-2017 dunnhumby Germany GmbH. All rights reserved License: Boost Software License Version 1.0. See LICENSE.txt for details. *******************************************************************************/ module dmqnode.connection.ConnectionHandler; import dmqnode.connection.SharedResources; import dmqnode.request.ConsumeRequest; import dmqnode.request.GetChannelSizeRequest; import dmqnode.request.GetChannelsRequest; import dmqnode.request.GetNumConnectionsRequest; import dmqnode.request.GetSizeRequest; import dmqnode.request.model.IDmqRequestResources; import dmqnode.request.PopRequest; import dmqnode.request.ProduceMultiRequest; import dmqnode.request.ProduceRequest; import dmqnode.request.PushMultiRequest; import dmqnode.request.PushRequest; import dmqnode.request.RemoveChannelRequest; import dmqnode.storage.model.StorageChannels; import dmqproto.node.request.model.DmqCommand; import Swarm = swarm.node.connection.ConnectionHandler; import swarm.node.model.INodeInfo; import dmqproto.client.legacy.DmqConst; import dmqnode.util.Downcast; /******************************************************************************* DMQ node connection handler setup class. Passed to the DMQ connection handler constructor. TODO: enable HMAC authentication by deriving from HmacAuthConnectionSetupParams *******************************************************************************/ public class ConnectionSetupParams : Swarm.ConnectionSetupParams { /*************************************************************************** Reference to the storage channels which the requests are operating on. ***************************************************************************/ public StorageChannels storage_channels; /*************************************************************************** Reference to the request resources pool shared between all connection handlers. ***************************************************************************/ public SharedResources shared_resources; } /******************************************************************************* DMQ node connection handler class. An object pool of these connection handlers is contained in the SelectListener which is instantiated inside the DmqNode. TODO: enable HMAC authentication by deriving from HmacAuthConnectionHandler *******************************************************************************/ public class ConnectionHandler : Swarm.ConnectionHandlerTemplate!(DmqConst.Command) { /*************************************************************************** Helper class adding a couple of DMQ-specific getters as well as the resource acquiring getters required by the DmqCommand protocol base class. The resources are acquired from the shared resources instance which is passed to ConnectionHandler's constructor (in the ConnectionSetupParams instance). Acquired resources are automatically relinquished in the destructor. Note that it is assumed that each request will own at most one of each resource type (it is not possible, for example, to acquire two value buffers). ***************************************************************************/ private scope class DmqRequestResources : RequestResources, IDmqRequestResources, DmqCommand.Resources { /*********************************************************************** Constructor. ***********************************************************************/ public this ( ) { super(this.setup.shared_resources); } /*********************************************************************** Forwarding DmqCommand.Resources methods ***********************************************************************/ override public char[]* getChannelBuffer ( ) { return this.channel_buffer; } override public char[]* getValueBuffer ( ) { return this.value_buffer; } override public StringListReader getChannelListReader ( ) { return this.string_list_reader; } /*********************************************************************** Storage channels getter. ***********************************************************************/ override public StorageChannels storage_channels ( ) { return this.setup.storage_channels; } /*********************************************************************** Node info getter. ***********************************************************************/ override public IDmqNodeInfo node_info ( ) { return downcastAssert!(IDmqNodeInfo)(this.setup.node_info); } /*********************************************************************** Channel buffer newer. ***********************************************************************/ override protected char[] new_channel_buffer ( ) { return new char[10]; } /*********************************************************************** Channel flags buffer newer. ***********************************************************************/ override protected bool[] new_channel_flags_buffer ( ) { return new bool[5]; } /*********************************************************************** Value buffer newer. ***********************************************************************/ override protected char[] new_value_buffer ( ) { return new char[50]; } /*********************************************************************** Channel list buffer newer ***********************************************************************/ override protected char[][] new_channel_list_buffer ( ) { return new char[][this.storage_channels.length]; } /*********************************************************************** Select event newer. ***********************************************************************/ override protected FiberSelectEvent new_event ( ) { return new FiberSelectEvent(this.outer.fiber); } /*********************************************************************** String list reader newer. Note: the string list reader returned by this method also acquires and uses a channel buffer. It is thus not possible to use the channel buffer independently. ***********************************************************************/ override protected StringListReader new_string_list_reader ( ) { this.channel_buffer(); return new StringListReader(this.outer.reader, this.acquired.channel_buffer); } /*********************************************************************** Loop ceder newer. ***********************************************************************/ override protected LoopCeder new_loop_ceder ( ) { return new LoopCeder(this.event); } /*********************************************************************** Select event initialiser. ***********************************************************************/ override protected void init_event ( FiberSelectEvent event ) { event.fiber = this.outer.fiber; } /*********************************************************************** String list reader initialiser. Note: the string list reader returned by this method also acquires and uses a channel buffer. It is thus not possible to use the channel buffer independently. ***********************************************************************/ override protected void init_string_list_reader ( StringListReader string_list_reader ) { this.channel_buffer(); string_list_reader.reinitialise(this.outer.reader, &this.acquired.channel_buffer); } /*********************************************************************** Loop ceder initialiser. ***********************************************************************/ override protected void init_loop_ceder ( LoopCeder loop_ceder ) { loop_ceder.event = this.event; } /*********************************************************************** Returns: setup parameters for this connection handler ***********************************************************************/ private ConnectionSetupParams setup ( ) { return downcastAssert!(ConnectionSetupParams)(this.outer.setup); } } /*************************************************************************** Constructor. Params: finalize_dg = user-specified finalizer, called when the connection is shut down setup = struct containing everything needed to set up a connection ***************************************************************************/ public this ( FinalizeDg finalize_dg, Swarm.ConnectionSetupParams setup ) { super(finalize_dg, setup); } /*************************************************************************** Command code 'None' handler. Treated the same as an invalid command code. ***************************************************************************/ override protected void handleNone ( ) { this.handleInvalidCommand(); } /*************************************************************************** Command code 'Push' handler. ***************************************************************************/ override protected void handlePush ( ) { this.handleCommand!(PushRequest, RequestStatsTracking.TimeAndCount); } /*************************************************************************** Command code 'Pop' handler. ***************************************************************************/ override protected void handlePop ( ) { this.handleCommand!(PopRequest, RequestStatsTracking.TimeAndCount); } /*************************************************************************** Command code 'GetChannels' handler. ***************************************************************************/ override protected void handleGetChannels ( ) { this.handleCommand!(GetChannelsRequest); } /*************************************************************************** Command code 'GetChannelSize' handler. ***************************************************************************/ override protected void handleGetChannelSize ( ) { this.handleCommand!(GetChannelSizeRequest); } /*************************************************************************** Command code 'GetSize' handler. ***************************************************************************/ override protected void handleGetSize ( ) { this.handleCommand!(GetSizeRequest); } /*************************************************************************** Command code 'Consume' handler. ***************************************************************************/ override protected void handleConsume ( ) { this.handleCommand!(ConsumeRequest, RequestStatsTracking.Count); } /*************************************************************************** Command code 'GetNumConnections' handler. ***************************************************************************/ override protected void handleGetNumConnections ( ) { this.handleCommand!(GetNumConnectionsRequest); } /*************************************************************************** Command code 'PushMulti' handler. ***************************************************************************/ override protected void handlePushMulti ( ) { this.handleCommand!(PushMultiRequest, RequestStatsTracking.TimeAndCount); } /*************************************************************************** Command code 'Produce' handler. ***************************************************************************/ override protected void handleProduce ( ) { this.handleCommand!(ProduceRequest, RequestStatsTracking.Count); } /*************************************************************************** Command code 'ProduceMulti' handler. ***************************************************************************/ override protected void handleProduceMulti ( ) { this.handleCommand!(ProduceMultiRequest, RequestStatsTracking.Count); } /*************************************************************************** Command code 'RemoveChannel' handler. ***************************************************************************/ override protected void handleRemoveChannel ( ) { this.handleCommand!(RemoveChannelRequest); } /*************************************************************************** Command handler method template. Template params: Handler = type of request handler stats_tracking = specifies which stats should be tracked ***************************************************************************/ private void handleCommand ( Handler : DmqCommand, RequestStatsTracking stats_tracking = RequestStatsTracking.None ) ( ) { scope resources = new DmqRequestResources; scope handler = new Handler(this.reader, this.writer, resources); // calls handler.handle() and checks memory and buffer allocation after // request finishes this.handleRequest!(ConnectionResources, DmqRequestResources, stats_tracking)(handler, resources, handler.command_name); } }
D
(formerly) a title of respect for a man in Turkey or Egypt the governor of a district or province in the Ottoman Empire
D
/Users/yohoo/Developer/leaveMyiPhone/DerivedData/leaveMyiPhone/Build/Intermediates/leaveMyiPhone.build/Debug-iphoneos/leaveMyiPhone.build/Objects-normal/arm64/autoCamViewController.o : /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/ViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/AppDelegate.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/autoCamViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/MainControllerViewController.swift /Users/yohoo/Developer/leaveMyiPhone/historyViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/LocalAuthentication.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AssetsLibrary.swiftmodule /Users/yohoo/Developer/leaveMyiPhone/DerivedData/leaveMyiPhone/Build/Intermediates/leaveMyiPhone.build/Debug-iphoneos/leaveMyiPhone.build/Objects-normal/arm64/autoCamViewController~partial.swiftmodule : /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/ViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/AppDelegate.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/autoCamViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/MainControllerViewController.swift /Users/yohoo/Developer/leaveMyiPhone/historyViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/LocalAuthentication.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AssetsLibrary.swiftmodule /Users/yohoo/Developer/leaveMyiPhone/DerivedData/leaveMyiPhone/Build/Intermediates/leaveMyiPhone.build/Debug-iphoneos/leaveMyiPhone.build/Objects-normal/arm64/autoCamViewController~partial.swiftdoc : /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/ViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/AppDelegate.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/autoCamViewController.swift /Users/yohoo/Developer/leaveMyiPhone/leaveMyiPhone/MainControllerViewController.swift /Users/yohoo/Developer/leaveMyiPhone/historyViewController.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Swift.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/UIKit.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Foundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Darwin.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/Dispatch.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/ObjectiveC.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreGraphics.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreImage.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AVFoundation.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreMedia.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/CoreAudio.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/LocalAuthentication.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/arm64/AssetsLibrary.swiftmodule
D
# FIXED PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/host/gap.c PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/bcomdef.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/comdef.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/../_common/cc26xx/_hal_types.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdint.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/_stdint40.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/stdint.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/cdefs.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/_types.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/machine/_types.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/machine/_stdint.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/_stdint.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdbool.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/inc/hal_defs.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_snv.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_board_cfg.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_mcu.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_nvic.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_ints.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/../inc/hw_chip_def.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_gpio.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_memmap.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/systick.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/debug.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/interrupt.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/cpu.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_cpu_scs.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../driverlib/rom.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/uart.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_uart.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/gpio.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/flash.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_flash.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_aon_sysctl.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_fcfg1.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/ioc.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_ioc.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/src/inc/icall.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdlib.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/_ti_config.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/linkage.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/inc/hal_assert.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/limits.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_memory.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_timers.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/sm.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/hci.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_ae.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/cc26xx/rf_hal.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ble.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_wl.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_common.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/rf/RF.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/dpl/ClockP.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stddef.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/dpl/SemaphoreP.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/utils/List.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/DeviceFamily.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_common_cmd.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_mailbox.h PROFILES/gap.obj: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/string.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_prop_cmd.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_ble_cmd.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_scheduler.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_config.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_user_config.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/inc/ble_user_config.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/src/inc/icall_user_config.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/inc/ble_dispatch.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gapbondmgr_internal.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gapbondmgr.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_internal.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/l2cap.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_advertiser_internal.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_scanner_internal.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_scanner.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/rom/rom_jt.h PROFILES/gap.obj: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/rom/map_direct.h C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/host/gap.c: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/bcomdef.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/comdef.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/../_common/cc26xx/_hal_types.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdint.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/_stdint40.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/stdint.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/cdefs.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/_types.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/machine/_types.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/machine/_stdint.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/sys/_stdint.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdbool.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/inc/hal_defs.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_snv.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_board_cfg.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_mcu.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_nvic.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_ints.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/../inc/hw_chip_def.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_gpio.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/inc/hw_memmap.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/systick.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/debug.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/interrupt.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/cpu.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_cpu_scs.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../driverlib/rom.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/uart.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_uart.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/gpio.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/flash.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_flash.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_aon_sysctl.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_fcfg1.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/ioc.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/../inc/hw_ioc.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/src/inc/icall.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stdlib.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/_ti_config.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/linkage.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/inc/hal_assert.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/limits.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_memory.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/osal/src/inc/osal_timers.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/sm.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/hci.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_ae.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/cc26xx/rf_hal.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/hal/src/target/_common/hal_types.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ble.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_wl.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_common.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/rf/RF.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/dpl/ClockP.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/stddef.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/dpl/SemaphoreP.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/drivers/utils/List.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/DeviceFamily.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_common_cmd.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_mailbox.h: C:/ti/ccs930/ccs/tools/compiler/ti-cgt-arm_18.12.4.LTS/include/string.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_prop_cmd.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/devices/cc26x0r2/driverlib/rf_ble_cmd.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_scheduler.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_config.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/controller/cc26xx/inc/ll_user_config.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/inc/ble_user_config.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/src/inc/icall_user_config.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/icall/inc/ble_dispatch.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gapbondmgr_internal.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gapbondmgr.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_internal.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/l2cap.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_advertiser_internal.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_scanner_internal.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/inc/gap_scanner.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/rom/rom_jt.h: C:/ti/simplelink_cc2640r2_sdk_3_40_00_10/source/ti/ble5stack/rom/map_direct.h:
D
/Users/louise/Desktop/ElectionLoginDemo/DerivedData/ElectionLoginDemo/Build/Intermediates/ElectionLoginDemo.build/Debug-iphonesimulator/ElectionLoginDemo.build/Objects-normal/x86_64/FrontViewController.o : /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/taiwan_area.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/popWindowController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/SignInViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/LoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/CitysViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconView.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/VillageViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/DistrictViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FrontViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/OccupationViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/myViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ReturnLoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AppDelegate.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/MainViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FirstEntryViewController.swift /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/SwiftOnoneSupport.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/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/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Users/louise/Desktop/ElectionLoginDemo/DerivedData/ElectionLoginDemo/Build/Intermediates/ElectionLoginDemo.build/Debug-iphonesimulator/ElectionLoginDemo.build/Objects-normal/x86_64/FrontViewController~partial.swiftmodule : /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/taiwan_area.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/popWindowController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/SignInViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/LoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/CitysViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconView.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/VillageViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/DistrictViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FrontViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/OccupationViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/myViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ReturnLoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AppDelegate.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/MainViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FirstEntryViewController.swift /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/SwiftOnoneSupport.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/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/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule /Users/louise/Desktop/ElectionLoginDemo/DerivedData/ElectionLoginDemo/Build/Intermediates/ElectionLoginDemo.build/Debug-iphonesimulator/ElectionLoginDemo.build/Objects-normal/x86_64/FrontViewController~partial.swiftdoc : /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/taiwan_area.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/popWindowController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/SignInViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/LoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/CitysViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconView.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/VillageViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/DistrictViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AreaIconViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FrontViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/OccupationViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/myViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/ReturnLoginViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/AppDelegate.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/MainViewController.swift /Users/louise/Desktop/ElectionLoginDemo/ElectionLoginDemo/FirstEntryViewController.swift /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/SwiftOnoneSupport.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/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/QuartzCore.swiftmodule /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreImage.swiftmodule
D
/******************************************************************************* * Copyright (c) 2000, 2006 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 <benoit@tionex.de> *******************************************************************************/ module dwtx.jface.text.source.IAnnotationAccessExtension; import dwtx.jface.text.source.ISharedTextColors; // packageimport import dwtx.jface.text.source.ILineRange; // packageimport import dwtx.jface.text.source.IAnnotationPresentation; // packageimport import dwtx.jface.text.source.IVerticalRulerInfoExtension; // packageimport import dwtx.jface.text.source.ICharacterPairMatcher; // packageimport import dwtx.jface.text.source.TextInvocationContext; // packageimport import dwtx.jface.text.source.LineChangeHover; // packageimport import dwtx.jface.text.source.IChangeRulerColumn; // packageimport import dwtx.jface.text.source.IAnnotationMap; // packageimport import dwtx.jface.text.source.IAnnotationModelListenerExtension; // packageimport import dwtx.jface.text.source.ISourceViewerExtension2; // packageimport import dwtx.jface.text.source.IAnnotationHover; // packageimport import dwtx.jface.text.source.ContentAssistantFacade; // packageimport import dwtx.jface.text.source.IAnnotationAccess; // packageimport import dwtx.jface.text.source.IVerticalRulerExtension; // packageimport import dwtx.jface.text.source.IVerticalRulerColumn; // packageimport import dwtx.jface.text.source.LineNumberRulerColumn; // packageimport import dwtx.jface.text.source.MatchingCharacterPainter; // packageimport import dwtx.jface.text.source.IAnnotationModelExtension; // packageimport import dwtx.jface.text.source.ILineDifferExtension; // packageimport import dwtx.jface.text.source.DefaultCharacterPairMatcher; // packageimport import dwtx.jface.text.source.LineNumberChangeRulerColumn; // packageimport import dwtx.jface.text.source.ISourceViewer; // packageimport import dwtx.jface.text.source.AnnotationModel; // packageimport import dwtx.jface.text.source.ILineDifferExtension2; // packageimport import dwtx.jface.text.source.IAnnotationModelListener; // packageimport import dwtx.jface.text.source.IVerticalRuler; // packageimport import dwtx.jface.text.source.DefaultAnnotationHover; // packageimport import dwtx.jface.text.source.SourceViewer; // packageimport import dwtx.jface.text.source.SourceViewerConfiguration; // packageimport import dwtx.jface.text.source.AnnotationBarHoverManager; // packageimport import dwtx.jface.text.source.CompositeRuler; // packageimport import dwtx.jface.text.source.ImageUtilities; // packageimport import dwtx.jface.text.source.VisualAnnotationModel; // packageimport import dwtx.jface.text.source.IAnnotationModel; // packageimport import dwtx.jface.text.source.ISourceViewerExtension3; // packageimport import dwtx.jface.text.source.ILineDiffInfo; // packageimport import dwtx.jface.text.source.VerticalRulerEvent; // packageimport import dwtx.jface.text.source.ChangeRulerColumn; // packageimport import dwtx.jface.text.source.ILineDiffer; // packageimport import dwtx.jface.text.source.AnnotationModelEvent; // packageimport import dwtx.jface.text.source.AnnotationColumn; // packageimport import dwtx.jface.text.source.AnnotationRulerColumn; // packageimport import dwtx.jface.text.source.IAnnotationHoverExtension; // packageimport import dwtx.jface.text.source.AbstractRulerColumn; // packageimport import dwtx.jface.text.source.ISourceViewerExtension; // packageimport import dwtx.jface.text.source.AnnotationMap; // packageimport import dwtx.jface.text.source.IVerticalRulerInfo; // packageimport import dwtx.jface.text.source.IAnnotationModelExtension2; // packageimport import dwtx.jface.text.source.LineRange; // packageimport import dwtx.jface.text.source.IAnnotationAccessExtension2; // packageimport import dwtx.jface.text.source.VerticalRuler; // packageimport import dwtx.jface.text.source.JFaceTextMessages; // packageimport import dwtx.jface.text.source.IOverviewRuler; // packageimport import dwtx.jface.text.source.Annotation; // packageimport import dwtx.jface.text.source.IVerticalRulerListener; // packageimport import dwtx.jface.text.source.ISourceViewerExtension4; // packageimport import dwtx.jface.text.source.AnnotationPainter; // packageimport import dwtx.jface.text.source.IAnnotationHoverExtension2; // packageimport import dwtx.jface.text.source.OverviewRuler; // packageimport import dwtx.jface.text.source.OverviewRulerHoverManager; // packageimport import dwt.dwthelper.utils; import dwt.graphics.GC; import dwt.graphics.Rectangle; import dwt.widgets.Canvas; /** * Extension interface for {@link dwtx.jface.text.source.IAnnotationAccess}.<p> * This interface replaces the methods of <code>IAnnotationAccess</code>.<p> * This interface provides * <ul> * <li> a label for the annotation type of a given annotation</li> * <li> the paint layer of a given annotation</li> * <li> means to paint a given annotation</li> * <li> information about the type hierarchy of the annotation type of a given annotation</li> * <ul>. * * @see dwtx.jface.text.source.IAnnotationAccess * @since 3.0 */ public interface IAnnotationAccessExtension { /** * The default annotation layer. */ static const int DEFAULT_LAYER= IAnnotationPresentation.DEFAULT_LAYER; /** * Returns the label for the given annotation's type. * * @param annotation the annotation * @return the label the given annotation's type or <code>null</code> if no such label exists */ String getTypeLabel(Annotation annotation); /** * Returns the layer for given annotation. Annotations are considered * being located at layers and are considered being painted starting with * layer 0 upwards. Thus an annotation at layer 5 will be drawn on top of * all co-located annotations at the layers 4 - 0. * * @param annotation the annotation * @return the layer of the given annotation */ int getLayer(Annotation annotation); /** * Draws a graphical representation of the given annotation within the given bounds. * <p> * <em>Note that this method is not used when drawing annotations on the editor's * text widget. This is handled trough a {@link dwtx.jface.text.source.AnnotationPainter.IDrawingStrategy}.</em> * </p> * @param annotation the given annotation * @param gc the drawing GC * @param canvas the canvas to draw on * @param bounds the bounds inside the canvas to draw on */ void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds); /** * Returns <code>true</code> if painting <code>annotation</code> will produce something * meaningful, <code>false</code> if not. E.g. if no image is available. * <p> * <em>Note that this method is not used when drawing annotations on the editor's * text widget. This is handled trough a {@link dwtx.jface.text.source.AnnotationPainter.IDrawingStrategy}.</em> * </p> * @param annotation the annotation to check whether it can be painted * @return <code>true</code> if painting <code>annotation</code> will succeed */ bool isPaintable(Annotation annotation); /** * Returns <code>true</code> if the given annotation is of the given type * or <code>false</code> otherwise. * * @param annotationType the annotation type * @param potentialSupertype the potential super annotation type * @return <code>true</code> if annotation type is a sub-type of the potential annotation super type */ bool isSubtype(Object annotationType, Object potentialSupertype); /** * Returns the list of super types for the given annotation type. This does not include the type * itself. The index in the array of super types indicates the length of the path in the hierarchy * graph to the given annotation type. * * @param annotationType the annotation type to check * @return the super types for the given annotation type */ Object[] getSupertypes(Object annotationType); }
D
module android.java.android.graphics.RecordingCanvas; public import android.java.android.graphics.RecordingCanvas_d_interface; import arsd.jni : ImportExportImpl; mixin ImportExportImpl!RecordingCanvas; import import17 = android.java.java.lang.Class; import import15 = android.java.android.graphics.DrawFilter;
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/expression.d, _expression.d) * Documentation: https://dlang.org/phobos/dmd_expression.html * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/expression.d */ module dmd.expression; import core.stdc.stdarg; import core.stdc.stdio; import core.stdc.string; import dmd.aggregate; import dmd.aliasthis; import dmd.apply; import dmd.arrayop; import dmd.arraytypes; import dmd.ast_node; import dmd.gluelayer; import dmd.canthrow; import dmd.complex; import dmd.constfold; import dmd.ctfeexpr; import dmd.ctorflow; import dmd.dcast; import dmd.dclass; import dmd.declaration; import dmd.delegatize; import dmd.dimport; import dmd.dinterpret; import dmd.dmodule; import dmd.dscope; import dmd.dstruct; import dmd.dsymbol; import dmd.dsymbolsem; import dmd.dtemplate; import dmd.errors; import dmd.escape; import dmd.expressionsem; import dmd.func; import dmd.globals; import dmd.hdrgen; import dmd.id; import dmd.identifier; import dmd.inline; import dmd.mtype; import dmd.nspace; import dmd.objc; import dmd.opover; import dmd.optimize; import dmd.root.ctfloat; import dmd.root.filename; import dmd.root.outbuffer; import dmd.root.rmem; import dmd.root.rootobject; import dmd.safe; import dmd.sideeffect; import dmd.target; import dmd.tokens; import dmd.typesem; import dmd.utf; import dmd.visitor; enum LOGSEMANTIC = false; void emplaceExp(T : Expression, Args...)(void* p, Args args) { scope tmp = new T(args); memcpy(p, cast(void*)tmp, __traits(classInstanceSize, T)); } void emplaceExp(T : UnionExp)(T* p, Expression e) { memcpy(p, cast(void*)e, e.size); } /**************************************** * Find the first non-comma expression. * Params: * e = Expressions connected by commas * Returns: * left-most non-comma expression */ inout(Expression) firstComma(inout Expression e) { Expression ex = cast()e; while (ex.op == TOK.comma) ex = (cast(CommaExp)ex).e1; return cast(inout)ex; } /**************************************** * Find the last non-comma expression. * Params: * e = Expressions connected by commas * Returns: * right-most non-comma expression */ inout(Expression) lastComma(inout Expression e) { Expression ex = cast()e; while (ex.op == TOK.comma) ex = (cast(CommaExp)ex).e2; return cast(inout)ex; } /***************************************** * Determine if `this` is available by walking up the enclosing * scopes until a function is found. * * Params: * sc = where to start looking for the enclosing function * Returns: * Found function if it satisfies `isThis()`, otherwise `null` */ FuncDeclaration hasThis(Scope* sc) { //printf("hasThis()\n"); Dsymbol p = sc.parent; while (p && p.isTemplateMixin()) p = p.parent; FuncDeclaration fdthis = p ? p.isFuncDeclaration() : null; //printf("fdthis = %p, '%s'\n", fdthis, fdthis ? fdthis.toChars() : ""); // Go upwards until we find the enclosing member function FuncDeclaration fd = fdthis; while (1) { if (!fd) { goto Lno; } if (!fd.isNested()) break; Dsymbol parent = fd.parent; while (1) { if (!parent) goto Lno; TemplateInstance ti = parent.isTemplateInstance(); if (ti) parent = ti.parent; else break; } fd = parent.isFuncDeclaration(); } if (!fd.isThis()) { goto Lno; } assert(fd.vthis); return fd; Lno: return null; // don't have 'this' available } /*********************************** * Determine if a `this` is needed to access `d`. * Params: * sc = context * d = declaration to check * Returns: * true means a `this` is needed */ bool isNeedThisScope(Scope* sc, Declaration d) { if (sc.intypeof == 1) return false; AggregateDeclaration ad = d.isThis(); if (!ad) return false; //printf("d = %s, ad = %s\n", d.toChars(), ad.toChars()); for (Dsymbol s = sc.parent; s; s = s.toParentLocal()) { //printf("\ts = %s %s, toParent2() = %p\n", s.kind(), s.toChars(), s.toParent2()); if (AggregateDeclaration ad2 = s.isAggregateDeclaration()) { if (ad2 == ad) return false; else if (ad2.isNested()) continue; else return true; } if (FuncDeclaration f = s.isFuncDeclaration()) { if (f.isMemberLocal()) break; } } return true; } /****************************** * check e is exp.opDispatch!(tiargs) or not * It's used to switch to UFCS the semantic analysis path */ bool isDotOpDispatch(Expression e) { if (auto dtie = e.isDotTemplateInstanceExp()) return dtie.ti.name == Id.opDispatch; return false; } /**************************************** * Expand tuples. * Input: * exps aray of Expressions * Output: * exps rewritten in place */ extern (C++) void expandTuples(Expressions* exps) { //printf("expandTuples()\n"); if (exps) { for (size_t i = 0; i < exps.dim; i++) { Expression arg = (*exps)[i]; if (!arg) continue; // Look for tuple with 0 members if (auto e = arg.isTypeExp()) { if (auto tt = e.type.toBasetype().isTypeTuple()) { if (!tt.arguments || tt.arguments.dim == 0) { exps.remove(i); if (i == exps.dim) return; i--; continue; } } } // Inline expand all the tuples while (arg.op == TOK.tuple) { TupleExp te = cast(TupleExp)arg; exps.remove(i); // remove arg exps.insert(i, te.exps); // replace with tuple contents if (i == exps.dim) return; // empty tuple, no more arguments (*exps)[i] = Expression.combine(te.e0, (*exps)[i]); arg = (*exps)[i]; } } } } /**************************************** * Expand alias this tuples. */ extern (C++) TupleDeclaration isAliasThisTuple(Expression e) { if (!e.type) return null; Type t = e.type.toBasetype(); Lagain: if (Dsymbol s = t.toDsymbol(null)) { if (auto ad = s.isAggregateDeclaration()) { s = ad.aliasthis; if (s && s.isVarDeclaration()) { TupleDeclaration td = s.isVarDeclaration().toAlias().isTupleDeclaration(); if (td && td.isexp) return td; } if (Type att = t.aliasthisOf()) { t = att; goto Lagain; } } } return null; } extern (C++) int expandAliasThisTuples(Expressions* exps, size_t starti = 0) { if (!exps || exps.dim == 0) return -1; for (size_t u = starti; u < exps.dim; u++) { Expression exp = (*exps)[u]; if (TupleDeclaration td = exp.isAliasThisTuple) { exps.remove(u); foreach (i, o; *td.objects) { auto d = o.isExpression().isDsymbolExp().s.isDeclaration(); auto e = new DotVarExp(exp.loc, exp, d); assert(d.type); e.type = d.type; exps.insert(u + i, e); } version (none) { printf("expansion ->\n"); foreach (e; exps) { printf("\texps[%d] e = %s %s\n", i, Token.tochars[e.op], e.toChars()); } } return cast(int)u; } } return -1; } /**************************************** * If `s` is a function template, i.e. the only member of a template * and that member is a function, return that template. * Params: * s = symbol that might be a function template * Returns: * template for that function, otherwise null */ extern (C++) TemplateDeclaration getFuncTemplateDecl(Dsymbol s) { FuncDeclaration f = s.isFuncDeclaration(); if (f && f.parent) { if (auto ti = f.parent.isTemplateInstance()) { if (!ti.isTemplateMixin() && ti.tempdecl) { auto td = ti.tempdecl.isTemplateDeclaration(); if (td.onemember && td.ident == f.ident) { return td; } } } } return null; } /************************************************ * If we want the value of this expression, but do not want to call * the destructor on it. */ Expression valueNoDtor(Expression e) { auto ex = lastComma(e); if (auto ce = ex.isCallExp()) { /* The struct value returned from the function is transferred * so do not call the destructor on it. * Recognize: * ((S _ctmp = S.init), _ctmp).this(...) * and make sure the destructor is not called on _ctmp * BUG: if ex is a CommaExp, we should go down the right side. */ if (auto dve = ce.e1.isDotVarExp()) { if (dve.var.isCtorDeclaration()) { // It's a constructor call if (auto comma = dve.e1.isCommaExp()) { if (auto ve = comma.e2.isVarExp()) { VarDeclaration ctmp = ve.var.isVarDeclaration(); if (ctmp) { ctmp.storage_class |= STC.nodtor; assert(!ce.isLvalue()); } } } } } } else if (auto ve = ex.isVarExp()) { auto vtmp = ve.var.isVarDeclaration(); if (vtmp && (vtmp.storage_class & STC.rvalue)) { vtmp.storage_class |= STC.nodtor; } } return e; } /********************************************* * If e is an instance of a struct, and that struct has a copy constructor, * rewrite e as: * (tmp = e),tmp * Input: * sc = just used to specify the scope of created temporary variable * destinationType = the type of the object on which the copy constructor is called; * may be null if the struct defines a postblit */ private Expression callCpCtor(Scope* sc, Expression e, Type destinationType) { if (auto ts = e.type.baseElemOf().isTypeStruct()) { StructDeclaration sd = ts.sym; if (sd.postblit || sd.hasCopyCtor) { /* Create a variable tmp, and replace the argument e with: * (tmp = e),tmp * and let AssignExp() handle the construction. * This is not the most efficient, ideally tmp would be constructed * directly onto the stack. */ auto tmp = copyToTemp(STC.rvalue, "__copytmp", e); if (sd.hasCopyCtor && destinationType) tmp.type = destinationType; tmp.storage_class |= STC.nodtor; tmp.dsymbolSemantic(sc); Expression de = new DeclarationExp(e.loc, tmp); Expression ve = new VarExp(e.loc, tmp); de.type = Type.tvoid; ve.type = e.type; return Expression.combine(de, ve); } } return e; } /************************************************ * Handle the postblit call on lvalue, or the move of rvalue. * * Params: * sc = the scope where the expression is encountered * e = the expression the needs to be moved or copied (source) * t = if the struct defines a copy constructor, the type of the destination * * Returns: * The expression that copy constructs or moves the value. */ extern (D) Expression doCopyOrMove(Scope *sc, Expression e, Type t = null) { if (auto ce = e.isCondExp()) { ce.e1 = doCopyOrMove(sc, ce.e1); ce.e2 = doCopyOrMove(sc, ce.e2); } else { e = e.isLvalue() ? callCpCtor(sc, e, t) : valueNoDtor(e); } return e; } /****************************************************************/ /* A type meant as a union of all the Expression types, * to serve essentially as a Variant that will sit on the stack * during CTFE to reduce memory consumption. */ struct UnionExp { // yes, default constructor does nothing extern (D) this(Expression e) { memcpy(&this, cast(void*)e, e.size); } /* Extract pointer to Expression */ extern (C++) Expression exp() return { return cast(Expression)&u; } /* Convert to an allocated Expression */ extern (C++) Expression copy() { Expression e = exp(); //if (e.size > sizeof(u)) printf("%s\n", Token::toChars(e.op)); assert(e.size <= u.sizeof); switch (e.op) { case TOK.cantExpression: return CTFEExp.cantexp; case TOK.voidExpression: return CTFEExp.voidexp; case TOK.break_: return CTFEExp.breakexp; case TOK.continue_: return CTFEExp.continueexp; case TOK.goto_: return CTFEExp.gotoexp; default: return e.copy(); } } private: // Ensure that the union is suitably aligned. align(8) union __AnonStruct__u { char[__traits(classInstanceSize, Expression)] exp; char[__traits(classInstanceSize, IntegerExp)] integerexp; char[__traits(classInstanceSize, ErrorExp)] errorexp; char[__traits(classInstanceSize, RealExp)] realexp; char[__traits(classInstanceSize, ComplexExp)] complexexp; char[__traits(classInstanceSize, SymOffExp)] symoffexp; char[__traits(classInstanceSize, StringExp)] stringexp; char[__traits(classInstanceSize, ArrayLiteralExp)] arrayliteralexp; char[__traits(classInstanceSize, AssocArrayLiteralExp)] assocarrayliteralexp; char[__traits(classInstanceSize, StructLiteralExp)] structliteralexp; char[__traits(classInstanceSize, NullExp)] nullexp; char[__traits(classInstanceSize, DotVarExp)] dotvarexp; char[__traits(classInstanceSize, AddrExp)] addrexp; char[__traits(classInstanceSize, IndexExp)] indexexp; char[__traits(classInstanceSize, SliceExp)] sliceexp; char[__traits(classInstanceSize, VectorExp)] vectorexp; } __AnonStruct__u u; } /******************************** * Test to see if two reals are the same. * Regard NaN's as equivalent. * Regard +0 and -0 as different. * Params: * x1 = first operand * x2 = second operand * Returns: * 1 if x1 is x2 * else 0 */ int RealEquals(real_t x1, real_t x2) { return (CTFloat.isNaN(x1) && CTFloat.isNaN(x2)) || CTFloat.isIdentical(x1, x2); } /************************ TypeDotIdExp ************************************/ /* Things like: * int.size * foo.size * (foo).size * cast(foo).size */ DotIdExp typeDotIdExp(const ref Loc loc, Type type, Identifier ident) { return new DotIdExp(loc, new TypeExp(loc, type), ident); } /*************************************************** * Given an Expression, find the variable it really is. * * For example, `a[index]` is really `a`, and `s.f` is really `s`. * Params: * e = Expression to look at * Returns: * variable if there is one, null if not */ VarDeclaration expToVariable(Expression e) { while (1) { switch (e.op) { case TOK.variable: return (cast(VarExp)e).var.isVarDeclaration(); case TOK.dotVariable: e = (cast(DotVarExp)e).e1; continue; case TOK.index: { IndexExp ei = cast(IndexExp)e; e = ei.e1; Type ti = e.type.toBasetype(); if (ti.ty == Tsarray) continue; return null; } case TOK.slice: { SliceExp ei = cast(SliceExp)e; e = ei.e1; Type ti = e.type.toBasetype(); if (ti.ty == Tsarray) continue; return null; } case TOK.this_: case TOK.super_: return (cast(ThisExp)e).var.isVarDeclaration(); default: return null; } } } enum OwnedBy : ubyte { code, // normal code expression in AST ctfe, // value expression for CTFE cache, // constant value cached for CTFE } enum WANTvalue = 0; // default enum WANTexpand = 1; // expand const/immutable variables if possible /*********************************************************** * http://dlang.org/spec/expression.html#expression */ extern (C++) abstract class Expression : ASTNode { TOK op; // to minimize use of dynamic_cast ubyte size; // # of bytes in Expression so we can copy() it ubyte parens; // if this is a parenthesized expression Type type; // !=null means that semantic() has been run Loc loc; // file location extern (D) this(const ref Loc loc, TOK op, int size) { //printf("Expression::Expression(op = %d) this = %p\n", op, this); this.loc = loc; this.op = op; this.size = cast(ubyte)size; } static void _init() { CTFEExp.cantexp = new CTFEExp(TOK.cantExpression); CTFEExp.voidexp = new CTFEExp(TOK.voidExpression); CTFEExp.breakexp = new CTFEExp(TOK.break_); CTFEExp.continueexp = new CTFEExp(TOK.continue_); CTFEExp.gotoexp = new CTFEExp(TOK.goto_); CTFEExp.showcontext = new CTFEExp(TOK.showCtfeContext); } /** * Deinitializes the global state of the compiler. * * This can be used to restore the state set by `_init` to its original * state. */ static void deinitialize() { CTFEExp.cantexp = CTFEExp.cantexp.init; CTFEExp.voidexp = CTFEExp.voidexp.init; CTFEExp.breakexp = CTFEExp.breakexp.init; CTFEExp.continueexp = CTFEExp.continueexp.init; CTFEExp.gotoexp = CTFEExp.gotoexp.init; CTFEExp.showcontext = CTFEExp.showcontext.init; } /********************************* * Does *not* do a deep copy. */ final Expression copy() { Expression e; if (!size) { debug { fprintf(stderr, "No expression copy for: %s\n", toChars()); printf("op = %d\n", op); } assert(0); } e = cast(Expression)mem.xmalloc(size); //printf("Expression::copy(op = %d) e = %p\n", op, e); return cast(Expression)memcpy(cast(void*)e, cast(void*)this, size); } Expression syntaxCopy() { //printf("Expression::syntaxCopy()\n"); //print(); return copy(); } // kludge for template.isExpression() override final DYNCAST dyncast() const { return DYNCAST.expression; } override const(char)* toChars() { OutBuffer buf; HdrGenState hgs; toCBuffer(this, &buf, &hgs); return buf.extractString(); } final void error(const(char)* format, ...) const { if (type != Type.terror) { va_list ap; va_start(ap, format); .verror(loc, format, ap); va_end(ap); } } final void errorSupplemental(const(char)* format, ...) { if (type == Type.terror) return; va_list ap; va_start(ap, format); .verrorSupplemental(loc, format, ap); va_end(ap); } final void warning(const(char)* format, ...) const { if (type != Type.terror) { va_list ap; va_start(ap, format); .vwarning(loc, format, ap); va_end(ap); } } final void deprecation(const(char)* format, ...) const { if (type != Type.terror) { va_list ap; va_start(ap, format); .vdeprecation(loc, format, ap); va_end(ap); } } /********************************** * Combine e1 and e2 by CommaExp if both are not NULL. */ extern (D) static Expression combine(Expression e1, Expression e2) { if (e1) { if (e2) { e1 = new CommaExp(e1.loc, e1, e2); e1.type = e2.type; } } else e1 = e2; return e1; } extern (D) static Expression combine(Expression e1, Expression e2, Expression e3) { return combine(combine(e1, e2), e3); } extern (D) static Expression combine(Expression e1, Expression e2, Expression e3, Expression e4) { return combine(combine(e1, e2), combine(e3, e4)); } /********************************** * If 'e' is a tree of commas, returns the rightmost expression * by stripping off it from the tree. The remained part of the tree * is returned via e0. * Otherwise 'e' is directly returned and e0 is set to NULL. */ extern (D) static Expression extractLast(Expression e, out Expression e0) { if (e.op != TOK.comma) { return e; } CommaExp ce = cast(CommaExp)e; if (ce.e2.op != TOK.comma) { e0 = ce.e1; return ce.e2; } else { e0 = e; Expression* pce = &ce.e2; while ((cast(CommaExp)(*pce)).e2.op == TOK.comma) { pce = &(cast(CommaExp)(*pce)).e2; } assert((*pce).op == TOK.comma); ce = cast(CommaExp)(*pce); *pce = ce.e1; return ce.e2; } } extern (D) static Expressions* arraySyntaxCopy(Expressions* exps) { Expressions* a = null; if (exps) { a = new Expressions(exps.dim); foreach (i, e; *exps) { (*a)[i] = e ? e.syntaxCopy() : null; } } return a; } dinteger_t toInteger() { //printf("Expression %s\n", Token::toChars(op)); error("integer constant expression expected instead of `%s`", toChars()); return 0; } uinteger_t toUInteger() { //printf("Expression %s\n", Token::toChars(op)); return cast(uinteger_t)toInteger(); } real_t toReal() { error("floating point constant expression expected instead of `%s`", toChars()); return CTFloat.zero; } real_t toImaginary() { error("floating point constant expression expected instead of `%s`", toChars()); return CTFloat.zero; } complex_t toComplex() { error("floating point constant expression expected instead of `%s`", toChars()); return complex_t(CTFloat.zero); } StringExp toStringExp() { return null; } TupleExp toTupleExp() { return null; } /*************************************** * Return !=0 if expression is an lvalue. */ bool isLvalue() { return false; } /******************************* * Give error if we're not an lvalue. * If we can, convert expression to be an lvalue. */ Expression toLvalue(Scope* sc, Expression e) { if (!e) e = this; else if (!loc.isValid()) loc = e.loc; if (e.op == TOK.type) error("`%s` is a `%s` definition and cannot be modified", e.type.toChars(), e.type.kind()); else error("`%s` is not an lvalue and cannot be modified", e.toChars()); return new ErrorExp(); } Expression modifiableLvalue(Scope* sc, Expression e) { //printf("Expression::modifiableLvalue() %s, type = %s\n", toChars(), type.toChars()); // See if this expression is a modifiable lvalue (i.e. not const) if (checkModifiable(sc) == 1) { assert(type); if (!type.isMutable()) { if (auto dve = this.isDotVarExp()) { if (isNeedThisScope(sc, dve.var)) for (Dsymbol s = sc.func; s; s = s.toParentLocal()) { FuncDeclaration ff = s.isFuncDeclaration(); if (!ff) break; if (!ff.type.isMutable) { error("cannot modify `%s` in `%s` function", toChars(), MODtoChars(type.mod)); return new ErrorExp(); } } } error("cannot modify `%s` expression `%s`", MODtoChars(type.mod), toChars()); return new ErrorExp(); } else if (!type.isAssignable()) { error("cannot modify struct instance `%s` of type `%s` because it contains `const` or `immutable` members", toChars(), type.toChars()); return new ErrorExp(); } } return toLvalue(sc, e); } final Expression implicitCastTo(Scope* sc, Type t) { return .implicitCastTo(this, sc, t); } final MATCH implicitConvTo(Type t) { return .implicitConvTo(this, t); } final Expression castTo(Scope* sc, Type t) { return .castTo(this, sc, t); } /**************************************** * Resolve __FILE__, __LINE__, __MODULE__, __FUNCTION__, __PRETTY_FUNCTION__, __FILE_FULL_PATH__ to loc. */ Expression resolveLoc(const ref Loc loc, Scope* sc) { this.loc = loc; return this; } /**************************************** * Check that the expression has a valid type. * If not, generates an error "... has no type". * Returns: * true if the expression is not valid. * Note: * When this function returns true, `checkValue()` should also return true. */ bool checkType() { return false; } /**************************************** * Check that the expression has a valid value. * If not, generates an error "... has no value". * Returns: * true if the expression is not valid or has void type. */ bool checkValue() { if (type && type.toBasetype().ty == Tvoid) { error("expression `%s` is `void` and has no value", toChars()); //print(); assert(0); if (!global.gag) type = Type.terror; return true; } return false; } extern (D) final bool checkScalar() { if (op == TOK.error) return true; if (type.toBasetype().ty == Terror) return true; if (!type.isscalar()) { error("`%s` is not a scalar, it is a `%s`", toChars(), type.toChars()); return true; } return checkValue(); } extern (D) final bool checkNoBool() { if (op == TOK.error) return true; if (type.toBasetype().ty == Terror) return true; if (type.toBasetype().ty == Tbool) { error("operation not allowed on `bool` `%s`", toChars()); return true; } return false; } extern (D) final bool checkIntegral() { if (op == TOK.error) return true; if (type.toBasetype().ty == Terror) return true; if (!type.isintegral()) { error("`%s` is not of integral type, it is a `%s`", toChars(), type.toChars()); return true; } return checkValue(); } extern (D) final bool checkArithmetic() { if (op == TOK.error) return true; if (type.toBasetype().ty == Terror) return true; if (!type.isintegral() && !type.isfloating()) { error("`%s` is not of arithmetic type, it is a `%s`", toChars(), type.toChars()); return true; } return checkValue(); } final bool checkDeprecated(Scope* sc, Dsymbol s) { return s.checkDeprecated(loc, sc); } extern (D) final bool checkDisabled(Scope* sc, Dsymbol s) { if (auto d = s.isDeclaration()) { return d.checkDisabled(loc, sc); } return false; } /********************************************* * Calling function f. * Check the purity, i.e. if we're in a pure function * we can only call other pure functions. * Returns true if error occurs. */ extern (D) final bool checkPurity(Scope* sc, FuncDeclaration f) { if (!sc.func) return false; if (sc.func == f) return false; if (sc.intypeof == 1) return false; if (sc.flags & (SCOPE.ctfe | SCOPE.debug_)) return false; /* Given: * void f() { * pure void g() { * /+pure+/ void h() { * /+pure+/ void i() { } * } * } * } * g() can call h() but not f() * i() can call h() and g() but not f() */ // Find the closest pure parent of the calling function FuncDeclaration outerfunc = sc.func; FuncDeclaration calledparent = f; if (outerfunc.isInstantiated()) { // The attributes of outerfunc should be inferred from the call of f. } else if (f.isInstantiated()) { // The attributes of f are inferred from its body. } else if (f.isFuncLiteralDeclaration()) { // The attributes of f are always inferred in its declared place. } else { /* Today, static local functions are impure by default, but they cannot * violate purity of enclosing functions. * * auto foo() pure { // non instantiated function * static auto bar() { // static, without pure attribute * impureFunc(); // impure call * // Although impureFunc is called inside bar, f(= impureFunc) * // is not callable inside pure outerfunc(= foo <- bar). * } * * bar(); * // Although bar is called inside foo, f(= bar) is callable * // bacause calledparent(= foo) is same with outerfunc(= foo). * } */ while (outerfunc.toParent2() && outerfunc.isPureBypassingInference() == PURE.impure && outerfunc.toParent2().isFuncDeclaration()) { outerfunc = outerfunc.toParent2().isFuncDeclaration(); if (outerfunc.type.ty == Terror) return true; } while (calledparent.toParent2() && calledparent.isPureBypassingInference() == PURE.impure && calledparent.toParent2().isFuncDeclaration()) { calledparent = calledparent.toParent2().isFuncDeclaration(); if (calledparent.type.ty == Terror) return true; } } // If the caller has a pure parent, then either the called func must be pure, // OR, they must have the same pure parent. if (!f.isPure() && calledparent != outerfunc) { FuncDeclaration ff = outerfunc; if (sc.flags & SCOPE.compile ? ff.isPureBypassingInference() >= PURE.weak : ff.setImpure()) { error("`pure` %s `%s` cannot call impure %s `%s`", ff.kind(), ff.toPrettyChars(), f.kind(), f.toPrettyChars()); return true; } } return false; } /******************************************* * Accessing variable v. * Check for purity and safety violations. * Returns true if error occurs. */ extern (D) final bool checkPurity(Scope* sc, VarDeclaration v) { //printf("v = %s %s\n", v.type.toChars(), v.toChars()); /* Look for purity and safety violations when accessing variable v * from current function. */ if (!sc.func) return false; if (sc.intypeof == 1) return false; // allow violations inside typeof(expression) if (sc.flags & (SCOPE.ctfe | SCOPE.debug_)) return false; // allow violations inside compile-time evaluated expressions and debug conditionals if (v.ident == Id.ctfe) return false; // magic variable never violates pure and safe if (v.isImmutable()) return false; // always safe and pure to access immutables... if (v.isConst() && !v.isRef() && (v.isDataseg() || v.isParameter()) && v.type.implicitConvTo(v.type.immutableOf())) return false; // or const global/parameter values which have no mutable indirections if (v.storage_class & STC.manifest) return false; // ...or manifest constants if (v.type.ty == Tstruct) { StructDeclaration sd = (cast(TypeStruct)v.type).sym; if (sd.hasNoFields) return false; } bool err = false; if (v.isDataseg()) { // https://issues.dlang.org/show_bug.cgi?id=7533 // Accessing implicit generated __gate is pure. if (v.ident == Id.gate) return false; /* Accessing global mutable state. * Therefore, this function and all its immediately enclosing * functions must be pure. */ /* Today, static local functions are impure by default, but they cannot * violate purity of enclosing functions. * * auto foo() pure { // non instantiated function * static auto bar() { // static, without pure attribute * globalData++; // impure access * // Although globalData is accessed inside bar, * // it is not accessible inside pure foo. * } * } */ for (Dsymbol s = sc.func; s; s = s.toParent2()) { FuncDeclaration ff = s.isFuncDeclaration(); if (!ff) break; if (sc.flags & SCOPE.compile ? ff.isPureBypassingInference() >= PURE.weak : ff.setImpure()) { error("`pure` %s `%s` cannot access mutable static data `%s`", ff.kind(), ff.toPrettyChars(), v.toChars()); err = true; break; } /* If the enclosing is an instantiated function or a lambda, its * attribute inference result is preferred. */ if (ff.isInstantiated()) break; if (ff.isFuncLiteralDeclaration()) break; } } else { /* Given: * void f() { * int fx; * pure void g() { * int gx; * /+pure+/ void h() { * int hx; * /+pure+/ void i() { } * } * } * } * i() can modify hx and gx but not fx */ Dsymbol vparent = v.toParent2(); for (Dsymbol s = sc.func; !err && s; s = s.toParent2()) { if (s == vparent) break; if (AggregateDeclaration ad = s.isAggregateDeclaration()) { if (ad.isNested()) continue; break; } FuncDeclaration ff = s.isFuncDeclaration(); if (!ff) break; if (ff.isNested() || ff.isThis()) { if (ff.type.isImmutable() || ff.type.isShared() && !MODimplicitConv(ff.type.mod, v.type.mod)) { OutBuffer ffbuf; OutBuffer vbuf; MODMatchToBuffer(&ffbuf, ff.type.mod, v.type.mod); MODMatchToBuffer(&vbuf, v.type.mod, ff.type.mod); error("%s%s `%s` cannot access %sdata `%s`", ffbuf.peekString(), ff.kind(), ff.toPrettyChars(), vbuf.peekString(), v.toChars()); err = true; break; } continue; } break; } } /* Do not allow safe functions to access __gshared data */ if (v.storage_class & STC.gshared) { if (sc.func.setUnsafe()) { error("`@safe` %s `%s` cannot access `__gshared` data `%s`", sc.func.kind(), sc.func.toChars(), v.toChars()); err = true; } } return err; } /********************************************* * Calling function f. * Check the safety, i.e. if we're in a @safe function * we can only call @safe or @trusted functions. * Returns true if error occurs. */ extern (D) final bool checkSafety(Scope* sc, FuncDeclaration f) { if (!sc.func) return false; if (sc.func == f) return false; if (sc.intypeof == 1) return false; if (sc.flags & SCOPE.ctfe) return false; if (!f.isSafe() && !f.isTrusted()) { if (sc.flags & SCOPE.compile ? sc.func.isSafeBypassingInference() : sc.func.setUnsafe() && !(sc.flags & SCOPE.debug_)) { if (!loc.isValid()) // e.g. implicitly generated dtor loc = sc.func.loc; const prettyChars = f.toPrettyChars(); error("`@safe` %s `%s` cannot call `@system` %s `%s`", sc.func.kind(), sc.func.toPrettyChars(), f.kind(), prettyChars); .errorSupplemental(f.loc, "`%s` is declared here", prettyChars); return true; } } return false; } /********************************************* * Calling function f. * Check the @nogc-ness, i.e. if we're in a @nogc function * we can only call other @nogc functions. * Returns true if error occurs. */ extern (D) final bool checkNogc(Scope* sc, FuncDeclaration f) { if (!sc.func) return false; if (sc.func == f) return false; if (sc.intypeof == 1) return false; if (sc.flags & SCOPE.ctfe) return false; if (!f.isNogc()) { if (sc.flags & SCOPE.compile ? sc.func.isNogcBypassingInference() : sc.func.setGC() && !(sc.flags & SCOPE.debug_)) { if (loc.linnum == 0) // e.g. implicitly generated dtor loc = sc.func.loc; error("`@nogc` %s `%s` cannot call non-@nogc %s `%s`", sc.func.kind(), sc.func.toPrettyChars(), f.kind(), f.toPrettyChars()); return true; } } return false; } /******************************************** * Check that the postblit is callable if t is an array of structs. * Returns true if error happens. */ extern (D) final bool checkPostblit(Scope* sc, Type t) { if (auto ts = t.baseElemOf().isTypeStruct()) { // https://issues.dlang.org/show_bug.cgi?id=11395 // Require TypeInfo generation for array concatenation semanticTypeInfo(sc, t); StructDeclaration sd = ts.sym; if (sd.postblit) { if (sd.postblit.checkDisabled(loc, sc)) return true; //checkDeprecated(sc, sd.postblit); // necessary? checkPurity(sc, sd.postblit); checkSafety(sc, sd.postblit); checkNogc(sc, sd.postblit); //checkAccess(sd, loc, sc, sd.postblit); // necessary? return false; } } return false; } extern (D) final bool checkRightThis(Scope* sc) { if (op == TOK.error) return true; if (op == TOK.variable && type.ty != Terror) { VarExp ve = cast(VarExp)this; if (isNeedThisScope(sc, ve.var)) { //printf("checkRightThis sc.intypeof = %d, ad = %p, func = %p, fdthis = %p\n", // sc.intypeof, sc.getStructClassScope(), func, fdthis); error("need `this` for `%s` of type `%s`", ve.var.toChars(), ve.var.type.toChars()); return true; } } return false; } /******************************* * Check whether the expression allows RMW operations, error with rmw operator diagnostic if not. * ex is the RHS expression, or NULL if ++/-- is used (for diagnostics) * Returns true if error occurs. */ extern (D) final bool checkReadModifyWrite(TOK rmwOp, Expression ex = null) { //printf("Expression::checkReadModifyWrite() %s %s", toChars(), ex ? ex.toChars() : ""); if (!type || !type.isShared()) return false; // atomicOp uses opAssign (+=/-=) rather than opOp (++/--) for the CT string literal. switch (rmwOp) { case TOK.plusPlus: case TOK.prePlusPlus: rmwOp = TOK.addAssign; break; case TOK.minusMinus: case TOK.preMinusMinus: rmwOp = TOK.minAssign; break; default: break; } error("read-modify-write operations are not allowed for `shared` variables. Use `core.atomic.atomicOp!\"%s\"(%s, %s)` instead.", Token.toChars(rmwOp), toChars(), ex ? ex.toChars() : "1"); return true; } /*************************************** * Parameters: * sc: scope * flag: 1: do not issue error message for invalid modification * Returns: * 0: is not modifiable * 1: is modifiable in default == being related to type.isMutable() * 2: is modifiable, because this is a part of initializing. */ int checkModifiable(Scope* sc, int flag = 0) { return type ? 1 : 0; // default modifiable } /***************************** * If expression can be tested for true or false, * returns the modified expression. * Otherwise returns ErrorExp. */ Expression toBoolean(Scope* sc) { // Default is 'yes' - do nothing Expression e = this; Type t = type; Type tb = type.toBasetype(); Type att = null; while (1) { // Structs can be converted to bool using opCast(bool)() if (auto ts = tb.isTypeStruct()) { AggregateDeclaration ad = ts.sym; /* Don't really need to check for opCast first, but by doing so we * get better error messages if it isn't there. */ if (Dsymbol fd = search_function(ad, Id._cast)) { e = new CastExp(loc, e, Type.tbool); e = e.expressionSemantic(sc); return e; } // Forward to aliasthis. if (ad.aliasthis && tb != att) { if (!att && tb.checkAliasThisRec()) att = tb; e = resolveAliasThis(sc, e); t = e.type; tb = e.type.toBasetype(); continue; } } break; } if (!t.isBoolean()) { if (tb != Type.terror) error("expression `%s` of type `%s` does not have a boolean value", toChars(), t.toChars()); return new ErrorExp(); } return e; } /************************************************ * Destructors are attached to VarDeclarations. * Hence, if expression returns a temp that needs a destructor, * make sure and create a VarDeclaration for that temp. */ Expression addDtorHook(Scope* sc) { return this; } /****************************** * Take address of expression. */ final Expression addressOf() { //printf("Expression::addressOf()\n"); debug { assert(op == TOK.error || isLvalue()); } Expression e = new AddrExp(loc, this, type.pointerTo()); return e; } /****************************** * If this is a reference, dereference it. */ final Expression deref() { //printf("Expression::deref()\n"); // type could be null if forward referencing an 'auto' variable if (type) if (auto tr = type.isTypeReference()) { Expression e = new PtrExp(loc, this, tr.next); return e; } return this; } final Expression optimize(int result, bool keepLvalue = false) { return Expression_optimize(this, result, keepLvalue); } // Entry point for CTFE. // A compile-time result is required. Give an error if not possible final Expression ctfeInterpret() { return .ctfeInterpret(this); } final int isConst() { return .isConst(this); } /******************************** * Does this expression statically evaluate to a boolean 'result' (true or false)? */ bool isBool(bool result) { return false; } bool hasCode() { return true; } final pure inout nothrow @nogc { inout(IntegerExp) isIntegerExp() { return op == TOK.int64 ? cast(typeof(return))this : null; } inout(ErrorExp) isErrorExp() { return op == TOK.error ? cast(typeof(return))this : null; } inout(VoidInitExp) isVoidInitExp() { return op == TOK.void_ ? cast(typeof(return))this : null; } inout(RealExp) isRealExp() { return op == TOK.float64 ? cast(typeof(return))this : null; } inout(ComplexExp) isComplexExp() { return op == TOK.complex80 ? cast(typeof(return))this : null; } inout(IdentifierExp) isIdentifierExp() { return op == TOK.identifier ? cast(typeof(return))this : null; } inout(DollarExp) isDollarExp() { return op == TOK.dollar ? cast(typeof(return))this : null; } inout(DsymbolExp) isDsymbolExp() { return op == TOK.dSymbol ? cast(typeof(return))this : null; } inout(ThisExp) isThisExp() { return op == TOK.this_ ? cast(typeof(return))this : null; } inout(SuperExp) isSuperExp() { return op == TOK.super_ ? cast(typeof(return))this : null; } inout(NullExp) isNullExp() { return op == TOK.null_ ? cast(typeof(return))this : null; } inout(StringExp) isStringExp() { return op == TOK.string_ ? cast(typeof(return))this : null; } inout(TupleExp) isTupleExp() { return op == TOK.tuple ? cast(typeof(return))this : null; } inout(ArrayLiteralExp) isArrayLiteralExp() { return op == TOK.arrayLiteral ? cast(typeof(return))this : null; } inout(AssocArrayLiteralExp) isAssocArrayLiteralExp() { return op == TOK.assocArrayLiteral ? cast(typeof(return))this : null; } inout(StructLiteralExp) isStructLiteralExp() { return op == TOK.structLiteral ? cast(typeof(return))this : null; } inout(TypeExp) isTypeExp() { return op == TOK.type ? cast(typeof(return))this : null; } inout(ScopeExp) isScopeExp() { return op == TOK.scope_ ? cast(typeof(return))this : null; } inout(TemplateExp) isTemplateExp() { return op == TOK.template_ ? cast(typeof(return))this : null; } inout(NewExp) isNewExp() { return op == TOK.new_ ? cast(typeof(return))this : null; } inout(NewAnonClassExp) isNewAnonClassExp() { return op == TOK.newAnonymousClass ? cast(typeof(return))this : null; } inout(SymOffExp) isSymOffExp() { return op == TOK.symbolOffset ? cast(typeof(return))this : null; } inout(VarExp) isVarExp() { return op == TOK.variable ? cast(typeof(return))this : null; } inout(OverExp) isOverExp() { return op == TOK.overloadSet ? cast(typeof(return))this : null; } inout(FuncExp) isFuncExp() { return op == TOK.function_ ? cast(typeof(return))this : null; } inout(DeclarationExp) isDeclarationExp() { return op == TOK.declaration ? cast(typeof(return))this : null; } inout(TypeidExp) isTypeidExp() { return op == TOK.typeid_ ? cast(typeof(return))this : null; } inout(TraitsExp) isTraitsExp() { return op == TOK.traits ? cast(typeof(return))this : null; } inout(HaltExp) isHaltExp() { return op == TOK.halt ? cast(typeof(return))this : null; } inout(IsExp) isExp() { return op == TOK.is_ ? cast(typeof(return))this : null; } inout(CompileExp) isCompileExp() { return op == TOK.mixin_ ? cast(typeof(return))this : null; } inout(ImportExp) isImportExp() { return op == TOK.import_ ? cast(typeof(return))this : null; } inout(AssertExp) isAssertExp() { return op == TOK.assert_ ? cast(typeof(return))this : null; } inout(DotIdExp) isDotIdExp() { return op == TOK.dotIdentifier ? cast(typeof(return))this : null; } inout(DotTemplateExp) isDotTemplateExp() { return op == TOK.dotTemplateDeclaration ? cast(typeof(return))this : null; } inout(DotVarExp) isDotVarExp() { return op == TOK.dotVariable ? cast(typeof(return))this : null; } inout(DotTemplateInstanceExp) isDotTemplateInstanceExp() { return op == TOK.dotTemplateInstance ? cast(typeof(return))this : null; } inout(DelegateExp) isDelegateExp() { return op == TOK.delegate_ ? cast(typeof(return))this : null; } inout(DotTypeExp) isDotTypeExp() { return op == TOK.dotType ? cast(typeof(return))this : null; } inout(CallExp) isCallExp() { return op == TOK.call ? cast(typeof(return))this : null; } inout(AddrExp) isAddrExp() { return op == TOK.address ? cast(typeof(return))this : null; } inout(PtrExp) isPtrExp() { return op == TOK.star ? cast(typeof(return))this : null; } inout(NegExp) isNegExp() { return op == TOK.negate ? cast(typeof(return))this : null; } inout(UAddExp) isUAddExp() { return op == TOK.uadd ? cast(typeof(return))this : null; } inout(ComExp) isComExp() { return op == TOK.tilde ? cast(typeof(return))this : null; } inout(NotExp) isNotExp() { return op == TOK.not ? cast(typeof(return))this : null; } inout(DeleteExp) isDeleteExp() { return op == TOK.delete_ ? cast(typeof(return))this : null; } inout(CastExp) isCastExp() { return op == TOK.cast_ ? cast(typeof(return))this : null; } inout(VectorExp) isVectorExp() { return op == TOK.vector ? cast(typeof(return))this : null; } inout(VectorArrayExp) isVectorArrayExp() { return op == TOK.vectorArray ? cast(typeof(return))this : null; } inout(SliceExp) isSliceExp() { return op == TOK.slice ? cast(typeof(return))this : null; } inout(ArrayLengthExp) isArrayLengthExp() { return op == TOK.arrayLength ? cast(typeof(return))this : null; } inout(ArrayExp) isArrayExp() { return op == TOK.array ? cast(typeof(return))this : null; } inout(DotExp) isDotExp() { return op == TOK.dot ? cast(typeof(return))this : null; } inout(CommaExp) isCommaExp() { return op == TOK.comma ? cast(typeof(return))this : null; } inout(IntervalExp) isIntervalExp() { return op == TOK.interval ? cast(typeof(return))this : null; } inout(DelegatePtrExp) isDelegatePtrExp() { return op == TOK.delegatePointer ? cast(typeof(return))this : null; } inout(DelegateFuncptrExp) isDelegateFuncptrExp() { return op == TOK.delegateFunctionPointer ? cast(typeof(return))this : null; } inout(IndexExp) isIndexExp() { return op == TOK.index ? cast(typeof(return))this : null; } inout(PostExp) isPostExp() { return (op == TOK.plusPlus || op == TOK.minusMinus) ? cast(typeof(return))this : null; } inout(PreExp) isPreExp() { return (op == TOK.prePlusPlus || op == TOK.preMinusMinus) ? cast(typeof(return))this : null; } inout(AssignExp) isAssignExp() { return op == TOK.assign ? cast(typeof(return))this : null; } inout(ConstructExp) isConstructExp() { return op == TOK.construct ? cast(typeof(return))this : null; } inout(BlitExp) isBlitExp() { return op == TOK.blit ? cast(typeof(return))this : null; } inout(AddAssignExp) isAddAssignExp() { return op == TOK.addAssign ? cast(typeof(return))this : null; } inout(MinAssignExp) isMinAssignExp() { return op == TOK.minAssign ? cast(typeof(return))this : null; } inout(MulAssignExp) isMulAssignExp() { return op == TOK.mulAssign ? cast(typeof(return))this : null; } inout(DivAssignExp) isDivAssignExp() { return op == TOK.divAssign ? cast(typeof(return))this : null; } inout(ModAssignExp) isModAssignExp() { return op == TOK.modAssign ? cast(typeof(return))this : null; } inout(AndAssignExp) isAndAssignExp() { return op == TOK.andAssign ? cast(typeof(return))this : null; } inout(OrAssignExp) isOrAssignExp() { return op == TOK.orAssign ? cast(typeof(return))this : null; } inout(XorAssignExp) isXorAssignExp() { return op == TOK.xorAssign ? cast(typeof(return))this : null; } inout(PowAssignExp) isPowAssignExp() { return op == TOK.powAssign ? cast(typeof(return))this : null; } inout(ShlAssignExp) isShlAssignExp() { return op == TOK.leftShiftAssign ? cast(typeof(return))this : null; } inout(ShrAssignExp) isShrAssignExp() { return op == TOK.rightShiftAssign ? cast(typeof(return))this : null; } inout(UshrAssignExp) isUshrAssignExp() { return op == TOK.unsignedRightShiftAssign ? cast(typeof(return))this : null; } inout(CatAssignExp) isCatAssignExp() { return (op == TOK.concatenateAssign || op == TOK.concatenateElemAssign || op == TOK.concatenateDcharAssign) ? cast(typeof(return))this : null; } inout(AddExp) isAddExp() { return op == TOK.add ? cast(typeof(return))this : null; } inout(MinExp) isMinExp() { return op == TOK.min ? cast(typeof(return))this : null; } inout(CatExp) isCatExp() { return op == TOK.concatenate ? cast(typeof(return))this : null; } inout(MulExp) isMulExp() { return op == TOK.mul ? cast(typeof(return))this : null; } inout(DivExp) isDivExp() { return op == TOK.div ? cast(typeof(return))this : null; } inout(ModExp) isModExp() { return op == TOK.mod ? cast(typeof(return))this : null; } inout(PowExp) isPowExp() { return op == TOK.pow ? cast(typeof(return))this : null; } inout(ShlExp) isShlExp() { return op == TOK.leftShift ? cast(typeof(return))this : null; } inout(ShrExp) isShrExp() { return op == TOK.rightShift ? cast(typeof(return))this : null; } inout(UshrExp) isUshrExp() { return op == TOK.unsignedRightShift ? cast(typeof(return))this : null; } inout(AndExp) isAndExp() { return op == TOK.and ? cast(typeof(return))this : null; } inout(OrExp) isOrExp() { return op == TOK.or ? cast(typeof(return))this : null; } inout(XorExp) isXorExp() { return op == TOK.xor ? cast(typeof(return))this : null; } inout(LogicalExp) isLogicalExp() { return (op == TOK.andAnd || op == TOK.orOr) ? cast(typeof(return))this : null; } //inout(CmpExp) isCmpExp() { return op == TOK. ? cast(typeof(return))this : null; } inout(InExp) isInExp() { return op == TOK.in_ ? cast(typeof(return))this : null; } inout(RemoveExp) isRemoveExp() { return op == TOK.remove ? cast(typeof(return))this : null; } inout(EqualExp) isEqualExp() { return (op == TOK.equal || op == TOK.notEqual) ? cast(typeof(return))this : null; } inout(IdentityExp) isIdentityExp() { return (op == TOK.identity || op == TOK.notIdentity) ? cast(typeof(return))this : null; } inout(CondExp) isCondExp() { return op == TOK.question ? cast(typeof(return))this : null; } inout(DefaultInitExp) isDefaultInitExp() { return op == TOK.default_ ? cast(typeof(return))this : null; } inout(FileInitExp) isFileInitExp() { return (op == TOK.file || op == TOK.fileFullPath) ? cast(typeof(return))this : null; } inout(LineInitExp) isLineInitExp() { return op == TOK.line ? cast(typeof(return))this : null; } inout(ModuleInitExp) isModuleInitExp() { return op == TOK.moduleString ? cast(typeof(return))this : null; } inout(FuncInitExp) isFuncInitExp() { return op == TOK.functionString ? cast(typeof(return))this : null; } inout(PrettyFuncInitExp) isPrettyFuncInitExp() { return op == TOK.prettyFunction ? cast(typeof(return))this : null; } inout(ClassReferenceExp) isClassReferenceExp() { return op == TOK.classReference ? cast(typeof(return))this : null; } } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class IntegerExp : Expression { private dinteger_t value; extern (D) this(const ref Loc loc, dinteger_t value, Type type) { super(loc, TOK.int64, __traits(classInstanceSize, IntegerExp)); //printf("IntegerExp(value = %lld, type = '%s')\n", value, type ? type.toChars() : ""); assert(type); if (!type.isscalar()) { //printf("%s, loc = %d\n", toChars(), loc.linnum); if (type.ty != Terror) error("integral constant must be scalar type, not `%s`", type.toChars()); type = Type.terror; } this.type = type; this.value = normalize(type.toBasetype().ty, value); } extern (D) this(dinteger_t value) { super(Loc.initial, TOK.int64, __traits(classInstanceSize, IntegerExp)); this.type = Type.tint32; this.value = cast(d_int32)value; } static IntegerExp create(Loc loc, dinteger_t value, Type type) { return new IntegerExp(loc, value, type); } static IntegerExp createi(Loc loc, int value, Type type) { return new IntegerExp(loc, value, type); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, dinteger_t value, Type type) { emplaceExp!(IntegerExp)(pue, loc, value, type); } static void emplacei(UnionExp* pue, Loc loc, int value, Type type) { emplaceExp!(IntegerExp)(pue, loc, value, type); } override bool equals(RootObject o) { if (this == o) return true; if (auto ne = (cast(Expression)o).isIntegerExp()) { if (type.toHeadMutable().equals(ne.type.toHeadMutable()) && value == ne.value) { return true; } } return false; } override dinteger_t toInteger() { // normalize() is necessary until we fix all the paints of 'type' return value = normalize(type.toBasetype().ty, value); } override real_t toReal() { // normalize() is necessary until we fix all the paints of 'type' const ty = type.toBasetype().ty; const val = normalize(ty, value); value = val; return (ty == Tuns64) ? real_t(cast(d_uns64)val) : real_t(cast(d_int64)val); } override real_t toImaginary() { return CTFloat.zero; } override complex_t toComplex() { return complex_t(toReal()); } override bool isBool(bool result) { bool r = toInteger() != 0; return result ? r : !r; } override Expression toLvalue(Scope* sc, Expression e) { if (!e) e = this; else if (!loc.isValid()) loc = e.loc; e.error("cannot modify constant `%s`", e.toChars()); return new ErrorExp(); } override void accept(Visitor v) { v.visit(this); } dinteger_t getInteger() { return value; } void setInteger(dinteger_t value) { this.value = normalize(type.toBasetype().ty, value); } static dinteger_t normalize(TY ty, dinteger_t value) { /* 'Normalize' the value of the integer to be in range of the type */ dinteger_t result; switch (ty) { case Tbool: result = (value != 0); break; case Tint8: result = cast(d_int8)value; break; case Tchar: case Tuns8: result = cast(d_uns8)value; break; case Tint16: result = cast(d_int16)value; break; case Twchar: case Tuns16: result = cast(d_uns16)value; break; case Tint32: result = cast(d_int32)value; break; case Tdchar: case Tuns32: result = cast(d_uns32)value; break; case Tint64: result = cast(d_int64)value; break; case Tuns64: result = cast(d_uns64)value; break; case Tpointer: if (target.ptrsize == 4) result = cast(d_uns32)value; else if (target.ptrsize == 8) result = cast(d_uns64)value; else assert(0); break; default: break; } return result; } override Expression syntaxCopy() { return this; } /** * Use this instead of creating new instances for commonly used literals * such as 0 or 1. * * Parameters: * v = The value of the expression * Returns: * A static instance of the expression, typed as `Tint32`. */ static IntegerExp literal(int v)() { __gshared IntegerExp theConstant; if (!theConstant) theConstant = new IntegerExp(v); return theConstant; } } /*********************************************************** * Use this expression for error recovery. * It should behave as a 'sink' to prevent further cascaded error messages. */ extern (C++) final class ErrorExp : Expression { extern (D) this() { if (global.errors == 0 && global.gaggedErrors == 0) { /* Unfortunately, errors can still leak out of gagged errors, * and we need to set the error count to prevent bogus code * generation. At least give a message. */ error("unknown, please file report on issues.dlang.org"); } super(Loc.initial, TOK.error, __traits(classInstanceSize, ErrorExp)); type = Type.terror; } override Expression toLvalue(Scope* sc, Expression e) { return this; } override void accept(Visitor v) { v.visit(this); } extern (C++) __gshared ErrorExp errorexp; // handy shared value } /*********************************************************** * An uninitialized value, * generated from void initializers. */ extern (C++) final class VoidInitExp : Expression { VarDeclaration var; /// the variable from where the void value came from, null if not known /// Useful for error messages extern (D) this(VarDeclaration var) { super(var.loc, TOK.void_, __traits(classInstanceSize, VoidInitExp)); this.var = var; this.type = var.type; } override const(char)* toChars() const { return "void"; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class RealExp : Expression { real_t value; extern (D) this(const ref Loc loc, real_t value, Type type) { super(loc, TOK.float64, __traits(classInstanceSize, RealExp)); //printf("RealExp::RealExp(%Lg)\n", value); this.value = value; this.type = type; } static RealExp create(Loc loc, real_t value, Type type) { return new RealExp(loc, value, type); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, real_t value, Type type) { emplaceExp!(RealExp)(pue, loc, value, type); } override bool equals(RootObject o) { if (this == o) return true; if (auto ne = (cast(Expression)o).isRealExp()) { if (type.toHeadMutable().equals(ne.type.toHeadMutable()) && RealEquals(value, ne.value)) { return true; } } return false; } override dinteger_t toInteger() { return cast(sinteger_t)toReal(); } override uinteger_t toUInteger() { return cast(uinteger_t)toReal(); } override real_t toReal() { return type.isreal() ? value : CTFloat.zero; } override real_t toImaginary() { return type.isreal() ? CTFloat.zero : value; } override complex_t toComplex() { return complex_t(toReal(), toImaginary()); } override bool isBool(bool result) { return result ? cast(bool)value : !cast(bool)value; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ComplexExp : Expression { complex_t value; extern (D) this(const ref Loc loc, complex_t value, Type type) { super(loc, TOK.complex80, __traits(classInstanceSize, ComplexExp)); this.value = value; this.type = type; //printf("ComplexExp::ComplexExp(%s)\n", toChars()); } static ComplexExp create(Loc loc, complex_t value, Type type) { return new ComplexExp(loc, value, type); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, complex_t value, Type type) { emplaceExp!(ComplexExp)(pue, loc, value, type); } override bool equals(RootObject o) { if (this == o) return true; if (auto ne = (cast(Expression)o).isComplexExp()) { if (type.toHeadMutable().equals(ne.type.toHeadMutable()) && RealEquals(creall(value), creall(ne.value)) && RealEquals(cimagl(value), cimagl(ne.value))) { return true; } } return false; } override dinteger_t toInteger() { return cast(sinteger_t)toReal(); } override uinteger_t toUInteger() { return cast(uinteger_t)toReal(); } override real_t toReal() { return creall(value); } override real_t toImaginary() { return cimagl(value); } override complex_t toComplex() { return value; } override bool isBool(bool result) { if (result) return cast(bool)value; else return !value; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) class IdentifierExp : Expression { Identifier ident; extern (D) this(const ref Loc loc, Identifier ident) { super(loc, TOK.identifier, __traits(classInstanceSize, IdentifierExp)); this.ident = ident; } static IdentifierExp create(Loc loc, Identifier ident) { return new IdentifierExp(loc, ident); } override final bool isLvalue() { return true; } override final Expression toLvalue(Scope* sc, Expression e) { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DollarExp : IdentifierExp { extern (D) this(const ref Loc loc) { super(loc, Id.dollar); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Won't be generated by parser. */ extern (C++) final class DsymbolExp : Expression { Dsymbol s; bool hasOverloads; extern (D) this(const ref Loc loc, Dsymbol s, bool hasOverloads = true) { super(loc, TOK.dSymbol, __traits(classInstanceSize, DsymbolExp)); this.s = s; this.hasOverloads = hasOverloads; } override bool isLvalue() { return true; } override Expression toLvalue(Scope* sc, Expression e) { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#this */ extern (C++) class ThisExp : Expression { VarDeclaration var; extern (D) this(const ref Loc loc) { super(loc, TOK.this_, __traits(classInstanceSize, ThisExp)); //printf("ThisExp::ThisExp() loc = %d\n", loc.linnum); } override final bool isBool(bool result) { return result; } override final bool isLvalue() { // Class `this` should be an rvalue; struct `this` should be an lvalue. return type.toBasetype().ty != Tclass; } override final Expression toLvalue(Scope* sc, Expression e) { if (type.toBasetype().ty == Tclass) { // Class `this` is an rvalue; struct `this` is an lvalue. return Expression.toLvalue(sc, e); } return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#super */ extern (C++) final class SuperExp : ThisExp { extern (D) this(const ref Loc loc) { super(loc); op = TOK.super_; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#null */ extern (C++) final class NullExp : Expression { ubyte committed; // !=0 if type is committed extern (D) this(const ref Loc loc, Type type = null) { super(loc, TOK.null_, __traits(classInstanceSize, NullExp)); this.type = type; } override bool equals(RootObject o) { if (auto e = o.isExpression()) { if (e.op == TOK.null_ && type.equals(e.type)) { return true; } } return false; } override bool isBool(bool result) { return result ? false : true; } override StringExp toStringExp() { if (implicitConvTo(Type.tstring)) { auto se = new StringExp(loc, cast(char*)mem.xcalloc(1, 1), 0); se.type = Type.tstring; return se; } return null; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#string_literals */ extern (C++) final class StringExp : Expression { union { char* string; // if sz == 1 wchar* wstring; // if sz == 2 dchar* dstring; // if sz == 4 } // (const if ownedByCtfe == OwnedBy.code) size_t len; // number of code units ubyte sz = 1; // 1: char, 2: wchar, 4: dchar ubyte committed; // !=0 if type is committed char postfix = 0; // 'c', 'w', 'd' OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(const ref Loc loc, char* string) { super(loc, TOK.string_, __traits(classInstanceSize, StringExp)); this.string = string; this.len = strlen(string); this.sz = 1; // work around LDC bug #1286 } extern (D) this(const ref Loc loc, void* string, size_t len) { super(loc, TOK.string_, __traits(classInstanceSize, StringExp)); this.string = cast(char*)string; this.len = len; this.sz = 1; // work around LDC bug #1286 } extern (D) this(const ref Loc loc, void* string, size_t len, char postfix) { super(loc, TOK.string_, __traits(classInstanceSize, StringExp)); this.string = cast(char*)string; this.len = len; this.postfix = postfix; this.sz = 1; // work around LDC bug #1286 } static StringExp create(Loc loc, char* s) { return new StringExp(loc, s); } static StringExp create(Loc loc, void* string, size_t len) { return new StringExp(loc, string, len); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, char* s) { emplaceExp!(StringExp)(pue, loc, s); } static void emplace(UnionExp* pue, Loc loc, void* string, size_t len) { emplaceExp!(StringExp)(pue, loc, string, len); } override bool equals(RootObject o) { //printf("StringExp::equals('%s') %s\n", o.toChars(), toChars()); if (auto e = o.isExpression()) { if (e.op == TOK.string_) { return compare(o) == 0; } } return false; } /********************************** * Return the number of code units the string would be if it were re-encoded * as tynto. * Params: * tynto = code unit type of the target encoding * Returns: * number of code units */ size_t numberOfCodeUnits(int tynto = 0) const { int encSize; switch (tynto) { case 0: return len; case Tchar: encSize = 1; break; case Twchar: encSize = 2; break; case Tdchar: encSize = 4; break; default: assert(0); } if (sz == encSize) return len; size_t result = 0; dchar c; switch (sz) { case 1: for (size_t u = 0; u < len;) { if (const p = utf_decodeChar(string, len, u, c)) { error("%s", p); return 0; } result += utf_codeLength(encSize, c); } break; case 2: for (size_t u = 0; u < len;) { if (const p = utf_decodeWchar(wstring, len, u, c)) { error("%s", p); return 0; } result += utf_codeLength(encSize, c); } break; case 4: foreach (u; 0 .. len) { result += utf_codeLength(encSize, dstring[u]); } break; default: assert(0); } return result; } /********************************************** * Write the contents of the string to dest. * Use numberOfCodeUnits() to determine size of result. * Params: * dest = destination * tyto = encoding type of the result * zero = add terminating 0 */ void writeTo(void* dest, bool zero, int tyto = 0) const { int encSize; switch (tyto) { case 0: encSize = sz; break; case Tchar: encSize = 1; break; case Twchar: encSize = 2; break; case Tdchar: encSize = 4; break; default: assert(0); } if (sz == encSize) { memcpy(dest, string, len * sz); if (zero) memset(dest + len * sz, 0, sz); } else assert(0); } /********************************************* * Get the code unit at index i * Params: * i = index * Returns: * code unit at index i */ dchar getCodeUnit(size_t i) const pure { assert(i < len); final switch (sz) { case 1: return string[i]; case 2: return wstring[i]; case 4: return dstring[i]; } } /********************************************* * Set the code unit at index i to c * Params: * i = index * c = code unit to set it to */ void setCodeUnit(size_t i, dchar c) { assert(i < len); final switch (sz) { case 1: string[i] = cast(char)c; break; case 2: wstring[i] = cast(wchar)c; break; case 4: dstring[i] = c; break; } } /************************************************** * If the string data is UTF-8 and can be accessed directly, * return a pointer to it. * Do not assume a terminating 0. * Returns: * pointer to string data if possible, null if not */ char* toPtr() { return (sz == 1) ? string : null; } override StringExp toStringExp() { return this; } /**************************************** * Convert string to char[]. */ StringExp toUTF8(Scope* sc) { if (sz != 1) { // Convert to UTF-8 string committed = 0; Expression e = castTo(sc, Type.tchar.arrayOf()); e = e.optimize(WANTvalue); auto se = e.isStringExp(); assert(se.sz == 1); return se; } return this; } override int compare(RootObject obj) { //printf("StringExp::compare()\n"); // Used to sort case statement expressions so we can do an efficient lookup StringExp se2 = cast(StringExp)obj; // This is a kludge so isExpression() in template.c will return 5 // for StringExp's. if (!se2) return 5; assert(se2.op == TOK.string_); const len1 = len; const len2 = se2.len; //printf("sz = %d, len1 = %d, len2 = %d\n", sz, (int)len1, (int)len2); if (len1 == len2) { switch (sz) { case 1: return memcmp(string, se2.string, len1); case 2: { wchar* s1 = cast(wchar*)string; wchar* s2 = cast(wchar*)se2.string; foreach (u; 0 .. len) { if (s1[u] != s2[u]) return s1[u] - s2[u]; } } break; case 4: { dchar* s1 = cast(dchar*)string; dchar* s2 = cast(dchar*)se2.string; foreach (u; 0 .. len) { if (s1[u] != s2[u]) return s1[u] - s2[u]; } } break; default: assert(0); } } return cast(int)(len1 - len2); } override bool isBool(bool result) { return result; } override bool isLvalue() { /* string literal is rvalue in default, but * conversion to reference of static array is only allowed. */ return (type && type.toBasetype().ty == Tsarray); } override Expression toLvalue(Scope* sc, Expression e) { //printf("StringExp::toLvalue(%s) type = %s\n", toChars(), type ? type.toChars() : NULL); return (type && type.toBasetype().ty == Tsarray) ? this : Expression.toLvalue(sc, e); } override Expression modifiableLvalue(Scope* sc, Expression e) { error("cannot modify string literal `%s`", toChars()); return new ErrorExp(); } uint charAt(uinteger_t i) const { uint value; switch (sz) { case 1: value = (cast(char*)string)[cast(size_t)i]; break; case 2: value = (cast(ushort*)string)[cast(size_t)i]; break; case 4: value = (cast(uint*)string)[cast(size_t)i]; break; default: assert(0); } return value; } /******************************** * Convert string contents to a 0 terminated string, * allocated by mem.xmalloc(). */ extern (D) const(char)[] toStringz() const { auto nbytes = len * sz; char* s = cast(char*)mem.xmalloc(nbytes + sz); writeTo(s, true); return s[0 .. nbytes]; } extern (D) const(char)[] peekSlice() const { assert(sz == 1); return this.string[0 .. len]; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class TupleExp : Expression { /* Tuple-field access may need to take out its side effect part. * For example: * foo().tupleof * is rewritten as: * (ref __tup = foo(); tuple(__tup.field0, __tup.field1, ...)) * The declaration of temporary variable __tup will be stored in TupleExp.e0. */ Expression e0; Expressions* exps; extern (D) this(const ref Loc loc, Expression e0, Expressions* exps) { super(loc, TOK.tuple, __traits(classInstanceSize, TupleExp)); //printf("TupleExp(this = %p)\n", this); this.e0 = e0; this.exps = exps; } extern (D) this(const ref Loc loc, Expressions* exps) { super(loc, TOK.tuple, __traits(classInstanceSize, TupleExp)); //printf("TupleExp(this = %p)\n", this); this.exps = exps; } extern (D) this(const ref Loc loc, TupleDeclaration tup) { super(loc, TOK.tuple, __traits(classInstanceSize, TupleExp)); this.exps = new Expressions(); this.exps.reserve(tup.objects.dim); foreach (o; *tup.objects) { if (Dsymbol s = getDsymbol(o)) { /* If tuple element represents a symbol, translate to DsymbolExp * to supply implicit 'this' if needed later. */ Expression e = new DsymbolExp(loc, s); this.exps.push(e); } else if (auto eo = o.isExpression()) { auto e = eo.copy(); e.loc = loc; // https://issues.dlang.org/show_bug.cgi?id=15669 this.exps.push(e); } else if (auto t = o.isType()) { Expression e = new TypeExp(loc, t); this.exps.push(e); } else { error("`%s` is not an expression", o.toChars()); } } } override TupleExp toTupleExp() { return this; } override Expression syntaxCopy() { return new TupleExp(loc, e0 ? e0.syntaxCopy() : null, arraySyntaxCopy(exps)); } override bool equals(RootObject o) { if (this == o) return true; if (auto e = o.isExpression()) if (auto te = e.isTupleExp()) { if (exps.dim != te.exps.dim) return false; if (e0 && !e0.equals(te.e0) || !e0 && te.e0) return false; foreach (i, e1; *exps) { Expression e2 = (*te.exps)[i]; if (!e1.equals(e2)) return false; } return true; } return false; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * [ e1, e2, e3, ... ] * * http://dlang.org/spec/expression.html#array_literals */ extern (C++) final class ArrayLiteralExp : Expression { /** If !is null, elements[] can be sparse and basis is used for the * "default" element value. In other words, non-null elements[i] overrides * this 'basis' value. */ Expression basis; Expressions* elements; OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(const ref Loc loc, Type type, Expressions* elements) { super(loc, TOK.arrayLiteral, __traits(classInstanceSize, ArrayLiteralExp)); this.type = type; this.elements = elements; } extern (D) this(const ref Loc loc, Type type, Expression e) { super(loc, TOK.arrayLiteral, __traits(classInstanceSize, ArrayLiteralExp)); this.type = type; elements = new Expressions(); elements.push(e); } extern (D) this(const ref Loc loc, Type type, Expression basis, Expressions* elements) { super(loc, TOK.arrayLiteral, __traits(classInstanceSize, ArrayLiteralExp)); this.type = type; this.basis = basis; this.elements = elements; } static ArrayLiteralExp create(Loc loc, Expressions* elements) { return new ArrayLiteralExp(loc, null, elements); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, Expressions* elements) { emplaceExp!(ArrayLiteralExp)(pue, loc, null, elements); } override Expression syntaxCopy() { return new ArrayLiteralExp(loc, null, basis ? basis.syntaxCopy() : null, arraySyntaxCopy(elements)); } override bool equals(RootObject o) { if (this == o) return true; Expression e = o.isExpression(); if (!e) return false; if (auto ae = e.isArrayLiteralExp()) { if (elements.dim != ae.elements.dim) return false; if (elements.dim == 0 && !type.equals(ae.type)) { return false; } foreach (i, e1; *elements) { Expression e2 = (*ae.elements)[i]; if (!e1) e1 = basis; if (!e2) e2 = ae.basis; if (e1 != e2 && (!e1 || !e2 || !e1.equals(e2))) return false; } return true; } return false; } Expression getElement(size_t i) { auto el = (*elements)[i]; return el ? el : basis; } override bool isBool(bool result) { size_t dim = elements ? elements.dim : 0; return result ? (dim != 0) : (dim == 0); } override StringExp toStringExp() { TY telem = type.nextOf().toBasetype().ty; if (telem == Tchar || telem == Twchar || telem == Tdchar || (telem == Tvoid && (!elements || elements.dim == 0))) { ubyte sz = 1; if (telem == Twchar) sz = 2; else if (telem == Tdchar) sz = 4; OutBuffer buf; if (elements) { foreach (i; 0 .. elements.dim) { auto ch = getElement(i); if (ch.op != TOK.int64) return null; if (sz == 1) buf.writeByte(cast(uint)ch.toInteger()); else if (sz == 2) buf.writeword(cast(uint)ch.toInteger()); else buf.write4(cast(uint)ch.toInteger()); } } char prefix; if (sz == 1) { prefix = 'c'; buf.writeByte(0); } else if (sz == 2) { prefix = 'w'; buf.writeword(0); } else { prefix = 'd'; buf.write4(0); } const size_t len = buf.offset / sz - 1; auto se = new StringExp(loc, buf.extractData(), len, prefix); se.sz = sz; se.type = type; return se; } return null; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * [ key0 : value0, key1 : value1, ... ] * * http://dlang.org/spec/expression.html#associative_array_literals */ extern (C++) final class AssocArrayLiteralExp : Expression { Expressions* keys; Expressions* values; OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(const ref Loc loc, Expressions* keys, Expressions* values) { super(loc, TOK.assocArrayLiteral, __traits(classInstanceSize, AssocArrayLiteralExp)); assert(keys.dim == values.dim); this.keys = keys; this.values = values; } override bool equals(RootObject o) { if (this == o) return true; auto e = o.isExpression(); if (!e) return false; if (auto ae = e.isAssocArrayLiteralExp()) { if (keys.dim != ae.keys.dim) return false; size_t count = 0; foreach (i, key; *keys) { foreach (j, akey; *ae.keys) { if (key.equals(akey)) { if (!(*values)[i].equals((*ae.values)[j])) return false; ++count; } } } return count == keys.dim; } return false; } override Expression syntaxCopy() { return new AssocArrayLiteralExp(loc, arraySyntaxCopy(keys), arraySyntaxCopy(values)); } override bool isBool(bool result) { size_t dim = keys.dim; return result ? (dim != 0) : (dim == 0); } override void accept(Visitor v) { v.visit(this); } } enum stageScrub = 0x1; /// scrubReturnValue is running enum stageSearchPointers = 0x2; /// hasNonConstPointers is running enum stageOptimize = 0x4; /// optimize is running enum stageApply = 0x8; /// apply is running enum stageInlineScan = 0x10; /// inlineScan is running enum stageToCBuffer = 0x20; /// toCBuffer is running /*********************************************************** * sd( e1, e2, e3, ... ) */ extern (C++) final class StructLiteralExp : Expression { StructDeclaration sd; /// which aggregate this is for Expressions* elements; /// parallels sd.fields[] with null entries for fields to skip Type stype; /// final type of result (can be different from sd's type) Symbol* sym; /// back end symbol to initialize with literal /** pointer to the origin instance of the expression. * once a new expression is created, origin is set to 'this'. * anytime when an expression copy is created, 'origin' pointer is set to * 'origin' pointer value of the original expression. */ StructLiteralExp origin; /// those fields need to prevent a infinite recursion when one field of struct initialized with 'this' pointer. StructLiteralExp inlinecopy; /** anytime when recursive function is calling, 'stageflags' marks with bit flag of * current stage and unmarks before return from this function. * 'inlinecopy' uses similar 'stageflags' and from multiple evaluation 'doInline' * (with infinite recursion) of this expression. */ int stageflags; bool useStaticInit; /// if this is true, use the StructDeclaration's init symbol OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(const ref Loc loc, StructDeclaration sd, Expressions* elements, Type stype = null) { super(loc, TOK.structLiteral, __traits(classInstanceSize, StructLiteralExp)); this.sd = sd; if (!elements) elements = new Expressions(); this.elements = elements; this.stype = stype; this.origin = this; //printf("StructLiteralExp::StructLiteralExp(%s)\n", toChars()); } static StructLiteralExp create(Loc loc, StructDeclaration sd, void* elements, Type stype = null) { return new StructLiteralExp(loc, sd, cast(Expressions*)elements, stype); } override bool equals(RootObject o) { if (this == o) return true; Expression e = o.isExpression(); if (!e) return false; if (auto se = e.isStructLiteralExp()) { if (!type.equals(se.type)) return false; if (elements.dim != se.elements.dim) return false; foreach (i, e1; *elements) { Expression e2 = (*se.elements)[i]; if (e1 != e2 && (!e1 || !e2 || !e1.equals(e2))) return false; } return true; } return false; } override Expression syntaxCopy() { auto exp = new StructLiteralExp(loc, sd, arraySyntaxCopy(elements), type ? type : stype); exp.origin = this; return exp; } /************************************** * Gets expression at offset of type. * Returns NULL if not found. */ Expression getField(Type type, uint offset) { //printf("StructLiteralExp::getField(this = %s, type = %s, offset = %u)\n", // /*toChars()*/"", type.toChars(), offset); Expression e = null; int i = getFieldIndex(type, offset); if (i != -1) { //printf("\ti = %d\n", i); if (i == sd.fields.dim - 1 && sd.isNested()) return null; assert(i < elements.dim); e = (*elements)[i]; if (e) { //printf("e = %s, e.type = %s\n", e.toChars(), e.type.toChars()); /* If type is a static array, and e is an initializer for that array, * then the field initializer should be an array literal of e. */ auto tsa = type.isTypeSArray(); if (tsa && e.type.castMod(0) != type.castMod(0)) { const length = cast(size_t)tsa.dim.toInteger(); auto z = new Expressions(length); foreach (ref q; *z) q = e.copy(); e = new ArrayLiteralExp(loc, type, z); } else { e = e.copy(); e.type = type; } if (useStaticInit && e.type.needsNested()) if (auto se = e.isStructLiteralExp()) { se.useStaticInit = true; } } } return e; } /************************************ * Get index of field. * Returns -1 if not found. */ int getFieldIndex(Type type, uint offset) { /* Find which field offset is by looking at the field offsets */ if (elements.dim) { foreach (i, v; sd.fields) { if (offset == v.offset && type.size() == v.type.size()) { /* context field might not be filled. */ if (i == sd.fields.dim - 1 && sd.isNested()) return cast(int)i; if (auto e = (*elements)[i]) { return cast(int)i; } break; } } } return -1; } override Expression addDtorHook(Scope* sc) { /* If struct requires a destructor, rewrite as: * (S tmp = S()),tmp * so that the destructor can be hung on tmp. */ if (sd.dtor && sc.func) { /* Make an identifier for the temporary of the form: * __sl%s%d, where %s is the struct name */ const size_t len = 10; char[len + 1] buf = void; buf[len] = 0; strcpy(buf.ptr, "__sl"); strncat(buf.ptr, sd.ident.toChars(), len - 4 - 1); assert(buf[len] == 0); auto tmp = copyToTemp(0, buf.ptr, this); Expression ae = new DeclarationExp(loc, tmp); Expression e = new CommaExp(loc, ae, new VarExp(loc, tmp)); e = e.expressionSemantic(sc); return e; } return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Mainly just a placeholder */ extern (C++) final class TypeExp : Expression { extern (D) this(const ref Loc loc, Type type) { super(loc, TOK.type, __traits(classInstanceSize, TypeExp)); //printf("TypeExp::TypeExp(%s)\n", type.toChars()); this.type = type; } override Expression syntaxCopy() { return new TypeExp(loc, type.syntaxCopy()); } override bool checkType() { error("type `%s` is not an expression", toChars()); return true; } override bool checkValue() { error("type `%s` has no value", toChars()); return true; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Mainly just a placeholder of * Package, Module, Nspace, and TemplateInstance (including TemplateMixin) * * A template instance that requires IFTI: * foo!tiargs(fargs) // foo!tiargs * is left until CallExp::semantic() or resolveProperties() */ extern (C++) final class ScopeExp : Expression { ScopeDsymbol sds; extern (D) this(const ref Loc loc, ScopeDsymbol sds) { super(loc, TOK.scope_, __traits(classInstanceSize, ScopeExp)); //printf("ScopeExp::ScopeExp(sds = '%s')\n", sds.toChars()); //static int count; if (++count == 38) *(char*)0=0; this.sds = sds; assert(!sds.isTemplateDeclaration()); // instead, you should use TemplateExp } override Expression syntaxCopy() { return new ScopeExp(loc, cast(ScopeDsymbol)sds.syntaxCopy(null)); } override bool checkType() { if (sds.isPackage()) { error("%s `%s` has no type", sds.kind(), sds.toChars()); return true; } if (auto ti = sds.isTemplateInstance()) { //assert(ti.needsTypeInference(sc)); if (ti.tempdecl && ti.semantictiargsdone && ti.semanticRun == PASS.init) { error("partial %s `%s` has no type", sds.kind(), toChars()); return true; } } return false; } override bool checkValue() { error("%s `%s` has no value", sds.kind(), sds.toChars()); return true; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Mainly just a placeholder */ extern (C++) final class TemplateExp : Expression { TemplateDeclaration td; FuncDeclaration fd; extern (D) this(const ref Loc loc, TemplateDeclaration td, FuncDeclaration fd = null) { super(loc, TOK.template_, __traits(classInstanceSize, TemplateExp)); //printf("TemplateExp(): %s\n", td.toChars()); this.td = td; this.fd = fd; } override bool isLvalue() { return fd !is null; } override Expression toLvalue(Scope* sc, Expression e) { if (!fd) return Expression.toLvalue(sc, e); assert(sc); return symbolToExp(fd, loc, sc, true); } override bool checkType() { error("%s `%s` has no type", td.kind(), toChars()); return true; } override bool checkValue() { error("%s `%s` has no value", td.kind(), toChars()); return true; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * thisexp.new(newargs) newtype(arguments) */ extern (C++) final class NewExp : Expression { Expression thisexp; // if !=null, 'this' for class being allocated Expressions* newargs; // Array of Expression's to call new operator Type newtype; Expressions* arguments; // Array of Expression's Expression argprefix; // expression to be evaluated just before arguments[] CtorDeclaration member; // constructor function NewDeclaration allocator; // allocator function bool onstack; // allocate on stack bool thrownew; // this NewExp is the expression of a ThrowStatement extern (D) this(const ref Loc loc, Expression thisexp, Expressions* newargs, Type newtype, Expressions* arguments) { super(loc, TOK.new_, __traits(classInstanceSize, NewExp)); this.thisexp = thisexp; this.newargs = newargs; this.newtype = newtype; this.arguments = arguments; } static NewExp create(Loc loc, Expression thisexp, Expressions* newargs, Type newtype, Expressions* arguments) { return new NewExp(loc, thisexp, newargs, newtype, arguments); } override Expression syntaxCopy() { return new NewExp(loc, thisexp ? thisexp.syntaxCopy() : null, arraySyntaxCopy(newargs), newtype.syntaxCopy(), arraySyntaxCopy(arguments)); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * thisexp.new(newargs) class baseclasses { } (arguments) */ extern (C++) final class NewAnonClassExp : Expression { Expression thisexp; // if !=null, 'this' for class being allocated Expressions* newargs; // Array of Expression's to call new operator ClassDeclaration cd; // class being instantiated Expressions* arguments; // Array of Expression's to call class constructor extern (D) this(const ref Loc loc, Expression thisexp, Expressions* newargs, ClassDeclaration cd, Expressions* arguments) { super(loc, TOK.newAnonymousClass, __traits(classInstanceSize, NewAnonClassExp)); this.thisexp = thisexp; this.newargs = newargs; this.cd = cd; this.arguments = arguments; } override Expression syntaxCopy() { return new NewAnonClassExp(loc, thisexp ? thisexp.syntaxCopy() : null, arraySyntaxCopy(newargs), cast(ClassDeclaration)cd.syntaxCopy(null), arraySyntaxCopy(arguments)); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) class SymbolExp : Expression { Declaration var; bool hasOverloads; extern (D) this(const ref Loc loc, TOK op, int size, Declaration var, bool hasOverloads) { super(loc, op, size); assert(var); this.var = var; this.hasOverloads = hasOverloads; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Offset from symbol */ extern (C++) final class SymOffExp : SymbolExp { dinteger_t offset; extern (D) this(const ref Loc loc, Declaration var, dinteger_t offset, bool hasOverloads = true) { if (auto v = var.isVarDeclaration()) { // FIXME: This error report will never be handled anyone. // It should be done before the SymOffExp construction. if (v.needThis()) .error(loc, "need `this` for address of `%s`", v.toChars()); hasOverloads = false; } super(loc, TOK.symbolOffset, __traits(classInstanceSize, SymOffExp), var, hasOverloads); this.offset = offset; } override bool isBool(bool result) { return result ? true : false; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Variable */ extern (C++) final class VarExp : SymbolExp { extern (D) this(const ref Loc loc, Declaration var, bool hasOverloads = true) { if (var.isVarDeclaration()) hasOverloads = false; super(loc, TOK.variable, __traits(classInstanceSize, VarExp), var, hasOverloads); //printf("VarExp(this = %p, '%s', loc = %s)\n", this, var.toChars(), loc.toChars()); //if (strcmp(var.ident.toChars(), "func") == 0) assert(0); this.type = var.type; } static VarExp create(Loc loc, Declaration var, bool hasOverloads = true) { return new VarExp(loc, var, hasOverloads); } override bool equals(RootObject o) { if (this == o) return true; if (auto ne = o.isExpression().isVarExp()) { if (type.toHeadMutable().equals(ne.type.toHeadMutable()) && var == ne.var) { return true; } } return false; } override int checkModifiable(Scope* sc, int flag) { //printf("VarExp::checkModifiable %s", toChars()); assert(type); return var.checkModify(loc, sc, null, flag); } override bool isLvalue() { if (var.storage_class & (STC.lazy_ | STC.rvalue | STC.manifest)) return false; return true; } override Expression toLvalue(Scope* sc, Expression e) { if (var.storage_class & STC.manifest) { error("manifest constant `%s` cannot be modified", var.toChars()); return new ErrorExp(); } if (var.storage_class & STC.lazy_) { error("lazy variable `%s` cannot be modified", var.toChars()); return new ErrorExp(); } if (var.ident == Id.ctfe) { error("cannot modify compiler-generated variable `__ctfe`"); return new ErrorExp(); } if (var.ident == Id.dollar) // https://issues.dlang.org/show_bug.cgi?id=13574 { error("cannot modify operator `$`"); return new ErrorExp(); } return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { //printf("VarExp::modifiableLvalue('%s')\n", var.toChars()); if (var.storage_class & STC.manifest) { error("cannot modify manifest constant `%s`", toChars()); return new ErrorExp(); } // See if this expression is a modifiable lvalue (i.e. not const) return Expression.modifiableLvalue(sc, e); } override void accept(Visitor v) { v.visit(this); } override Expression syntaxCopy() { auto ret = super.syntaxCopy(); return ret; } } /*********************************************************** * Overload Set */ extern (C++) final class OverExp : Expression { OverloadSet vars; extern (D) this(const ref Loc loc, OverloadSet s) { super(loc, TOK.overloadSet, __traits(classInstanceSize, OverExp)); //printf("OverExp(this = %p, '%s')\n", this, var.toChars()); vars = s; type = Type.tvoid; } override bool isLvalue() { return true; } override Expression toLvalue(Scope* sc, Expression e) { return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Function/Delegate literal */ extern (C++) final class FuncExp : Expression { FuncLiteralDeclaration fd; TemplateDeclaration td; TOK tok; extern (D) this(const ref Loc loc, Dsymbol s) { super(loc, TOK.function_, __traits(classInstanceSize, FuncExp)); this.td = s.isTemplateDeclaration(); this.fd = s.isFuncLiteralDeclaration(); if (td) { assert(td.literal); assert(td.members && td.members.dim == 1); fd = (*td.members)[0].isFuncLiteralDeclaration(); } tok = fd.tok; // save original kind of function/delegate/(infer) assert(fd.fbody); } override bool equals(RootObject o) { if (this == o) return true; auto e = o.isExpression(); if (!e) return false; if (auto fe = e.isFuncExp()) { return fd == fe.fd; } return false; } extern (D) void genIdent(Scope* sc) { if (fd.ident == Id.empty) { const(char)* s; if (fd.fes) s = "__foreachbody"; else if (fd.tok == TOK.reserved) s = "__lambda"; else if (fd.tok == TOK.delegate_) s = "__dgliteral"; else s = "__funcliteral"; DsymbolTable symtab; if (FuncDeclaration func = sc.parent.isFuncDeclaration()) { if (func.localsymtab is null) { // Inside template constraint, symtab is not set yet. // Initialize it lazily. func.localsymtab = new DsymbolTable(); } symtab = func.localsymtab; } else { ScopeDsymbol sds = sc.parent.isScopeDsymbol(); if (!sds.symtab) { // Inside template constraint, symtab may not be set yet. // Initialize it lazily. assert(sds.isTemplateInstance()); sds.symtab = new DsymbolTable(); } symtab = sds.symtab; } assert(symtab); Identifier id = Identifier.generateId(s, symtab.len() + 1); fd.ident = id; if (td) td.ident = id; symtab.insert(td ? cast(Dsymbol)td : cast(Dsymbol)fd); } } override Expression syntaxCopy() { if (td) return new FuncExp(loc, td.syntaxCopy(null)); else if (fd.semanticRun == PASS.init) return new FuncExp(loc, fd.syntaxCopy(null)); else // https://issues.dlang.org/show_bug.cgi?id=13481 // Prevent multiple semantic analysis of lambda body. return new FuncExp(loc, fd); } extern (D) MATCH matchType(Type to, Scope* sc, FuncExp* presult, int flag = 0) { //printf("FuncExp::matchType('%s'), to=%s\n", type ? type.toChars() : "null", to.toChars()); if (presult) *presult = null; TypeFunction tof = null; if (to.ty == Tdelegate) { if (tok == TOK.function_) { if (!flag) error("cannot match function literal to delegate type `%s`", to.toChars()); return MATCH.nomatch; } tof = cast(TypeFunction)to.nextOf(); } else if (to.ty == Tpointer && (tof = to.nextOf().isTypeFunction()) !is null) { if (tok == TOK.delegate_) { if (!flag) error("cannot match delegate literal to function pointer type `%s`", to.toChars()); return MATCH.nomatch; } } if (td) { if (!tof) { L1: if (!flag) error("cannot infer parameter types from `%s`", to.toChars()); return MATCH.nomatch; } // Parameter types inference from 'tof' assert(td._scope); TypeFunction tf = fd.type.isTypeFunction(); //printf("\ttof = %s\n", tof.toChars()); //printf("\ttf = %s\n", tf.toChars()); size_t dim = tf.parameterList.length; if (tof.parameterList.length != dim || tof.parameterList.varargs != tf.parameterList.varargs) goto L1; auto tiargs = new Objects(); tiargs.reserve(td.parameters.dim); foreach (tp; *td.parameters) { size_t u = 0; for (; u < dim; u++) { Parameter p = tf.parameterList[u]; if (auto ti = p.type.isTypeIdentifier()) if (ti && ti.ident == tp.ident) { break; } } assert(u < dim); Parameter pto = tof.parameterList[u]; Type t = pto.type; if (t.ty == Terror) goto L1; tiargs.push(t); } // Set target of return type inference if (!tf.next && tof.next) fd.treq = to; auto ti = new TemplateInstance(loc, td, tiargs); Expression ex = (new ScopeExp(loc, ti)).expressionSemantic(td._scope); // Reset inference target for the later re-semantic fd.treq = null; if (ex.op == TOK.error) return MATCH.nomatch; if (auto ef = ex.isFuncExp()) return ef.matchType(to, sc, presult, flag); else goto L1; } if (!tof || !tof.next) return MATCH.nomatch; assert(type && type != Type.tvoid); if (fd.type.ty == Terror) return MATCH.nomatch; auto tfx = fd.type.isTypeFunction(); bool convertMatch = (type.ty != to.ty); if (fd.inferRetType && tfx.next.implicitConvTo(tof.next) == MATCH.convert) { /* If return type is inferred and covariant return, * tweak return statements to required return type. * * interface I {} * class C : Object, I{} * * I delegate() dg = delegate() { return new class C(); } */ convertMatch = true; auto tfy = new TypeFunction(tfx.parameterList, tof.next, tfx.linkage, STC.undefined_); tfy.mod = tfx.mod; tfy.isnothrow = tfx.isnothrow; tfy.isnogc = tfx.isnogc; tfy.purity = tfx.purity; tfy.isproperty = tfx.isproperty; tfy.isref = tfx.isref; tfy.iswild = tfx.iswild; tfy.deco = tfy.merge().deco; tfx = tfy; } Type tx; if (tok == TOK.delegate_ || tok == TOK.reserved && (type.ty == Tdelegate || type.ty == Tpointer && to.ty == Tdelegate)) { // Allow conversion from implicit function pointer to delegate tx = new TypeDelegate(tfx); tx.deco = tx.merge().deco; } else { assert(tok == TOK.function_ || tok == TOK.reserved && type.ty == Tpointer); tx = tfx.pointerTo(); } //printf("\ttx = %s, to = %s\n", tx.toChars(), to.toChars()); MATCH m = tx.implicitConvTo(to); if (m > MATCH.nomatch) { // MATCH.exact: exact type match // MATCH.constant: covairiant type match (eg. attributes difference) // MATCH.convert: context conversion m = convertMatch ? MATCH.convert : tx.equals(to) ? MATCH.exact : MATCH.constant; if (presult) { (*presult) = cast(FuncExp)copy(); (*presult).type = to; // https://issues.dlang.org/show_bug.cgi?id=12508 // Tweak function body for covariant returns. (*presult).fd.modifyReturns(sc, tof.next); } } else if (!flag) { auto ts = toAutoQualChars(tx, to); error("cannot implicitly convert expression `%s` of type `%s` to `%s`", toChars(), ts[0], ts[1]); } return m; } override const(char)* toChars() { return fd.toChars(); } override bool checkType() { if (td) { error("template lambda has no type"); return true; } return false; } override bool checkValue() { if (td) { error("template lambda has no value"); return true; } return false; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Declaration of a symbol * * D grammar allows declarations only as statements. However in AST representation * it can be part of any expression. This is used, for example, during internal * syntax re-writes to inject hidden symbols. */ extern (C++) final class DeclarationExp : Expression { Dsymbol declaration; extern (D) this(const ref Loc loc, Dsymbol declaration) { super(loc, TOK.declaration, __traits(classInstanceSize, DeclarationExp)); this.declaration = declaration; } override Expression syntaxCopy() { return new DeclarationExp(loc, declaration.syntaxCopy(null)); } override bool hasCode() { if (auto vd = declaration.isVarDeclaration()) { return !(vd.storage_class & (STC.manifest | STC.static_)); } return false; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * typeid(int) */ extern (C++) final class TypeidExp : Expression { RootObject obj; extern (D) this(const ref Loc loc, RootObject o) { super(loc, TOK.typeid_, __traits(classInstanceSize, TypeidExp)); this.obj = o; } override Expression syntaxCopy() { return new TypeidExp(loc, objectSyntaxCopy(obj)); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * __traits(identifier, args...) */ extern (C++) final class TraitsExp : Expression { Identifier ident; Objects* args; extern (D) this(const ref Loc loc, Identifier ident, Objects* args) { super(loc, TOK.traits, __traits(classInstanceSize, TraitsExp)); this.ident = ident; this.args = args; } override Expression syntaxCopy() { return new TraitsExp(loc, ident, TemplateInstance.arraySyntaxCopy(args)); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class HaltExp : Expression { extern (D) this(const ref Loc loc) { super(loc, TOK.halt, __traits(classInstanceSize, HaltExp)); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * is(targ id tok tspec) * is(targ id == tok2) */ extern (C++) final class IsExp : Expression { Type targ; Identifier id; // can be null Type tspec; // can be null TemplateParameters* parameters; TOK tok; // ':' or '==' TOK tok2; // 'struct', 'union', etc. extern (D) this(const ref Loc loc, Type targ, Identifier id, TOK tok, Type tspec, TOK tok2, TemplateParameters* parameters) { super(loc, TOK.is_, __traits(classInstanceSize, IsExp)); this.targ = targ; this.id = id; this.tok = tok; this.tspec = tspec; this.tok2 = tok2; this.parameters = parameters; } override Expression syntaxCopy() { // This section is identical to that in TemplateDeclaration::syntaxCopy() TemplateParameters* p = null; if (parameters) { p = new TemplateParameters(parameters.dim); foreach (i, el; *parameters) (*p)[i] = el.syntaxCopy(); } return new IsExp(loc, targ.syntaxCopy(), id, tok, tspec ? tspec.syntaxCopy() : null, tok2, p); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) abstract class UnaExp : Expression { Expression e1; Type att1; // Save alias this type to detect recursion extern (D) this(const ref Loc loc, TOK op, int size, Expression e1) { super(loc, op, size); this.e1 = e1; } override Expression syntaxCopy() { UnaExp e = cast(UnaExp)copy(); e.type = null; e.e1 = e.e1.syntaxCopy(); return e; } /******************************** * The type for a unary expression is incompatible. * Print error message. * Returns: * ErrorExp */ final Expression incompatibleTypes() { if (e1.type.toBasetype() == Type.terror) return e1; if (e1.op == TOK.type) { error("incompatible type for `%s(%s)`: cannot use `%s` with types", Token.toChars(op), e1.toChars(), Token.toChars(op)); } else { error("incompatible type for `%s(%s)`: `%s`", Token.toChars(op), e1.toChars(), e1.type.toChars()); } return new ErrorExp(); } /********************* * Mark the operand as will never be dereferenced, * which is useful info for @safe checks. * Do before semantic() on operands rewrites them. */ final void setNoderefOperand() { if (auto edi = e1.isDotIdExp()) edi.noderef = true; } override final Expression resolveLoc(const ref Loc loc, Scope* sc) { e1 = e1.resolveLoc(loc, sc); return this; } override void accept(Visitor v) { v.visit(this); } } alias fp_t = UnionExp function(const ref Loc loc, Type, Expression, Expression); alias fp2_t = int function(const ref Loc loc, TOK, Expression, Expression); /*********************************************************** */ extern (C++) abstract class BinExp : Expression { Expression e1; Expression e2; Type att1; // Save alias this type to detect recursion Type att2; // Save alias this type to detect recursion extern (D) this(const ref Loc loc, TOK op, int size, Expression e1, Expression e2) { super(loc, op, size); this.e1 = e1; this.e2 = e2; } override Expression syntaxCopy() { BinExp e = cast(BinExp)copy(); e.type = null; e.e1 = e.e1.syntaxCopy(); e.e2 = e.e2.syntaxCopy(); return e; } /******************************** * The types for a binary expression are incompatible. * Print error message. * Returns: * ErrorExp */ final Expression incompatibleTypes() { if (e1.type.toBasetype() == Type.terror) return e1; if (e2.type.toBasetype() == Type.terror) return e2; // CondExp uses 'a ? b : c' but we're comparing 'b : c' TOK thisOp = (op == TOK.question) ? TOK.colon : op; if (e1.op == TOK.type || e2.op == TOK.type) { error("incompatible types for `(%s) %s (%s)`: cannot use `%s` with types", e1.toChars(), Token.toChars(thisOp), e2.toChars(), Token.toChars(op)); } else if (e1.type.equals(e2.type)) { error("incompatible types for `(%s) %s (%s)`: both operands are of type `%s`", e1.toChars(), Token.toChars(thisOp), e2.toChars(), e1.type.toChars()); } else { auto ts = toAutoQualChars(e1.type, e2.type); error("incompatible types for `(%s) %s (%s)`: `%s` and `%s`", e1.toChars(), Token.toChars(thisOp), e2.toChars(), ts[0], ts[1]); } return new ErrorExp(); } extern (D) final Expression checkOpAssignTypes(Scope* sc) { // At that point t1 and t2 are the merged types. type is the original type of the lhs. Type t1 = e1.type; Type t2 = e2.type; // T opAssign floating yields a floating. Prevent truncating conversions (float to int). // See issue 3841. // Should we also prevent double to float (type.isfloating() && type.size() < t2.size()) ? if (op == TOK.addAssign || op == TOK.minAssign || op == TOK.mulAssign || op == TOK.divAssign || op == TOK.modAssign || op == TOK.powAssign) { if ((type.isintegral() && t2.isfloating())) { warning("`%s %s %s` is performing truncating conversion", type.toChars(), Token.toChars(op), t2.toChars()); } } // generate an error if this is a nonsensical *=,/=, or %=, eg real *= imaginary if (op == TOK.mulAssign || op == TOK.divAssign || op == TOK.modAssign) { // Any multiplication by an imaginary or complex number yields a complex result. // r *= c, i*=c, r*=i, i*=i are all forbidden operations. const(char)* opstr = Token.toChars(op); if (t1.isreal() && t2.iscomplex()) { error("`%s %s %s` is undefined. Did you mean `%s %s %s.re`?", t1.toChars(), opstr, t2.toChars(), t1.toChars(), opstr, t2.toChars()); return new ErrorExp(); } else if (t1.isimaginary() && t2.iscomplex()) { error("`%s %s %s` is undefined. Did you mean `%s %s %s.im`?", t1.toChars(), opstr, t2.toChars(), t1.toChars(), opstr, t2.toChars()); return new ErrorExp(); } else if ((t1.isreal() || t1.isimaginary()) && t2.isimaginary()) { error("`%s %s %s` is an undefined operation", t1.toChars(), opstr, t2.toChars()); return new ErrorExp(); } } // generate an error if this is a nonsensical += or -=, eg real += imaginary if (op == TOK.addAssign || op == TOK.minAssign) { // Addition or subtraction of a real and an imaginary is a complex result. // Thus, r+=i, r+=c, i+=r, i+=c are all forbidden operations. if ((t1.isreal() && (t2.isimaginary() || t2.iscomplex())) || (t1.isimaginary() && (t2.isreal() || t2.iscomplex()))) { error("`%s %s %s` is undefined (result is complex)", t1.toChars(), Token.toChars(op), t2.toChars()); return new ErrorExp(); } if (type.isreal() || type.isimaginary()) { assert(global.errors || t2.isfloating()); e2 = e2.castTo(sc, t1); } } if (op == TOK.mulAssign) { if (t2.isfloating()) { if (t1.isreal()) { if (t2.isimaginary() || t2.iscomplex()) { e2 = e2.castTo(sc, t1); } } else if (t1.isimaginary()) { if (t2.isimaginary() || t2.iscomplex()) { switch (t1.ty) { case Timaginary32: t2 = Type.tfloat32; break; case Timaginary64: t2 = Type.tfloat64; break; case Timaginary80: t2 = Type.tfloat80; break; default: assert(0); } e2 = e2.castTo(sc, t2); } } } } else if (op == TOK.divAssign) { if (t2.isimaginary()) { if (t1.isreal()) { // x/iv = i(-x/v) // Therefore, the result is 0 e2 = new CommaExp(loc, e2, new RealExp(loc, CTFloat.zero, t1)); e2.type = t1; Expression e = new AssignExp(loc, e1, e2); e.type = t1; return e; } else if (t1.isimaginary()) { Type t3; switch (t1.ty) { case Timaginary32: t3 = Type.tfloat32; break; case Timaginary64: t3 = Type.tfloat64; break; case Timaginary80: t3 = Type.tfloat80; break; default: assert(0); } e2 = e2.castTo(sc, t3); Expression e = new AssignExp(loc, e1, e2); e.type = t1; return e; } } } else if (op == TOK.modAssign) { if (t2.iscomplex()) { error("cannot perform modulo complex arithmetic"); return new ErrorExp(); } } return this; } extern (D) final bool checkIntegralBin() { bool r1 = e1.checkIntegral(); bool r2 = e2.checkIntegral(); return (r1 || r2); } extern (D) final bool checkArithmeticBin() { bool r1 = e1.checkArithmetic(); bool r2 = e2.checkArithmetic(); return (r1 || r2); } /********************* * Mark the operands as will never be dereferenced, * which is useful info for @safe checks. * Do before semantic() on operands rewrites them. */ final void setNoderefOperands() { if (auto edi = e1.isDotIdExp()) edi.noderef = true; if (auto edi = e2.isDotIdExp()) edi.noderef = true; } final Expression reorderSettingAAElem(Scope* sc) { BinExp be = this; auto ie = be.e1.isIndexExp(); if (!ie) return be; if (ie.e1.type.toBasetype().ty != Taarray) return be; /* Fix evaluation order of setting AA element * https://issues.dlang.org/show_bug.cgi?id=3825 * Rewrite: * aa[k1][k2][k3] op= val; * as: * auto ref __aatmp = aa; * auto ref __aakey3 = k1, __aakey2 = k2, __aakey1 = k3; * auto ref __aaval = val; * __aatmp[__aakey3][__aakey2][__aakey1] op= __aaval; // assignment */ Expression e0; while (1) { Expression de; ie.e2 = extractSideEffect(sc, "__aakey", de, ie.e2); e0 = Expression.combine(de, e0); auto ie1 = ie.e1.isIndexExp(); if (!ie1 || ie1.e1.type.toBasetype().ty != Taarray) { break; } ie = ie1; } assert(ie.e1.type.toBasetype().ty == Taarray); Expression de; ie.e1 = extractSideEffect(sc, "__aatmp", de, ie.e1); e0 = Expression.combine(de, e0); be.e2 = extractSideEffect(sc, "__aaval", e0, be.e2, true); //printf("-e0 = %s, be = %s\n", e0.toChars(), be.toChars()); return Expression.combine(e0, be); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) class BinAssignExp : BinExp { extern (D) this(const ref Loc loc, TOK op, int size, Expression e1, Expression e2) { super(loc, op, size, e1, e2); } override final bool isLvalue() { return true; } override final Expression toLvalue(Scope* sc, Expression ex) { // Lvalue-ness will be handled in glue layer. return this; } override final Expression modifiableLvalue(Scope* sc, Expression e) { // should check e1.checkModifiable() ? return toLvalue(sc, this); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * https://dlang.org/spec/expression.html#mixin_expressions */ extern (C++) final class CompileExp : Expression { Expressions* exps; extern (D) this(const ref Loc loc, Expressions* exps) { super(loc, TOK.mixin_, __traits(classInstanceSize, CompileExp)); this.exps = exps; } override Expression syntaxCopy() { return new CompileExp(loc, arraySyntaxCopy(exps)); } override bool equals(RootObject o) { if (this == o) return true; auto e = o.isExpression(); if (!e) return false; if (auto ce = e.isCompileExp()) { if (exps.dim != ce.exps.dim) return false; foreach (i, e1; *exps) { Expression e2 = (*ce.exps)[i]; if (e1 != e2 && (!e1 || !e2 || !e1.equals(e2))) return false; } return true; } return false; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ImportExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.import_, __traits(classInstanceSize, ImportExp), e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * https://dlang.org/spec/expression.html#assert_expressions */ extern (C++) final class AssertExp : UnaExp { Expression msg; extern (D) this(const ref Loc loc, Expression e, Expression msg = null) { super(loc, TOK.assert_, __traits(classInstanceSize, AssertExp), e); this.msg = msg; } override Expression syntaxCopy() { return new AssertExp(loc, e1.syntaxCopy(), msg ? msg.syntaxCopy() : null); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DotIdExp : UnaExp { Identifier ident; bool noderef; // true if the result of the expression will never be dereferenced bool wantsym; // do not replace Symbol with its initializer during semantic() extern (D) this(const ref Loc loc, Expression e, Identifier ident) { super(loc, TOK.dotIdentifier, __traits(classInstanceSize, DotIdExp), e); this.ident = ident; } static DotIdExp create(Loc loc, Expression e, Identifier ident) { return new DotIdExp(loc, e, ident); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Mainly just a placeholder */ extern (C++) final class DotTemplateExp : UnaExp { TemplateDeclaration td; extern (D) this(const ref Loc loc, Expression e, TemplateDeclaration td) { super(loc, TOK.dotTemplateDeclaration, __traits(classInstanceSize, DotTemplateExp), e); this.td = td; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DotVarExp : UnaExp { Declaration var; bool hasOverloads; extern (D) this(const ref Loc loc, Expression e, Declaration var, bool hasOverloads = true) { if (var.isVarDeclaration()) hasOverloads = false; super(loc, TOK.dotVariable, __traits(classInstanceSize, DotVarExp), e); //printf("DotVarExp()\n"); this.var = var; this.hasOverloads = hasOverloads; } override int checkModifiable(Scope* sc, int flag) { //printf("DotVarExp::checkModifiable %s %s\n", toChars(), type.toChars()); if (checkUnsafeAccess(sc, this, false, !flag)) return 2; if (e1.op == TOK.this_) return var.checkModify(loc, sc, e1, flag); /* https://issues.dlang.org/show_bug.cgi?id=12764 * If inside a constructor and an expression of type `this.field.var` * is encountered, where `field` is a struct declaration with * default construction disabled, we must make sure that * assigning to `var` does not imply that `field` was initialized */ if (sc.func && sc.func.isCtorDeclaration()) { // if inside a constructor scope and e1 of this DotVarExp // is a DotVarExp, then check if e1.e1 is a `this` identifier if (auto dve = e1.isDotVarExp()) { if (dve.e1.op == TOK.this_) { scope v = dve.var.isVarDeclaration(); /* if v is a struct member field with no initializer, no default construction * and v wasn't intialized before */ if (v && v.isField() && !v._init && !v.ctorinit) { if (auto ts = v.type.isTypeStruct()) { if (ts.sym.noDefaultCtor) { /* checkModify will consider that this is an initialization * of v while it is actually an assignment of a field of v */ scope modifyLevel = v.checkModify(loc, sc, dve.e1, flag); // reflect that assigning a field of v is not initialization of v v.ctorinit = false; if (modifyLevel == 2) return 1; return modifyLevel; } } } } } } //printf("\te1 = %s\n", e1.toChars()); return e1.checkModifiable(sc, flag); } override bool isLvalue() { return true; } override Expression toLvalue(Scope* sc, Expression e) { //printf("DotVarExp::toLvalue(%s)\n", toChars()); if (e1.op == TOK.this_ && sc.ctorflow.fieldinit.length && !(sc.ctorflow.callSuper & CSX.any_ctor)) { if (VarDeclaration vd = var.isVarDeclaration()) { auto ad = vd.isMember2(); if (ad && ad.fields.dim == sc.ctorflow.fieldinit.length) { foreach (i, f; ad.fields) { if (f == vd) { if (!(sc.ctorflow.fieldinit[i].csx & CSX.this_ctor)) { /* If the address of vd is taken, assume it is thereby initialized * https://issues.dlang.org/show_bug.cgi?id=15869 */ modifyFieldVar(loc, sc, vd, e1); } break; } } } } } return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { version (none) { printf("DotVarExp::modifiableLvalue(%s)\n", toChars()); printf("e1.type = %s\n", e1.type.toChars()); printf("var.type = %s\n", var.type.toChars()); } return Expression.modifiableLvalue(sc, e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * foo.bar!(args) */ extern (C++) final class DotTemplateInstanceExp : UnaExp { TemplateInstance ti; extern (D) this(const ref Loc loc, Expression e, Identifier name, Objects* tiargs) { super(loc, TOK.dotTemplateInstance, __traits(classInstanceSize, DotTemplateInstanceExp), e); //printf("DotTemplateInstanceExp()\n"); this.ti = new TemplateInstance(loc, name, tiargs); } extern (D) this(const ref Loc loc, Expression e, TemplateInstance ti) { super(loc, TOK.dotTemplateInstance, __traits(classInstanceSize, DotTemplateInstanceExp), e); this.ti = ti; } override Expression syntaxCopy() { return new DotTemplateInstanceExp(loc, e1.syntaxCopy(), ti.name, TemplateInstance.arraySyntaxCopy(ti.tiargs)); } bool findTempDecl(Scope* sc) { static if (LOGSEMANTIC) { printf("DotTemplateInstanceExp::findTempDecl('%s')\n", toChars()); } if (ti.tempdecl) return true; Expression e = new DotIdExp(loc, e1, ti.name); e = e.expressionSemantic(sc); if (e.op == TOK.dot) e = (cast(DotExp)e).e2; Dsymbol s = null; switch (e.op) { case TOK.overloadSet: s = (cast(OverExp)e).vars; break; case TOK.dotTemplateDeclaration: s = (cast(DotTemplateExp)e).td; break; case TOK.scope_: s = (cast(ScopeExp)e).sds; break; case TOK.dotVariable: s = (cast(DotVarExp)e).var; break; case TOK.variable: s = (cast(VarExp)e).var; break; default: return false; } return ti.updateTempDecl(sc, s); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DelegateExp : UnaExp { FuncDeclaration func; bool hasOverloads; extern (D) this(const ref Loc loc, Expression e, FuncDeclaration f, bool hasOverloads = true) { super(loc, TOK.delegate_, __traits(classInstanceSize, DelegateExp), e); this.func = f; this.hasOverloads = hasOverloads; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DotTypeExp : UnaExp { Dsymbol sym; // symbol that represents a type extern (D) this(const ref Loc loc, Expression e, Dsymbol s) { super(loc, TOK.dotType, __traits(classInstanceSize, DotTypeExp), e); this.sym = s; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class CallExp : UnaExp { Expressions* arguments; // function arguments FuncDeclaration f; // symbol to call bool directcall; // true if a virtual call is devirtualized extern (D) this(const ref Loc loc, Expression e, Expressions* exps) { super(loc, TOK.call, __traits(classInstanceSize, CallExp), e); this.arguments = exps; } extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.call, __traits(classInstanceSize, CallExp), e); } extern (D) this(const ref Loc loc, Expression e, Expression earg1) { super(loc, TOK.call, __traits(classInstanceSize, CallExp), e); this.arguments = new Expressions(); if (earg1) this.arguments.push(earg1); } extern (D) this(const ref Loc loc, Expression e, Expression earg1, Expression earg2) { super(loc, TOK.call, __traits(classInstanceSize, CallExp), e); auto arguments = new Expressions(2); (*arguments)[0] = earg1; (*arguments)[1] = earg2; this.arguments = arguments; } /*********************************************************** * Instatiates a new function call expression * Params: * loc = location * fd = the declaration of the function to call * earg1 = the function argument */ extern(D) this(const ref Loc loc, FuncDeclaration fd, Expression earg1) { this(loc, new VarExp(loc, fd, false), earg1); this.f = fd; } static CallExp create(Loc loc, Expression e, Expressions* exps) { return new CallExp(loc, e, exps); } static CallExp create(Loc loc, Expression e) { return new CallExp(loc, e); } static CallExp create(Loc loc, Expression e, Expression earg1) { return new CallExp(loc, e, earg1); } /*********************************************************** * Creates a new function call expression * Params: * loc = location * fd = the declaration of the function to call * earg1 = the function argument */ static CallExp create(Loc loc, FuncDeclaration fd, Expression earg1) { return new CallExp(loc, fd, earg1); } override Expression syntaxCopy() { return new CallExp(loc, e1.syntaxCopy(), arraySyntaxCopy(arguments)); } override bool isLvalue() { Type tb = e1.type.toBasetype(); if (tb.ty == Tdelegate || tb.ty == Tpointer) tb = tb.nextOf(); auto tf = tb.isTypeFunction(); if (tf && tf.isref) { if (auto dve = e1.isDotVarExp()) if (dve.var.isCtorDeclaration()) return false; return true; // function returns a reference } return false; } override Expression toLvalue(Scope* sc, Expression e) { if (isLvalue()) return this; return Expression.toLvalue(sc, e); } override Expression addDtorHook(Scope* sc) { /* Only need to add dtor hook if it's a type that needs destruction. * Use same logic as VarDeclaration::callScopeDtor() */ if (auto tf = e1.type.isTypeFunction()) { if (tf.isref) return this; } Type tv = type.baseElemOf(); if (auto ts = tv.isTypeStruct()) { StructDeclaration sd = ts.sym; if (sd.dtor) { /* Type needs destruction, so declare a tmp * which the back end will recognize and call dtor on */ auto tmp = copyToTemp(0, "__tmpfordtor", this); auto de = new DeclarationExp(loc, tmp); auto ve = new VarExp(loc, tmp); Expression e = new CommaExp(loc, de, ve); e = e.expressionSemantic(sc); return e; } } return this; } override void accept(Visitor v) { v.visit(this); } } FuncDeclaration isFuncAddress(Expression e, bool* hasOverloads = null) { if (auto ae = e.isAddrExp()) { auto ae1 = ae.e1; if (auto ve = ae1.isVarExp()) { if (hasOverloads) *hasOverloads = ve.hasOverloads; return ve.var.isFuncDeclaration(); } if (auto dve = ae1.isDotVarExp()) { if (hasOverloads) *hasOverloads = dve.hasOverloads; return dve.var.isFuncDeclaration(); } } else { if (auto soe = e.isSymOffExp()) { if (hasOverloads) *hasOverloads = soe.hasOverloads; return soe.var.isFuncDeclaration(); } if (auto dge = e.isDelegateExp()) { if (hasOverloads) *hasOverloads = dge.hasOverloads; return dge.func.isFuncDeclaration(); } } return null; } /*********************************************************** */ extern (C++) final class AddrExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.address, __traits(classInstanceSize, AddrExp), e); } extern (D) this(const ref Loc loc, Expression e, Type t) { this(loc, e); type = t; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class PtrExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.star, __traits(classInstanceSize, PtrExp), e); //if (e.type) // type = ((TypePointer *)e.type).next; } extern (D) this(const ref Loc loc, Expression e, Type t) { super(loc, TOK.star, __traits(classInstanceSize, PtrExp), e); type = t; } override int checkModifiable(Scope* sc, int flag) { if (auto se = e1.isSymOffExp()) { return se.var.checkModify(loc, sc, null, flag); } else if (auto ae = e1.isAddrExp()) { return ae.e1.checkModifiable(sc, flag); } return 1; } override bool isLvalue() { return true; } override Expression toLvalue(Scope* sc, Expression e) { return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { //printf("PtrExp::modifiableLvalue() %s, type %s\n", toChars(), type.toChars()); return Expression.modifiableLvalue(sc, e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class NegExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.negate, __traits(classInstanceSize, NegExp), e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class UAddExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.uadd, __traits(classInstanceSize, UAddExp), e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ComExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.tilde, __traits(classInstanceSize, ComExp), e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class NotExp : UnaExp { extern (D) this(const ref Loc loc, Expression e) { super(loc, TOK.not, __traits(classInstanceSize, NotExp), e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DeleteExp : UnaExp { bool isRAII; // true if called automatically as a result of scoped destruction extern (D) this(const ref Loc loc, Expression e, bool isRAII) { super(loc, TOK.delete_, __traits(classInstanceSize, DeleteExp), e); this.isRAII = isRAII; } override Expression toBoolean(Scope* sc) { error("`delete` does not give a boolean result"); return new ErrorExp(); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * Possible to cast to one type while painting to another type */ extern (C++) final class CastExp : UnaExp { Type to; // type to cast to ubyte mod = cast(ubyte)~0; // MODxxxxx extern (D) this(const ref Loc loc, Expression e, Type t) { super(loc, TOK.cast_, __traits(classInstanceSize, CastExp), e); this.to = t; } /* For cast(const) and cast(immutable) */ extern (D) this(const ref Loc loc, Expression e, ubyte mod) { super(loc, TOK.cast_, __traits(classInstanceSize, CastExp), e); this.mod = mod; } override Expression syntaxCopy() { return to ? new CastExp(loc, e1.syntaxCopy(), to.syntaxCopy()) : new CastExp(loc, e1.syntaxCopy(), mod); } override Expression addDtorHook(Scope* sc) { if (to.toBasetype().ty == Tvoid) // look past the cast(void) e1 = e1.addDtorHook(sc); return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class VectorExp : UnaExp { TypeVector to; // the target vector type before semantic() uint dim = ~0; // number of elements in the vector OwnedBy ownedByCtfe = OwnedBy.code; extern (D) this(const ref Loc loc, Expression e, Type t) { super(loc, TOK.vector, __traits(classInstanceSize, VectorExp), e); assert(t.ty == Tvector); to = cast(TypeVector)t; } static VectorExp create(Loc loc, Expression e, Type t) { return new VectorExp(loc, e, t); } // Same as create, but doesn't allocate memory. static void emplace(UnionExp* pue, Loc loc, Expression e, Type type) { emplaceExp!(VectorExp)(pue, loc, e, type); } override Expression syntaxCopy() { return new VectorExp(loc, e1.syntaxCopy(), to.syntaxCopy()); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * e1.array property for vectors. * * https://dlang.org/spec/simd.html#properties */ extern (C++) final class VectorArrayExp : UnaExp { extern (D) this(const ref Loc loc, Expression e1) { super(loc, TOK.vectorArray, __traits(classInstanceSize, VectorArrayExp), e1); } override bool isLvalue() { return e1.isLvalue(); } override Expression toLvalue(Scope* sc, Expression e) { e1 = e1.toLvalue(sc, e); return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * e1 [lwr .. upr] * * http://dlang.org/spec/expression.html#slice_expressions */ extern (C++) final class SliceExp : UnaExp { Expression upr; // null if implicit 0 Expression lwr; // null if implicit [length - 1] VarDeclaration lengthVar; bool upperIsInBounds; // true if upr <= e1.length bool lowerIsLessThanUpper; // true if lwr <= upr bool arrayop; // an array operation, rather than a slice /************************************************************/ extern (D) this(const ref Loc loc, Expression e1, IntervalExp ie) { super(loc, TOK.slice, __traits(classInstanceSize, SliceExp), e1); this.upr = ie ? ie.upr : null; this.lwr = ie ? ie.lwr : null; } extern (D) this(const ref Loc loc, Expression e1, Expression lwr, Expression upr) { super(loc, TOK.slice, __traits(classInstanceSize, SliceExp), e1); this.upr = upr; this.lwr = lwr; } override Expression syntaxCopy() { auto se = new SliceExp(loc, e1.syntaxCopy(), lwr ? lwr.syntaxCopy() : null, upr ? upr.syntaxCopy() : null); se.lengthVar = this.lengthVar; // bug7871 return se; } override int checkModifiable(Scope* sc, int flag) { //printf("SliceExp::checkModifiable %s\n", toChars()); if (e1.type.ty == Tsarray || (e1.op == TOK.index && e1.type.ty != Tarray) || e1.op == TOK.slice) { return e1.checkModifiable(sc, flag); } return 1; } override bool isLvalue() { /* slice expression is rvalue in default, but * conversion to reference of static array is only allowed. */ return (type && type.toBasetype().ty == Tsarray); } override Expression toLvalue(Scope* sc, Expression e) { //printf("SliceExp::toLvalue(%s) type = %s\n", toChars(), type ? type.toChars() : NULL); return (type && type.toBasetype().ty == Tsarray) ? this : Expression.toLvalue(sc, e); } override Expression modifiableLvalue(Scope* sc, Expression e) { error("slice expression `%s` is not a modifiable lvalue", toChars()); return this; } override bool isBool(bool result) { return e1.isBool(result); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ArrayLengthExp : UnaExp { extern (D) this(const ref Loc loc, Expression e1) { super(loc, TOK.arrayLength, __traits(classInstanceSize, ArrayLengthExp), e1); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * e1 [ a0, a1, a2, a3 ,... ] * * http://dlang.org/spec/expression.html#index_expressions */ extern (C++) final class ArrayExp : UnaExp { Expressions* arguments; // Array of Expression's a0..an size_t currentDimension; // for opDollar VarDeclaration lengthVar; extern (D) this(const ref Loc loc, Expression e1, Expression index = null) { super(loc, TOK.array, __traits(classInstanceSize, ArrayExp), e1); arguments = new Expressions(); if (index) arguments.push(index); } extern (D) this(const ref Loc loc, Expression e1, Expressions* args) { super(loc, TOK.array, __traits(classInstanceSize, ArrayExp), e1); arguments = args; } override Expression syntaxCopy() { auto ae = new ArrayExp(loc, e1.syntaxCopy(), arraySyntaxCopy(arguments)); ae.lengthVar = this.lengthVar; // bug7871 return ae; } override bool isLvalue() { if (type && type.toBasetype().ty == Tvoid) return false; return true; } override Expression toLvalue(Scope* sc, Expression e) { if (type && type.toBasetype().ty == Tvoid) error("`void`s have no value"); return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DotExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.dot, __traits(classInstanceSize, DotExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class CommaExp : BinExp { /// This is needed because AssignExp rewrites CommaExp, hence it needs /// to trigger the deprecation. const bool isGenerated; /// Temporary variable to enable / disable deprecation of comma expression /// depending on the context. /// Since most constructor calls are rewritting, the only place where /// false will be passed will be from the parser. bool allowCommaExp; extern (D) this(const ref Loc loc, Expression e1, Expression e2, bool generated = true) { super(loc, TOK.comma, __traits(classInstanceSize, CommaExp), e1, e2); allowCommaExp = isGenerated = generated; } override int checkModifiable(Scope* sc, int flag) { return e2.checkModifiable(sc, flag); } override bool isLvalue() { return e2.isLvalue(); } override Expression toLvalue(Scope* sc, Expression e) { e2 = e2.toLvalue(sc, null); return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { e2 = e2.modifiableLvalue(sc, e); return this; } override bool isBool(bool result) { return e2.isBool(result); } override Expression toBoolean(Scope* sc) { auto ex2 = e2.toBoolean(sc); if (ex2.op == TOK.error) return ex2; e2 = ex2; type = e2.type; return this; } override Expression addDtorHook(Scope* sc) { e2 = e2.addDtorHook(sc); return this; } override void accept(Visitor v) { v.visit(this); } /** * If the argument is a CommaExp, set a flag to prevent deprecation messages * * It's impossible to know from CommaExp.semantic if the result will * be used, hence when there is a result (type != void), a deprecation * message is always emitted. * However, some construct can produce a result but won't use it * (ExpStatement and for loop increment). Those should call this function * to prevent unwanted deprecations to be emitted. * * Params: * exp = An expression that discards its result. * If the argument is null or not a CommaExp, nothing happens. */ static void allow(Expression exp) { if (exp) if (auto ce = exp.isCommaExp()) ce.allowCommaExp = true; } } /*********************************************************** * Mainly just a placeholder */ extern (C++) final class IntervalExp : Expression { Expression lwr; Expression upr; extern (D) this(const ref Loc loc, Expression lwr, Expression upr) { super(loc, TOK.interval, __traits(classInstanceSize, IntervalExp)); this.lwr = lwr; this.upr = upr; } override Expression syntaxCopy() { return new IntervalExp(loc, lwr.syntaxCopy(), upr.syntaxCopy()); } override void accept(Visitor v) { v.visit(this); } } extern (C++) final class DelegatePtrExp : UnaExp { extern (D) this(const ref Loc loc, Expression e1) { super(loc, TOK.delegatePointer, __traits(classInstanceSize, DelegatePtrExp), e1); } override bool isLvalue() { return e1.isLvalue(); } override Expression toLvalue(Scope* sc, Expression e) { e1 = e1.toLvalue(sc, e); return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { if (sc.func.setUnsafe()) { error("cannot modify delegate pointer in `@safe` code `%s`", toChars()); return new ErrorExp(); } return Expression.modifiableLvalue(sc, e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DelegateFuncptrExp : UnaExp { extern (D) this(const ref Loc loc, Expression e1) { super(loc, TOK.delegateFunctionPointer, __traits(classInstanceSize, DelegateFuncptrExp), e1); } override bool isLvalue() { return e1.isLvalue(); } override Expression toLvalue(Scope* sc, Expression e) { e1 = e1.toLvalue(sc, e); return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { if (sc.func.setUnsafe()) { error("cannot modify delegate function pointer in `@safe` code `%s`", toChars()); return new ErrorExp(); } return Expression.modifiableLvalue(sc, e); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * e1 [ e2 ] */ extern (C++) final class IndexExp : BinExp { VarDeclaration lengthVar; bool modifiable = false; // assume it is an rvalue bool indexIsInBounds; // true if 0 <= e2 && e2 <= e1.length - 1 extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.index, __traits(classInstanceSize, IndexExp), e1, e2); //printf("IndexExp::IndexExp('%s')\n", toChars()); } override Expression syntaxCopy() { auto ie = new IndexExp(loc, e1.syntaxCopy(), e2.syntaxCopy()); ie.lengthVar = this.lengthVar; // bug7871 return ie; } override int checkModifiable(Scope* sc, int flag) { if (e1.type.ty == Tsarray || e1.type.ty == Taarray || (e1.op == TOK.index && e1.type.ty != Tarray) || e1.op == TOK.slice) { return e1.checkModifiable(sc, flag); } return 1; } override bool isLvalue() { return true; } override Expression toLvalue(Scope* sc, Expression e) { return this; } override Expression modifiableLvalue(Scope* sc, Expression e) { //printf("IndexExp::modifiableLvalue(%s)\n", toChars()); Expression ex = markSettingAAElem(); if (ex.op == TOK.error) return ex; return Expression.modifiableLvalue(sc, e); } Expression markSettingAAElem() { if (e1.type.toBasetype().ty == Taarray) { Type t2b = e2.type.toBasetype(); if (t2b.ty == Tarray && t2b.nextOf().isMutable()) { error("associative arrays can only be assigned values with immutable keys, not `%s`", e2.type.toChars()); return new ErrorExp(); } modifiable = true; if (auto ie = e1.isIndexExp()) { Expression ex = ie.markSettingAAElem(); if (ex.op == TOK.error) return ex; assert(ex == e1); } } return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * For both i++ and i-- */ extern (C++) final class PostExp : BinExp { extern (D) this(TOK op, const ref Loc loc, Expression e) { super(loc, op, __traits(classInstanceSize, PostExp), e, new IntegerExp(loc, 1, Type.tint32)); assert(op == TOK.minusMinus || op == TOK.plusPlus); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * For both ++i and --i */ extern (C++) final class PreExp : UnaExp { extern (D) this(TOK op, const ref Loc loc, Expression e) { super(loc, op, __traits(classInstanceSize, PreExp), e); assert(op == TOK.preMinusMinus || op == TOK.prePlusPlus); } override void accept(Visitor v) { v.visit(this); } } enum MemorySet { blockAssign = 1, // setting the contents of an array referenceInit = 2, // setting the reference of STC.ref_ variable } /*********************************************************** */ extern (C++) class AssignExp : BinExp { int memset; // combination of MemorySet flags /************************************************************/ /* op can be TOK.assign, TOK.construct, or TOK.blit */ extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.assign, __traits(classInstanceSize, AssignExp), e1, e2); } override final bool isLvalue() { // Array-op 'x[] = y[]' should make an rvalue. // Setting array length 'x.length = v' should make an rvalue. if (e1.op == TOK.slice || e1.op == TOK.arrayLength) { return false; } return true; } override final Expression toLvalue(Scope* sc, Expression ex) { if (e1.op == TOK.slice || e1.op == TOK.arrayLength) { return Expression.toLvalue(sc, ex); } /* In front-end level, AssignExp should make an lvalue of e1. * Taking the address of e1 will be handled in low level layer, * so this function does nothing. */ return this; } override final Expression toBoolean(Scope* sc) { // Things like: // if (a = b) ... // are usually mistakes. error("assignment cannot be used as a condition, perhaps `==` was meant?"); return new ErrorExp(); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ConstructExp : AssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, e1, e2); op = TOK.construct; } // Internal use only. If `v` is a reference variable, the assinment // will become a reference initialization automatically. extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) { auto ve = new VarExp(loc, v); assert(v.type && ve.type); super(loc, ve, e2); op = TOK.construct; if (v.storage_class & (STC.ref_ | STC.out_)) memset |= MemorySet.referenceInit; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class BlitExp : AssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, e1, e2); op = TOK.blit; } // Internal use only. If `v` is a reference variable, the assinment // will become a reference rebinding automatically. extern (D) this(const ref Loc loc, VarDeclaration v, Expression e2) { auto ve = new VarExp(loc, v); assert(v.type && ve.type); super(loc, ve, e2); op = TOK.blit; if (v.storage_class & (STC.ref_ | STC.out_)) memset |= MemorySet.referenceInit; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class AddAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.addAssign, __traits(classInstanceSize, AddAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class MinAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.minAssign, __traits(classInstanceSize, MinAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class MulAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.mulAssign, __traits(classInstanceSize, MulAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class DivAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.divAssign, __traits(classInstanceSize, DivAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ModAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.modAssign, __traits(classInstanceSize, ModAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class AndAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.andAssign, __traits(classInstanceSize, AndAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class OrAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.orAssign, __traits(classInstanceSize, OrAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class XorAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.xorAssign, __traits(classInstanceSize, XorAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class PowAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.powAssign, __traits(classInstanceSize, PowAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ShlAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.leftShiftAssign, __traits(classInstanceSize, ShlAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ShrAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.rightShiftAssign, __traits(classInstanceSize, ShrAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class UshrAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.unsignedRightShiftAssign, __traits(classInstanceSize, UshrAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * The ~= operator. It can have one of the following operators: * * TOK.concatenateAssign - appending T[] to T[] * TOK.concatenateElemAssign - appending T to T[] * TOK.concatenateDcharAssign - appending dchar to T[] * * The parser initially sets it to TOK.concatenateAssign, and semantic() later decides which * of the three it will be set to. */ extern (C++) final class CatAssignExp : BinAssignExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.concatenateAssign, __traits(classInstanceSize, CatAssignExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#add_expressions */ extern (C++) final class AddExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.add, __traits(classInstanceSize, AddExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class MinExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.min, __traits(classInstanceSize, MinExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#cat_expressions */ extern (C++) final class CatExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.concatenate, __traits(classInstanceSize, CatExp), e1, e2); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { e1 = e1.resolveLoc(loc, sc); e2 = e2.resolveLoc(loc, sc); return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#mul_expressions */ extern (C++) final class MulExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.mul, __traits(classInstanceSize, MulExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#mul_expressions */ extern (C++) final class DivExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.div, __traits(classInstanceSize, DivExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#mul_expressions */ extern (C++) final class ModExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.mod, __traits(classInstanceSize, ModExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#pow_expressions */ extern (C++) final class PowExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.pow, __traits(classInstanceSize, PowExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ShlExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.leftShift, __traits(classInstanceSize, ShlExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ShrExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.rightShift, __traits(classInstanceSize, ShrExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class UshrExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.unsignedRightShift, __traits(classInstanceSize, UshrExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class AndExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.and, __traits(classInstanceSize, AndExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class OrExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.or, __traits(classInstanceSize, OrExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class XorExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.xor, __traits(classInstanceSize, XorExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * http://dlang.org/spec/expression.html#andand_expressions * http://dlang.org/spec/expression.html#oror_expressions */ extern (C++) final class LogicalExp : BinExp { extern (D) this(const ref Loc loc, TOK op, Expression e1, Expression e2) { super(loc, op, __traits(classInstanceSize, LogicalExp), e1, e2); assert(op == TOK.andAnd || op == TOK.orOr); } override Expression toBoolean(Scope* sc) { auto ex2 = e2.toBoolean(sc); if (ex2.op == TOK.error) return ex2; e2 = ex2; return this; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * `op` is one of: * TOK.lessThan, TOK.lessOrEqual, TOK.greaterThan, TOK.greaterOrEqual * * http://dlang.org/spec/expression.html#relation_expressions */ extern (C++) final class CmpExp : BinExp { extern (D) this(TOK op, const ref Loc loc, Expression e1, Expression e2) { super(loc, op, __traits(classInstanceSize, CmpExp), e1, e2); assert(op == TOK.lessThan || op == TOK.lessOrEqual || op == TOK.greaterThan || op == TOK.greaterOrEqual); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class InExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.in_, __traits(classInstanceSize, InExp), e1, e2); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * This deletes the key e1 from the associative array e2 */ extern (C++) final class RemoveExp : BinExp { extern (D) this(const ref Loc loc, Expression e1, Expression e2) { super(loc, TOK.remove, __traits(classInstanceSize, RemoveExp), e1, e2); type = Type.tbool; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * `==` and `!=` * * TOK.equal and TOK.notEqual * * http://dlang.org/spec/expression.html#equality_expressions */ extern (C++) final class EqualExp : BinExp { extern (D) this(TOK op, const ref Loc loc, Expression e1, Expression e2) { super(loc, op, __traits(classInstanceSize, EqualExp), e1, e2); assert(op == TOK.equal || op == TOK.notEqual); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * `is` and `!is` * * TOK.identity and TOK.notIdentity * * http://dlang.org/spec/expression.html#identity_expressions */ extern (C++) final class IdentityExp : BinExp { extern (D) this(TOK op, const ref Loc loc, Expression e1, Expression e2) { super(loc, op, __traits(classInstanceSize, IdentityExp), e1, e2); assert(op == TOK.identity || op == TOK.notIdentity); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** * `econd ? e1 : e2` * * http://dlang.org/spec/expression.html#conditional_expressions */ extern (C++) final class CondExp : BinExp { Expression econd; extern (D) this(const ref Loc loc, Expression econd, Expression e1, Expression e2) { super(loc, TOK.question, __traits(classInstanceSize, CondExp), e1, e2); this.econd = econd; } override Expression syntaxCopy() { return new CondExp(loc, econd.syntaxCopy(), e1.syntaxCopy(), e2.syntaxCopy()); } override int checkModifiable(Scope* sc, int flag) { return e1.checkModifiable(sc, flag) && e2.checkModifiable(sc, flag); } override bool isLvalue() { return e1.isLvalue() && e2.isLvalue(); } override Expression toLvalue(Scope* sc, Expression ex) { // convert (econd ? e1 : e2) to *(econd ? &e1 : &e2) CondExp e = cast(CondExp)copy(); e.e1 = e1.toLvalue(sc, null).addressOf(); e.e2 = e2.toLvalue(sc, null).addressOf(); e.type = type.pointerTo(); return new PtrExp(loc, e, type); } override Expression modifiableLvalue(Scope* sc, Expression e) { //error("conditional expression %s is not a modifiable lvalue", toChars()); e1 = e1.modifiableLvalue(sc, e1); e2 = e2.modifiableLvalue(sc, e2); return toLvalue(sc, this); } override Expression toBoolean(Scope* sc) { auto ex1 = e1.toBoolean(sc); auto ex2 = e2.toBoolean(sc); if (ex1.op == TOK.error) return ex1; if (ex2.op == TOK.error) return ex2; e1 = ex1; e2 = ex2; return this; } void hookDtors(Scope* sc) { extern (C++) final class DtorVisitor : StoppableVisitor { alias visit = typeof(super).visit; public: Scope* sc; CondExp ce; VarDeclaration vcond; bool isThen; extern (D) this(Scope* sc, CondExp ce) { this.sc = sc; this.ce = ce; } override void visit(Expression e) { //printf("(e = %s)\n", e.toChars()); } override void visit(DeclarationExp e) { auto v = e.declaration.isVarDeclaration(); if (v && !v.isDataseg()) { if (v._init) { if (auto ei = v._init.isExpInitializer()) ei.exp.accept(this); } if (v.needsScopeDtor()) { if (!vcond) { vcond = copyToTemp(STC.volatile_, "__cond", ce.econd); vcond.dsymbolSemantic(sc); Expression de = new DeclarationExp(ce.econd.loc, vcond); de = de.expressionSemantic(sc); Expression ve = new VarExp(ce.econd.loc, vcond); ce.econd = Expression.combine(de, ve); } //printf("\t++v = %s, v.edtor = %s\n", v.toChars(), v.edtor.toChars()); Expression ve = new VarExp(vcond.loc, vcond); if (isThen) v.edtor = new LogicalExp(v.edtor.loc, TOK.andAnd, ve, v.edtor); else v.edtor = new LogicalExp(v.edtor.loc, TOK.orOr, ve, v.edtor); v.edtor = v.edtor.expressionSemantic(sc); //printf("\t--v = %s, v.edtor = %s\n", v.toChars(), v.edtor.toChars()); } } } } scope DtorVisitor v = new DtorVisitor(sc, this); //printf("+%s\n", toChars()); v.isThen = true; walkPostorder(e1, v); v.isThen = false; walkPostorder(e2, v); //printf("-%s\n", toChars()); } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) class DefaultInitExp : Expression { TOK subop; // which of the derived classes this is extern (D) this(const ref Loc loc, TOK subop, int size) { super(loc, TOK.default_, size); this.subop = subop; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class FileInitExp : DefaultInitExp { extern (D) this(const ref Loc loc, TOK tok) { super(loc, tok, __traits(classInstanceSize, FileInitExp)); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { //printf("FileInitExp::resolve() %s\n", toChars()); const(char)* s; if (subop == TOK.fileFullPath) s = FileName.toAbsolute(loc.isValid() ? loc.filename : sc._module.srcfile.name.toChars()); else s = loc.isValid() ? loc.filename : sc._module.ident.toChars(); Expression e = new StringExp(loc, cast(char*)s); e = e.expressionSemantic(sc); e = e.castTo(sc, type); return e; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class LineInitExp : DefaultInitExp { extern (D) this(const ref Loc loc) { super(loc, TOK.line, __traits(classInstanceSize, LineInitExp)); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { Expression e = new IntegerExp(loc, loc.linnum, Type.tint32); e = e.castTo(sc, type); return e; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class ModuleInitExp : DefaultInitExp { extern (D) this(const ref Loc loc) { super(loc, TOK.moduleString, __traits(classInstanceSize, ModuleInitExp)); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { const char* s = (sc.callsc ? sc.callsc : sc)._module.toPrettyChars(); Expression e = new StringExp(loc, cast(char*)s); e = e.expressionSemantic(sc); e = e.castTo(sc, type); return e; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class FuncInitExp : DefaultInitExp { extern (D) this(const ref Loc loc) { super(loc, TOK.functionString, __traits(classInstanceSize, FuncInitExp)); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { const(char)* s; if (sc.callsc && sc.callsc.func) s = sc.callsc.func.Dsymbol.toPrettyChars(); else if (sc.func) s = sc.func.Dsymbol.toPrettyChars(); else s = ""; Expression e = new StringExp(loc, cast(char*)s); e = e.expressionSemantic(sc); e = e.castTo(sc, type); return e; } override void accept(Visitor v) { v.visit(this); } } /*********************************************************** */ extern (C++) final class PrettyFuncInitExp : DefaultInitExp { extern (D) this(const ref Loc loc) { super(loc, TOK.prettyFunction, __traits(classInstanceSize, PrettyFuncInitExp)); } override Expression resolveLoc(const ref Loc loc, Scope* sc) { FuncDeclaration fd = (sc.callsc && sc.callsc.func) ? sc.callsc.func : sc.func; const(char)* s; if (fd) { const funcStr = fd.Dsymbol.toPrettyChars(); OutBuffer buf; functionToBufferWithIdent(fd.type.isTypeFunction(), &buf, funcStr); s = buf.extractString(); } else { s = ""; } Expression e = new StringExp(loc, cast(char*)s); e = e.expressionSemantic(sc); e = e.castTo(sc, type); return e; } override void accept(Visitor v) { v.visit(this); } } /** * Objective-C class reference expression. * * Used to get the metaclass of an Objective-C class, `NSObject.Class`. */ extern (C++) final class ObjcClassReferenceExp : Expression { ClassDeclaration classDeclaration; extern (D) this(const ref Loc loc, ClassDeclaration classDeclaration) { super(loc, TOK.objcClassReference, __traits(classInstanceSize, ObjcClassReferenceExp)); this.classDeclaration = classDeclaration; type = objc.getRuntimeMetaclass(classDeclaration).getType(); } override void accept(Visitor v) { v.visit(this); } }
D
/* Copyright (c) 2015, Dennis Meuwissen 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. 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. License does not apply to code and information found in the ./info directory. */ module game.map.map; import std.string; import std.stdio; import std.path; import std.math; import game.game; import game.style.style; import game.entities.entity; import game.entities.obstacle; import game.entities.decoration; import game.entities.powerup; import game.entities.vehicle; import game.entities.typenames; import game.map.block; import game.map.mapreader; import game.map.mapreadergta1; import game.map.mapreadergta2; import game.map.mapprocessor; import game.map.mapprocessorgta1; import game.map.mapprocessorgta2; import util.binaryfile; import util.vector3; import util.color; import util.log; public alias short MapCoord; public enum RouteType : ubyte { POLICE = 0xFF } public struct Route { RouteType type; Vector3[] vertices; } public enum ZoneType : ubyte { GENERAL = 0, NAVIGATION = 1, TRAFFIC_LIGHT = 2, ARROW_BLOCKER = 5, RAILWAY_STATION = 6, BUS_STOP = 7, TRIGGER = 8, INFORMATION = 10, RAILWAY_STATION_ENTRY = 11, RAILWAY_STATION_EXIT = 12, RAILWAY_STOP = 13, GANG = 14, NAVIGATION_LOCAL = 15, RESTART = 16, RESTART_ARREST = 20 } public struct Zone { ZoneType type; MapCoord x; MapCoord y; MapCoord width; MapCoord height; ubyte sampleIndex; string name; } public enum LocationType : ubyte { POLICE_STATION, HOSPITAL, FIRE_STATION } public struct Location { LocationType type; Vector3 coordinates; } public struct Light { RGBA color; float x; float y; float z; float radius; float intensity; float timeRandom; float timeOn; float timeOff; } public enum JunctionType : ubyte { UNKNOWN1 = 0, UNKNOWN2 = 1, UNKNOWN3 = 2, } public struct JunctionNetwork { Junction[] junctions; Segment[] segments; } public struct Junction { ushort segmentNorth; ushort segmentSouth; ushort segmentEast; ushort segmentWest; JunctionType type; MapCoord x1; MapCoord y1; MapCoord x2; MapCoord y2; } public struct Segment { ushort junction1; ushort junction2; MapCoord x1; MapCoord y1; MapCoord x2; MapCoord y2; } public struct MapEntity { EntityClass classId; string entityType; ubyte entityRemap; VehicleModelIndex vehicleModel; ubyte vehicleRemap; Vector3 position; float rotation; float pitch; float roll; ubyte routeIndex; alias position this; } public final class Map { private MapCoord _width; private MapCoord _height; private MapCoord _depth; private float[8] _shades; private Block[][][] _blocks; private MapEntity[] _mapEntities; private Entity[] _entities; private Route[] _routes; private Zone[] _zones; private Location[] _locations; private Light[] _lights; private Animation[] _animations; private JunctionNetwork _junctionNetwork; private MapProcessor _processor; this(const string fileName, TypeNames!EntityTypeIndex entityTypeNames) { MapReader reader; BinaryFile file = new BinaryFile(fileName); const string ext = extension(fileName).toLower(); if (ext == ".cmp") { Log.write(Color.NORMAL, "Reading GTA 1 map '%s'...", file.name); reader = new MapReaderGTA1(file); _processor = new MapProcessorGTA1(this); } else if (ext == ".gmp") { Log.write(Color.NORMAL, "Reading GTA 2 map '%s'...", file.name); reader = new MapReaderGTA2(file); _processor = new MapProcessorGTA2(this); } reader.readHeader(); _width = reader.width; _height = reader.height; _depth = reader.depth; _blocks = reader.readBlockData(); _mapEntities = reader.readMapEntities(entityTypeNames); _routes = reader.readRoutes(); _locations = reader.readLocations(); _zones = reader.readZones(); _lights = reader.readLights(); _animations = reader.readAnimations(); _junctionNetwork = reader.readJunctionNetwork(); Log.write(Color.NORMAL, "%dx%dx%d blocks.", _width, _height, _depth); Log.write(Color.NORMAL, "%d map entities.", _mapEntities.length); Log.write(Color.NORMAL, "%d routes.", _routes.length); Log.write(Color.NORMAL, "%d locations.", _locations.length); Log.write(Color.NORMAL, "%d zones.", _zones.length); Log.write(Color.NORMAL, "%d lights.", _lights.length); Log.write(Color.NORMAL, "%d animations.", _animations.length); Log.write(Color.NORMAL, "%d junctions, %d segments.", _junctionNetwork.junctions.length, _junctionNetwork.segments.length); file.close(); setShadingLevel(15); } public void spawnMapEntities(Style style) { Log.write(Color.NORMAL, "Spawning map entities..."); Entity ent; foreach (MapEntity mapEntity; _mapEntities) { if (mapEntity.classId == EntityClass.OBSTACLE) { EntityObstacle obstacle = new EntityObstacle(style.getEntityType(mapEntity.entityType)); ent = cast(Entity)obstacle; ent.remap = mapEntity.entityRemap; } else if (mapEntity.classId == EntityClass.POWERUP) { EntityPowerup powerup = new EntityPowerup(style.getEntityType(mapEntity.entityType), 0); ent = cast(Entity)powerup; } else if (mapEntity.classId == EntityClass.DECORATION) { EntityDecoration decoration = new EntityDecoration(style.getEntityType(mapEntity.entityType)); ent = cast(Entity)decoration; ent.remap = mapEntity.entityRemap; } else if (mapEntity.classId == EntityClass.VEHICLE) { VehicleType* vehicleType = style.getVehicleType(mapEntity.vehicleModel); EntityVehicle vehicle = new EntityVehicle(vehicleType); if (gameMode == GameMode.GTA1 && mapEntity.vehicleRemap > 0) { vehicle.hsl = vehicleType.remapsHSL[mapEntity.vehicleRemap - 1]; } ent.remap = mapEntity.vehicleRemap; ent = cast(Entity)vehicle; } else { Log.write(Color.WARNING, "Unknown map entity class %d.", mapEntity.classId); continue; } ent.position = mapEntity.position; ent.rotation = mapEntity.rotation; ent.roll = mapEntity.roll; ent.pitch = mapEntity.pitch; _entities ~= ent; } } public Entity spawn(Style style, const string entityTypeName, const Vector3 pos, const float angle) { EntityType type = style.getEntityType(entityTypeName); Entity entity; if (type.classId == EntityClass.OBSTACLE) { EntityObstacle obstacle = new EntityObstacle(type); entity = cast(Entity)obstacle; } else if (type.classId == EntityClass.POWERUP) { EntityPowerup powerup= new EntityPowerup(type, 0); entity = cast(Entity)powerup; } else if (type.classId == EntityClass.DECORATION) { EntityDecoration decoration = new EntityDecoration(type); entity = cast(Entity)decoration; } else { Log.write(Color.WARNING, "Unknown map entity class %d.", type.classId); return null; } entity.position = pos; entity.rotation = angle; _entities ~= entity; return entity; } public Entity spawnVehicle(Style style, const VehicleModelIndex model, const Vector3 pos, const float angle, const ubyte remap) { VehicleType* vehicleType = style.getVehicleType(model); EntityVehicle entity = new EntityVehicle(vehicleType); if (gameMode == GameMode.GTA1 && remap > 0) { entity.hsl = vehicleType.remapsHSL[remap - 1]; } entity.remap = remap; entity.position = pos; entity.rotation = angle; _entities ~= entity; return entity; } public Entity spawnPowerup(Style style, const string entityTypeName, const Vector3 pos, const uint timer) { EntityType type = style.getEntityType(entityTypeName); EntityPowerup entity = new EntityPowerup(type, timer); entity.position = pos; _entities ~= entity; return entity; } public MapCoord getSpawnZ(const MapCoord x, const MapCoord y) { const MapCoord bX = cast(MapCoord)(x / BLOCK_SIZE); const MapCoord bY = cast(MapCoord)(y / BLOCK_SIZE); if (bX < 0 || bX >= _width || bY < 0 || bY >= _height) { return 0; } // TODO: Account for slopes. for (MapCoord bZ = cast(MapCoord)(_depth - 1); bZ >= 0; bZ--) { if (_blocks[bX][bY][bZ].type != BlockType.AIR) { return cast(MapCoord)(bZ * BLOCK_SIZE + BLOCK_SIZE); } } return cast(MapCoord)(_depth * BLOCK_SIZE); } public void update(const double delta) { foreach (Entity entity; _entities) { entity.update(delta); } } public void addLight(Light light) { _lights ~= light; } public void process(Style style) { _processor.process(style); } public Block[][][] getBlocks() { return _blocks; } public MapEntity[] getMapEntities() { return _mapEntities; } public Entity[] getEntities() { return _entities; } public Animation[] getAnimations() { return _animations; } public void setShadingLevel(ubyte shadingLevel) { shadingLevel = shadingLevel % 32; foreach (int index, ref float shade; _shades) { shade = 1.0 - log10(index + 1) * (shadingLevel / 31.0); } } @property public MapCoord width() { return _width; } @property public MapCoord height() { return _height; } @property public MapCoord depth() { return _depth; } @property public float[8] shades() { return _shades; } }
D
/Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Database/Database.swift.o : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Database~partial.swiftmodule : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Fluent.build/Database~partial.swiftdoc : /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Database.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Database/Driver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Entity/Entity.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Filters.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/Memory+Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Memory/MemoryDriver.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Database+Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Migration.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/Preparation.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Preparation/PreparationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Action.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Comparison.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Filter.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Group.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Join.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Limit.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Scope.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Query/Sort.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Children.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Parent.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/RelationError.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Relations/Siblings.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Database+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Creator.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Field.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema+Modifier.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Schema/Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Query.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL+Schema.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQL.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/SQL/SQLSerializer.swift /Users/thendral/POC/vapor/Friends/Packages/Fluent-1.3.7/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/thendral/POC/vapor/Friends/.build/debug/Node.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/PathIndexable.swiftmodule /Users/thendral/POC/vapor/Friends/.build/debug/Polymorphic.swiftmodule
D
/home/zbf/workspace/git/RTAP/target/debug/deps/lettre_email-6d0784ebc4658c6d.rmeta: /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/lib.rs /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/error.rs /home/zbf/workspace/git/RTAP/target/debug/deps/liblettre_email-6d0784ebc4658c6d.rlib: /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/lib.rs /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/error.rs /home/zbf/workspace/git/RTAP/target/debug/deps/lettre_email-6d0784ebc4658c6d.d: /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/lib.rs /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/error.rs /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/lib.rs: /home/zbf/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/lettre_email-0.9.2/src/error.rs:
D
module android.java.android.icu.util.TimeZone_d_interface; import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers; static import arsd.jni; import import1 = android.java.android.icu.util.ULocale_d_interface; import import6 = android.java.java.lang.Integer_d_interface; import import0 = android.java.java.util.Locale_d_interface; import import7 = android.java.java.lang.Class_d_interface; import import2 = android.java.java.util.Date_d_interface; import import3 = android.java.android.icu.util.TimeZone_d_interface; import import4 = android.java.java.util.Set_d_interface; import import5 = android.java.android.icu.util.TimeZone_SystemTimeZoneType_d_interface; final class TimeZone : IJavaObject { static immutable string[] _d_canCastTo = [ "java/io/Serializable", "java/lang/Cloneable", "android/icu/util/Freezable", ]; @Import this(arsd.jni.Default); @Import int getOffset(int, int, int, int, int, int); @Import int getOffset(long); @Import void getOffset(long, bool, int[]); @Import void setRawOffset(int); @Import int getRawOffset(); @Import string getID(); @Import void setID(string); @Import string getDisplayName(); @Import string getDisplayName(import0.Locale); @Import string getDisplayName(import1.ULocale); @Import string getDisplayName(bool, int); @Import string getDisplayName(bool, int, import0.Locale); @Import string getDisplayName(bool, int, import1.ULocale); @Import int getDSTSavings(); @Import bool useDaylightTime(); @Import bool observesDaylightTime(); @Import bool inDaylightTime(import2.Date); @Import static import3.TimeZone getTimeZone(string); @Import static import3.TimeZone getFrozenTimeZone(string); @Import static import3.TimeZone getTimeZone(string, int); @Import static import4.Set getAvailableIDs(import5.TimeZone_SystemTimeZoneType, string, import6.Integer); @Import static string[] getAvailableIDs(int); @Import static string[] getAvailableIDs(string); @Import static string[] getAvailableIDs(); @Import static int countEquivalentIDs(string); @Import static string getEquivalentID(string, int); @Import static import3.TimeZone getDefault(); @Import bool hasSameRules(import3.TimeZone); @Import IJavaObject clone(); @Import bool equals(IJavaObject); @Import int hashCode(); @Import static string getTZDataVersion(); @Import static string getCanonicalID(string); @Import static string getCanonicalID(string, bool[]); @Import static string getRegion(string); @Import static string getWindowsID(string); @Import static string getIDForWindowsID(string, string); @Import bool isFrozen(); @Import import3.TimeZone freeze(); @Import import3.TimeZone cloneAsThawed(); @Import import7.Class getClass(); @Import @JavaName("toString") string toString_(); override string toString() { return arsd.jni.javaObjectToString(this); } @Import void notify(); @Import void notifyAll(); @Import void wait(long); @Import void wait(long, int); @Import void wait(); mixin IJavaObjectImplementation!(false); public static immutable string _javaParameterString = "Landroid/icu/util/TimeZone;"; }
D
module dtk.tkwidgets; public { import dtk.widget; import dtk.widgets.button; import dtk.widgets.canvas; import dtk.widgets.entry; import dtk.widgets.frame; import dtk.widgets.grid; import dtk.widgets.label; import dtk.widgets.listbox; import dtk.widgets.menu; import dtk.widgets.menubutton; import dtk.widgets.panedwindow; import dtk.widgets.radiobutton; import dtk.widgets.radioframe; import dtk.widgets.text; import dtk.widgets.toplevel; import dtk.widgets.table; }
D
module sketchup_api.slapi; extern (C):
D
// REQUIRED_ARGS: // module test42; import std.stdio; import core.stdc.stdio; import std.string; import core.memory; /***************************************************/ class Foo { template myCast(T) { T myCast(U)(U val) { return cast(T) val; } } } void test1() { Foo foo = new Foo; int i = foo.myCast!(int)(1.0); } /***************************************************/ template A() { static T foo(T)(T t) { return 7 + t; } } struct Bar { mixin A!() a; } void test2() { auto i = A!().foo(1); assert(i == 8); i = Bar.a.foo!(int)(2); assert(i == 9); i = Bar.a.foo(3); assert(i == 10); } /***************************************************/ void test3() { auto i = mixin("__LINE__"); writefln("%d", i); assert(i == 53); } /***************************************************/ class C4 { void Stamp(){} this() { } S4 cursor; } struct S4 { } void test4() { } /***************************************************/ char a5 = (cast(char[])['a']) [$-1]; void test5() { assert(a5 == 'a'); } /***************************************************/ // Bug 1200. One case moved to deprecate1.d void foo6a() { do debug {} while (true); } void foo6b() { while (true) debug {} } void foo6c() { with (Object.init) debug {} } void foo6d() { synchronized debug {} } void foo6e() { // volatile debug {} } void test6() { } /***************************************************/ class C7 { public this(){ } } interface I7 { void fnc(); } void test7() { char[][] t; foreach( char[] c; t ){ new class( c ) C7, I7 { public this( char[] c ){ super(); } void fnc(){ } }; } } /***************************************************/ const ulong[] A8 = ([1LU])[0..$]; void test8() { assert(A8[0] == 1); } /***************************************************/ void test9() { writeln(long.max.stringof); writeln(ulong.max.stringof); assert(long.max.stringof == "9223372036854775807L"); assert(ulong.max.stringof == "18446744073709551615LU"); } /***************************************************/ const ulong[] A10 = [1UL]; const ulong[] B10 = A10 ~ [1UL]; void test10() { } /***************************************************/ class Base11 { private final void foo() {} } class Derived11 : Base11 { void foo() {} } void test11() { } /***************************************************/ void test12() { int[] bar; assert((bar ~ 1).length == bar.length + 1); int[][] baz; assert((baz ~ cast(int[])[1]).length == baz.length + 1); char[][] foo; assert((foo ~ cast(char[])"foo").length == foo.length + 1); assert((cast(char[])"foo" ~ foo).length == foo.length + 1); printf("%d\n", (foo ~ cast(char[])"foo")[0].length); assert((foo ~ [cast(char[])"foo"]).length == foo.length + 1); char[] qux; assert(([qux] ~ cast(char[])"foo").length == [qux].length + 1); assert(([cast(dchar[])"asdf"] ~ cast(dchar[])"foo").length == [cast(dchar[])"asdf"].length + 1); string[] quux; auto quuux = quux.dup; quuux ~= "foo"; assert (quuux.length == quux.length + 1); } /***************************************************/ int prop() { return 3; } void test13() { auto x = prop; assert(x == 3); } /***************************************************/ void recurse(ref int i) { int j = i; recurse(j); } void test14() { } /***************************************************/ void bar15(void delegate(int) dg) { dg(7); } class C15 { int x; private void callback(int i) { x = i + 3; } void foo() { bar15(&callback); assert(x == 10); } } void test15() { C15 c = new C15(); c.foo(); } /***************************************************/ void bar16(int i, ...) { } void foo16() { } void foo16(int) { } void test16() { bar16(1, cast(void function())&foo16); } /***************************************************/ void foo17(char[4] buf, dchar c) { } void foo17(string s) { } void foo17(wstring s) { } void test17() { wstring w; .foo17(w); } /***************************************************/ struct S18 { version (Dversion2) { static void opCall(string msg) { assert(0); } } static void opCall() { } } void test18() { S18(); } /***************************************************/ class C19 { version (Dversion2) { static void opCall(string msg) { assert(0); } } static void opCall() { } } void test19() { C19(); } /***************************************************/ extern (System) void test20() { } /***************************************************/ void func21() { } int foo21() { return *cast(int*)&func21; } void test21() { foo21(); } /***************************************************/ void bar22(alias T)() { assert(3 == T); } class Test22 { int a; mixin bar22!(a); } void test22() { Test22 t = new Test22(); t.a = 3; t.bar22(); } /***************************************************/ static this() { printf("one\n"); } static this() { printf("two\n"); } static ~this() { printf("~two\n"); } static ~this() { printf("~one\n"); } void test23() { } /***************************************************/ class Foo24 { static string gen() { return "abc"; } } auto s24 = Foo24.gen(); void test24() { assert(s24 == "abc"); } /***************************************************/ void test25() { int[10] arrayA = [0,1,2,3,4,5,6,7,8,9]; foreach(int i; arrayA) { writeln(i); } } /************************************/ const char[][7] DAY_NAME = [ DAY.SUN: "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ]; enum DAY { SUN, MON, TUE, WED, THU, FRI, SAT } void test27() { assert(DAY_NAME[DAY.SUN] == "sunday"); assert(DAY_NAME[DAY.MON] == "monday"); assert(DAY_NAME[DAY.TUE] == "tuesday"); assert(DAY_NAME[DAY.WED] == "wednesday"); assert(DAY_NAME[DAY.THU] == "thursday"); assert(DAY_NAME[DAY.FRI] == "friday"); assert(DAY_NAME[DAY.SAT] == "saturday"); } /***************************************************/ void test28() { } /***************************************************/ struct C29 { C29 copy() { return this; } } void foo29(C29 _c) { foo29( _c.copy() ); } void test29() { C29 c; //foo(c); } /***************************************************/ template Tuple31(T...) { alias T Tuple31; } alias Tuple31!(int,int) TType31; void bar31(TType31) { } void test31() { } /***************************************************/ template Foo32(T : S!(T), alias S) { alias int Foo32; } struct Struct32(T) { } void test32() { Foo32!(Struct32!(int)) f; } /***************************************************/ void test33() { string a = "a"; string b = "b"; string c = a ~ b; assert(c == "ab"); } /***************************************************/ void foo34(in string s) { string t = s; } void test34() { } /***************************************************/ struct S35 { string toString() { return "foo"; } } void test35() { S35 s; auto t = typeid(S35); writefln("s = %s", s); writefln("s = %s", t); auto tis = cast(TypeInfo_Struct)t; writefln("s = %s", tis); writefln("s = %s", tis.xtoString); assert(tis.xtoString != null); } /***************************************************/ void test36() { void[0] x; auto y = x; alias x z; } /***************************************************/ template isStaticArray(T : U[], U) { const bool isStaticArray = is(typeof(U) == typeof(T.init)); } template isStaticArray(T, U = void) { const bool isStaticArray = false; } template isStaticArray(T : T[N], size_t N) { const bool isStaticArray = true; } static assert (isStaticArray!(int[51])); static assert (isStaticArray!(int[][2])); static assert (isStaticArray!(char[][int][11])); static assert (!isStaticArray!(int[])); static assert (!isStaticArray!(int[char])); static assert (!isStaticArray!(int[1][])); static assert(isStaticArray!(void[0])); void test37() { } /***************************************************/ template Foo38(T) { const bool Foo38 = false; } template Foo38(T : U[N], U, size_t N) { const bool Foo38 = true; } void test38() { static assert (Foo38!(int[51])); } /***************************************************/ void test39() { } /***************************************************/ void test40() { static x = [[1.0, 2.0], [3.0, 4.0]]; // works assert(x[0][0] == 1.0); assert(x[0][1] == 2.0); assert(x[1][0] == 3.0); assert(x[1][1] == 4.0); auto y = [[1.0, 2.0], [3.0, 4.0]]; // fails assert(y[0][0] == 1.0); assert(y[0][1] == 2.0); assert(y[1][0] == 3.0); assert(y[1][1] == 4.0); } /***************************************************/ align(16) struct S41 { int[4] a; } shared int x41; shared S41 s41; void test41() { printf("&x = %p\n", &x41); printf("&s = %p\n", &s41); assert((cast(int)&s41 & 0xF) == 0); } /***************************************************/ int test42(string[] args = null) { foreach(p; args){ version(dummy) int i; } return 0; } /***************************************************/ void foo43(float length, byte b) { // b /= cast(cfloat) length; } void test43() { } /***************************************************/ void test44() { ifloat f = 1.0fi; // f *= 2.0fi; // illegal but compiles writefln("%s", f); // assert(f == 0i); } /***************************************************/ int foo45(int i) { if(i==0){ return 2; } assert(0); } void test45() { version (Win32) // this test fails in -release because asserts will be removed { assert(foo45(0)==2); try{ foo45(1); }catch{ return cast(void)0; } assert(0); } } /***************************************************/ void va_copy46(out void* dest, void* src) { dest = src; } void test46() { } /***************************************************/ void test47() { enum { _P_WAIT, _P_NOWAIT, _P_OVERLAY } alias _P_WAIT P_WAIT; alias _P_NOWAIT P_NOWAIT; } /***************************************************/ void f48(int x) { const(char)[] blah = (x == 1 ? "hello".dup : "world"); } void test48() { f48(1); } /***************************************************/ void test49() { assert((25.5).stringof ~ (3.01).stringof == "25.53.01"); assert(25.5.stringof ~ 3.01.stringof == "25.53.01"); } /***************************************************/ class Ap50 { ulong size; static uint valuex; void update(ubyte input, int i) { valuex = (((size + i) & 1) == 0) ? 0 : input; } } void test50() { } /***************************************************/ int* foo51() { assert(is(typeof(return) == int*)); return null; } void test51() { foo51(); } /***************************************************/ template Foo52(ulong U) { int Foo52 = 1; } template Foo52(uint U) { int Foo52 = 2; } template Foo52(ubyte U) { int Foo52 = 3; } void test52() { const uint u = 3; auto s = Foo52!(u); assert(s == 2); } /***************************************************/ void test53() { extern int x; } /***************************************************/ void func54(string delegate() dg) { dg(); } void test54() { string[] k=["adf","AsdfadSF","dfdsfassdf"]; foreach(d;k) { printf("%.*s\n", d.length, d.ptr); string foo() {assert(d!="");return d;} func54(&foo); func54(delegate string() {assert(d!="");return d;}); } } /***************************************************/ // bug 1767 class DebugInfo { alias int CVHeaderType ; enum anon:CVHeaderType{ CV_NONE, CV_DOS, CV_NT, CV_DBG } } void test55() { } /***************************************************/ template T56() { int i; } struct S56 { alias T56!() data; } class C56 { alias T56!() data; } void test56() { S56.data.i = 3; C56.data.i = 4; assert(S56.data.i == 4); } /***************************************************/ void writecrossing(bool goal) { writeln(goal?"escape":"return"); } void test57() { writecrossing(true); writecrossing(false); } /***************************************************/ void f58(int n) {} void g58(char[] s) {} char[][] a58; class bar58 { int i; void func() { f58(i); foreach (s; a58) { if (s == s){} if (s[0..0] == "" && s[0..0]) g58(s); } f58(i); } } void test58() { } /***************************************************/ void test59() { int[] array = new int[5]; uint check = 0; foreach (it; array.ptr .. array.ptr + array.length) { ++check; } assert(check == array.length); } /***************************************************/ final class Foo60() { void bar() { int baz; baz = 1; } } void test60() { auto foo = new Foo60!(); } /***************************************************/ class ZipEntry61 { ZipEntryInfo61 info; this() {} } struct ZipEntryInfo61 {} void test61() { } /***************************************************/ void test62() { int foo() { return 0; } int bar() { return 0; } auto t1 = typeid(typeof(foo)); auto t2 = typeid(typeof(bar)); t1.tsize(); } /***************************************************/ struct S63 { int a; static int foo() { return a.sizeof; } } void test63() { int x = S63.a.sizeof; assert(x == 4); assert(S63.foo() == 4); } /***************************************************/ string[] foo64() { return [[]]; } void test64() { auto a = foo64(); assert(a.length == 1); assert(a[0].length == 0); } /***************************************************/ string[][] foo65() { string[][] result = []; string[] s = []; result ~= [s]; return result; } void test65() { auto s = foo65(); assert(s.length == 1); assert(s[0].length == 0); } /***************************************************/ string[][] foo66() { string[] strings = ["a","bc"]; string [][] result = []; foreach (s; strings) { result ~= [s]; } return result; } void test66() { auto s = foo66(); assert(s.length == 2); assert(s[0].length == 1); assert(s[0][0].length == 1); assert(s[1].length == 1); assert(s[1][0].length == 2); } /***************************************************/ template Tuple67(A...) { alias A Tuple67; } template Bar67() { const s = "a bar"; } void test67() { alias Tuple67!(Bar67!()) tuple; static const i = 0; alias tuple[0] bara; alias tuple[i] barb; static assert(bara.s == "a bar"); static assert(barb.s == "a bar"); } /***************************************************/ template Tuple68(A...) { alias A Tuple68; } size_t foo68() { return 1; } void test68() { alias Tuple68!("one", "two") tuple; static assert(tuple[foo68()] == "two"); } /***************************************************/ class Base69 {} class Da69 : Base69 {} class Db69 : Base69 {} void test69() { int i; auto b = i ? new Da69 : new Db69; assert(is(typeof(b) == Base69)); } /***************************************************/ struct Bar70 { Bar70[] bars; } void test70() { Bar70 node; } /***************************************************/ template Foo71(string s) { string b = s; } void test71() { size_t s = Foo71!( "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "When dealing with complex template tuples, it's very easy to overflow the maximum symbol length allowed by OPTLINK. This is, simply put, a damn shame, because it prevents otherwise completely legal code from compiling and linking with DMDWin, whereas it works perfectly fine when using DMDNix or GDC. I know that this is neither a simple nor a small issue to fix: either the ancient, nearly-immutable OPTLINK would have to be modified, or DMDWin would have to be changed to output a more reasonable format, in which case a new linker would probably have to be written. Until then, this issue should stand as a reminder that DMDWin is inherently limited. Oplink isn't the issue. The OMF file format has a hard limit. This results in the only solutions being: convert DMD to use some other .obj format or have DMD do something else for name mangling. In talking to Walter, the issue is that it's easy to get symbols that have more info in them than can be fit into the limit. (the limit has already stretched by gziping the symbols.) The simple solution I have proposed is to just MD5 (or what not) the symbols. The only issue (besides a vanishingly small chance of a hash collision) is that this looses information so you can't look at a symbol and directly determine what it was. My answer to that is, who cares? The only place where hashing provides less info than compressing is in a debugger and it can grab the full symbol from a table in the static data segment. I suppose as a stopgap measure that'd work fine, and might even be controlled by a compiler switch, so that in the general case debugger info wouldn't be affected. And what's more -- the only time these issues come up is with templates, which a lot of debuggers have serious problems with anyway, so.. I would set it up as a method of last resort. It wouldn't be used unless the symbol can't be used any other way. " ).b.length; } /***************************************************/ class B72 { this(bool b, string c){} } class C72 : B72 { this() { alias typeof(super(false,"hello")) foo; super(false,"hello"); } } void test72() { } /***************************************************/ template Foo73() { mixin ("const int x = 3;"); //const int x = 3; static if (x == 3) { pragma(msg, "success"); } } alias Foo73!() foo73; void test73() { } /***************************************************/ alias uint foo74; void simple_func_t(T)(T s, foo74 i) { assert(s == "hello"); assert(i == 3); } void test74() { simple_func_t("hello", 3); } /***************************************************/ void foo75(T)(T[] x ...) { assert(x.length == 3); assert(x[0] == 2); assert(x[1] == 3); assert(x[2] == 4); assert(is(T == int)); } void test75() { foo75(2,3,4); } /***************************************************/ void delegate(U) Curry(A, U...)(void delegate(A,U) dg,A arg) { struct ArgRecord { A arg; typeof(dg) callback; void OpCall(U args) { callback(arg,args); } } auto temp = new ArgRecord; temp.arg = arg; temp.callback = dg; return &temp.OpCall; } void delegate(A) Seq(A...)(void delegate(A)[] dgs...) { return Curry(delegate void(void delegate(A)[] dgs1,A args) { foreach(dg; dgs1) dg(args); }, dgs); } struct Foo76 { void fred(int i) {} } void test76() { void delegate(int) tmp; auto bob = new Foo76; auto dan = new Foo76; tmp = Seq!(int)(&bob.fred); // this works tmp = Seq!(int)(&bob.fred, &dan.fred); // this works tmp = Seq (&bob.fred); // this doesn't tmp = Seq (&bob.fred, &dan.fred); // neither does this } /***************************************************/ int x77; void foo77() { x77 = 1; static if(true) { } else { } } void test77() { foo77(); assert(x77 == 1); } /***************************************************/ class Foo78 { template TBar(T) { T x; // Compiles, but is implicitly static void func(T t) // Ok, non-static member template function { assert(t == 2); assert(this.bar == 42); } } int bar = 42; } void test78() { alias Foo78 Foo; Foo.TBar!(int).x = 2; //Foo.TBar!(int).func(2); // error, since funcx is not static Foo f = new Foo; Foo g = new Foo; f.TBar!(int).func(2); // works f.TBar!(int).x = 10; g.TBar!(int).x = 20; assert(f.TBar!(int).x == 20); // prints 20 } /***************************************************/ class C79 { } void test79() { C79 c = new C79(); writeln(c.__vptr); writeln(c.__vptr[0]); writeln(cast(void*)c.classinfo); assert(c.__vptr[0] == cast(void*)c.classinfo); writeln(c.__monitor); assert(c.__monitor == null); synchronized (c) { writeln(c.__monitor); assert(c.__monitor !is null); } } /***************************************************/ class Test80{ template test(){ enum int test=1; } } void test80() { assert(Test80.test!()==1); assert((new Test80).test!()==1); } /***************************************************/ class Test81 { static const test2=1; template test(){ static const int test=1; } } void test81() { auto a=new Test81; static assert(typeof(a).test2==1);//ok alias typeof(a) t; static assert(t.test!()==1);//ok static assert(typeof(a).test!()==1);//syntax error } /***************************************************/ deprecated { alias real A82; void foo82(A82 x) { } } void test82() { } /***************************************************/ class Bar83 { deprecated void foo(int param) { } void foo(string param) { } } void test83() { Bar83 b = new Bar83; string str = "bar"; b.foo(str); } /***************************************************/ void test84() { int[0][10] arr; printf("%u\n", &arr[9] - &arr[0]); auto i = &arr[9] - &arr[0]; assert(i == 0); } /***************************************************/ class myid { string buf; this(string str ) { buf = str; } } struct Lex { static myid myidinst; static void Init() { myidinst = new myid("abc"); } } void test85() { Lex.Init(); assert(cast(myid)(Lex.myidinst) !is null); } /***************************************************/ struct Time { long ticks; } struct Stamps { Time created, /// time created accessed, /// last time accessed modified; /// last time modified } Stamps getTimeStamps() { foreach(i; 0..10) { } Stamps time = void; time.modified = Time(20); time.accessed = Time(20); time.created = Time(20); return time; } Time accessed () { foreach(i; 0..10) { } return timeStamps(4).accessed; } Stamps timeStamps (int name) { return getTimeStamps(); } void test86() { assert(accessed().ticks == 20); } /***************************************************/ const bool foo87 = is(typeof(function void() { })); const bar87 = is(typeof(function void() { })); void test87() { assert(foo87 == true); assert(bar87 == true); } /***************************************************/ int function() wrap88(void function()) { return null; } void test88() { printf("test88\n"); if (0) wrap88(&test88)(); } /***************************************************/ struct S89 { static const float[2] z = 3; } class C89 { static const float[2] z = 3; } void bar89(float f) { assert(f == 3); } void test89() { printf("test89\n"); bar89(S89.z[0]); bar89(S89.z[1]); bar89(C89.z[0]); bar89(C89.z[1]); } /***************************************************/ void trigger(char[] txt) { txt[0] = 'x'; scope(exit) { txt[0] = 'x'; } return; } void test90() { } /***************************************************/ void test91() { enum ABC { a, b, c } assert(ABC.stringof == "ABC"); } /***************************************************/ int x92; int f92() { x92++; return 0; } void test92() { int[1] a; a[f92()] += 42L; assert(x92 == 1); } /***************************************************/ void test93() { void foo() { } static assert(is(typeof(1 || foo()) == void)); static assert(is(typeof(1 && foo()) == void)); } /***************************************************/ void foo94(T)() { } struct f94(alias func=foo94!(int)) { } void test94() { f94!() myf; } /***************************************************/ struct X95 { import core.stdc.stdio; } void test95() { X95.core.stdc.stdio.printf("hello\n"); } /***************************************************/ template foo96(alias bar) { pragma(msg, bar.stringof ~ " " ~ typeof(bar).stringof); static assert((bar.stringof ~ " " ~ typeof(bar).stringof) == "myInt int" || (bar.stringof ~ " " ~ typeof(bar).stringof) == "myBool bool"); void foo96() {} } void test96() { int myInt; bool myBool; foo96!(myInt)(); foo96!(myBool)(); } /***************************************************/ void test97() { const short[] ct = cast(short[]) [cast(byte)1, 1]; writeln(ct); assert(ct.length == 2 && ct[0] == 1 && ct[1] == 1); short[] rt = cast(short[]) [cast(byte)1, cast(byte)1].dup; writeln(rt); assert(rt.length == 1 && rt[0] == 257); } /***************************************************/ class Foo98 { string foo = "abc"; size_t i = 0; void bar() { printf("%c\n", foo[i]); i++; printf("%c\n", foo[i]); assert(foo[i] == 'b'); } } void test98() { auto f = new Foo98(); f.bar(); } /***************************************************/ template implicitlyConverts99(S, T) { enum bool implicitlyConverts99 = T.sizeof >= S.sizeof && is(typeof({S s; T t = s;}())); } static assert(!implicitlyConverts99!(long, short)); void test99() { } /***************************************************/ void test100() { static void check(ulong value) { real r = value; ulong d = cast(ulong)r; printf("ulong: %llu => real: %Lg => ulong: %llu\n", value, r, d); assert(d == value); } // check biggest power of 2 representable in ulong: 2^63 check(1L << 63); // check biggest representable uneven number static if (real.mant_dig >= 64) // > 64: limited by ulong precision check(ulong.max); // 2^64-1 else check((1L << real.mant_dig) - 1); } /***************************************************/ auto e101(int x) { return 5; } void test101() { assert(is(typeof(e101(3)) == int)); } /***************************************************/ version(X86) { int x103; void external(...) { printf("external: %d\n", *cast (int *) _argptr); x103 = *cast (int *) _argptr; } class C103 { void method () { void internal (...) { printf("internal: %d\n", *cast (int *)_argptr); x103 = *cast (int *) _argptr; } internal (43); assert(x103 == 43); } } void test103() { external(42); assert(x103 == 42); (new C103).method (); } } else version(X86_64) { pragma(msg, "Not ported to x86-64 compatible varargs, yet."); void test103() {} } else static assert(false, "Unknown platform"); /***************************************************/ class C104 { template Bar() { } } static assert(!is(typeof(C104.Bar.foo))); void test104() { } /***************************************************/ template Templ(T) { const char [] XXX = Type.mangleof; alias T Type; } void test105() { Templ!(int).Type x; auto s = Templ!(int).XXX; writeln(s); assert(s == "i"); } /***************************************************/ // rejects-valid 2.012. class foo107 {} alias foo107 bar107; void x107() { bar107 a = new bar107(); bar107 b = new bar107(); bool c = (a == b); } void test107() { } /***************************************************/ struct Foo108 { char[] byLine()() { return null; } } void test108() { Foo108 foo; foreach (char c; foo.byLine) { } } /***************************************************/ void test109() { double x[] = new double[1]; assert(x[0] != 0); } /***************************************************/ void test110() { struct C { int[0] b; } static C g_c2_ = { }; } /***************************************************/ template Foo111(T...) { alias T Foo111; } void test111() { auto y = (Foo111!(int) x){ return 0; }; } /***************************************************/ bool isNull(string str) { return str is null; } const bool foo112 = isNull("hello!"); void test112() { assert(!foo112); } /***************************************************/ void test113() { for (int j=1; j<2; j++) { int x = (j<0) ? -j : j; int q=0; for (int i=0; i<x; i++) ++q; assert(q!=0); } } /***************************************************/ struct VariantN { static int opCall(int value) { return 0; } void foo() { VariantN v; v.bar(42, 5); } void bar(int value, int i) { int args[2] = [ VariantN(value), VariantN(i) ]; } } void test114() { } /***************************************************/ class B115 : A115!(B115) { } class A115(T) { } void test115() { } /***************************************************/ struct Foo116 { this(U...)(U values) { } } void test116() { new Foo116; } /***************************************************/ void test117() { float f = 7; f = f * 2; assert(f == 14); double d = 7; d = d * 2; assert(d == 14); real r = 7; r = r * 2; assert(r == 14); } /***************************************************/ void test118() { int foo(real x) { real y = -x*-x; return cast(int)y; } auto i = foo(4.0); assert(i == 16); } /***************************************************/ class A119 { static class B119 : C119.D { } } abstract class C119 { static class D { } } void test119() { } /***************************************************/ class A120 { class B120 : C120.D { } } class C120 : E120 { static class D { } } interface E120 { } void test120() { } /***************************************************/ void test121() { static assert(null is null); } /***************************************************/ T[] find123(alias pred, T)(T[] input) { while (input.length > 0) { if (pred(input[0])) break; input = input[1 .. $]; } return input; } void test123() { int[] a = [ 1, 2, 3, 4, -5, 3, -4 ]; find123!(function bool(int i) { return i < 0; })(a); } /***************************************************/ static assert(!is(typeof((){(){} ;-() {};}))); /***************************************************/ struct Foobar; /***************************************************/ int test124() { int result; dchar[] aa; alias uint foo_t; foreach (foo_t i, dchar d; aa) { } return result; } /***************************************************/ int foo125(int x) { while (1) { if (x) return 3; x++; } } void test125() { foo125(4); } /***************************************************/ int foo126(int x) { while (1) { if (x) return 3; x++; } assert(0); } void test126() { foo126(4); } /***************************************************/ struct S127(T, int topology = 1) { this(T value) { } } void cons127(int t)(S127!(int, t) tail) { } void test127() { S127!(int)(1); S127!(int, 1) lst; cons127(lst); } /***************************************************/ struct S128(T, int topology = 1) { this(T value) { } } void cons128(int t)(S128!(int, t) tail) { } void test128() { S128!(int, 1)(1); S128!(int) lst; cons128(lst); } /***************************************************/ struct R129(R : E[], E) { E[] forward; static R129 opCall(E[] range) { R129 result = {}; result.forward = range; return result; } } R129!(E[]) retro129(E)(E[] r) { return R129!(E[])(r); } int begin129(F)(R129!(F) range) { return 0; } void test129() { int[] a = [ 1, 2, 3 ]; auto r = retro129(a); auto i = begin129(r); } /***************************************************/ // 12725 struct R12725(R : E[], E) { } int begin12725(F)(R12725!(F) range) { return 0; } void test12725() { R12725!(int[], int) r; auto i = begin12725(r); } /***************************************************/ // 12728 struct Matrix12728(T, uint m, uint n = m, ubyte f = 0) { void foo(uint r)(auto ref in Matrix12728!(T, n, r) b) { } } void test12728() { alias Matrix4 = Matrix12728!(float, 4); Matrix4 m; m.foo(m); } /***************************************************/ struct S130 { byte[3] x; } __gshared S130 e130; const(S130) example130() { return e130; } void test130() { } /***************************************************/ void foo131(real z) {} void test131() { real F = 1; foo131( 1 + (F*3*2.1) ); } /***************************************************/ float getFloat() { return 11468.78f; } void test132() { uint i = cast(uint) 11468.78f; assert(i == 11468); uint j = cast(uint) getFloat(); assert(j == 11468); } /***************************************************/ template T133(string s) { const string T133 = s; } string f133(string s) { return s; } void test133() { int foo; //writeln(foo.stringof); assert ("foo" == f133(foo.stringof)); assert ("foo" == T133!(foo.stringof)); } /***************************************************/ public struct foo134 { public this(real aleft) { } } class bar134 { final void fun(foo134 arg = foo134(0.)) { } } /***************************************************/ void test135() { char[char[3]] ac; char[3] c = "abc"; ac["abc"]='a'; assert(ac[c]=='a'); char[dchar[3]] ad; dchar[3] d = "abc"d; ad["abc"d]='a'; assert(ad[d]=='a'); } /***************************************************/ void test136() { struct S { int i[3]; } enum S s = S(8); const int i = s.i[2]; assert(i == 8); } /***************************************************/ struct Particle { char[16] name; } class ReadSystem { size_t[char[16]] pKindsIdx; void t(Particle p) { auto idx=p.name in pKindsIdx; } } void test137() { char[16] n; size_t[char[16]] aa; auto r=n in aa; // works } /***************************************************/ long test138(int y) { return *cast(long*)(&y); } /***************************************************/ void test139() { auto famousNamedConstants = [ "pi" : 3.14, "e" : 2.71, "moving sofa" : 2.22 ]; assert(famousNamedConstants["e"]==2.71); } /***************************************************/ int* get140() { return (new int[4]).ptr; } void test140() { int* p = get140(); p[0..3] = 0; p[0] = 7; } /***************************************************/ class Foo141 { Foo141 next; void start() in { assert (!next); } body { void* p = cast(void*)this; } } /***************************************************/ void a142(int b = 1+2)(){}; void test142() { a142!(1+2)(); a142(); } /***************************************************/ class A143 { invariant() { } void fill() { } } class B143 : A143 { override void fill() { } } void test143() { auto b = new B143(); b.fill(); } /***************************************************/ struct Pair { static Pair opCall(uint a, uint b) { return Pair.init; } } struct Stack { Pair pop() { return Pair.init; } } void test144() { Stack stack; Pair item = stack.pop; } /***************************************************/ struct Ashes { int ashes = cast(int)0; } void funky (Ashes s = Ashes()) { } struct S145 { real a = 0, b = 0; } void func145(S145 s = S145()) { } void test145() { funky(); func145(); } /***************************************************/ string foo146(T...)(T args) { string ret; foreach(arg; args) { ret = arg; } assert(ret=="b"); // passes return ret; } void test146() { string s = foo146("b"); assert(s == "b"); // fails } /***************************************************/ void test147() { string s = "foo"; dchar c = 'x'; s ~= c; assert(s == "foox"); wstring ws = "foo"; ws ~= c; assert(ws == "foox"); } /***************************************************/ void test148() { string a = "\U00091234"; string b; b ~= "\U00091234"; if (a != b) { assert(0); } } /***************************************************/ void test149() { long[1] b = void; b[0] = -1L; b[0] >>>= 2; assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL); } /***************************************************/ bool foo150() { int x; return cast(void*) (x & 1) == null; } /***************************************************/ // 3521 void crash(int x) { if (x==200) return; asm { int 3; } } void test151() { int x; bug3521(&x); } void bug3521(int *a){ int c = 0; *a = 0; if ( *a || (*a != (c = 200)) ) crash(c); } /***************************************************/ string foo152(T...)() { return ""; } void test152() { foo152!(int, char)(); } /***************************************************/ int get_value() { return 1; } int[2] array1; int[2] array2; int foo153(ulong a1, ulong extra, ulong extra2, ulong extra3) { if (!((a1 & 1) | (get_value() | array1[cast(uint)(a1^1)]))) return 0; if (0 >= array2[cast(uint)(a1^1)]) return 0; return 1; } void test153() { foo153(0, 0, 0, 0); } /***************************************************/ class B154 : A154 { } enum SomeEnum { EnumMember = 10 } class A154 { SomeEnum someEnum() { return SomeEnum.EnumMember; } } void test154() { auto b = new B154(); assert(cast(int)b.someEnum == 10); } /***************************************************/ struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } } /***************************************************/ void f156(Value156.Id t) { assert(cast(int)t == 1); } struct Value156 { public static enum Id { A, B } } void test156() { Value156.Id t = Value156.Id.B; f156(t); } /***************************************************/ X157 x157; enum X157 { Y }; interface Foo157 { Policy157 fn(); } enum Policy157 {Default, Cached, Direct} void test157() { } /***************************************************/ class X158 { Y158.NY t; enum NX { BLA, BLA1 } } class Y158 { enum NY { FOO, BAR } X158.NX nx; } /***************************************************/ struct Foo159 { Bar.Baz x; struct Bar { struct Baz {} } } /***************************************************/ void test160() { long[1] b = void; b[0] = -1L; b[0] >>>= 2; assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL); int i = -1; assert(i >>>2 == 0x3FFFFFFF); } /***************************************************/ class A161 { struct B { D161 x; struct C {} } } struct D161 {} class C161 { A a; struct A { uint m; } enum { E = 0 } } /***************************************************/ interface A162 { C162 foo(); C162 foo() const; } class B162 : A162 { C162 foo() { return null; } C162 foo() const { return null; } } abstract class C162 : A162 { C162 foo() { return null; } C162 foo() const { return null; } } /***************************************************/ void func163( A... )( string name, string v ) { } void test163() { func163!( int, long, float )( "val", "10" ); func163!()( "tmp", "77" ); alias func163!() TMP; TMP( "tmp", "77" ); } /***************************************************/ class A164 { B164 foo() { return null; } B164 foo() const { return null; } } abstract class B164 : A164 { override final B164 foo() { return null; } override final B164 foo() const { return null; } } /***************************************************/ class A165 { B165 foo() { return null; } const(B165) foo() const { return null; } } abstract class B165 : A165 { override final B165 foo() { return null; } override final const(B165) foo() const { return null; } } /***************************************************/ struct A166 { B166 xxx; static this () { } } struct B166 {} /***************************************************/ void x168(T)() { static assert(false); } template y168(T) { const bool y168 = is(typeof( { x168!(T)(); } )); } static assert(!y168!(int)); /***************************************************/ void test169() { int AssociativeArray; int[int] foo; foreach (x; foo) { } } /***************************************************/ FwdEnum this_fails; enum : int { E170 = 2 } enum FwdEnum : int { E2 = E170 } /***************************************************/ // 3740 abstract class Address { abstract int nameLen(); } class Class171 : Address { FwdStruct z; struct FwdStruct { } override int nameLen() { return 0; } } void test171 () { Class171 xxx = new Class171; assert(typeid(Class171).vtbl.length - typeid(Object).vtbl.length == 1); } /***************************************************/ struct Foo172 { enum bool BAR = is (typeof({}())); static assert (BAR == is (typeof({}()))); } /***************************************************/ const char[][ 89 ] ENUM_NAME = [ 1:"N0" ]; void test173() { switch(`Hi`.dup) { case ENUM_NAME[1]: default: break; } } /***************************************************/ class A174 { void x() { } } class B174 : A174 { override void x() { assert(0); } final void do_x() { super.x(); } } void test174() { auto b = new B174(); b.do_x(); } /***************************************************/ void badvariadic(...) {} static assert(!is(typeof(mixin(badvariadic())))); /***************************************************/ struct Foo176 { int x; } Foo176 getFoo(Foo176 irrelevant) { Foo176 p = Foo176(400); if ( p.x > p.x ) return irrelevant; else return p; } void test176() { assert(getFoo( Foo176(0) ).x == 400); } /***************************************************/ int test177() { long[1] c = [0]; // must be long int [1] d = [1]; int k = 0; if (!d[0]) k = 1; k = d[0] + k + k; if (c[0]) assert(c[0]); return k; } /***************************************************/ struct S178 { int x; template T(int val) { enum S178 T = { val }; } } const x178 = S178.T!(0); /***************************************************/ double[100_000] arr = 0.0; /***************************************************/ alias ireal BUG3919; alias typeof(BUG3919.init*BUG3919.init) ICE3919; alias typeof(BUG3919.init/BUG3919.init) ICE3920; /***************************************************/ struct S179 { char a, b, c, d; } void show(char[] args...) { assert(args[0]=='A'); assert(args[1]=='L'); assert(args[2]=='D'); assert(args[3]=='O'); } void A179( S179 ss ) { show( ss.a, ss.b, ss.c, ss.d ); } void test179() { S179 ss3; ss3.a = 'A'; ss3.b = 'L'; ss3.c = 'D'; ss3.d = 'O'; A179( ss3 ); } /***************************************************/ struct XY { union { int x, y; } } struct AHolder { XY aa; void a(XY x) { aa = x; } } struct AB { AHolder aHolder; XY b; void a(XY x) { aHolder.a(x); } } struct Main { AB ab; void setB() { ab.b = XY(); } void f() { ab.a(XY.init); setB(); } } /***************************************************/ void fooa181(int x, int y, int[0] a, int z, int t) { if (!(x == 2 && y == 4 && z == 6 && t == 8)) assert(0); } void foob181(int x, int y, int[0] a) { if (!(x == 2 && y == 4)) assert(0); } void fooc181(int[0] a, int x, int y) { if (!(x == 2 && y == 4)) assert(0); } void food181(int[0] a) { } void test181() { int[0] arr = 0; fooa181(2, 4, arr, 6, 8); foob181(2, 4, arr); fooc181(arr, 2, 4); food181(arr); } /***************************************************/ // 4042 template isQObjectType(T) { enum isQObjectType = is(T.__isQObjectType); } template QTypeInfo(T) { static if (!isQObjectType!T) { enum size = T.sizeof; } } struct QList(T) { alias QTypeInfo!T TI; int x; void foo() { x++; } } void exec(QList!(QAction) actions) {} interface IQGraphicsItem { } abstract class QGraphicsObject : IQGraphicsItem { } class QGraphicsWidget : QGraphicsObject { } class QAction { void associatedGraphicsWidgets(QList!(QGraphicsWidget) a) { QList!(QGraphicsWidget) x; } } void test182() { } /***************************************************/ enum { a183 = b183() } int b183() { return 0; } /***************************************************/ struct Z184 { int bar = 1; union { Foo184 foo; } } struct Foo184 { size_t offset = 0;} /***************************************************/ struct BB185 { Item185[1] aa; } struct CC185 { Item185 aa; } struct Item185 { byte data; } /***************************************************/ const PM_QS_INPUT = QS_INPUT; const QS_INPUT = 2; /***************************************************/ alias A187 B187; const int A187 = 1; /***************************************************/ int foo188(int[3] s) { return s[0] + s[1] + s[2]; } void test188() { int[3] t = [1,3,4]; auto i = foo188(t); if (i != 8) assert(0); } /***************************************************/ template X189(alias fn) { alias typeof(fn) X189; } void a189()(T1189 x) { alias X189!(T1189.foo) P; //line 7 x.foo(); } class T1189 { void foo() { printf("T1.foo()\n"); } } class T2189 : T1189 { void bla() { printf("T2.blah()\n"); assert(false); //line 19 } } void test189() { a189!()(new T2189()); } /***************************************************/ void test190() { string s; if (true) scope(exit) s ~= "a"; if (false) { } else scope(exit) s ~= "b"; if (true) scope(exit) scope(exit) s ~= "c"; foreach(x; 1..2) scope(exit) s ~= "d"; if (true) L1: scope(exit) s ~= "e"; do scope(exit) s ~= "f"; while (false); int i; while (++i == 1) scope(exit) s ~= "g"; try { } finally scope(exit) s ~= "h"; assert(s == "abcdefgh"); } /***************************************************/ struct S191 { int last = 0; S191 opCall(int i) { printf("%d %d\n", last, i); assert(i == 1 && last == 0 || i == 2 && last == 1 || i == 3 && last == 1); last = i; return this; } } void test191() { S191 t; t(1)(2); t(3); } /***************************************************/ enum foo192 { item, } //pragma(msg, foo.mangleof); static assert(foo192.mangleof == "E6test426foo192"); /***************************************************/ void test193() { enum Shapes { Circle, Square } int i; Shapes s; pragma(msg, i.stringof); pragma(msg, s.stringof); static assert(i.stringof == "i"); static assert(s.stringof == "s"); } /***************************************************/ void test194() { uint[][] b = [[ 1, 2, ]]; } /***************************************************/ alias int T195; class C195 { int yum = x195; } const T195 x195 = 0; /***************************************************/ union A196 { double[2] a; double[2] b; } union B196 { public: double[2] a; double[2] b; } static assert(A196.sizeof == B196.sizeof); /***************************************************/ template Compileable(int z) { bool OK;} struct Bug3569 { int bar() { return 7; } } struct Bug3569b { Bug3569 foo; void crash() { static assert(!is(typeof(Compileable!(foo.bar())))); static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar())))); } } void test197() { } /***************************************************/ void test198() // Bugzilla 4506 { int c = 1; for (int k = 0; k < 2; k++) { assert((k == 0 && c == 1) || (k == 1 && c == -1)); c *= -1; } } /***************************************************/ // Bugzilla 4514 void g199(void delegate(void*, void*) d) { } struct X199 { void f(void*, void*) {} void n() { g199(&f); } } /***************************************************/ // Bugzilla 4443 struct Struct4443 { int x; char[5] unused; } void foo4443(Struct4443 *dest, Struct4443[] arr) { int junk = arr[$-1].x; if (dest || arr[$-1].x) { *dest = arr[$-1]; } } void test200() { Struct4443[1] a; Struct4443 info; foo4443(&info, a); } /***************************************************/ // Bugzilla 2931 struct Bug2931 { int val[3][4]; } struct Outer2931 { Bug2931 p = Bug2931(67); // Applies to struct static initializers too int zoom = 2; int move = 3; int scale = 4; } int bug2931() { Outer2931 v; assert(v.move==3); assert(v.scale == 4); return v.zoom; } int bug2931_2() { Outer2931 v; Bug2931 w = Bug2931(68); assert(v.move==3); for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { assert(w.val[j][i] == 68); assert(v.p.val[j][i] == 67); } } assert(v.scale == 4); return v.zoom; } static assert(bug2931()==2); void test201() { assert(bug2931()==2); assert(bug2931_2()==2); } /***************************************************/ // This was the original varargs example in std.vararg import core.vararg; void foo202(int x, ...) { printf("%d arguments\n", _arguments.length); for (int i = 0; i < _arguments.length; i++) { int j = va_arg!(int)(_argptr); printf("\t%d\n", j); assert(j == i + 2); } } void fooRef202(ref int x, ...) { printf("%d arguments\n", _arguments.length); for (int i = 0; i < _arguments.length; i++) { int j = va_arg!(int)(_argptr); printf("\t%d\n", j); assert(j == i + 2); } } void test202() { foo202(1, 2, 3, 4, 5); printf("---\n"); int x = 1; fooRef202(x, 2, 3, 4, 5); } /***************************************************/ // Bugzilla 1418 class A203 { char name = 'A'; class B203 { char name = 'B'; } } void test203() { class C203 { char name = 'C'; } auto a = new A203; auto b = a.new B203; auto c = new C203; writeln(a.tupleof); // prints: A writeln(b.tupleof); // prints: B main.A writeln(c.tupleof); // prints: C 0000 assert(a.tupleof.length == 1 && a.tupleof[0] == 'A'); assert(b.tupleof.length == 1 && b.tupleof[0] == 'B'); assert(c.tupleof.length == 1 && c.tupleof[0] == 'C'); } /***************************************************/ // Bugzilla 4516 struct A204 { B204 b; } enum B204 { Z } /***************************************************/ // Bugzilla 4503 class Collection205(T) { } ICollection c; alias Collection205!int ICollection; /***************************************************/ enum TaskStatus:int { Building=-1, } TaskStatus test206(char[] s){ char[] t="TaskStatus".dup; if (s.length>t.length && s[0..t.length]==t){ long res=0; if (s[t.length]=='-') res= -res; // <= OPnegass return cast(TaskStatus)cast(int)res; } assert(0); } /***************************************************/ struct UN { double dd; long ll; } bool cmp( UN * pU ) { return pU.dd >= pU.ll ? true : false; } struct UN2 { real dd; long ll; } bool cmp2( UN2 * pU ) { return pU.dd >= pU.ll ? true : false; } struct UN3 { double dd; int ll; } bool cmp3( UN3 * pU ) { return pU.dd >= pU.ll ? true : false; } void test207() { static UN u = { 10.50, 10 }; auto i = cmp(&u); printf( "%d\n", cmp( &u ) ); assert(i); static UN2 u2 = { 10.50, 10 }; i = cmp2(&u2); assert(i); static UN3 u3 = { 10.50, 10 }; i = cmp3(&u3); assert(i); static UN3 u3_1 = { 9.50, 10 }; i = cmp3(&u3_1); assert(!i); } /***************************************************/ template fail4302() { static assert(0); } template bug4302() { alias fail4302!() bad; } static if (is(bug4302!())) {} /***************************************************/ template tough4302() { template bar() { template far() { static assert(0); } alias far!() par; } static if (is(bar!())) {} } alias tough4302!() tougher; /***************************************************/ template Bug6602A(T) { Bug6602B!(T).Result result; } template Bug6602B(U) { static assert(is(U == int)); alias bool Result; } enum bug6602Compiles = __traits(compiles, Bug6602A!short); /***************************************************/ // Bugzilla 3493 const bar209 = foo209; const int * foo209 = null; /***************************************************/ // 3418 void test210() { ulong a = 1; a = cast(ulong)(a * 2.0L); } /***************************************************/ static assert(!is(typeof(Object.tupleof[2000]=0))); /***************************************************/ struct Ghost {} void bug4430(T)(int x) {} void bug4430(T)(Ghost x) {} void test212() { bug4430!(char)( 777 ); } /***************************************************/ // 4768 struct A213 { B213 b; } enum B213 { Z213 = 2 } void test213() { A213 x; assert(x.b == 2); } /***************************************************/ void g214(int j) { } void test214() { struct S { int i; void f() { g214(i); } } auto s = S(); } /***************************************************/ template Q(s...) { alias s q; } void test215() { class C {} enum assocarrayliteral = Q!( [1:2] ).q.stringof; enum complex80 = Q!( 1+1.0i ).q.stringof; //enum dottype = Q!( C.Object.toString ).q.stringof; enum halt = (assert(0), 0).stringof; // ICE w/ -release //enum remove = Q!( [1:2].remove(1) ).q.stringof; enum templat = Q!( Q ).q.stringof; } /***************************************************/ // 4941 template T216(_...) { alias _ T216; } size_t mid216(size_t n) { return n/2; } alias T216!(int, int)[0 .. mid216($)] A216; alias T216!(1, 2, 3)[0 .. mid216($)] B216; void test216() { T216!(int, int, int) values; auto slice = values[0 .. mid216($)]; // C } /***************************************************/ int bug4529a() { return 0; } int function() bug4529b; auto ivorBomb1 = typeid(typeof(bug4529a)); auto ivorBomb2 = typeid(typeof(bug4529b)); /***************************************************/ void bug5218c(char [3] s) {} void bug5218w(wchar [3] s) {} void bug5218d(dchar [3] s) {} void test217() { bug5218c("abc"); bug5218w("abc"w); bug5218d("abc"d); } /***************************************************/ // 2954 void test218() { char[char[3]] ac; char[3] c = "abc"; ac["abc"]='a'; assert(ac[c]=='a'); char[dchar[3]] ad; dchar[3] d = "abc"d; ad["abc"d]='a'; assert(ad[d]=='a'); } /***************************************************/ // 2206 template T219(U) { class C {} } void test219() { mixin T219!(int); // using a named mixin here fixes it pragma(msg, T219!(int).C.mangleof); pragma(msg, C.mangleof); // incorrectly outputs the same as above assert(T219!(int).C.classinfo !is C.classinfo); // fails assert(T219!(int).C.mangleof != C.mangleof); // fails } /***************************************************/ // 2206 class D220 {} template T220(U) { class C { this() { } } } void test220() { mixin T220!(int); // all print 8 writeln(T220!(int).C.classinfo.initializer.length); writeln(C.classinfo.initializer.length); writeln(D220.classinfo.initializer.length); auto c = new C; // segfault in _d_newclass } /***************************************************/ const struct S5110 { static int value; } static assert(is(typeof(S5110.value) == int)); /***************************************************/ class C5110 { override: string toString() { return ""; } class Nested { void gun() {} } } /***************************************************/ immutable class Bug5504 { void foo(T)(T a) {} template xx(X) { void hoo(T)(T a) {} } } shared class Bug5504b { void foo(T)(T a) {} template xx(X) { void hoo(T)(T a) {} } } void test5504() { immutable Bug5504 c; c.foo(10); c.xx!(int).hoo(10); shared Bug5504b d; d.foo(10); d.xx!(int).hoo(10); } /***************************************************/ void bug5105() // compilation test -- don't need to run { auto c = new shared(C5105); c.foo(10); } synchronized shared class C5105 { void foo(T)(T a) {} } /***************************************************/ // 5145 interface I221{ void bla(); } interface J221 { I221 sync (); } class A221 : B221 { final override I221 sync() in { assert( valid ); } body { return null; } } class B221 : J221 { override I221 sync() in { assert( valid ); } body { return null; } final bool valid() { return true; } } /***************************************************/ template Bug3276(bool B) { static if (B) alias Bug3276!(false) Bug3276; else alias double Bug3276; } template Bug3276_b(alias W) { alias W!(true) Bug3276_b; } alias Bug3276_b!(Bug3276) Bug3276_c; /***************************************************/ // 5294 void foo222(int) {} void test222() { int count; for (int i = 0; i < 2; i++) { count++; foo222(i * 5 - 6); // comment this out and it makes 2 loops } printf("%d\n", count); // compile with -O and it prints 1 assert(count == 2); } /***************************************************/ void foo223(long x,long a,long b,long c,long d,long e,long f) { assert(x == 0x123456789ABCDEF0); } void test223() { foo223(0x123456789ABCDEF0,2,3,4,5,6,7); } /***************************************************/ // 4379 template BigTuple(U...) { alias U BigTuple; } alias BigTuple!(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1) Tuple4379; void test224() { foreach(x; Tuple4379) { } } /***************************************************/ // 3681 public final class A3681 { private this() { int i =0; int j = i + 1; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; } } /***************************************************/ 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()) == ``); static assert(mixin(ice4390()) == ``); /***************************************************/ // 190 alias int avocado; void eat(avocado x225 = .x225); avocado x225; void test225() { } /***************************************************/ // 5534 void doStuff(byte start, byte end, uint increment = 1U) { auto output = new byte[3]; size_t count = 0; for(byte i = start; i < end; i += increment) { output[count++] = i; } } void test226() { doStuff(0, 3); } /***************************************************/ // 5536 void test227() { int[] as = [111, 666]; as ~= as[$ - 2]; assert(as.length == 3); assert(as[2] == 111); } /***************************************************/ // 4017 struct _A { uint data; } const A_SIZE = (A4017.sizeof); alias _A A4017; /***************************************************/ // 5455 void thrw(Data *s) { throw new Exception("xxx"); } struct Data { Rapper *w; uint n, m; } struct Rapper { ubyte * dat; ubyte[] con() { return dat[0..1]; } } uint jaz(ubyte[] data) { return cast(uint)data.length; } struct Resp { void set(Data *data, string[] soup) { switch(soup[0]) { default: } uint[] f = [jaz(data.w ? data.w.con[data.n ..data.m] : null), data.m - data.n]; thrw(data); } } /**************************************/ // 5571 void test228() { auto b = new bool; printf("%p\n", b); *b = false; } /***************************************************/ // 5572 void doSynchronized() { printf("In doSynchronized() 1: %p\n", cast(void*) global229); synchronized { printf("In doSynchronized() 2: %p\n", cast(void*) global229); } } __gshared Object global229; void test229() { auto local = new Object; global229 = local; printf("In main() 1: %p\t%p\n", cast(void*) global229, cast(void*) local); doSynchronized(); printf("In main() 1: %p\t%p\n", cast(void*) global229, cast(void*) local); assert(cast(void*) global229 == cast(void*) local); } /***************************************************/ static immutable real negtab[14] = [ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L, 1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ]; static immutable real postab[13] = [ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L, 1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ]; float parse(ref string p) { printf("test1\n"); real ldval = 0.0; int exp = 0; long msdec = 0; msdec = 123; exp = 2; ldval = msdec; printf("ldval = %Lg\n", ldval); if (ldval) { uint u = 0; int pow = 4096; while (exp > 0) { while (exp >= pow) { ldval *= postab[u]; exp -= pow; } pow >>= 1; u++; } while (exp < 0) { while (exp <= -pow) { ldval *= negtab[u]; exp += pow; } pow >>= 1; u++; } } return ldval; } void test230() { float f; string s = "123e+2"; f = parse( s ); //printf("f = %g\n", f); assert( f == 123e+2f ); } /***************************************************/ class Bug4033 {} class Template4033(T) { static assert(is(T : Bug4033)); } alias Template4033!(Z4033) Bla; class Z4033 : Bug4033 { } /***************************************************/ struct Bug4322 { int[1] a = void; } void bug4322() { Bug4322 f = Bug4322(); Bug4322 g = Bug4322.init; } /***************************************************/ bool bug5672(long v) { return (v & 1) == 1; return (v & 1) == 1; } /***************************************************/ void bug5717() { string s, s2; s = "Привет"; for (int i=0; i<s.length; i++) s2 ~= s[i]; assert(s == s2); } /***************************************************/ // 3086 class X231 { void a() {} void b(int z, short c) {} void c(int z, short d) {} } void test231() { auto z = new X231(); TypeInfo a = typeid(typeof(&z.a)); TypeInfo b = typeid(typeof(&z.b)); TypeInfo c = typeid(typeof(&z.c)); assert(a !is b, "1"); assert(a != b, "2"); assert(b == c, "3"); } /***************************************************/ // 4140 const A232 = [1,2,3]; const B232 = A232[1..A232.length]; const C232 = A232[1..$]; void test232() { assert(A232[0] == 1); assert(A232[1] == 2); assert(A232[2] == 3); assert(B232[0] == 2); assert(B232[1] == 3); assert(C232[0] == 2); assert(C232[1] == 3); } /***************************************************/ // 1389 void test233() { int a; mixin("a") = 666; } /***************************************************/ // 5735 struct A234 {} void foo234(bool cond){} void test234() { A234 a; int i; static assert(!__traits(compiles, assert(a))); // type A does not have a boolean value static assert(!__traits(compiles, assert(i || a))); // type A does not have a boolean value static assert(!__traits(compiles, assert(0 || a))); // OK // if(a) {} // type A does not have a boolean value // if(i || a) {} // type A does not have a boolean value // if(0 || a) {} // type A does not have a boolean value static assert(!__traits(compiles, foo234(a))); // cannot implicitly convert type A to bool static assert(!__traits(compiles, foo234(i || a))); // OK static assert(!__traits(compiles, foo234(0 || a))); // OK } /***************************************************/ int space() { return 4001; } void oddity4001() { const int bowie = space(); static assert(space() == 4001); // OK static assert(bowie == 4001); // doesn't compile } /***************************************************/ int bug3809() { asm { nop; } return 0; } struct BUG3809 { int xx; } void bug3809b() { } /***************************************************/ // void bug6184() { bool cmp(ref int[3] a, ref int[3] b) { return a is b; } static struct Ary { int[3] ary; } auto a = new Ary; auto b = new Ary; assert(!cmp(a.ary, b.ary)); b = a; assert(cmp(a.ary, b.ary)); // change high bit of ary address *(cast(size_t*)&b) ^= (1UL << (size_t.sizeof * 4)); assert(!cmp(a.ary, b.ary)); } /***************************************************/ // 6229 int test6229() { { ubyte a = 2; ubyte b = 4; b += a; } char a = 2; char b = 4; b += a; wchar c = 2; wchar d = 4; c /= d; return b; } /***************************************************/ // XMMBug class XMMPainter { float call() { return sumFloats(0.0f, 0.0f); } static float sumFloats(float a, float b) { return a + b; } } void test6270() { auto painter = new XMMPainter; assert(XMMPainter.sumFloats(20, painter.call()) == 20.0f); auto dg = () { return XMMPainter.sumFloats(0.0f, 0.0f); }; assert(XMMPainter.sumFloats(20, dg()) == 20.0f); } /***************************************************/ void testrolror(int shift) { uint a = 7; uint r; r = (a >> shift) | (a << (int.sizeof * 8 - shift)); assert(r == 0x8000_0003); r = (r << shift) | (r >> (int.sizeof * 8 - shift)); assert(r == 7); } void test236() { testrolror(1); } /***************************************************/ // 4460 void test237() { foreach (s, i; [ "a":1, "b":2 ]) { writeln(s, i); } } /***************************************************/ void foo238(long a, long b) { while (1) // prevent inlining { long x = a / b; long y = a % b; assert(x == 3); assert(y == 1); break; } } void test238() { long a, b; a = 10; b = 3; long x = a / b; long y = a % b; // evaluate at compile time assert(x == 3); assert(y == 1); foo238(a, b); } /***************************************************/ // 5239 struct S239 { int x; } int test239() { S239[4] w = void; w[$-2].x = 217; return w[2].x; } /***************************************************/ void enforce6506b(bool condition, void delegate() m) { assert(!condition); } void toImpl6506b(int value) { void f(){} enforce6506b(value >= 0, &f); } void test6506() { toImpl6506b(-112345); } /***************************************************/ // 6505 double foo240() { return 1.0; } void test240() { double a = foo240(); double b = foo240(); double x = a*a + a*a + a*a + a*a + a*a + a*a + a*a + a*b + a*b; assert(x > 0); } /***************************************************/ // 6563 int foo6563(float a, float b, float c, float d, float e, float f, float g, float h) { assert(a == 1); return 0; // return something to prevent folding } void test6563() { auto res = foo6563(1, 1, 1, 1, 1, 1, 1, 1); } /***************************************************/ ubyte foo241(ubyte[] data) { ubyte a, b, c, d; a = data[0]; b = data[1]; c = data[2]; d = data[3]; c <<= 1; if (c & 0x80) c >>= 1; d <<= 1; if (d & 0x80) d >>= 1; return d; } void test241() { ubyte[4] data; data[3] = 0x40; assert(foo241(data[]) == 0x40); data[3] = 0x20; assert(foo241(data[]) == 0x40); } /***************************************************/ struct Foo6665 { double[2][2] dat; double foo(size_t i, size_t j) { return dat[i][j] = 0; } } void test6665() { Foo6665 a; } /***************************************************/ double entropy(double[] probs) { double result = 0; foreach (p; probs) { if (!p) continue; result -= p; } return result; } /***************************************************/ long b5364(long bmax){ if(true){ } if(bmax >= 0) bmax = -1; return bmax; } void test5364() { assert(b5364(0) == -1L); } /***************************************************/ struct FPoint { float x, y; } void constructBezier(FPoint p0, FPoint p1, FPoint p2, ref FPoint[3] quad) { quad[0] = p0; quad[1] = FPoint(p1.x, p1.y); quad[$-1] = p2; } void test6189() { auto p0 = FPoint(0, 0); auto p1 = FPoint(1, 1); auto p2 = FPoint(2, 2); // avoid inline of call FPoint[3] quad; auto f = &constructBezier; f(p0, p1, p2, quad); assert(quad == [p0, p1, p2]); } /***************************************************/ // 6997 long fun6997(long a,long b,long c) { return a < b ? a < c ? a : b < c ? b : c : b; } long baz6997(long a, long b) { bool s = (a<0) != (b<0); a = a > 0 ? a : -a; return s ? a : a; } struct S6997 { ulong bar, qux; bool c; S6997 foo() { if(!c) { long a = baz6997(bar, 0), b = baz6997(bar, 0), c = baz6997(bar, 0); return S6997(fun6997(a,b,c), fun6997(a,b,c)); } return S6997(); } } void test6997() { auto x = S6997().foo(); } /***************************************************/ ubyte foo7026(uint n) { ubyte[5] buf = void; ubyte wsize; while (true) { if ((n & ~0x7F) == 0) { buf[wsize++] = cast(ubyte)n; break; } else { buf[wsize++] = cast(ubyte)((n & 0x7F) | 0x80); n >>= 7; } } printf("%hhu\n", wsize); return buf[0]; } void test7026() { if (foo7026(3) != 3) assert(0); } /***************************************************/ void test6354() { foreach(j; 0 .. 2) { scope(failure) int i = 0; ushort left = 0xffU; left <<= (ushort.sizeof - 1) * 8; assert((((left & 0xff00U) >> 8) | ((left & 0x00ffU) << 8)) == 0xffu); } } /***************************************************/ struct S7072 { this(A)(A args) { } } void test7072() { auto s = S7072( null ); } /***************************************************/ struct Point6881 { float _x, _y; void rotateCCW() { float tmp = -_x; _x = _y; _y = tmp; } } /***************************************************/ // 7212 void foo7212(scope int delegate(int a) dg) { } void foo7212(bool a) { } void test7212() { foo7212((int a) => a); } /***************************************************/ void test242() { foreach(v; long.max / 8 .. long.max / 8 + 1) { immutable long t1 = v; long t2 = t1 + t1; t2 *= 1L << 1; assert(t2 > long.max / 4); } } /***************************************************/ // 7290 void foo7290a(alias dg)() { assert(dg(5) == 7); } void foo7290b(scope int delegate(int a) dg) { assert(dg(5) == 7); } void foo7290c(int delegate(int a) dg) { assert(dg(5) == 7); } void test7290() { int add = 2; scope dg = (int a) => a + add; assert(GC.addrOf(dg.ptr) == null); foo7290a!dg(); foo7290b(dg); foo7290c(dg); } /***************************************************/ void test7367() { char a = '\x00'; char b = '\xFF'; assert(a < b); } /***************************************************/ // 7375 class A7375 {} class B7375(int i) : A7375 {} class C7375(int i) : B7375!i {} template DerivedAlias(int i) { alias B7375!i DerivedAlias; } alias DerivedAlias!22 X7375; void test7375() { A7375 foo = new C7375!11(); assert(cast(B7375!22)foo is null); } /***************************************************/ void test6504() { for (int i=0; i<3; ++i) { /+ char[] x2 = "xxx" ~ ['c']; if (i == 0) assert(x2[1] == 'x'); x2[1] = 'q'; +/ } } /***************************************************/ struct S7424a { @property inout(int) g()() inout { return 7424; } void test1() { int f = g; assert(f == 7424); assert(g == 7424); } void test2() const { int f = g; assert(f == 7424); assert(g == 7424); } void test3() immutable { int f = g; assert(f == 7424); assert(g == 7424); } } struct S7425 { inout(T) g(T)(T x) inout { return x; } void test1() { int f = g(2); assert(f == 2); } void test2() const { double y = g(4.5); assert(y == 4.5); } } void test7424() { S7424a s1; s1.test1(); s1.test2(); immutable(S7424a) s2; s2.test2(); s2.test3(); const(S7424a) s3; s3.test2(); S7425 s4; s4.test1(); s4.test2(); } /***************************************************/ struct Logger { static bool info()() { return false; } } void test7422() { if (Logger.info()) { } } /***************************************************/ struct S7502 { int[0x1000] arr; } S7502 s7502; void test7502() { s7502 = s7502.init; } /***************************************************/ void nextis(void delegate() dg = {}) {} void test4820() { nextis(); } /***************************************************/ void test4820_2() { void nextis(void delegate() dg = {}) {} nextis(); } /***************************************************/ template T3509(bool b) { static assert (b); } template Mix3509() { void f() {} } class C3509 { alias T3509!(is(typeof(M.f))) U; mixin Mix3509!() M; } /***************************************************/ struct S3510(int x) {} template Mix3510() { Sa s; } class C3510 { mixin Mix3510!(); alias S3510!(0) Sa; } /***************************************************/ struct Array243(T) if (is(T == bool)) { struct Range { Array243!bool _outer; ulong _a, _b, _c; ulong _d; } Range opSlice() { return Range(this, 0, 3); } } void test243() { Array243!bool a; } /***************************************************/ // 7742 struct Foo7742 { static immutable f = Foo7742(1, 2); int x, y; } struct Bar7742 { int x, y; static immutable f = Bar7742(1, 2); } void test7742() { assert(Foo7742.f.x == 1); assert(Foo7742.f.y == 2); assert(Bar7742.f.x == 1); assert(Bar7742.f.y == 2); } /***************************************************/ // 7807 interface Interface7807 { Interface7807 getNext(); const(Interface7807) getNext() const; } class Implementation7807 : Interface7807 { Implementation7807 getNext() { return this; } const(Implementation7807) getNext() const { return null; } } void test7807() { auto mc = new Implementation7807(); assert(mc.getNext() is mc); Interface7807 mi = mc; assert(mi.getNext() is mi); auto cc = new const(Implementation7807)(); assert(cc.getNext() is null); const(Interface7807) ci = cc; assert(ci.getNext() is null); } /***************************************************/ // 7815 enum Closure { Matrix } struct BasicMatrix { mixin Operand!( Closure.Matrix ); } template Operand( Closure closure_ ) { alias closure_ closure; } struct Expression( string op_, Lhs, Rhs = void ) { enum lhsClosure = closureOf!Lhs; } template closureOf( T ) { enum closureOf = T.closure; } alias Expression!("+", BasicMatrix) Foo7815; /***************************************************/ struct Test244 { static immutable c = Test244(); static if( true ){} } /***************************************************/ int noswap245(ubyte *data) { return (data[0]<< 0) | (data[1]<< 8) | (data[2]<< 16) | (data[3]<< 24); } int bswap245(ubyte *data) { return (data[0]<< 24) | (data[1]<< 16) | (data[2]<< 8 ) | (data[3]<< 0 ); } void test245() { int x1 = 0x01234567; x1 = noswap245(cast(ubyte *)&x1); assert(x1 == 0x01234567); x1 = bswap245(cast(ubyte *)&x1); assert(x1 == 0x67452301); } /***************************************************/ mixin template mix7974() { uint _x; } struct Foo7974 { static immutable Foo7974 fa = Foo7974(0); this(uint x) { _x = x; } mixin mix7974!(); } /***************************************************/ // 4155 float getnanf() { return float.nan; } double getnand() { return double.nan; } real getnanr() { return real.nan; } void test4155() { assert(getnanf() != 0); assert(getnand() != 0); assert(getnanr() != 0); } /***************************************************/ // 7911 struct Klass7911 { double value; //static const Klass zero; // Does not trigger bug! static const Klass7911 zero = {0}; // Bug trigger #1 static if (true) // Bug trigger #2 static if (true) Klass7911 foo() { return Klass7911(); } } void test7911() { auto a = Klass7911().foo(); } /***************************************************/ // 8429 static if(true) version = Foo8429; static if(true) version(Foo8429) {} /***************************************************/ // 8069 interface I8069 { void f(); } struct A8069 { final class B8069 : I8069 { A8069 a; void f() {} } } /***************************************************/ // 8095 void bug8095(int p0, int *p1, int z, int edx, int *p4, int p5) { int x = z / 3; if (z) { int c = p5 + *p1 + p0; // *p1 segfaults -- it does *z !! if ( z / 5 ) c = 1; *p4 = c; x = c; } void never_used() { ++x; int * unused = p1; // kills p4 somehow } } void test8095() { int x, y; bug8095(0, &x, 1, 0, &y, 0); } /***************************************************/ // 8091 int solve1(int n) { int a; return ((a = n ? (n>=1u) : 1) != 0) ? a : 0; // return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0; } int solve2(int n) { int a; // return ((a = n ? (n>=1u) : 1) != 0) ? a : 0; return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0; } void test8091() { assert(solve1(1) == 1); assert(solve2(1) == 1); } /***************************************************/ struct IPoint { int x, y; } void bug6189_2(uint half, IPoint pos, float[4] *pts, uint unused) { pos.y += half; float xo = pos.x; float yo = pos.y; (*pts)[0] = xo; (*pts)[1] = yo; (*pts)[2] = xo; } void test6189_2() { auto pos = IPoint(2, 2); float[4] pts; pts[0] = pts[1] = pts[2] = pts[3] = 0; bug6189_2(0, pos, &pts, 0); assert(pts[0] == 2); } /***************************************************/ // 8199 version (D_InlineAsm_X86_64) { version = Check; enum Align = 0x8; } else version (D_InlineAsm_X86) { version = Check; version (OSX) enum Align = 0xC; } void onFailure() { assert(0, "alignment failure"); } void checkAlign() { version (Check) { static if (is(typeof(Align))) asm { naked; mov EAX, ESP; and EAX, 0xF; cmp EAX, Align; je Lpass; call onFailure; Lpass: ret; } } else return; } void foo8199() { } void test8199() { try foo8199(); finally checkAlign(); } /***************************************************/ void test246() { struct Struct { void method() {} } auto val = Struct(); } /***************************************************/ double sqrt8454(double d) { return d/2; } void foo8454(cdouble m) {} void test8454() { foo8454(0 - sqrt8454(1.0) * 1i); } /***************************************************/ // 8423 struct S8423 { int opCmp(S8423 rhs) { return 1; } } void enforce8423(bool value, string a, string b) { if (!value) assert(false); } void test8423() { auto a = S8423(); auto b = S8423(); enforce8423(a > b, null, null); } /***************************************************/ class Foo8496 { public: void foo(uint value) { ubyte size = value < (0x7fU << 0 ) ? 1 : value < (0x7fU << 14) ? 2 : 3; import std.stdio; writeln(size); assert(size == 2); } } void test8496() { Foo8496 f = new Foo8496(); f.foo(1000000); } /***************************************************/ long foo8840() { return 4; } int bar8840(long g) { assert(g == 4); return printf("%llx\n", g); } void test8840() { long f1 = foo8840(); long f2 = foo8840(); long f = (f1 < f2 ? f1 : f2); int len = (f == 0 ? 0 : bar8840(f)); } /***************************************************/ struct S8889 { real f; int i; } void test8889() { } /***************************************************/ struct S8870 { float x = 0; float y = 0; float z = 0; float w = 0; } void test8870() { S8870 r1 = S8870(1,2,3,4); S8870 r2 = S8870(5,6,7,8); foo8870(r1, r2, false, 1); bar8870(r1, r2, false, 1); } //extern (C) void foo8870(S8870 t1, S8870 t2, bool someBool, float finalFloat) { printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w); printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w); printf("someBool: %d\n", someBool); printf("finalFloat: %g\n", finalFloat); assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4); assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8); assert(someBool == false); assert(finalFloat == 1); } extern (C) void bar8870(S8870 t1, S8870 t2, bool someBool, float finalFloat) { printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w); printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w); printf("someBool: %d\n", someBool); printf("finalFloat: %g\n", finalFloat); assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4); assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8); assert(someBool == false); assert(finalFloat == 1); } /***************************************************/ int foo9781(int[1] x) { return x[0] * x[0]; } void test9781() { foo9781([7]); } /***************************************************/ struct S247 { size_t length; size_t ptr; } S247 foo247() { S247 f; f.length = 7; f.ptr = 8; return f; } void test247() { S247 f; f = foo247(); assert(f.length == 7); assert(f.ptr == 8); } /***************************************************/ // 8340 void test8340(){ byte[] ba = [1,2,3,4,5]; short[] sa = [1,2,3,4,5]; int[] ia = [1,2,3,4,5]; long[] la = [1,2,3,4,5]; ba[2] *= -1; sa[2] *= -1; ia[2] *= -1; la[2] *= -1; assert(ba == [1,2,-3,4,5]); assert(sa == [1,2,-3,4,5]); assert(ia == [1,2,-3,4,5]); assert(la == [1,2,-3,4,5]); } /***************************************************/ // 8376 void test8376() { int i = 0; int[2] a; a[1]=1; while(!a[0]){ if(a[i]) continue; a[i] = 1; } } /***************************************************/ // Don't call, compile only void test8987(){ int last = 0; int count = 0; int d; for (int x = 0; count < 100; x++){ d = 3; while (x / d) d += 2; if (x & d) { last = x; count++; } } printf("Last: %d\n", last); } /***************************************************/ // 8796 int* wrong8796(int* p) { *p++ = 1; return p; } void test8796() { int[3] arr; int* q = arr.ptr; q = wrong8796(q); assert(q != arr.ptr); } /***************************************************/ // 9171 ulong bitcomb9171(ulong v) { if(v) { ulong result; if(v & 1) { auto r = bitcomb9171(v >> 1); printf("r=%016llx\n", r); auto z = ((r & (r-1) ^ r)); check9171("str", z>>1); // printf("z=%016llx\n", z>>1); return r; } else { auto fb = v & (v-1) ^ v; result = (fb >> 1) | (v ^ fb); } return result; } return 0; } void check9171(const char *s, ulong v) { assert(v == 0x80000000); } void test9171() { bitcomb9171(0b1110000000000000010000000000000000000000000000000001); } /***************************************************/ // 9248 void test9248() { void*[] a = [cast(void*)1]; void*[] b = [cast(void*)2]; auto c = a ~ b; assert(c == [cast(void*)1, cast(void*)2]); } /***************************************************/ // 14682 void test14682a() { // operands int[] a1; int[][] a2; int[][][] a3; int[][][][] a4; // results int[] r1w = []; assert(r1w.length == 0); int[][] r2w = []; assert(r2w.length == 0); int[][][] r3w = []; assert(r3w.length == 0); int[][][][] r4w = []; assert(r4w.length == 0); // ---- int[][] r2x = [[]]; assert(r2x.length == 1 && r2x[0].length == 0); int[][][] r3x = [[]]; assert(r3x.length == 1 && r3x[0].length == 0); int[][][][] r4x = [[]]; assert(r4x.length == 1 && r4x[0].length == 0); // ---- int[][][] r3y = [[[]]]; assert(r3y.length == 1 && r3y[0].length == 1 && r3y[0][0].length == 0); int[][][][] r4y = [[[]]]; assert(r4y.length == 1 && r4y[0].length == 1 && r4y[0][0].length == 0); // ---- int[][][][] r4z = [[[[]]]]; assert(r4z.length == 1 && r4z[0].length == 1 && r4z[0][0].length == 1 && r4z[0][0][0].length == 0); // ArrayLiteralExp conforms to the type of LHS. { auto x = a1 ~ [] ; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity { auto x = a2 ~ [] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity { auto x = a3 ~ [] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity { auto x = a4 ~ [] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity // ---- //{ auto x = a1 ~ [[]] ; } // (see test14682b) { auto x = a2 ~ [[]] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity { auto x = a3 ~ [[]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity { auto x = a4 ~ [[]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity // ---- static assert(!__traits(compiles, { auto x = a1 ~ [[[]]] ; })); //{ auto x = a2 ~ [[[]]] ; } // (see test14682b) { auto x = a3 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity { auto x = a4 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity // ---- static assert(!__traits(compiles, { auto x = a1 ~ [[[[]]]]; })); static assert(!__traits(compiles, { auto x = a2 ~ [[[[]]]]; })); //{ auto x = a3 ~ [[[[]]]]; } // (see test14682b) { auto x = a4 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity // ArrayLiteralExp conforms to the type of RHS. { auto x = [] ~ a1; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity { auto x = [] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity { auto x = [] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity { auto x = [] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity // ---- //{ auto x = [[]] ~ a1; } // (see test14682b) { auto x = [[]] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity { auto x = [[]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity { auto x = [[]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity // ---- static assert(!__traits(compiles, { auto x = [[[]]] ~ a1; })); //{ auto x = [[[]]] ~ a2; } // (see test14682b) { auto x = [[[]]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity { auto x = [[[]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity // ---- static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a1; })); static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a2; })); //{ auto x = [[[[]]]] ~ a3; } // (see test14682b) { auto x = [[[[]]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity } void test14682b() { // operands int[] a1; int[][] a2; int[][][] a3; int[][][][] a4; // results int[][] r2a = [[], [] ]; assert(r2a.length == 2 && r2a[0].length == 0 && r2a[1].length == 0); //int[][][] r3a = [[], [[]] ]; // should work, but doesn't //int[][][][] r4a = [[], [[[]]]]; // should work, but doesn't int[][][] r3a; { r3a.length = 2; r3a[0] = []; r3a[1] = [[]] ; } assert(r3a.length == 2 && r3a[0].length == 0 && r3a[1].length == 1 && r3a[1][0].length == 0); int[][][][] r4a; { r4a.length = 2; r4a[0] = []; r4a[1] = [[[]]]; } assert(r4a.length == 2 && r4a[0].length == 0 && r4a[1].length == 1 && r4a[1][0].length == 1 && r4a[1][0][0].length == 0); // ---- int[][] r2b = [ [] , []]; assert(r2b.length == 2 && r2b[1].length == 0 && r2b[0].length == 0); //int[][][] r3b = [ [[]] , []]; // should work, but doesn't //int[][][][] r4b = [[[[]]], []]; // should work, but doesn't int[][][] r3b; { r3b.length = 2; r3b[0] = [[]] ; r3b[1] = []; } assert(r3b.length == 2 && r3b[1].length == 0 && r3b[0].length == 1 && r3b[0][0].length == 0); int[][][][] r4b; { r4b.length = 2; r4b[0] = [[[]]]; r4b[1] = []; } assert(r4b.length == 2 && r4b[1].length == 0 && r4b[0].length == 1 && r4b[0][0].length == 1 && r4b[0][0][0].length == 0); // ArrayLiteralExp conforms to the typeof(LHS)->arrayOf(). { auto x = a1 ~ [[]] ; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2a); } // fix { auto x = a2 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3a); } // fix { auto x = a3 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4a); } // fix // ArrayLiteralExp conforms to the typeof(RHS)->arrayOf(). { auto x = [[]] ~ a1; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2b); } // fix { auto x = [[[]]] ~ a2; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3b); } // fix { auto x = [[[[]]]] ~ a3; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4b); } // fix } /***************************************************/ // 9739 class Foo9739 { int val = 1; this(int arg = 2) { val = arg; } } class Bar9739 : Foo9739 { } void test9739() { Bar9739 bar = new Bar9739; assert(bar.val == 2); } /***************************************************/ // 6057 void test6057() { enum Foo { A=1, B=2 } Foo[] bar = [cast(Foo)1]; } /***************************************************/ ulong d2ulong(double u) { return cast(ulong)u; } void testdbl_to_ulong() { auto u = d2ulong(12345.6); //writeln(u); assert(u == 12345); static if (real.mant_dig <= 64) { real adjust = 1.0L/real.epsilon; u = d2ulong(adjust); //writefln("%s %s", adjust, u); static if(real.mant_dig == 64) assert(u == 9223372036854775808UL); else static if(real.mant_dig == 53) assert(u == 4503599627370496UL); else static assert(false, "Test not implemented for this architecture"); auto v = d2ulong(adjust * 1.1); //writefln("%s %s %s", adjust, v, u + u/10); // The following can vary in the last bits with different optimization settings, // i.e. the conversion from real to double may not happen. //assert(v == 10145709240540254208UL); } } /***************************************************/ uint d2uint(double u) { return cast(uint)u; } void testdbl_to_uint() { auto u = d2uint(12345.6); //writeln(u); assert(u == 12345); } /***************************************************/ ulong r2ulong(real u) { return cast(ulong)u; } void testreal_to_ulong() { auto u = r2ulong(12345.6L); //writeln(u); assert(u == 12345); real adjust = 1.0L/real.epsilon; u = r2ulong(adjust); //writefln("%s %s", adjust, u); static if(real.mant_dig == 64) assert(u == 9223372036854775808UL); else static if(real.mant_dig == 53) assert(u == 4503599627370496UL); else static assert(false, "Test not implemented for this architecture"); auto v = r2ulong(adjust * 1.1); writefln("%s %s %s", adjust, v, u + u/10); //assert(v == 10145709240540253389UL); } /***************************************************/ long testbt1(long a, long b, int c) { return a + ((b >> c) & 1); // return a + ((b & (1L << c)) != 0); } long testbt2(long a, long b, int c) { // return a + ((b >> c) & 1); return a + ((b & (1L << c)) != 0); } int testbt3(int a, int b, int c) { return a + ((b >> c) & 1); // return a + ((b & (1 << c)) != 0); } int testbt4(int a, int b, int c) { // return a + ((b >> c) & 1); return a + ((b & (1 << c)) != 0); } void test248() { auto a1 = testbt1(3, 4, 2); assert(a1 == 4); a1 = testbt2(3, 4, 2); assert(a1 == 4); a1 = testbt3(3, 4, 2); assert(a1 == 4); a1 = testbt4(3, 4, 2); assert(a1 == 4); a1 = testbt1(3, 8, 2); assert(a1 == 3); a1 = testbt2(3, 8, 2); assert(a1 == 3); a1 = testbt3(3, 8, 2); assert(a1 == 3); a1 = testbt4(3, 8, 2); assert(a1 == 3); } /***************************************************/ int foo249(int a, int b) { return a + ((b & 0x80) != 0); } long bar249(long a, int b) { return a + ((b & 0x80) != 0); } void test249() { { auto i = foo249(3, 6); assert(i == 3); i = foo249(3, 0x88); assert(i == 4); } { auto i = bar249(3, 6); assert(i == 3); i = bar249(3, 0x88); assert(i == 4); } } /***************************************************/ // These should all compile to a BT instruction when -O, for -m32 and -m64 int bt32(uint *p, uint b) { return ((p[b >> 5] & (1 << (b & 0x1F)))) != 0; } int bt64a(ulong *p, uint b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; } int bt64b(ulong *p, size_t b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; } void test250() { static uint[2] a1 = [0x1001_1100, 0x0220_0012]; if ( bt32(a1.ptr,30)) assert(0); if (!bt32(a1.ptr,8)) assert(0); if ( bt32(a1.ptr,30+32)) assert(0); if (!bt32(a1.ptr,1+32)) assert(0); static ulong[2] a2 = [0x1001_1100_12345678, 0x0220_0012_12345678]; if ( bt64a(a2.ptr,30+32)) assert(0); if (!bt64a(a2.ptr,8+32)) assert(0); if ( bt64a(a2.ptr,30+32+64)) assert(0); if (!bt64a(a2.ptr,1+32+64)) assert(0); if ( bt64b(a2.ptr,30+32)) assert(0); if (!bt64b(a2.ptr,8+32)) assert(0); if ( bt64b(a2.ptr,30+32+64)) assert(0); if (!bt64b(a2.ptr,1+32+64)) assert(0); } /***************************************************/ struct S251 { int a,b,c,d; } S251 foo251(S251 s) { S251 a = s; S251 b = a; // copy propagation S251 c = b; S251 d = c; S251 e = d; // dead assignment return d; } void test251() { S251 a; a.a = 1; a.b = 2; a.c = 3; a.d = 4; a = foo251(a); assert(a.a == 1); assert(a.b == 2); assert(a.c == 3); assert(a.d == 4); } /***************************************************/ // 9387 void bug9387a(double x) { } void ice9387() { double x = 0.3; double r = x*0.1; double q = x*0.1 + r; double p = x*0.1 + r*0.2; if ( q ) p = -p; bug9387a(p); } /***************************************************/ void bug6962(string value) { string v = value; try { v = v[0LU..0LU]; return; } finally { assert(!v.length); } } void test6962() { bug6962("42"); } /***************************************************/ int[1] foo4414() { return [7]; } ubyte[4] bytes4414() { ubyte[4] x; x[0] = 7; x[1] = 8; x[2] = 9; x[3] = 10; return x; } void test4414() { { int x = foo4414()[0]; assert(x == 7); } { auto x = bytes4414()[0..4]; if (x[0] != 7 || x[1] != 8 || x[2] != 9 || x[3] != 10) assert(0); } } /***************************************************/ void test9844() { int a = -1; long b = -1; assert(a == -1); assert(b == -1L); } /***************************************************/ // 10628 abstract class B10628 { static if (! __traits(isVirtualMethod, foo)) { } private bool _bar; public void foo(); } class D10628 : B10628 { public override void foo() {} } void test10628() { assert(typeid(D10628).vtbl.length - typeid(Object).vtbl.length == 1); } /***************************************************/ // 11265 struct S11265 { class InnerClass { S11265 s; bool empty() { return true; } } } void test11265() { S11265.InnerClass trav = new S11265.InnerClass(); trav.empty(); } /***************************************************/ struct TimeOfDay { void roll(int value) { value %= 60; auto newVal = _seconds + value; if(newVal < 0) newVal += 60; else if(newVal >= 60) newVal -= 60; _seconds = cast(ubyte)newVal; } ubyte _seconds; } void test10633() { TimeOfDay tod = TimeOfDay(0); tod.roll(-1); assert(tod._seconds == 59); } /***************************************************/ import std.stdio; void _assertEq (ubyte lhs, short rhs, string msg, string file, size_t line) { immutable result = lhs == rhs; if(!result) { string op = "=="; if(msg.length > 0) writefln(`_assertEq failed: [%s] is not [%s].`, lhs, rhs); else writefln(`_assertEq failed: [%s] is not [%s]: %s`, lhs, rhs, msg); } assert(result); } struct Date { short year; ubyte month; ubyte day; } struct MonthDay { ubyte month; short day; } void test10642() { static void test(Date date, int day, MonthDay expected, size_t line = __LINE__) { _assertEq(date.day, expected.day, "", __FILE__, line); } test(Date(1999, 1, 1), 1, MonthDay(1,1)); } /***************************************************/ // 11581 alias TT11581(T...) = T; void test11581() { static class A {} static class C { alias Types = TT11581!(4, int); } static C makeC() { return null; } alias T = TT11581!(A); // edim == IntergerExp(0) auto a1 = new T[0]; static assert(is(typeof(a1) == A)); enum d2 = 0; // edim == TypeIdentifier('d2') --> IdentifierExp auto a2 = new T[d2]; static assert(is(typeof(a2) == A)); alias U = int; int d3 = 3; // edim == TypeIdentifier('d3') --> IdentifierExp auto a3 = new U[d3]; static assert(is(typeof(a3) == U[])); assert(a3.length == d3); // edim == IndexExp(DotIdExp(CallExp(makeC, []), 'Types'), 0) auto a4 = new U[makeC().Types[0]]; static assert(is(typeof(a4) == U[])); assert(a4.length == C.Types[0]); } /***************************************************/ // 7436 void test7436() { ubyte a = 10; float f = 6; ubyte b = a += f; assert(b == 16); } /***************************************************/ // 12138 struct S12138 { int num; this(int n) { num = n; } ~this() { num = 0; } } void test12138() { label: auto s = S12138(10); assert(s.num == 10); } /***************************************************/ // 14430 void setCookie(long x = 1L << 32L, string y = null){ assert(y.ptr is null); } void test14430(){ setCookie(); } /***************************************************/ // 14510 alias Vector14510 = ulong[3]; void fun14510(Vector14510 vec, bool recursive = false) { assert(vec[2] == 0); if (recursive) return; fun14510(vec, true); } void test14510() { Vector14510 vec; fun14510(vec); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=16027 void test16027() { double value = 1.0; value *= -1.0; assert(value == -1.0); // fails, value is +1.0 value = 1.0; value = value * -1.0; assert(value == -1.0); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=16530 double entropy2(double[] probs) { double result = 0; foreach (p; probs) { __gshared int x; ++x; if (!p) continue; import std.math : log2; result -= p * log2(p); } return result; } void test16530() { import std.stdio; if (entropy2([1.0, 0, 0]) != 0.0) assert(0); } /***************************************************/ void test252() { __gshared int x = 7; __gshared long y = 217; if ((-1 - x) != ~x) assert(0); if ((-1 - y) != ~y) assert(0); } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=7997 void test7997() { __gshared int[0] foos; foreach (f; foos) {} } /***************************************************/ // https://issues.dlang.org/show_bug.cgi?id=5332 int[0] arr5332; void test5332() { auto a = arr5332; } /***************************************************/ int main() { test1(); test2(); test3(); test4(); test5(); test6(); test7(); test8(); test9(); test10(); test11(); test12(); test13(); test14(); test15(); test16(); test17(); test18(); test19(); test20(); test21(); test22(); test23(); test24(); test25(); test27(); test28(); test29(); test31(); test32(); test33(); test34(); test35(); test36(); test37(); test38(); test39(); test40(); test41(); test42(); test43(); test44(); test45(); test46(); test47(); test48(); test49(); test50(); test51(); test52(); test53(); test54(); test55(); test56(); test57(); test58(); test59(); test60(); test61(); test62(); test63(); test64(); test65(); test66(); test67(); test68(); test69(); test70(); test71(); test72(); test73(); test74(); test75(); test76(); test77(); test78(); test79(); test80(); test81(); test82(); test83(); test84(); test85(); test86(); test87(); test88(); test89(); test90(); test91(); test92(); test93(); test94(); test95(); test96(); test97(); test98(); test99(); test100(); test101(); test103(); test104(); test105(); test107(); test108(); test109(); test110(); test111(); test112(); test113(); test114(); test115(); test116(); test117(); test118(); test119(); test120(); test121(); //test122(); test123(); test124(); test125(); test126(); test127(); test128(); test129(); test130(); test131(); test132(); test133(); // test135(); test136(); test137(); test139(); test140(); test142(); test143(); test144(); test145(); test146(); test147(); test148(); test149(); test151(); test152(); test153(); test154(); test156(); test157(); test160(); test163(); test169(); test171(); test173(); test174(); test176(); test177(); test179(); test181(); test182(); test188(); test189(); test190(); test191(); test193(); test194(); test198(); test200(); test201(); test202(); test203(); // test208(); test210(); test212(); test213(); test214(); test215(); test216(); test217(); test218(); test219(); test220(); test222(); test223(); test224(); test225(); test226(); test227(); test228(); test229(); test230(); test230(); bug5717(); test231(); test232(); test233(); bug6184(); test236(); test237(); test238(); test239(); test6229(); test6270(); test6506(); test240(); test6563(); test241(); test6665(); test5364(); test6189(); test6997(); test7026(); test6354(); test7072(); test7212(); test242(); test7290(); test7367(); test7375(); test6504(); test7422(); test7424(); test7502(); test4820(); test4820_2(); test243(); test7742(); test245(); test7807(); test4155(); test7911(); test8095(); test8091(); test6189_2(); test8199(); test246(); test8454(); test8423(); test8496(); test8840(); test8889(); test8870(); test9781(); test247(); test8340(); test8376(); test8796(); test9171(); test9248(); test14682a(); test14682b(); test9739(); testdbl_to_ulong(); testdbl_to_uint(); testreal_to_ulong(); test248(); test249(); test250(); test6057(); test251(); test6962(); test4414(); test9844(); test10628(); test11265(); test10633(); test10642(); test11581(); test7436(); test12138(); test14430(); test14510(); test16027(); test16530(); test252(); test7997(); test5332(); writefln("Success"); return 0; }
D
module dlangide.workspace.workspace; import dlangide.workspace.project; import dlangide.workspace.workspacesettings; import dlangide.ui.frame; import dlangui.core.logger; import dlangui.core.settings; import std.algorithm : map; import std.conv; import std.file; import std.path; import std.range : array; import std.utf; import ddebug.common.debugger; enum BuildOperation { Build, Clean, Rebuild, Run, Upgrade } enum BuildConfiguration { Debug, Release, Unittest } /** Exception thrown on Workspace errors */ class WorkspaceException : Exception { this(string msg, string file = __FILE__, size_t line = __LINE__) { super(msg, file, line); } } immutable string WORKSPACE_EXTENSION = ".dlangidews"; immutable string WORKSPACE_SETTINGS_EXTENSION = ".wssettings"; /// return true if filename matches rules for workspace file names bool isWorkspaceFile(string filename) { return filename.endsWith(WORKSPACE_EXTENSION); } /// DlangIDE workspace class Workspace : WorkspaceItem { protected Project[] _projects; protected SettingsFile _workspaceFile; protected WorkspaceSettings _settings; protected IDEFrame _frame; protected BuildConfiguration _buildConfiguration; protected ProjectConfiguration _projectConfiguration = ProjectConfiguration.DEFAULT; this(IDEFrame frame, string fname = WORKSPACE_EXTENSION) { super(fname); _workspaceFile = new SettingsFile(fname); _settings = new WorkspaceSettings(fname ? fname ~ WORKSPACE_SETTINGS_EXTENSION : null); _frame = frame; } ProjectSourceFile findSourceFile(string projectFileName, string fullFileName) { foreach(p; _projects) { ProjectSourceFile res = p.findSourceFile(projectFileName, fullFileName); if (res) return res; } return null; } @property Project[] projects() { return _projects; } @property BuildConfiguration buildConfiguration() { return _buildConfiguration; } @property void buildConfiguration(BuildConfiguration config) { _buildConfiguration = config; } @property ProjectConfiguration projectConfiguration() { return _projectConfiguration; } @property void projectConfiguration(ProjectConfiguration config) { _projectConfiguration = config; } protected Project _startupProject; @property Project startupProject() { return _startupProject; } @property void startupProject(Project project) { _startupProject = project; _frame.setProjectConfigurations(project.configurations.keys.map!(k => k.to!dstring).array); _settings.startupProjectName = toUTF8(project.name); } /// setups currrent project configuration by name void setStartupProjectConfiguration(string conf) { if(_startupProject && conf in _startupProject.configurations) { _projectConfiguration = _startupProject.configurations[conf]; } } private void updateBreakpointFiles(Breakpoint[] breakpoints) { foreach(bp; breakpoints) { Project project = findProjectByName(bp.projectName); if (project) bp.fullFilePath = project.relativeToAbsolutePath(bp.projectFilePath); } } private void updateBookmarkFiles(EditorBookmark[] bookmarks) { foreach(bp; bookmarks) { Project project = findProjectByName(bp.projectName); if (project) bp.fullFilePath = project.relativeToAbsolutePath(bp.projectFilePath); } } Breakpoint[] getSourceFileBreakpoints(ProjectSourceFile file) { Breakpoint[] res = _settings.getProjectBreakpoints(toUTF8(file.project.name), file.projectFilePath); updateBreakpointFiles(res); return res; } void setSourceFileBreakpoints(ProjectSourceFile file, Breakpoint[] breakpoints) { _settings.setProjectBreakpoints(toUTF8(file.project.name), file.projectFilePath, breakpoints); } EditorBookmark[] getSourceFileBookmarks(ProjectSourceFile file) { EditorBookmark[] res = _settings.getProjectBookmarks(toUTF8(file.project.name), file.projectFilePath); updateBookmarkFiles(res); return res; } void setSourceFileBookmarks(ProjectSourceFile file, EditorBookmark[] bookmarks) { _settings.setProjectBookmarks(toUTF8(file.project.name), file.projectFilePath, bookmarks); } /// returns all workspace breakpoints Breakpoint[] getBreakpoints() { Breakpoint[] res = _settings.getBreakpoints(); updateBreakpointFiles(res); return res; } protected void fillStartupProject() { string s = _settings.startupProjectName; if ((!_startupProject || !_startupProject.name.toUTF8.equal(s)) && _projects.length) { if (!s.empty) { foreach(p; _projects) { if (p.name.toUTF8.equal(s)) { _startupProject = p; } } } if (!_startupProject) { startupProject = _projects[0]; } } } /// tries to find source file in one of projects, returns found project source file item, or null if not found ProjectSourceFile findSourceFileItem(string filename, bool fullFileName=true) { foreach (Project p; _projects) { ProjectSourceFile res = p.findSourceFileItem(filename, fullFileName); if (res) return res; } return null; } /// find project in workspace by filename Project findProject(string filename) { foreach (Project p; _projects) { if (p.filename.equal(filename)) return p; } return null; } /// find project in workspace by filename Project findProjectByName(string name) { foreach (Project p; _projects) { if (p.name.toUTF8.equal(name)) return p; } return null; } void addProject(Project p) { _projects ~= p; p.workspace = this; fillStartupProject(); } Project removeProject(int index) { if (index < 0 || index > _projects.length) return null; Project res = _projects[index]; for (int j = index; j + 1 < _projects.length; j++) _projects[j] = _projects[j + 1]; return res; } bool isDependencyProjectUsed(string filename) { foreach(p; _projects) if (!p.isDependency && p.findDependencyProject(filename)) return true; return false; } void cleanupUnusedDependencies() { for (int i = cast(int)_projects.length - 1; i >= 0; i--) { if (_projects[i].isDependency) { if (!isDependencyProjectUsed(_projects[i].filename)) removeProject(i); } } } bool addDependencyProject(Project p) { for (int i = 0; i < _projects.length; i++) { if (_projects[i].filename.equal(p.filename)) { _projects[i] = p; return false; } } addProject(p); return true; } string absoluteToRelativePath(string path) { return toForwardSlashSeparator(relativePath(path, _dir)); } override bool save(string fname = null) { if (fname.length > 0) filename = fname; if (_filename.empty) // no file name specified return false; _settings.save(_filename ~ WORKSPACE_SETTINGS_EXTENSION); _workspaceFile.setString("name", toUTF8(_name)); _workspaceFile.setString("description", toUTF8(_description)); Setting projects = _workspaceFile.objectByPath("projects", true); projects.clear(SettingType.OBJECT); foreach (Project p; _projects) { if (p.isDependency) continue; // don't save dependency string pname = toUTF8(p.name); string ppath = absoluteToRelativePath(p.filename); projects[pname] = ppath; } if (!_workspaceFile.save(_filename, true)) { Log.e("Cannot save workspace file"); return false; } return true; } override bool load(string fname = null) { if (fname.length > 0) filename = fname; if (!exists(_filename) || !isFile(_filename)) { return false; } Log.d("Reading workspace from file ", _filename); if (!_workspaceFile.load(_filename)) { Log.e("Cannot read workspace file"); return false; } _settings.load(filename ~ WORKSPACE_SETTINGS_EXTENSION); _name = toUTF32(_workspaceFile["name"].str); _description = toUTF32(_workspaceFile["description"].str); Log.d("workspace name: ", _name); Log.d("workspace description: ", _description); if (_name.empty()) { Log.e("empty workspace name"); return false; } auto originalStartupProjectName = _settings.startupProjectName; Setting projects = _workspaceFile.objectByPath("projects", true); foreach(string key, Setting value; projects) { string path = value.str; Log.d("project: ", key, " path:", path); if (!isAbsolute(path)) path = buildNormalizedPath(_dir, path); //, "dub.json" Project project = new Project(this, path); _projects ~= project; project.load(); } _settings.startupProjectName = originalStartupProjectName; fillStartupProject(); return true; } void close() { } void refresh() { foreach (Project p; _projects) { p.refresh(); } } } /// global workspace __gshared Workspace currentWorkspace;
D
/******************************************************************************* * Copyright (c) 2004, 2006 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 <benoit@tionex.de> *******************************************************************************/ module dwtx.jface.resource.DeviceResourceManager; import dwtx.jface.resource.AbstractResourceManager; import dwtx.jface.resource.DeviceResourceDescriptor; import dwtx.jface.resource.ImageDescriptor; import dwt.graphics.Device; import dwt.graphics.Image; import dwt.dwthelper.utils; /** * Manages DWT resources for a particular device. * * <p> * IMPORTANT: in most cases clients should use a <code>LocalResourceManager</code> instead of a * <code>DeviceResourceManager</code>. To create a resource manager on a particular display, * use <code>new LocalResourceManager(JFaceResources.getResources(myDisplay))</code>. * <code>DeviceResourceManager</code> should only be used directly when managing * resources for a device other than a Display (such as a printer). * </p> * * @see LocalResourceManager * * @since 3.1 */ public final class DeviceResourceManager : AbstractResourceManager { private Device device; private Image missingImage; /* (non-Javadoc) * @see dwtx.jface.resource.ResourceManager#getDevice() */ public override Device getDevice() { return device; } /** * Creates a new registry for the given device. * * @param device device to manage */ public this(Device device) { this.device = device; } /* (non-Javadoc) * @see dwtx.jface.resource.AbstractResourceManager#allocate(dwtx.jface.resource.DeviceResourceDescriptor) */ protected override Object allocate(DeviceResourceDescriptor descriptor){ return descriptor.createResource(device); } /* (non-Javadoc) * @see dwtx.jface.resource.AbstractResourceManager#deallocate(java.lang.Object, dwtx.jface.resource.DeviceResourceDescriptor) */ protected override void deallocate(Object resource, DeviceResourceDescriptor descriptor) { descriptor.destroyResource(resource); } /* (non-Javadoc) * @see dwtx.jface.resource.ResourceManager#getDefaultImage() */ protected override Image getDefaultImage() { if (missingImage is null) { missingImage = ImageDescriptor.getMissingImageDescriptor().createImage(); } return missingImage; } /* (non-Javadoc) * @see dwtx.jface.resource.AbstractResourceManager#dispose() */ public override void dispose() { super.dispose(); if (missingImage !is null) { missingImage.dispose(); missingImage = null; } } }
D
// { dg-do compile } // { dg-options "-O3 -fdump-tree-optimized-raw" } import gcc.attributes; int glob1; int easily_inlinable(int i) { glob1 = i; return 2; } @optStrategy("none") int call_easily_inlinable(int i) { return easily_inlinable(i); } // { dg-final { scan-tree-dump "gimple_call <easily_inlinable" "optimized" } } pragma(inline, true) int always_inline() { return 321; } @optStrategy("none") int call_always_inline() { return always_inline(); } // { dg-final { scan-tree-dump "gimple_call <always_inline" "optimized" } } int glob2; @optStrategy("none") void optnone_function(int i) { glob2 = i; } void call_optnone() { optnone_function(1); } // { dg-final { scan-tree-dump "gimple_call <optnone_function" "optimized" } } @optStrategy("optsize") void optsize_fn() { } @optStrategy("minsize") void minsize_fn() { }
D
/* * Copyright © 2011 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * 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 AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Benjamin Franzke <benjaminfranzke@googlemail.com> */ module dew.gbm; extern(C): public: nothrow: import std.stdint; version = __GBM__; struct gbm_device; struct gbm_bo; struct gbm_surface; struct gbm_import_fd_data { int fd; uint32_t width; uint32_t height; uint32_t stride; uint32_t format; } // Abstraction representing the handle to a buffer allocated by the manager union gbm_bo_handle { void *ptr; int32_t s32; uint32_t u32; int64_t s64; uint64_t u64; } // Format of the allocated buffer enum { GBM_BO_FORMAT_XRGB8888, // RGB with 8 bits per channel in a 32 bit value GBM_BO_FORMAT_ARGB8888 // ARGB with 8 bits per channel in a 32 bit value } auto __gbm_fourcc_code(T)(T a, T b, T c, T d) { return (cast(uint32_t)(a) | (cast(uint32_t)(b) << 8) | (cast(uint32_t)(c) << 16) | (cast(uint32_t)(d) << 24)); } enum GBM_FORMAT_BIG_ENDIAN = (1<<31); // format is big endian instead of little endian // color index enum GBM_FORMAT_C8 = __gbm_fourcc_code('C', '8', ' ', ' '); // [7:0] C // 8 bpp RGB enum GBM_FORMAT_RGB332 = __gbm_fourcc_code('R', 'G', 'B', '8'); // [7:0] R:G:B 3:3:2 enum GBM_FORMAT_BGR233 = __gbm_fourcc_code('B', 'G', 'R', '8'); // [7:0] B:G:R 2:3:3 // 16 bpp RGB enum GBM_FORMAT_XRGB4444 = __gbm_fourcc_code('X', 'R', '1', '2'); // [15:0] x:R:G:B 4:4:4:4 little endian enum GBM_FORMAT_XBGR4444 = __gbm_fourcc_code('X', 'B', '1', '2'); // [15:0] x:B:G:R 4:4:4:4 little endian enum GBM_FORMAT_RGBX4444 = __gbm_fourcc_code('R', 'X', '1', '2'); // [15:0] R:G:B:x 4:4:4:4 little endian enum GBM_FORMAT_BGRX4444 = __gbm_fourcc_code('B', 'X', '1', '2'); // [15:0] B:G:R:x 4:4:4:4 little endian enum GBM_FORMAT_ARGB4444 = __gbm_fourcc_code('A', 'R', '1', '2'); // [15:0] A:R:G:B 4:4:4:4 little endian enum GBM_FORMAT_ABGR4444 = __gbm_fourcc_code('A', 'B', '1', '2'); // [15:0] A:B:G:R 4:4:4:4 little endian enum GBM_FORMAT_RGBA4444 = __gbm_fourcc_code('R', 'A', '1', '2'); // [15:0] R:G:B:A 4:4:4:4 little endian enum GBM_FORMAT_BGRA4444 = __gbm_fourcc_code('B', 'A', '1', '2'); // [15:0] B:G:R:A 4:4:4:4 little endian enum GBM_FORMAT_XRGB1555 = __gbm_fourcc_code('X', 'R', '1', '5'); // [15:0] x:R:G:B 1:5:5:5 little endian enum GBM_FORMAT_XBGR1555 = __gbm_fourcc_code('X', 'B', '1', '5'); // [15:0] x:B:G:R 1:5:5:5 little endian enum GBM_FORMAT_RGBX5551 = __gbm_fourcc_code('R', 'X', '1', '5'); // [15:0] R:G:B:x 5:5:5:1 little endian enum GBM_FORMAT_BGRX5551 = __gbm_fourcc_code('B', 'X', '1', '5'); // [15:0] B:G:R:x 5:5:5:1 little endian enum GBM_FORMAT_ARGB1555 = __gbm_fourcc_code('A', 'R', '1', '5'); // [15:0] A:R:G:B 1:5:5:5 little endian enum GBM_FORMAT_ABGR1555 = __gbm_fourcc_code('A', 'B', '1', '5'); // [15:0] A:B:G:R 1:5:5:5 little endian enum GBM_FORMAT_RGBA5551 = __gbm_fourcc_code('R', 'A', '1', '5'); // [15:0] R:G:B:A 5:5:5:1 little endian enum GBM_FORMAT_BGRA5551 = __gbm_fourcc_code('B', 'A', '1', '5'); // [15:0] B:G:R:A 5:5:5:1 little endian enum GBM_FORMAT_RGB565 = __gbm_fourcc_code('R', 'G', '1', '6'); // [15:0] R:G:B 5:6:5 little endian enum GBM_FORMAT_BGR565 = __gbm_fourcc_code('B', 'G', '1', '6'); // [15:0] B:G:R 5:6:5 little endian // 24 bpp RGB enum GBM_FORMAT_RGB888 = __gbm_fourcc_code('R', 'G', '2', '4'); // [23:0] R:G:B little endian enum GBM_FORMAT_BGR888 = __gbm_fourcc_code('B', 'G', '2', '4'); // [23:0] B:G:R little endian // 32 bpp RGB enum GBM_FORMAT_XRGB8888 = __gbm_fourcc_code('X', 'R', '2', '4'); // [31:0] x:R:G:B 8:8:8:8 little endian enum GBM_FORMAT_XBGR8888 = __gbm_fourcc_code('X', 'B', '2', '4'); // [31:0] x:B:G:R 8:8:8:8 little endian enum GBM_FORMAT_RGBX8888 = __gbm_fourcc_code('R', 'X', '2', '4'); // [31:0] R:G:B:x 8:8:8:8 little endian enum GBM_FORMAT_BGRX8888 = __gbm_fourcc_code('B', 'X', '2', '4'); // [31:0] B:G:R:x 8:8:8:8 little endian enum GBM_FORMAT_ARGB8888 = __gbm_fourcc_code('A', 'R', '2', '4'); // [31:0] A:R:G:B 8:8:8:8 little endian enum GBM_FORMAT_ABGR8888 = __gbm_fourcc_code('A', 'B', '2', '4'); // [31:0] A:B:G:R 8:8:8:8 little endian enum GBM_FORMAT_RGBA8888 = __gbm_fourcc_code('R', 'A', '2', '4'); // [31:0] R:G:B:A 8:8:8:8 little endian enum GBM_FORMAT_BGRA8888 = __gbm_fourcc_code('B', 'A', '2', '4'); // [31:0] B:G:R:A 8:8:8:8 little endian enum GBM_FORMAT_XRGB2101010 = __gbm_fourcc_code('X', 'R', '3', '0'); // [31:0] x:R:G:B 2:10:10:10 little endian enum GBM_FORMAT_XBGR2101010 = __gbm_fourcc_code('X', 'B', '3', '0'); // [31:0] x:B:G:R 2:10:10:10 little endian enum GBM_FORMAT_RGBX1010102 = __gbm_fourcc_code('R', 'X', '3', '0'); // [31:0] R:G:B:x 10:10:10:2 little endian enum GBM_FORMAT_BGRX1010102 = __gbm_fourcc_code('B', 'X', '3', '0'); // [31:0] B:G:R:x 10:10:10:2 little endian enum GBM_FORMAT_ARGB2101010 = __gbm_fourcc_code('A', 'R', '3', '0'); // [31:0] A:R:G:B 2:10:10:10 little endian enum GBM_FORMAT_ABGR2101010 = __gbm_fourcc_code('A', 'B', '3', '0'); // [31:0] A:B:G:R 2:10:10:10 little endian enum GBM_FORMAT_RGBA1010102 = __gbm_fourcc_code('R', 'A', '3', '0'); // [31:0] R:G:B:A 10:10:10:2 little endian enum GBM_FORMAT_BGRA1010102 = __gbm_fourcc_code('B', 'A', '3', '0'); // [31:0] B:G:R:A 10:10:10:2 little endian // packed YCbCr enum GBM_FORMAT_YUYV = __gbm_fourcc_code('Y', 'U', 'Y', 'V'); // [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian enum GBM_FORMAT_YVYU = __gbm_fourcc_code('Y', 'V', 'Y', 'U'); // [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian enum GBM_FORMAT_UYVY = __gbm_fourcc_code('U', 'Y', 'V', 'Y'); // [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian enum GBM_FORMAT_VYUY = __gbm_fourcc_code('V', 'Y', 'U', 'Y'); // [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian enum GBM_FORMAT_AYUV = __gbm_fourcc_code('A', 'Y', 'U', 'V'); // [31:0] A:Y:Cb:Cr 8:8:8:8 little endian /* * 2 plane YCbCr * index 0 = Y plane, [7:0] Y * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian * or * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian */ enum GBM_FORMAT_NV12 = __gbm_fourcc_code('N', 'V', '1', '2'); // 2x2 subsampled Cr:Cb plane enum GBM_FORMAT_NV21 = __gbm_fourcc_code('N', 'V', '2', '1'); // 2x2 subsampled Cb:Cr plane enum GBM_FORMAT_NV16 = __gbm_fourcc_code('N', 'V', '1', '6'); // 2x1 subsampled Cr:Cb plane enum GBM_FORMAT_NV61 = __gbm_fourcc_code('N', 'V', '6', '1'); // 2x1 subsampled Cb:Cr plane /* * 3 plane YCbCr * index 0: Y plane, [7:0] Y * index 1: Cb plane, [7:0] Cb * index 2: Cr plane, [7:0] Cr * or * index 1: Cr plane, [7:0] Cr * index 2: Cb plane, [7:0] Cb */ enum GBM_FORMAT_YUV410 = __gbm_fourcc_code('Y', 'U', 'V', '9'); // 4x4 subsampled Cb (1) and Cr (2) planes enum GBM_FORMAT_YVU410 = __gbm_fourcc_code('Y', 'V', 'U', '9'); // 4x4 subsampled Cr (1) and Cb (2) planes enum GBM_FORMAT_YUV411 = __gbm_fourcc_code('Y', 'U', '1', '1'); // 4x1 subsampled Cb (1) and Cr (2) planes enum GBM_FORMAT_YVU411 = __gbm_fourcc_code('Y', 'V', '1', '1'); // 4x1 subsampled Cr (1) and Cb (2) planes enum GBM_FORMAT_YUV420 = __gbm_fourcc_code('Y', 'U', '1', '2'); // 2x2 subsampled Cb (1) and Cr (2) planes enum GBM_FORMAT_YVU420 = __gbm_fourcc_code('Y', 'V', '1', '2'); // 2x2 subsampled Cr (1) and Cb (2) planes enum GBM_FORMAT_YUV422 = __gbm_fourcc_code('Y', 'U', '1', '6'); // 2x1 subsampled Cb (1) and Cr (2) planes enum GBM_FORMAT_YVU422 = __gbm_fourcc_code('Y', 'V', '1', '6'); // 2x1 subsampled Cr (1) and Cb (2) planes enum GBM_FORMAT_YUV444 = __gbm_fourcc_code('Y', 'U', '2', '4'); // non-subsampled Cb (1) and Cr (2) planes enum GBM_FORMAT_YVU444 = __gbm_fourcc_code('Y', 'V', '2', '4'); // non-subsampled Cr (1) and Cb (2) planes enum { GBM_BO_USE_SCANOUT = (1 << 0), // Buffer is going to be presented to the screen using an API such as KMS GBM_BO_USE_CURSOR = (1 << 1), // Buffer is going to be used as cursor GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR, // Deprecated GBM_BO_USE_RENDERING = (1 << 2), // Buffer is to be used for rendering - for example it is going to be used as the storage for a color buffer GBM_BO_USE_WRITE = (1 << 3), // Buffer can be used for gbm_bo_write. This is guaranteed to work with GBM_BO_USE_CURSOR. but may not work for other combinations. GBM_BO_USE_LINEAR = (1 << 4), // Buffer is linear, i.e. not tiled. GBM_BO_IMPORT_WL_BUFFER = 0x5501, GBM_BO_IMPORT_EGL_IMAGE = 0x5502, GBM_BO_IMPORT_FD = 0x5503 } export int gbm_device_get_fd(gbm_device *gbm); export const(char)* gbm_device_get_backend_name(gbm_device *gbm); export int gbm_device_is_format_supported(gbm_device *gbm, uint32_t format, uint32_t usage); export void gbm_device_destroy(gbm_device *gbm); export gbm_device* gbm_create_device(int fd); export gbm_bo* gbm_bo_create(gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags); export gbm_bo* gbm_bo_import(gbm_device *gbm, uint32_t type, void *buffer, uint32_t usage); export uint32_t gbm_bo_get_width(gbm_bo *bo); export uint32_t gbm_bo_get_height(gbm_bo *bo); export uint32_t gbm_bo_get_stride(gbm_bo *bo); export uint32_t gbm_bo_get_format(gbm_bo *bo); export gbm_device* gbm_bo_get_device(gbm_bo *bo); export gbm_bo_handle gbm_bo_get_handle(gbm_bo *bo); export int gbm_bo_get_fd(gbm_bo *bo); export int gbm_bo_write(gbm_bo *bo, const void *buf, size_t count); export void gbm_bo_set_user_data(gbm_bo *bo, void *data, void function(gbm_bo*, void*) destroy_user_data); export void* gbm_bo_get_user_data(gbm_bo *bo); export void gbm_bo_destroy(gbm_bo *bo); export gbm_surface* gbm_surface_create(gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags); export int gbm_surface_needs_lock_front_buffer(gbm_surface *surface); export gbm_bo* gbm_surface_lock_front_buffer(gbm_surface *surface); export void gbm_surface_release_buffer(gbm_surface *surface, gbm_bo *bo); export int gbm_surface_has_free_buffers(gbm_surface *surface); export void gbm_surface_destroy(gbm_surface *surface);
D
# FIXED Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/sysctl.c Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F28x_Project.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Cla_typedefs.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_device.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/assert.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/linkage.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdarg.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdbool.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stddef.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdint.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_adc.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_analogsubsys.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_can.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cla.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cmpss.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cputimer.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dac.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dcsm.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dma.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_ecap.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_emif.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_epwm.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_epwm_xbar.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_eqep.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_flash.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_gpio.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_i2c.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_input_xbar.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_ipc.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_mcbsp.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_memconfig.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_nmiintrupt.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_output_xbar.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_piectrl.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_pievect.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sci.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sdfm.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_spi.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sysctrl.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_upp.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_xbar.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_xint.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Examples.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_GlobalPrototypes.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_cputimervars.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Cla_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_EPwm_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Adc_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Emif_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Gpio_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_I2c_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Ipc_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Pie_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Dma_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_SysCtrl_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Upp_defines.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_defaultisr.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/inc/hw_types.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/debug.h Comun/driverlib/sysctl.obj: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/sysctl.h C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/sysctl.c: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F28x_Project.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Cla_typedefs.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_device.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/assert.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/linkage.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdarg.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdbool.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stddef.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/ti-cgt-c2000_16.9.6.LTS/include/stdint.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_adc.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_analogsubsys.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_can.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cla.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cmpss.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_cputimer.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dac.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dcsm.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_dma.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_ecap.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_emif.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_epwm.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_epwm_xbar.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_eqep.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_flash.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_gpio.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_i2c.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_input_xbar.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_ipc.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_mcbsp.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_memconfig.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_nmiintrupt.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_output_xbar.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_piectrl.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_pievect.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sci.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sdfm.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_spi.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_sysctrl.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_upp.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_xbar.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_headers/include/F2837xD_xint.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Examples.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_GlobalPrototypes.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_cputimervars.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Cla_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_EPwm_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Adc_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Emif_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Gpio_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_I2c_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Ipc_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Pie_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Dma_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_SysCtrl_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_Upp_defines.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/F2837xD_defaultisr.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/F2837xD_common/include/inc/hw_types.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/debug.h: C:/Users/dagaro/workspace/Firmware_Test/UFCharger/F2837xD/Comun/driverlib/sysctl.h:
D
import std.stdio; uint palindrome(uint x){ int y=0; while(x != 0){ y = y*10 + x%10; x = (x - x%10)/10; } return y; } bool isPalindrome(uint x){ return x == palindrome(x); } void main(){ const int upper = 1000; int largest = 0; for(int i=0; i<upper; i++){ for(int j=0; j<=i; j++){ if(isPalindrome(i*j) && i*j>largest){ largest = i*j; } } } writefln("The largest palindrome is %d",largest); }
D
/Users/kimhyewon/Documents/Server/tennis/build/tennis.build/Debug/FluentMySQL.build/Objects-normal/x86_64/MySQLSerializer.o : /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLDriver.swift /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLSerializer.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/kimhyewon/Documents/Server/tennis/build/Debug/Fluent.framework/Modules/Fluent.swiftmodule/x86_64.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/Darwin.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/ObjectiveC.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/kimhyewon/Documents/Server/tennis/build/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/MySQL.framework/Modules/MySQL.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/JSON.framework/Modules/JSON.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Jay.framework/Modules/Jay.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/tennis.build/Debug/FluentMySQL.build/Objects-normal/x86_64/MySQLSerializer~partial.swiftmodule : /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLDriver.swift /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLSerializer.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/kimhyewon/Documents/Server/tennis/build/Debug/Fluent.framework/Modules/Fluent.swiftmodule/x86_64.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/Darwin.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/ObjectiveC.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/kimhyewon/Documents/Server/tennis/build/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/MySQL.framework/Modules/MySQL.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/JSON.framework/Modules/JSON.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Jay.framework/Modules/Jay.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/tennis.build/Debug/FluentMySQL.build/Objects-normal/x86_64/MySQLSerializer~partial.swiftdoc : /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLDriver.swift /Users/kimhyewon/Documents/Server/tennis/Packages/FluentMySQL-1.0.1/Sources/FluentMySQL/MySQLSerializer.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/kimhyewon/Documents/Server/tennis/build/Debug/Fluent.framework/Modules/Fluent.swiftmodule/x86_64.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/Darwin.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/ObjectiveC.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/kimhyewon/Documents/Server/tennis/build/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/MySQL.framework/Modules/MySQL.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Core.framework/Modules/Core.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/libc.framework/Modules/libc.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/JSON.framework/Modules/JSON.swiftmodule/x86_64.swiftmodule /Users/kimhyewon/Documents/Server/tennis/build/Debug/Jay.framework/Modules/Jay.swiftmodule/x86_64.swiftmodule
D
/// Images IO and manipulation module. module img; import std.exception; import std.typecons : Nullable, Flag, Yes, No; /// Internal representation of an image. enum ImageFormat { /// 1 bit per pixel alpha value. Used for masking. a1, /// 8 bits per pixel alpha value. Used for masking. a8, /// 32 bits per pixel RGB. Upper 8 bits are unused. xrgb, /// 32 bits per pixel ARGB. Stored in machine native byte order. argb, /// 32 bits per pixel ARGB. RGB channels are premultiplied by the alpha /// channel. Applications can use this format to boost the alpha blending /// computations. Stored in machine native byte order. argbPremult, } /// Whether the format only has alpha component. @property bool isPureAlpha(in ImageFormat format) { return format == ImageFormat.a1 || format == ImageFormat.a8; } /// Whether the format has alpha component. @property bool hasAlpha(in ImageFormat format) { return format != ImageFormat.xrgb; } /// Whether the format has color components. @property bool hasRgb(in ImageFormat format) { return !format.isPureAlpha; } /// How many bits per pixel for a format? @property size_t bpp(in ImageFormat format) pure { final switch(format) { case ImageFormat.a1: return 1; case ImageFormat.a8: return 8; case ImageFormat.xrgb: case ImageFormat.argb: case ImageFormat.argbPremult: return 32; } } /// The number of bytes needed for each row of an image to be aligned to the /// given alignment (4 bytes by default). /// This is often useful for image manipulation or to be used as textures. size_t imageAlignedStride(in ImageFormat format, in uint width, in size_t alignment=4) pure { immutable size_t bits = format.bpp * width; return (((bits + 7) / 8) + alignment-1) & (-alignment); } unittest { enum strideAlignment = 4; assert(ImageFormat.a1.imageAlignedStride(0) == 0); assert(ImageFormat.a1.imageAlignedStride(1) == strideAlignment); assert(ImageFormat.a1.imageAlignedStride(5) == strideAlignment); assert(ImageFormat.a1.imageAlignedStride(48) == 2*strideAlignment); assert(ImageFormat.a1.imageAlignedStride(64) == 2*strideAlignment); assert(ImageFormat.a1.imageAlignedStride(65) == 3*strideAlignment); assert(ImageFormat.a8.imageAlignedStride(1) == strideAlignment); assert(ImageFormat.a8.imageAlignedStride(3) == strideAlignment); assert(ImageFormat.a8.imageAlignedStride(4) == strideAlignment); assert(ImageFormat.a8.imageAlignedStride(5) == 2*strideAlignment); assert(ImageFormat.a8.imageAlignedStride(8) == 2*strideAlignment); assert(ImageFormat.a8.imageAlignedStride(9) == 3*strideAlignment); assert(ImageFormat.argb.imageAlignedStride(1) == strideAlignment); assert(ImageFormat.argb.imageAlignedStride(2) == 2*strideAlignment); assert(ImageFormat.argb.imageAlignedStride(3) == 3*strideAlignment); assert(ImageFormat.argb.imageAlignedStride(4) == 4*strideAlignment); assert(ImageFormat.argb.imageAlignedStride(5) == 5*strideAlignment); } /// Format of a serialized image enum ImageFileFormat { png, jpeg, } /// In-memory representation of an image. class Image { private ubyte[] _data; private ImageFormat _format; private uint _width; // in px private uint _height; // in px private size_t _stride; // in bytes /// Allocates an image with format and size. /// Image stride is given by max(minStride, format.imageAlignedStride(size.width)) /// The pixel content is not initialized. this(ImageFormat format, uint[2] size, size_t minStride=0) { import std.array : uninitializedArray; import std.algorithm : max; _format = format; _width = size[0]; _height = size[1]; _stride = max(minStride, format.imageAlignedStride(size[0])); _data = uninitializedArray!(ubyte[])(_stride * _height); } /// Initialize an $(D Image) with existing $(D data) and $(D format), /// $(D width) and $(D stride). /// Notes: /// - $(D data) is kept within the $(D Image) without any copy or relocation /// - the $(D height) is computed as $(D data.length / stride). The data slice /// must be therefore adjusted to reflect the correct height; /// /// Stride can be used to pass in a slice of a bigger image. this(ubyte[] data, in ImageFormat fmt, in uint width, in size_t stride) { const height = data.length / stride; enforce(data.length >= stride && data.length % stride == 0); enforce(width <= 8*stride/fmt.bpp, "image from data: invalid width (bigger than stride)"); this(data, fmt, width, cast(uint)height, stride); } /// ditto immutable this(immutable(ubyte)[] data, in ImageFormat fmt, in uint width, in size_t stride) { const height = data.length / stride; enforce(data.length >= stride && data.length % stride == 0); enforce(width <= 8*stride/fmt.bpp, "image from data: invalid width (bigger than stride)"); this(data, fmt, width, cast(uint)height, stride); } private this(ubyte[] data, ImageFormat format, uint width, uint height, size_t stride) { _data = data; _format = format; _width = width; _height = height; _stride = stride; } private immutable this (immutable(ubyte)[] data, ImageFormat format, uint width, uint height, size_t stride) { _data = data; _format = format; _width = width; _height = height; _stride = stride; } /// Direct access to pixel data. @property inout(ubyte)[] data() inout { return _data; } /// Direct access to the pixel data of one line inout(ubyte)[] line(in uint l) inout in { assert(l < _height); } out(line) { assert(line.length == _width*_format.bpp/8); } body { immutable start = l * _stride; immutable end = start + _width*_format.bpp/8; return _data[start .. end]; } /// Get the internal format @property ImageFormat format() const { return _format; } /// The width of the image @property uint width() const { return _width; } /// The height of the image @property uint height() const { return _height; } /// The size of the image @property uint[2] size() const { return [ _width, _height ]; } /// Get the number of bytes between two rows @property size_t stride() const { return _stride; } /// blit pixels from src into this image. /// The two formats must be identical and this must be big enough in both directions /// Unimplemented for ImageFormat.a1. void blitFrom(const(Image) src, in int[2] srcOrig, in int[2] destOrig, in uint[2] size, in bool yReversed=false) { enforce(format == src.format, "image blit: format mismatch"); enforce(src.width >= srcOrig[0]+size[0], "image blit: src[0] too small"); enforce(src.height >= srcOrig[1]+size[1]); enforce(this.width >= destOrig[0]+size[0]); enforce(this.height >= destOrig[1]+size[1]); assert(format != ImageFormat.a1); immutable pixelStride = bpp(format)/8; immutable copyStride = pixelStride * size[0]; foreach(l; 0 .. size[1]) { immutable srcL = yReversed ? (size[1]-(l+srcOrig[1])-1) : (l+srcOrig[1]); immutable srcPos = srcL * src.stride + pixelStride * srcOrig[0]; immutable destL = l+destOrig[1]; immutable destPos = destL * this.stride + pixelStride * destOrig[0]; _data[destPos .. destPos+copyStride] = src.data[srcPos .. srcPos+copyStride]; } } /// Read the file specified by filename and load into an Image. static Image loadFromFile(in string filename, in ImageFormat format) { auto io = imgIOFromFile(filename); if (!io) { throw new Exception("Unrecognized image format"); } return io.readFile(filename, format); } /// Read the file specified by buffer and load into an Image. /// Reads in ImageFormat.argb static Image loadFromMemory(in ubyte[] data, in ImageFormat format) { auto io = imgIOFromMem(data); if (!io) { throw new Exception("Unrecognized image format"); } return io.readMem(data, format); } /// Read the file specified at compile time by using an import expression /// to read the bytes static Image loadFromView(string path)(in ImageFormat format) { immutable data = cast(immutable(ubyte)[])import(path); auto io = imgIOFromMem(data); if (!io) { throw new Exception("Unrecognized image format:" ~ path); } return io.readMem(data, format); } /// Save the image to the specified buffer. /// Only ImageFormat.argb is supported. void saveToFile(in string filename) const { auto io = imgIOFromFile(filename); io.writeFile(this, filename); } /// Duplicates the image into an image completely independant of this one. @property Image dup() const { return new Image(_data.dup, _format, _width, _height, _stride); } /// Duplicates the image into an immutable image @property immutable(Image) idup() const { return new immutable Image(_data.idup, _format, _width, _height, _stride); } /// Convert the image into another format. If format is the same, dup is returned. /// It is only possible to convert between a1 and a8 or between one of the /// rgb formats. An unsupported conversion tentative will throw. Image convert(in ImageFormat format) const { if (format == _format) { return dup; } if (format.isPureAlpha != _format.isPureAlpha && format.hasRgb != _format.hasRgb) { import std.conv : to; throw new Exception( "Unsupported image conversion from "~_format.to!string~ " to "~format.to!string ); } immutable stride = format.imageAlignedStride(_width); auto res = new Image ( new ubyte[stride * _height], format, _width, _height, stride ); if (_format == ImageFormat.a8 && format == ImageFormat.a1) { /// TODO: accumulation of 4 bytes at a time foreach (l; 0 .. _height) { const from = line(l); auto to = res.line(l); int count=0; int ind =0; ubyte val=0; foreach (p; 0 .. _width) { if (from[p] > 127) val &= (1 << count); if (++count == 8) { to[ind++] = val; val = 0; count = 0; } } // if we are not multiple of 8, the last byte is not written assert(count == 0 || _width % 8); if (count) to[ind] = val; } } else if (_format == ImageFormat.a1 && format == ImageFormat.a8) { /// TODO: accumulation of 4 bytes at a time foreach (l; 0 .. _height) { const from = line(l); auto to = res.line(l); foreach (p; 0 .. _width) { to[p] = getA1(from, p) ? 0xff : 0x00; } } } else if ((_format == ImageFormat.xrgb && format == ImageFormat.argb) || (_format == ImageFormat.argb && format == ImageFormat.xrgb)) { fourBytesConv!eraseAlpha(this, res); } else if (_format == ImageFormat.argbPremult) { assert(format.hasRgb); fourBytesConv!unpremultiply(this, res); } else if (format == ImageFormat.argbPremult) { assert(_format.hasRgb); fourBytesConv!premultiply(this, res); } else { assert(false); } return res; } } /// Create a slice of the given image, referencing the same data. /// ImageFormat.a1 is not supported. Image slice(Image img, in int[2] offset, in uint[2] size) { assert(img); assert(img.format != ImageFormat.a1); enforce(offset[0]+size[0] <= img.width); enforce(offset[1]+size[1] <= img.height); const bytesPerPix = img.format.bpp / 8; const dataOffset = (offset[1]*img.stride + offset[0]) * bytesPerPix; const dataLen = (size[1]*img.stride + size[0]) * bytesPerPix; auto dataSlice = img.data[dataOffset .. dataOffset + dataLen]; return new Image ( dataSlice, img.format, cast(ushort)size[0], cast(ushort)size[1], img.stride ); } /// Create a slice of the given image, referencing the same data. /// ImageFormat.a1 is not supported. immutable(Image) slice(immutable(Image) img, in int[2] offset, in uint[2] size) { assert(img); assert(img.format != ImageFormat.a1); enforce(offset[0]+size[0] <= img.width); enforce(offset[1]+size[1] <= img.height); const bytesPerPix = img.format.bpp / 8; const dataOffset = (offset[1]*img.stride + offset[0]) * bytesPerPix; const dataLen = (size[1]*img.stride + size[0]) * bytesPerPix; immutable dataSlice = img.data[dataOffset .. dataOffset + dataLen]; return new immutable Image ( dataSlice, img.format, cast(ushort)size[0], cast(ushort)size[1], img.stride ); } unittest { import std.algorithm : equal; ubyte[] data = new ubyte[8*8]; foreach(i; 0 .. 8*8) { data[i] = cast(ubyte)i; } // 0, 1, 2, 3, 4, 5 ... // 8, 9, 10, 11, ... // 16, 17, 23, ... // ... auto big = new Image(data, ImageFormat.a8, 8, 8); auto small = big.slice(IPoint(5, 4), ISize(3, 2)); assert(small.stride == big.stride); assert(small.size == ISize(3, 2)); assert(small.line(0).equal([37, 38, 39])); assert(small.line(1).equal([45, 46, 47])); } /// Assumes the image is unique and converts it into an immutable image immutable(Image) assumeUnique(ref Image img) { import std.exception : assumeUnique; immutable res = new immutable(Image)( assumeUnique(img.data), img.format, img.width, img.height, img.stride ); img = null; return res; } /// ditto immutable(Image) assumeUnique(Image img) { import std.exception : assumeUnique; return new immutable(Image)( assumeUnique(img.data), img.format, img.width, img.height, img.stride ); } private void fourBytesConv(alias convFn)(const(Image) from, Image to) if (is(typeof(convFn(uint.init)) == uint)) in { assert(from.size == to.size); assert(from.format.bpp == 32 && to.format.bpp == 32); } body { foreach (l; 0 .. from.height) { const lfrom = from.line(l); auto lto = to.line(l); foreach (offset; 0 .. from.width) { immutable px = getArgb(lfrom, offset); setArgb(lto, offset, convFn(px)); } } } /// Apply in-place the conversion function to each 4 bytes group of data. /// If the image has 4 bytes component, each pixel will be processed individually. /// Image.stride is always 4 bytes aligned. void apply(alias convFn)(Image img) if (is(typeof(convFn(uint.init)) == uint)) { foreach (l; 0 .. img.height) { auto line = img.line(l); foreach (i; 0 .. img.width) { immutable px = getArgb(line, i); setArgb(line, i, convFn(px)); } } } // pixel access helpers /// Get the alpha component of a argb pixel value. @property ubyte alpha(in uint value) { return (value >> 24) & 0xff; } /// Get the red component of a argb or rgb pixel value. @property ubyte red(in uint value) { return (value >> 16) & 0xff; } /// Get the green component of a argb or rgb pixel value. @property ubyte green(in uint value) { return (value >> 8) & 0xff; } /// Get the blue component of a argb or rgb pixel value. @property ubyte blue(in uint value) { return value & 0xff; } /// Builds a rgb pixel value from its components. uint rgb (in ubyte red, in ubyte green, in ubyte blue) { return (red << 16) | (green << 8) | blue; } /// Builds a argb pixel value from its components. uint argb (in ubyte alpha, in ubyte red, in ubyte green, in ubyte blue) { return (alpha << 24) | (red << 16) | (green << 8) | blue; } /// Premultiplies a argb value. Due to integer rounding, the assertion /// $(D premultiply(unpremultiply(value)) == value) is not guaranteed. uint premultiply(in uint value) { immutable alpha = value.alpha; return argb( alpha, cast(ubyte)(value.red * alpha / 255), cast(ubyte)(value.green * alpha / 255), cast(ubyte)(value.blue * alpha / 255), ); } /// Unpremultiplies a argb value. Due to integer rounding, the assertion /// $(D unpremultiply(premultiply(value)) == value) is not guaranteed. uint unpremultiply(in uint value) { immutable alpha = value.alpha; if (!alpha) return value; else return argb( alpha, cast(ubyte)(value.red * 255 / alpha), cast(ubyte)(value.green * 255 / alpha), cast(ubyte)(value.blue * 255 / alpha), ); } /// Erase the alpha channel of the given pixel. uint eraseAlpha(in uint value) { return 0xff000000 & value; } /// Get a pixel value from a $(D ImageFormat.a1) scanline. /// Setter is not given because would be too inefficient. Typically one would /// instead accumulate at least 8 values to push one byte or more at a time. bool getA1(in ubyte[] data, in size_t offset) in { assert(data.length > offset/8); } body { return (data[offset / 8] & (0x80 >> (offset & 7))) != 0; } /// Get a pixel value from a rgb or argb scanline with an offset in pixel. uint getArgb(in ubyte[] data, in size_t offset) in { assert(data.length >= offset*4+4); } body { immutable index = offset*4; union bi { ubyte[4] b; uint i; } bi px = void; px.b = data[index .. index+4]; return px.i; } unittest { ubyte[] data = [ 0x01, 0x10, 0x23, 0xf4, 0x45, 0x23, 0x18, 0x60, 0xa5, 0x65, 0x53, 0x34, 0xdb, 0x04, 0xe8, 0x11, ]; version(BigEndian) { assert(getArgb(data, 0) == 0x011023f4); assert(getArgb(data, 1) == 0x45231860); assert(getArgb(data, 2) == 0xa5655334); assert(getArgb(data, 3) == 0xdb04e811); } version(LittleEndian) { assert(getArgb(data, 0) == 0xf4231001); assert(getArgb(data, 1) == 0x60182345); assert(getArgb(data, 2) == 0x345365a5); assert(getArgb(data, 3) == 0x11e804db); } } /// Set a pixel value within a rgb or argb scanline with an offset in pixel. void setArgb(ubyte[] data, in size_t offset, in uint argb) in { assert(data.length >= offset*4+4); } body { immutable index = offset*4; union bi { ubyte[4] b; uint i; } bi px = void; px.i = argb; data[index .. index+4] = px.b; } unittest { ubyte[16] data; version(BigEndian) { data.setArgb(0, 0x011023f4); data.setArgb(1, 0x45231860); data.setArgb(2, 0xa5655334); data.setArgb(3, 0xdb04e811); } version(LittleEndian) { data.setArgb(0, 0xf4231001); data.setArgb(1, 0x60182345); data.setArgb(2, 0x345365a5); data.setArgb(3, 0x11e804db); } assert(data == [ 0x01, 0x10, 0x23, 0xf4, 0x45, 0x23, 0x18, 0x60, 0xa5, 0x65, 0x53, 0x34, 0xdb, 0x04, 0xe8, 0x11, ]); } /// Checks the first few bytes of the given data to check for a valid serialized /// image signature. Nullable!ImageFileFormat checkImgSig(const(ubyte)[] data) pure { import std.algorithm : equal; import std.range : only; Nullable!ImageFileFormat res; if (data.length >= 8 && data[0 .. 8].equal(only(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a))) { res = ImageFileFormat.png; } else if (data.length >= 11 && data[0 .. 3].equal(only(0xff, 0xd8, 0xff)) && (data[3] & 0xfe) == 0xe0 && data[6 .. 11].equal(only(0x4a, 0x46, 0x49, 0x46, 0x00))) { res = ImageFileFormat.jpeg; } return res; } private { import img.libjpeg.turbojpeg; import img.libpng.png; import std.path; import std.string; import std.uni : toLower; ImgIO imgIOFromFile (string filename) out (result) { assert(result !is null); } body { /// TODO: do not trust extension. immutable ext = filename.extension.toLower; switch (ext) { case ".png": return new PngIO; case ".jpg": case ".jpeg": return new JpegIO; default: return null; } } ImgIO imgIOFromMem(const(ubyte)[] data) { auto fmt = checkImgSig(data); if (fmt.isNull) return null; return imgIOFromFormat(fmt); } ImgIO imgIOFromFormat(in ImageFileFormat format) { final switch (format) { case ImageFileFormat.png: return new PngIO; case ImageFileFormat.jpeg: return new JpegIO; } } interface ImgIO { Image readFile(in string filename, in ImageFormat format); Image readMem(in ubyte[] data, in ImageFormat format); void writeFile(in Image img, in string filename); } class PngIO : ImgIO { static uint pngFormat(ImageFormat format) { final switch (format) { case ImageFormat.a1: assert(false); case ImageFormat.a8: return PNG_FORMAT_GRAY; case ImageFormat.xrgb: case ImageFormat.argb: case ImageFormat.argbPremult: version(LittleEndian) { return PNG_FORMAT_BGRA; } else { return PNG_FORMAT_ARGB; } } } override Image readFile(in string filename, in ImageFormat format) { png_image pimg; pimg.version_ = PNG_IMAGE_VERSION; if (!png_image_begin_read_from_file(&pimg, filename.toStringz)) { throw new Exception("could not read image from "~filename); } scope(exit) png_image_free(&pimg); return readFinish(&pimg, format); } override Image readMem(in ubyte[] data, in ImageFormat format) { png_image pimg; pimg.version_ = PNG_IMAGE_VERSION; if (!png_image_begin_read_from_memory(&pimg, data.ptr, data.length)) { throw new Exception("could not read image from memory"); } scope(exit) png_image_free(&pimg); return readFinish(&pimg, format); } private Image readFinish(png_imagep pimg, in ImageFormat format) { ImageFormat readFmt = format; // 1 bpp is not supported by libpng if (format == ImageFormat.a1) readFmt = ImageFormat.a8; immutable rowStride = imageAlignedStride(readFmt, pimg.width); immutable numBytes = rowStride*pimg.height; pimg.format = pngFormat(readFmt); ubyte[] buf = new ubyte[numBytes]; if (!png_image_finish_read(pimg, null, cast(void*)buf, cast(int)rowStride, null)) { throw new Exception("could not finish read image"); } auto img = new Image(buf, readFmt, pimg.width, rowStride); if (format == ImageFormat.a1) { return img.convert(ImageFormat.a1); } if (format == ImageFormat.argbPremult) { img.apply!premultiply(); } return img; } override void writeFile(in Image img, in string filename) { png_image pimg; pimg.version_ = PNG_IMAGE_VERSION; pimg.format = pngFormat(img.format); pimg.width = img.width; pimg.height = img.height; png_image_write_to_file(&pimg, filename.toStringz, 0, img.data.ptr, 0, null); } } class JpegIO : ImgIO { static uint jpegFormat(ImageFormat format) { final switch (format) { case ImageFormat.a1: assert(false); case ImageFormat.a8: return TJPF.TJPF_GRAY; case ImageFormat.xrgb: case ImageFormat.argb: case ImageFormat.argbPremult: version(LittleEndian) { return TJPF.TJPF_BGRA; } else { return TJPF.TJPF_ARGB; } } } string errorMsg() { import core.stdc.string : strlen; char* msg = tjGetErrorStr(); auto len = strlen(msg); return msg[0..len].idup; } override Image readFile(in string filename, in ImageFormat format) { import std.file : read; auto bytes = cast(ubyte[]) read(filename); return readMem(bytes, format); } override Image readMem(in ubyte[] bytes, in ImageFormat format) { import core.stdc.config : c_ulong; ImageFormat readFmt = format; // 1 bpp is not supported by libjpeg if (format == ImageFormat.a1) readFmt = ImageFormat.a8; tjhandle jpeg = tjInitDecompress(); scope(exit) tjDestroy(jpeg); // const cast needed. arrgh! int width, height, jpegsubsamp; if (tjDecompressHeader2(jpeg, cast(ubyte*)bytes.ptr, cast(c_ulong)bytes.length, &width, &height, &jpegsubsamp) != 0) { throw new Exception("could not read from memory: "~errorMsg()); } immutable rowStride = imageAlignedStride(ImageFormat.argb, width); auto data = new ubyte[rowStride * height]; if(tjDecompress2(jpeg, cast(ubyte*)bytes.ptr, cast(c_ulong)bytes.length, data.ptr, width, cast(int)rowStride, height, jpegFormat(readFmt), 0) != 0) { throw new Exception("could not read from memory: "~errorMsg()); } auto img = new Image(data, ImageFormat.argb, width, rowStride); if (format == ImageFormat.a1) { return img.convert(ImageFormat.a1); } if (format == ImageFormat.argbPremult) { img.apply!premultiply(); } return img; } override void writeFile(in Image img, in string filename) { import std.file : write; import core.stdc.config : c_ulong; tjhandle jpeg = tjInitCompress(); scope(exit) tjDestroy(jpeg); c_ulong len; ubyte *bytes; if (tjCompress2(jpeg, cast(ubyte*)img.data.ptr, img.width, 0, img.height, jpegFormat(img.format), &bytes, &len, TJSAMP.TJSAMP_444, 100, TJFLAG_FASTDCT) != 0) { throw new Exception("could not encode to jpeg "~filename.baseName~": "~errorMsg()); } scope(exit) tjFree(bytes); write(filename, cast(void[])bytes[0..cast(uint)len]); } } }
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/lexer.d, _lexer.d) * Documentation: https://dlang.org/phobos/dmd_lexer.html * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/lexer.d */ module dmd.lexer; import core.stdc.ctype; import core.stdc.errno; import core.stdc.stdarg; import core.stdc.stdio; import core.stdc.string; import core.stdc.time; import dmd.entity; import dmd.errors; import dmd.globals; import dmd.id; import dmd.identifier; import dmd.root.ctfloat; import dmd.root.outbuffer; import dmd.root.port; import dmd.root.rmem; import dmd.tokens; import dmd.utf; import dmd.utils; nothrow: private enum LS = 0x2028; // UTF line separator private enum PS = 0x2029; // UTF paragraph separator /******************************************** * Do our own char maps */ private static immutable cmtable = () { ubyte[256] table; foreach (const c; 0 .. table.length) { if ('0' <= c && c <= '7') table[c] |= CMoctal; if (c_isxdigit(c)) table[c] |= CMhex; if (c_isalnum(c) || c == '_') table[c] |= CMidchar; switch (c) { case 'x': case 'X': case 'b': case 'B': table[c] |= CMzerosecond; break; case '0': .. case '9': case 'e': case 'E': case 'f': case 'F': case 'l': case 'L': case 'p': case 'P': case 'u': case 'U': case 'i': case '.': case '_': table[c] |= CMzerosecond | CMdigitsecond; break; default: break; } switch (c) { case '\\': case '\n': case '\r': case 0: case 0x1A: case '\'': break; default: if (!(c & 0x80)) table[c] |= CMsinglechar; break; } } return table; }(); private { enum CMoctal = 0x1; enum CMhex = 0x2; enum CMidchar = 0x4; enum CMzerosecond = 0x8; enum CMdigitsecond = 0x10; enum CMsinglechar = 0x20; } private bool isoctal(const char c) pure @nogc @safe { return (cmtable[c] & CMoctal) != 0; } private bool ishex(const char c) pure @nogc @safe { return (cmtable[c] & CMhex) != 0; } private bool isidchar(const char c) pure @nogc @safe { return (cmtable[c] & CMidchar) != 0; } private bool isZeroSecond(const char c) pure @nogc @safe { return (cmtable[c] & CMzerosecond) != 0; } private bool isDigitSecond(const char c) pure @nogc @safe { return (cmtable[c] & CMdigitsecond) != 0; } private bool issinglechar(const char c) pure @nogc @safe { return (cmtable[c] & CMsinglechar) != 0; } private bool c_isxdigit(const int c) pure @nogc @safe { return (( c >= '0' && c <= '9') || ( c >= 'a' && c <= 'f') || ( c >= 'A' && c <= 'F')); } private bool c_isalnum(const int c) pure @nogc @safe { return (( c >= '0' && c <= '9') || ( c >= 'a' && c <= 'z') || ( c >= 'A' && c <= 'Z')); } unittest { //printf("lexer.unittest\n"); /* Not much here, just trying things out. */ string text = "int"; // We rely on the implicit null-terminator scope diagnosticReporter = new StderrDiagnosticReporter(global.params.useDeprecated); scope Lexer lex1 = new Lexer(null, text.ptr, 0, text.length, 0, 0, diagnosticReporter); TOK tok; tok = lex1.nextToken(); //printf("tok == %s, %d, %d\n", Token::toChars(tok), tok, TOK.int32); assert(tok == TOK.int32); tok = lex1.nextToken(); assert(tok == TOK.endOfFile); tok = lex1.nextToken(); assert(tok == TOK.endOfFile); tok = lex1.nextToken(); assert(tok == TOK.endOfFile); } unittest { // We don't want to see Lexer error output during these tests. uint errors = global.startGagging(); scope(exit) global.endGagging(errors); // Test malformed input: even malformed input should end in a TOK.endOfFile. static immutable char[][] testcases = [ // Testcase must end with 0 or 0x1A. [0], // not malformed, but pathological ['\'', 0], ['\'', 0x1A], ['{', '{', 'q', '{', 0], [0xFF, 0], [0xFF, 0x80, 0], [0xFF, 0xFF, 0], [0xFF, 0xFF, 0], ['x', '"', 0x1A], ]; foreach (testcase; testcases) { scope diagnosticReporter = new StderrDiagnosticReporter(global.params.useDeprecated); scope Lexer lex2 = new Lexer(null, testcase.ptr, 0, testcase.length-1, 0, 0, diagnosticReporter); TOK tok = lex2.nextToken(); size_t iterations = 1; while ((tok != TOK.endOfFile) && (iterations++ < testcase.length)) { tok = lex2.nextToken(); } assert(tok == TOK.endOfFile); tok = lex2.nextToken(); assert(tok == TOK.endOfFile); } } /*********************************************************** */ class Lexer { private __gshared OutBuffer stringbuffer; Loc scanloc; // for error messages Loc prevloc; // location of token before current const(char)* p; // current character Token token; private { const(char)* base; // pointer to start of buffer const(char)* end; // pointer to last element of buffer const(char)* line; // start of current line bool doDocComment; // collect doc comment information bool anyToken; // seen at least one token bool commentToken; // comments are TOK.comment's int inTokenStringConstant; // can be larger than 1 when in nested q{} strings int lastDocLine; // last line of previous doc comment DiagnosticReporter diagnosticReporter; Token* tokenFreelist; } nothrow: /********************* * Creates a Lexer for the source code base[begoffset..endoffset+1]. * The last character, base[endoffset], must be null (0) or EOF (0x1A). * * Params: * filename = used for error messages * base = source code, must be terminated by a null (0) or EOF (0x1A) character * begoffset = starting offset into base[] * endoffset = the last offset to read into base[] * doDocComment = handle documentation comments * commentToken = comments become TOK.comment's * diagnosticReporter = the diagnostic reporter to use */ this(const(char)* filename, const(char)* base, size_t begoffset, size_t endoffset, bool doDocComment, bool commentToken, DiagnosticReporter diagnosticReporter) pure in { assert(diagnosticReporter !is null); } body { this.diagnosticReporter = diagnosticReporter; scanloc = Loc(filename, 1, 1); //printf("Lexer::Lexer(%p,%d)\n",base,length); //printf("lexer.filename = %s\n", filename); token = Token.init; this.base = base; this.end = base + endoffset; p = base + begoffset; line = p; this.doDocComment = doDocComment; this.commentToken = commentToken; this.inTokenStringConstant = 0; this.lastDocLine = 0; //initKeywords(); /* If first line starts with '#!', ignore the line */ if (p && p[0] == '#' && p[1] == '!') { p += 2; while (1) { char c = *p++; switch (c) { case 0: case 0x1A: p--; goto case; case '\n': break; default: continue; } break; } endOfLine(); } } /// Returns: `true` if any errors occurred during lexing or parsing. final bool errors() { return diagnosticReporter.errorCount > 0; } /// Returns: a newly allocated `Token`. Token* allocateToken() pure nothrow @safe { if (tokenFreelist) { Token* t = tokenFreelist; tokenFreelist = t.next; t.next = null; return t; } return new Token(); } /// Frees the given token by returning it to the freelist. private void releaseToken(Token* token) pure nothrow @nogc @safe { if (mem.isGCEnabled) *token = Token.init; token.next = tokenFreelist; tokenFreelist = token; } final TOK nextToken() { prevloc = token.loc; if (token.next) { Token* t = token.next; memcpy(&token, t, Token.sizeof); releaseToken(t); } else { scan(&token); } //printf(token.toChars()); return token.value; } /*********************** * Look ahead at next token's value. */ final TOK peekNext() { return peek(&token).value; } /*********************** * Look 2 tokens ahead at value. */ final TOK peekNext2() { Token* t = peek(&token); return peek(t).value; } /**************************** * Turn next token in buffer into a token. */ final void scan(Token* t) { const lastLine = scanloc.linnum; Loc startLoc; t.blockComment = null; t.lineComment = null; while (1) { t.ptr = p; //printf("p = %p, *p = '%c'\n",p,*p); t.loc = loc(); switch (*p) { case 0: case 0x1A: t.value = TOK.endOfFile; // end of file // Intentionally not advancing `p`, such that subsequent calls keep returning TOK.endOfFile. return; case ' ': case '\t': case '\v': case '\f': p++; continue; // skip white space case '\r': p++; if (*p != '\n') // if CR stands by itself endOfLine(); continue; // skip white space case '\n': p++; endOfLine(); continue; // skip white space case '0': if (!isZeroSecond(p[1])) // if numeric literal does not continue { ++p; t.unsvalue = 0; t.value = TOK.int32Literal; return; } goto Lnumber; case '1': .. case '9': if (!isDigitSecond(p[1])) // if numeric literal does not continue { t.unsvalue = *p - '0'; ++p; t.value = TOK.int32Literal; return; } Lnumber: t.value = number(t); return; case '\'': if (issinglechar(p[1]) && p[2] == '\'') { t.unsvalue = p[1]; // simple one character literal t.value = TOK.charLiteral; p += 3; } else t.value = charConstant(t); return; case 'r': if (p[1] != '"') goto case_ident; p++; goto case '`'; case '`': wysiwygStringConstant(t); return; case 'x': if (p[1] != '"') goto case_ident; p++; auto start = p; auto hexString = new OutBuffer(); t.value = hexStringConstant(t); hexString.write(start[0 .. p - start]); error("Built-in hex string literals are obsolete, use `std.conv.hexString!%s` instead.", hexString.extractChars()); return; case 'q': if (p[1] == '"') { p++; delimitedStringConstant(t); return; } else if (p[1] == '{') { p++; tokenStringConstant(t); return; } else goto case_ident; case '"': escapeStringConstant(t); return; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': /*case 'q': case 'r':*/ case 's': case 't': case 'u': case 'v': case 'w': /*case 'x':*/ case 'y': case 'z': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': case_ident: { while (1) { const c = *++p; if (isidchar(c)) continue; else if (c & 0x80) { const s = p; const u = decodeUTF(); if (isUniAlpha(u)) continue; error("char 0x%04x not allowed in identifier", u); p = s; } break; } Identifier id = Identifier.idPool(cast(char*)t.ptr, cast(uint)(p - t.ptr)); t.ident = id; t.value = cast(TOK)id.getValue(); anyToken = 1; if (*t.ptr == '_') // if special identifier token { __gshared bool initdone = false; __gshared char[11 + 1] date; __gshared char[8 + 1] time; __gshared char[24 + 1] timestamp; if (!initdone) // lazy evaluation { initdone = true; time_t ct; .time(&ct); const p = ctime(&ct); assert(p); sprintf(&date[0], "%.6s %.4s", p + 4, p + 20); sprintf(&time[0], "%.8s", p + 11); sprintf(&timestamp[0], "%.24s", p); } if (id == Id.DATE) { t.ustring = date.ptr; goto Lstr; } else if (id == Id.TIME) { t.ustring = time.ptr; goto Lstr; } else if (id == Id.VENDOR) { t.ustring = global.vendor.xarraydup.ptr; goto Lstr; } else if (id == Id.TIMESTAMP) { t.ustring = timestamp.ptr; Lstr: t.value = TOK.string_; t.postfix = 0; t.len = cast(uint)strlen(t.ustring); } else if (id == Id.VERSIONX) { t.value = TOK.int64Literal; t.unsvalue = global.versionNumber(); } else if (id == Id.EOFX) { t.value = TOK.endOfFile; // Advance scanner to end of file while (!(*p == 0 || *p == 0x1A)) p++; } } //printf("t.value = %d\n",t.value); return; } case '/': p++; switch (*p) { case '=': p++; t.value = TOK.divAssign; return; case '*': p++; startLoc = loc(); while (1) { while (1) { const c = *p; switch (c) { case '/': break; case '\n': endOfLine(); p++; continue; case '\r': p++; if (*p != '\n') endOfLine(); continue; case 0: case 0x1A: error("unterminated /* */ comment"); p = end; t.loc = loc(); t.value = TOK.endOfFile; return; default: if (c & 0x80) { const u = decodeUTF(); if (u == PS || u == LS) endOfLine(); } p++; continue; } break; } p++; if (p[-2] == '*' && p - 3 != t.ptr) break; } if (commentToken) { t.loc = startLoc; t.value = TOK.comment; return; } else if (doDocComment && t.ptr[2] == '*' && p - 4 != t.ptr) { // if /** but not /**/ getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1); lastDocLine = scanloc.linnum; } continue; case '/': // do // style comments startLoc = loc(); while (1) { const c = *++p; switch (c) { case '\n': break; case '\r': if (p[1] == '\n') p++; break; case 0: case 0x1A: if (commentToken) { p = end; t.loc = startLoc; t.value = TOK.comment; return; } if (doDocComment && t.ptr[2] == '/') { getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1); lastDocLine = scanloc.linnum; } p = end; t.loc = loc(); t.value = TOK.endOfFile; return; default: if (c & 0x80) { const u = decodeUTF(); if (u == PS || u == LS) break; } continue; } break; } if (commentToken) { p++; endOfLine(); t.loc = startLoc; t.value = TOK.comment; return; } if (doDocComment && t.ptr[2] == '/') { getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1); lastDocLine = scanloc.linnum; } p++; endOfLine(); continue; case '+': { int nest; startLoc = loc(); p++; nest = 1; while (1) { char c = *p; switch (c) { case '/': p++; if (*p == '+') { p++; nest++; } continue; case '+': p++; if (*p == '/') { p++; if (--nest == 0) break; } continue; case '\r': p++; if (*p != '\n') endOfLine(); continue; case '\n': endOfLine(); p++; continue; case 0: case 0x1A: error("unterminated /+ +/ comment"); p = end; t.loc = loc(); t.value = TOK.endOfFile; return; default: if (c & 0x80) { uint u = decodeUTF(); if (u == PS || u == LS) endOfLine(); } p++; continue; } break; } if (commentToken) { t.loc = startLoc; t.value = TOK.comment; return; } if (doDocComment && t.ptr[2] == '+' && p - 4 != t.ptr) { // if /++ but not /++/ getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1); lastDocLine = scanloc.linnum; } continue; } default: break; } t.value = TOK.div; return; case '.': p++; if (isdigit(*p)) { /* Note that we don't allow ._1 and ._ as being * valid floating point numbers. */ p--; t.value = inreal(t); } else if (p[0] == '.') { if (p[1] == '.') { p += 2; t.value = TOK.dotDotDot; } else { p++; t.value = TOK.slice; } } else t.value = TOK.dot; return; case '&': p++; if (*p == '=') { p++; t.value = TOK.andAssign; } else if (*p == '&') { p++; t.value = TOK.andAnd; } else t.value = TOK.and; return; case '|': p++; if (*p == '=') { p++; t.value = TOK.orAssign; } else if (*p == '|') { p++; t.value = TOK.orOr; } else t.value = TOK.or; return; case '-': p++; if (*p == '=') { p++; t.value = TOK.minAssign; } else if (*p == '-') { p++; t.value = TOK.minusMinus; } else t.value = TOK.min; return; case '+': p++; if (*p == '=') { p++; t.value = TOK.addAssign; } else if (*p == '+') { p++; t.value = TOK.plusPlus; } else t.value = TOK.add; return; case '<': p++; if (*p == '=') { p++; t.value = TOK.lessOrEqual; // <= } else if (*p == '<') { p++; if (*p == '=') { p++; t.value = TOK.leftShiftAssign; // <<= } else t.value = TOK.leftShift; // << } else t.value = TOK.lessThan; // < return; case '>': p++; if (*p == '=') { p++; t.value = TOK.greaterOrEqual; // >= } else if (*p == '>') { p++; if (*p == '=') { p++; t.value = TOK.rightShiftAssign; // >>= } else if (*p == '>') { p++; if (*p == '=') { p++; t.value = TOK.unsignedRightShiftAssign; // >>>= } else t.value = TOK.unsignedRightShift; // >>> } else t.value = TOK.rightShift; // >> } else t.value = TOK.greaterThan; // > return; case '!': p++; if (*p == '=') { p++; t.value = TOK.notEqual; // != } else t.value = TOK.not; // ! return; case '=': p++; if (*p == '=') { p++; t.value = TOK.equal; // == } else if (*p == '>') { p++; t.value = TOK.goesTo; // => } else t.value = TOK.assign; // = return; case '~': p++; if (*p == '=') { p++; t.value = TOK.concatenateAssign; // ~= } else t.value = TOK.tilde; // ~ return; case '^': p++; if (*p == '^') { p++; if (*p == '=') { p++; t.value = TOK.powAssign; // ^^= } else t.value = TOK.pow; // ^^ } else if (*p == '=') { p++; t.value = TOK.xorAssign; // ^= } else t.value = TOK.xor; // ^ return; case '(': p++; t.value = TOK.leftParentheses; return; case ')': p++; t.value = TOK.rightParentheses; return; case '[': p++; t.value = TOK.leftBracket; return; case ']': p++; t.value = TOK.rightBracket; return; case '{': p++; t.value = TOK.leftCurly; return; case '}': p++; t.value = TOK.rightCurly; return; case '?': p++; t.value = TOK.question; return; case ',': p++; t.value = TOK.comma; return; case ';': p++; t.value = TOK.semicolon; return; case ':': p++; t.value = TOK.colon; return; case '$': p++; t.value = TOK.dollar; return; case '@': p++; t.value = TOK.at; return; case '*': p++; if (*p == '=') { p++; t.value = TOK.mulAssign; } else t.value = TOK.mul; return; case '%': p++; if (*p == '=') { p++; t.value = TOK.modAssign; } else t.value = TOK.mod; return; case '#': { p++; Token n; scan(&n); if (n.value == TOK.identifier) { if (n.ident == Id.line) { poundLine(); continue; } else { const locx = loc(); warning(locx, "C preprocessor directive `#%s` is not supported", n.ident.toChars()); } } else if (n.value == TOK.if_) { error("C preprocessor directive `#if` is not supported, use `version` or `static if`"); } t.value = TOK.pound; return; } default: { dchar c = *p; if (c & 0x80) { c = decodeUTF(); // Check for start of unicode identifier if (isUniAlpha(c)) goto case_ident; if (c == PS || c == LS) { endOfLine(); p++; continue; } } if (c < 0x80 && isprint(c)) error("character '%c' is not a valid token", c); else error("character 0x%02x is not a valid token", c); p++; continue; } } } } final Token* peek(Token* ct) { Token* t; if (ct.next) t = ct.next; else { t = allocateToken(); scan(t); ct.next = t; } return t; } /********************************* * tk is on the opening (. * Look ahead and return token that is past the closing ). */ final Token* peekPastParen(Token* tk) { //printf("peekPastParen()\n"); int parens = 1; int curlynest = 0; while (1) { tk = peek(tk); //tk.print(); switch (tk.value) { case TOK.leftParentheses: parens++; continue; case TOK.rightParentheses: --parens; if (parens) continue; tk = peek(tk); break; case TOK.leftCurly: curlynest++; continue; case TOK.rightCurly: if (--curlynest >= 0) continue; break; case TOK.semicolon: if (curlynest) continue; break; case TOK.endOfFile: break; default: continue; } return tk; } } /******************************************* * Parse escape sequence. */ private uint escapeSequence() { return Lexer.escapeSequence(token.loc, diagnosticReporter, p); } /** Parse the given string literal escape sequence into a single character. Params: loc = the location of the current token handler = the diagnostic reporter object sequence = pointer to string with escape sequence to parse. this is a reference variable that is also used to return the position after the sequence Returns: the escaped sequence as a single character */ private static dchar escapeSequence(const ref Loc loc, DiagnosticReporter handler, ref const(char)* sequence) in { assert(handler !is null); } body { const(char)* p = sequence; // cache sequence reference on stack scope(exit) sequence = p; uint c = *p; int ndigits; switch (c) { case '\'': case '"': case '?': case '\\': Lconsume: p++; break; case 'a': c = 7; goto Lconsume; case 'b': c = 8; goto Lconsume; case 'f': c = 12; goto Lconsume; case 'n': c = 10; goto Lconsume; case 'r': c = 13; goto Lconsume; case 't': c = 9; goto Lconsume; case 'v': c = 11; goto Lconsume; case 'u': ndigits = 4; goto Lhex; case 'U': ndigits = 8; goto Lhex; case 'x': ndigits = 2; Lhex: p++; c = *p; if (ishex(cast(char)c)) { uint v = 0; int n = 0; while (1) { if (isdigit(cast(char)c)) c -= '0'; else if (islower(c)) c -= 'a' - 10; else c -= 'A' - 10; v = v * 16 + c; c = *++p; if (++n == ndigits) break; if (!ishex(cast(char)c)) { handler.error(loc, "escape hex sequence has %d hex digits instead of %d", n, ndigits); break; } } if (ndigits != 2 && !utf_isValidDchar(v)) { handler.error(loc, "invalid UTF character \\U%08x", v); v = '?'; // recover with valid UTF character } c = v; } else { handler.error(loc, "undefined escape hex sequence \\%c%c", sequence[0], c); p++; } break; case '&': // named character entity for (const idstart = ++p; 1; p++) { switch (*p) { case ';': c = HtmlNamedEntity(idstart, p - idstart); if (c == ~0) { handler.error(loc, "unnamed character entity &%.*s;", cast(int)(p - idstart), idstart); c = '?'; } p++; break; default: if (isalpha(*p) || (p != idstart && isdigit(*p))) continue; handler.error(loc, "unterminated named entity &%.*s;", cast(int)(p - idstart + 1), idstart); c = '?'; break; } break; } break; case 0: case 0x1A: // end of file c = '\\'; break; default: if (isoctal(cast(char)c)) { uint v = 0; int n = 0; do { v = v * 8 + (c - '0'); c = *++p; } while (++n < 3 && isoctal(cast(char)c)); c = v; if (c > 0xFF) handler.error(loc, "escape octal sequence \\%03o is larger than \\377", c); } else { handler.error(loc, "undefined escape sequence \\%c", c); p++; } break; } return c; } /** Lex a wysiwyg string. `p` must be pointing to the first character before the contents of the string literal. The character pointed to by `p` will be used as the terminating character (i.e. backtick or double-quote). Params: result = pointer to the token that accepts the result */ private void wysiwygStringConstant(Token* result) { result.value = TOK.string_; Loc start = loc(); auto terminator = p[0]; p++; stringbuffer.reset(); while (1) { dchar c = p[0]; p++; switch (c) { case '\n': endOfLine(); break; case '\r': if (p[0] == '\n') continue; // ignore c = '\n'; // treat EndOfLine as \n character endOfLine(); break; case 0: case 0x1A: error("unterminated string constant starting at %s", start.toChars()); result.setString(); // rewind `p` so it points to the EOF character p--; return; default: if (c == terminator) { result.setString(stringbuffer); stringPostfix(result); return; } else if (c & 0x80) { p--; const u = decodeUTF(); p++; if (u == PS || u == LS) endOfLine(); stringbuffer.writeUTF8(u); continue; } break; } stringbuffer.writeByte(c); } } /************************************** * Lex hex strings: * x"0A ae 34FE BD" */ private TOK hexStringConstant(Token* t) { Loc start = loc(); uint n = 0; uint v = ~0; // dead assignment, needed to suppress warning p++; stringbuffer.reset(); while (1) { dchar c = *p++; switch (c) { case ' ': case '\t': case '\v': case '\f': continue; // skip white space case '\r': if (*p == '\n') continue; // ignore '\r' if followed by '\n' // Treat isolated '\r' as if it were a '\n' goto case '\n'; case '\n': endOfLine(); continue; case 0: case 0x1A: error("unterminated string constant starting at %s", start.toChars()); t.setString(); // decrement `p`, because it needs to point to the next token (the 0 or 0x1A character is the TOK.endOfFile token). p--; return TOK.hexadecimalString; case '"': if (n & 1) { error("odd number (%d) of hex characters in hex string", n); stringbuffer.writeByte(v); } t.setString(stringbuffer); stringPostfix(t); return TOK.hexadecimalString; default: if (c >= '0' && c <= '9') c -= '0'; else if (c >= 'a' && c <= 'f') c -= 'a' - 10; else if (c >= 'A' && c <= 'F') c -= 'A' - 10; else if (c & 0x80) { p--; const u = decodeUTF(); p++; if (u == PS || u == LS) endOfLine(); else error("non-hex character \\u%04x in hex string", u); } else error("non-hex character '%c' in hex string", c); if (n & 1) { v = (v << 4) | c; stringbuffer.writeByte(v); } else v = c; n++; break; } } assert(0); // see bug 15731 } /** Lex a delimited string. Some examples of delimited strings are: --- q"(foo(xxx))" // "foo(xxx)" q"[foo$(LPAREN)]" // "foo$(LPAREN)" q"/foo]/" // "foo]" q"HERE foo HERE" // "foo\n" --- It is assumed that `p` points to the opening double-quote '"'. Params: result = pointer to the token that accepts the result */ private void delimitedStringConstant(Token* result) { result.value = TOK.string_; Loc start = loc(); dchar delimleft = 0; dchar delimright = 0; uint nest = 1; uint nestcount = ~0; // dead assignment, needed to suppress warning Identifier hereid = null; uint blankrol = 0; uint startline = 0; p++; stringbuffer.reset(); while (1) { dchar c = *p++; //printf("c = '%c'\n", c); switch (c) { case '\n': Lnextline: endOfLine(); startline = 1; if (blankrol) { blankrol = 0; continue; } if (hereid) { stringbuffer.writeUTF8(c); continue; } break; case '\r': if (*p == '\n') continue; // ignore c = '\n'; // treat EndOfLine as \n character goto Lnextline; case 0: case 0x1A: error("unterminated delimited string constant starting at %s", start.toChars()); result.setString(); // decrement `p`, because it needs to point to the next token (the 0 or 0x1A character is the TOK.endOfFile token). p--; return; default: if (c & 0x80) { p--; c = decodeUTF(); p++; if (c == PS || c == LS) goto Lnextline; } break; } if (delimleft == 0) { delimleft = c; nest = 1; nestcount = 1; if (c == '(') delimright = ')'; else if (c == '{') delimright = '}'; else if (c == '[') delimright = ']'; else if (c == '<') delimright = '>'; else if (isalpha(c) || c == '_' || (c >= 0x80 && isUniAlpha(c))) { // Start of identifier; must be a heredoc Token tok; p--; scan(&tok); // read in heredoc identifier if (tok.value != TOK.identifier) { error("identifier expected for heredoc, not %s", tok.toChars()); delimright = c; } else { hereid = tok.ident; //printf("hereid = '%s'\n", hereid.toChars()); blankrol = 1; } nest = 0; } else { delimright = c; nest = 0; if (isspace(c)) error("delimiter cannot be whitespace"); } } else { if (blankrol) { error("heredoc rest of line should be blank"); blankrol = 0; continue; } if (nest == 1) { if (c == delimleft) nestcount++; else if (c == delimright) { nestcount--; if (nestcount == 0) goto Ldone; } } else if (c == delimright) goto Ldone; if (startline && (isalpha(c) || c == '_' || (c >= 0x80 && isUniAlpha(c))) && hereid) { Token tok; auto psave = p; p--; scan(&tok); // read in possible heredoc identifier //printf("endid = '%s'\n", tok.ident.toChars()); if (tok.value == TOK.identifier && tok.ident is hereid) { /* should check that rest of line is blank */ goto Ldone; } p = psave; } stringbuffer.writeUTF8(c); startline = 0; } } Ldone: if (*p == '"') p++; else if (hereid) error("delimited string must end in %s\"", hereid.toChars()); else error("delimited string must end in %c\"", delimright); result.setString(stringbuffer); stringPostfix(result); } /** Lex a token string. Some examples of token strings are: --- q{ foo(xxx) } // " foo(xxx) " q{foo$(LPAREN)} // "foo$(LPAREN)" q{{foo}"}"} // "{foo}"}"" --- It is assumed that `p` points to the opening curly-brace '{'. Params: result = pointer to the token that accepts the result */ private void tokenStringConstant(Token* result) { result.value = TOK.string_; uint nest = 1; const start = loc(); const pstart = ++p; inTokenStringConstant++; scope(exit) inTokenStringConstant--; while (1) { Token tok; scan(&tok); switch (tok.value) { case TOK.leftCurly: nest++; continue; case TOK.rightCurly: if (--nest == 0) { result.setString(pstart, p - 1 - pstart); stringPostfix(result); return; } continue; case TOK.endOfFile: error("unterminated token string constant starting at %s", start.toChars()); result.setString(); return; default: continue; } } } /** Scan a double-quoted string while building the processed string value by handling escape sequences. The result is returned in the given `t` token. This function assumes that `p` currently points to the opening double-quote of the string. Params: t = the token to set the resulting string to */ private void escapeStringConstant(Token* t) { t.value = TOK.string_; const start = loc(); p++; stringbuffer.reset(); while (1) { dchar c = *p++; switch (c) { case '\\': switch (*p) { case 'u': case 'U': case '&': c = escapeSequence(); stringbuffer.writeUTF8(c); continue; default: c = escapeSequence(); break; } break; case '\n': endOfLine(); break; case '\r': if (*p == '\n') continue; // ignore c = '\n'; // treat EndOfLine as \n character endOfLine(); break; case '"': t.setString(stringbuffer); stringPostfix(t); return; case 0: case 0x1A: // decrement `p`, because it needs to point to the next token (the 0 or 0x1A character is the TOK.endOfFile token). p--; error("unterminated string constant starting at %s", start.toChars()); t.setString(); return; default: if (c & 0x80) { p--; c = decodeUTF(); if (c == LS || c == PS) { c = '\n'; endOfLine(); } p++; stringbuffer.writeUTF8(c); continue; } break; } stringbuffer.writeByte(c); } } /************************************** */ private TOK charConstant(Token* t) { TOK tk = TOK.charLiteral; //printf("Lexer::charConstant\n"); p++; dchar c = *p++; switch (c) { case '\\': switch (*p) { case 'u': t.unsvalue = escapeSequence(); tk = TOK.wcharLiteral; break; case 'U': case '&': t.unsvalue = escapeSequence(); tk = TOK.dcharLiteral; break; default: t.unsvalue = escapeSequence(); break; } break; case '\n': L1: endOfLine(); goto case; case '\r': goto case '\''; case 0: case 0x1A: // decrement `p`, because it needs to point to the next token (the 0 or 0x1A character is the TOK.endOfFile token). p--; goto case; case '\'': error("unterminated character constant"); t.unsvalue = '?'; return tk; default: if (c & 0x80) { p--; c = decodeUTF(); p++; if (c == LS || c == PS) goto L1; if (c < 0xD800 || (c >= 0xE000 && c < 0xFFFE)) tk = TOK.wcharLiteral; else tk = TOK.dcharLiteral; } t.unsvalue = c; break; } if (*p != '\'') { error("unterminated character constant"); t.unsvalue = '?'; return tk; } p++; return tk; } /*************************************** * Get postfix of string literal. */ private void stringPostfix(Token* t) pure @nogc { switch (*p) { case 'c': case 'w': case 'd': t.postfix = *p; p++; break; default: t.postfix = 0; break; } } /************************************** * Read in a number. * If it's an integer, store it in tok.TKutok.Vlong. * integers can be decimal, octal or hex * Handle the suffixes U, UL, LU, L, etc. * If it's double, store it in tok.TKutok.Vdouble. * Returns: * TKnum * TKdouble,... */ private TOK number(Token* t) { int base = 10; const start = p; uinteger_t n = 0; // unsigned >=64 bit integer type int d; bool err = false; bool overflow = false; bool anyBinaryDigitsNoSingleUS = false; bool anyHexDigitsNoSingleUS = false; dchar c = *p; if (c == '0') { ++p; c = *p; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': base = 8; break; case 'x': case 'X': ++p; base = 16; break; case 'b': case 'B': ++p; base = 2; break; case '.': if (p[1] == '.') goto Ldone; // if ".." if (isalpha(p[1]) || p[1] == '_' || p[1] & 0x80) goto Ldone; // if ".identifier" or ".unicode" goto Lreal; // '.' is part of current token case 'i': case 'f': case 'F': goto Lreal; case '_': ++p; base = 8; break; case 'L': if (p[1] == 'i') goto Lreal; break; default: break; } } while (1) { c = *p; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': ++p; d = c - '0'; break; case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': ++p; if (base != 16) { if (c == 'e' || c == 'E' || c == 'f' || c == 'F') goto Lreal; } if (c >= 'a') d = c + 10 - 'a'; else d = c + 10 - 'A'; break; case 'L': if (p[1] == 'i') goto Lreal; goto Ldone; case '.': if (p[1] == '.') goto Ldone; // if ".." if (base == 10 && (isalpha(p[1]) || p[1] == '_' || p[1] & 0x80)) goto Ldone; // if ".identifier" or ".unicode" if (base == 16 && (!ishex(p[1]) || p[1] == '_' || p[1] & 0x80)) goto Ldone; // if ".identifier" or ".unicode" if (base == 2) goto Ldone; // if ".identifier" or ".unicode" goto Lreal; // otherwise as part of a floating point literal case 'p': case 'P': case 'i': Lreal: p = start; return inreal(t); case '_': ++p; continue; default: goto Ldone; } // got a digit here, set any necessary flags, check for errors anyHexDigitsNoSingleUS = true; anyBinaryDigitsNoSingleUS = true; if (!err && d >= base) { error("%s digit expected, not `%c`", base == 2 ? "binary".ptr : base == 8 ? "octal".ptr : "decimal".ptr, c); err = true; } // Avoid expensive overflow check if we aren't at risk of overflow if (n <= 0x0FFF_FFFF_FFFF_FFFFUL) n = n * base + d; else { import core.checkedint : mulu, addu; n = mulu(n, base, overflow); n = addu(n, d, overflow); } } Ldone: if (overflow && !err) { error("integer overflow"); err = true; } if ((base == 2 && !anyBinaryDigitsNoSingleUS) || (base == 16 && !anyHexDigitsNoSingleUS)) error("`%.*s` isn't a valid integer literal, use `%.*s0` instead", cast(int)(p - start), start, 2, start); enum FLAGS : int { none = 0, decimal = 1, // decimal unsigned = 2, // u or U suffix long_ = 4, // L suffix } FLAGS flags = (base == 10) ? FLAGS.decimal : FLAGS.none; // Parse trailing 'u', 'U', 'l' or 'L' in any combination const psuffix = p; while (1) { FLAGS f; switch (*p) { case 'U': case 'u': f = FLAGS.unsigned; goto L1; case 'l': f = FLAGS.long_; error("lower case integer suffix 'l' is not allowed. Please use 'L' instead"); goto L1; case 'L': f = FLAGS.long_; L1: p++; if ((flags & f) && !err) { error("unrecognized token"); err = true; } flags = cast(FLAGS)(flags | f); continue; default: break; } break; } if (base == 8 && n >= 8) { if (err) // can't translate invalid octal value, just show a generic message error("octal literals larger than 7 are no longer supported"); else error("octal literals `0%llo%.*s` are no longer supported, use `std.conv.octal!%llo%.*s` instead", n, cast(int)(p - psuffix), psuffix, n, cast(int)(p - psuffix), psuffix); } TOK result; switch (flags) { case FLAGS.none: /* Octal or Hexadecimal constant. * First that fits: int, uint, long, ulong */ if (n & 0x8000000000000000L) result = TOK.uns64Literal; else if (n & 0xFFFFFFFF00000000L) result = TOK.int64Literal; else if (n & 0x80000000) result = TOK.uns32Literal; else result = TOK.int32Literal; break; case FLAGS.decimal: /* First that fits: int, long, long long */ if (n & 0x8000000000000000L) { if (!err) { error("signed integer overflow"); err = true; } result = TOK.uns64Literal; } else if (n & 0xFFFFFFFF80000000L) result = TOK.int64Literal; else result = TOK.int32Literal; break; case FLAGS.unsigned: case FLAGS.decimal | FLAGS.unsigned: /* First that fits: uint, ulong */ if (n & 0xFFFFFFFF00000000L) result = TOK.uns64Literal; else result = TOK.uns32Literal; break; case FLAGS.decimal | FLAGS.long_: if (n & 0x8000000000000000L) { if (!err) { error("signed integer overflow"); err = true; } result = TOK.uns64Literal; } else result = TOK.int64Literal; break; case FLAGS.long_: if (n & 0x8000000000000000L) result = TOK.uns64Literal; else result = TOK.int64Literal; break; case FLAGS.unsigned | FLAGS.long_: case FLAGS.decimal | FLAGS.unsigned | FLAGS.long_: result = TOK.uns64Literal; break; default: debug { printf("%x\n", flags); } assert(0); } t.unsvalue = n; return result; } /************************************** * Read in characters, converting them to real. * Bugs: * Exponent overflow not detected. * Too much requested precision is not detected. */ private TOK inreal(Token* t) { //printf("Lexer::inreal()\n"); debug { assert(*p == '.' || isdigit(*p)); } bool isWellformedString = true; stringbuffer.reset(); auto pstart = p; bool hex = false; dchar c = *p++; // Leading '0x' if (c == '0') { c = *p++; if (c == 'x' || c == 'X') { hex = true; c = *p++; } } // Digits to left of '.' while (1) { if (c == '.') { c = *p++; break; } if (isdigit(c) || (hex && isxdigit(c)) || c == '_') { c = *p++; continue; } break; } // Digits to right of '.' while (1) { if (isdigit(c) || (hex && isxdigit(c)) || c == '_') { c = *p++; continue; } break; } if (c == 'e' || c == 'E' || (hex && (c == 'p' || c == 'P'))) { c = *p++; if (c == '-' || c == '+') { c = *p++; } bool anyexp = false; while (1) { if (isdigit(c)) { anyexp = true; c = *p++; continue; } if (c == '_') { c = *p++; continue; } if (!anyexp) { error("missing exponent"); isWellformedString = false; } break; } } else if (hex) { error("exponent required for hex float"); isWellformedString = false; } --p; while (pstart < p) { if (*pstart != '_') stringbuffer.writeByte(*pstart); ++pstart; } stringbuffer.writeByte(0); auto sbufptr = cast(const(char)*)stringbuffer[].ptr; TOK result; bool isOutOfRange = false; t.floatvalue = (isWellformedString ? CTFloat.parse(sbufptr, &isOutOfRange) : CTFloat.zero); switch (*p) { case 'F': case 'f': if (isWellformedString && !isOutOfRange) isOutOfRange = Port.isFloat32LiteralOutOfRange(sbufptr); result = TOK.float32Literal; p++; break; default: if (isWellformedString && !isOutOfRange) isOutOfRange = Port.isFloat64LiteralOutOfRange(sbufptr); result = TOK.float64Literal; break; case 'l': error("use 'L' suffix instead of 'l'"); goto case 'L'; case 'L': result = TOK.float80Literal; p++; break; } if (*p == 'i' || *p == 'I') { if (*p == 'I') error("use 'i' suffix instead of 'I'"); p++; switch (result) { case TOK.float32Literal: result = TOK.imaginary32Literal; break; case TOK.float64Literal: result = TOK.imaginary64Literal; break; case TOK.float80Literal: result = TOK.imaginary80Literal; break; default: break; } } const isLong = (result == TOK.float80Literal || result == TOK.imaginary80Literal); if (isOutOfRange && !isLong) { const char* suffix = (result == TOK.float32Literal || result == TOK.imaginary32Literal) ? "f" : ""; error(scanloc, "number `%s%s` is not representable", sbufptr, suffix); } debug { switch (result) { case TOK.float32Literal: case TOK.float64Literal: case TOK.float80Literal: case TOK.imaginary32Literal: case TOK.imaginary64Literal: case TOK.imaginary80Literal: break; default: assert(0); } } return result; } final Loc loc() pure @nogc { scanloc.charnum = cast(uint)(1 + p - line); return scanloc; } final void error(const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.error(token.loc, format, args); va_end(args); } final void error(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.error(loc, format, args); va_end(args); } final void errorSupplemental(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.errorSupplemental(loc, format, args); va_end(args); } final void warning(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.warning(loc, format, args); va_end(args); } final void warningSupplemental(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.warningSupplemental(loc, format, args); va_end(args); } final void deprecation(const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.deprecation(token.loc, format, args); va_end(args); } final void deprecation(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.deprecation(loc, format, args); va_end(args); } final void deprecationSupplemental(const ref Loc loc, const(char)* format, ...) { va_list args; va_start(args, format); diagnosticReporter.deprecationSupplemental(loc, format, args); va_end(args); } /********************************************* * parse: * #line linnum [filespec] * also allow __LINE__ for linnum, and __FILE__ for filespec */ private void poundLine() { auto linnum = this.scanloc.linnum; const(char)* filespec = null; const loc = this.loc(); Token tok; scan(&tok); if (tok.value == TOK.int32Literal || tok.value == TOK.int64Literal) { const lin = cast(int)(tok.unsvalue - 1); if (lin != tok.unsvalue - 1) error("line number `%lld` out of range", cast(ulong)tok.unsvalue); else linnum = lin; } else if (tok.value == TOK.line) { } else goto Lerr; while (1) { switch (*p) { case 0: case 0x1A: case '\n': Lnewline: if (!inTokenStringConstant) { this.scanloc.linnum = linnum; if (filespec) this.scanloc.filename = filespec; } return; case '\r': p++; if (*p != '\n') { p--; goto Lnewline; } continue; case ' ': case '\t': case '\v': case '\f': p++; continue; // skip white space case '_': if (memcmp(p, "__FILE__".ptr, 8) == 0) { p += 8; filespec = mem.xstrdup(scanloc.filename); continue; } goto Lerr; case '"': if (filespec) goto Lerr; stringbuffer.reset(); p++; while (1) { uint c; c = *p; switch (c) { case '\n': case '\r': case 0: case 0x1A: goto Lerr; case '"': stringbuffer.writeByte(0); filespec = mem.xstrdup(cast(const(char)*)stringbuffer[].ptr); p++; break; default: if (c & 0x80) { uint u = decodeUTF(); if (u == PS || u == LS) goto Lerr; } stringbuffer.writeByte(c); p++; continue; } break; } continue; default: if (*p & 0x80) { uint u = decodeUTF(); if (u == PS || u == LS) goto Lnewline; } goto Lerr; } } Lerr: error(loc, "#line integer [\"filespec\"]\\n expected"); } /******************************************** * Decode UTF character. * Issue error messages for invalid sequences. * Return decoded character, advance p to last character in UTF sequence. */ private uint decodeUTF() { const s = p; assert(*s & 0x80); // Check length of remaining string up to 4 UTF-8 characters size_t len; for (len = 1; len < 4 && s[len]; len++) { } size_t idx = 0; dchar u; const msg = utf_decodeChar(s, len, idx, u); p += idx - 1; if (msg) { error("%s", msg); } return u; } /*************************************************** * Parse doc comment embedded between t.ptr and p. * Remove trailing blanks and tabs from lines. * Replace all newlines with \n. * Remove leading comment character from each line. * Decide if it's a lineComment or a blockComment. * Append to previous one for this token. * * If newParagraph is true, an extra newline will be * added between adjoining doc comments. */ private void getDocComment(Token* t, uint lineComment, bool newParagraph) pure { /* ct tells us which kind of comment it is: '/', '*', or '+' */ const ct = t.ptr[2]; /* Start of comment text skips over / * *, / + +, or / / / */ const(char)* q = t.ptr + 3; // start of comment text const(char)* qend = p; if (ct == '*' || ct == '+') qend -= 2; /* Scan over initial row of ****'s or ++++'s or ////'s */ for (; q < qend; q++) { if (*q != ct) break; } /* Remove leading spaces until start of the comment */ int linestart = 0; if (ct == '/') { while (q < qend && (*q == ' ' || *q == '\t')) ++q; } else if (q < qend) { if (*q == '\r') { ++q; if (q < qend && *q == '\n') ++q; linestart = 1; } else if (*q == '\n') { ++q; linestart = 1; } } /* Remove trailing row of ****'s or ++++'s */ if (ct != '/') { for (; q < qend; qend--) { if (qend[-1] != ct) break; } } /* Comment is now [q .. qend]. * Canonicalize it into buf[]. */ OutBuffer buf; void trimTrailingWhitespace() { const s = buf.peekSlice(); auto len = s.length; while (len && (s[len - 1] == ' ' || s[len - 1] == '\t')) --len; buf.setsize(len); } for (; q < qend; q++) { char c = *q; switch (c) { case '*': case '+': if (linestart && c == ct) { linestart = 0; /* Trim preceding whitespace up to preceding \n */ trimTrailingWhitespace(); continue; } break; case ' ': case '\t': break; case '\r': if (q[1] == '\n') continue; // skip the \r goto Lnewline; default: if (c == 226) { // If LS or PS if (q[1] == 128 && (q[2] == 168 || q[2] == 169)) { q += 2; goto Lnewline; } } linestart = 0; break; Lnewline: c = '\n'; // replace all newlines with \n goto case; case '\n': linestart = 1; /* Trim trailing whitespace */ trimTrailingWhitespace(); break; } buf.writeByte(c); } /* Trim trailing whitespace (if the last line does not have newline) */ trimTrailingWhitespace(); // Always end with a newline const s = buf.peekSlice(); if (s.length == 0 || s[$ - 1] != '\n') buf.writeByte('\n'); // It's a line comment if the start of the doc comment comes // after other non-whitespace on the same line. auto dc = (lineComment && anyToken) ? &t.lineComment : &t.blockComment; // Combine with previous doc comment, if any if (*dc) *dc = combineComments(*dc, buf.peekSlice(), newParagraph).toDString(); else *dc = buf.extractSlice(true); } /******************************************** * Combine two document comments into one, * separated by an extra newline if newParagraph is true. */ static const(char)* combineComments(const(char)[] c1, const(char)[] c2, bool newParagraph) pure { //printf("Lexer::combineComments('%s', '%s', '%i')\n", c1, c2, newParagraph); const(int) newParagraphSize = newParagraph ? 1 : 0; // Size of the combining '\n' if (!c1) return c2.ptr; if (!c2) return c1.ptr; int insertNewLine = 0; if (c1.length && c1[$ - 1] != '\n') insertNewLine = 1; const retSize = c1.length + insertNewLine + newParagraphSize + c2.length; auto p = cast(char*)mem.xmalloc_noscan(retSize + 1); p[0 .. c1.length] = c1[]; if (insertNewLine) p[c1.length] = '\n'; if (newParagraph) p[c1.length + insertNewLine] = '\n'; p[retSize - c2.length .. retSize] = c2[]; p[retSize] = 0; return p; } private: void endOfLine() pure @nogc @safe { scanloc.linnum++; line = p; } } unittest { static final class AssertDiagnosticReporter : DiagnosticReporter { override int errorCount() { assert(0); } override int warningCount() { assert(0); } override int deprecationCount() { assert(0); } override void error(const ref Loc, const(char)*, va_list) { assert(0); } override void errorSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } override void warning(const ref Loc, const(char)*, va_list) { assert(0); } override void warningSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } override void deprecation(const ref Loc, const(char)*, va_list) { assert(0); } override void deprecationSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } } static void test(T)(string sequence, T expected) { scope assertOnError = new AssertDiagnosticReporter(); auto p = cast(const(char)*)sequence.ptr; assert(expected == Lexer.escapeSequence(Loc.initial, assertOnError, p)); assert(p == sequence.ptr + sequence.length); } test(`'`, '\''); test(`"`, '"'); test(`?`, '?'); test(`\`, '\\'); test(`0`, '\0'); test(`a`, '\a'); test(`b`, '\b'); test(`f`, '\f'); test(`n`, '\n'); test(`r`, '\r'); test(`t`, '\t'); test(`v`, '\v'); test(`x00`, 0x00); test(`xff`, 0xff); test(`xFF`, 0xff); test(`xa7`, 0xa7); test(`x3c`, 0x3c); test(`xe2`, 0xe2); test(`1`, '\1'); test(`42`, '\42'); test(`357`, '\357'); test(`u1234`, '\u1234'); test(`uf0e4`, '\uf0e4'); test(`U0001f603`, '\U0001f603'); test(`&quot;`, '"'); test(`&lt;`, '<'); test(`&gt;`, '>'); } unittest { static final class ExpectDiagnosticReporter : DiagnosticReporter { string expected; bool gotError; nothrow: this(string expected) { this.expected = expected; } override int errorCount() { assert(0); } override int warningCount() { assert(0); } override int deprecationCount() { assert(0); } override void error(const ref Loc loc, const(char)* format, va_list args) { gotError = true; char[100] buffer = void; auto actual = buffer[0 .. vsprintf(buffer.ptr, format, args)]; assert(expected == actual); } override void errorSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } override void warning(const ref Loc, const(char)*, va_list) { assert(0); } override void warningSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } override void deprecation(const ref Loc, const(char)*, va_list) { assert(0); } override void deprecationSupplemental(const ref Loc, const(char)*, va_list) { assert(0); } } static void test(string sequence, string expectedError, dchar expectedReturnValue, uint expectedScanLength) { scope handler = new ExpectDiagnosticReporter(expectedError); auto p = cast(const(char)*)sequence.ptr; auto actualReturnValue = Lexer.escapeSequence(Loc.initial, handler, p); assert(handler.gotError); assert(expectedReturnValue == actualReturnValue); auto actualScanLength = p - sequence.ptr; assert(expectedScanLength == actualScanLength); } test("c", `undefined escape sequence \c`, 'c', 1); test("!", `undefined escape sequence \!`, '!', 1); test("x1", `escape hex sequence has 1 hex digits instead of 2`, '\x01', 2); test("u1" , `escape hex sequence has 1 hex digits instead of 4`, 0x1, 2); test("u12" , `escape hex sequence has 2 hex digits instead of 4`, 0x12, 3); test("u123", `escape hex sequence has 3 hex digits instead of 4`, 0x123, 4); test("U0" , `escape hex sequence has 1 hex digits instead of 8`, 0x0, 2); test("U00" , `escape hex sequence has 2 hex digits instead of 8`, 0x00, 3); test("U000" , `escape hex sequence has 3 hex digits instead of 8`, 0x000, 4); test("U0000" , `escape hex sequence has 4 hex digits instead of 8`, 0x0000, 5); test("U0001f" , `escape hex sequence has 5 hex digits instead of 8`, 0x0001f, 6); test("U0001f6" , `escape hex sequence has 6 hex digits instead of 8`, 0x0001f6, 7); test("U0001f60", `escape hex sequence has 7 hex digits instead of 8`, 0x0001f60, 8); test("ud800" , `invalid UTF character \U0000d800`, '?', 5); test("udfff" , `invalid UTF character \U0000dfff`, '?', 5); test("U00110000", `invalid UTF character \U00110000`, '?', 9); test("xg0" , `undefined escape hex sequence \xg`, 'g', 2); test("ug000" , `undefined escape hex sequence \ug`, 'g', 2); test("Ug0000000", `undefined escape hex sequence \Ug`, 'g', 2); test("&BAD;", `unnamed character entity &BAD;` , '?', 5); test("&quot", `unterminated named entity &quot;`, '?', 5); test("400", `escape octal sequence \400 is larger than \377`, 0x100, 3); }
D
/Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Scan.o : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Scan~partial.swiftmodule : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.build/Objects-normal/x86_64/Scan~partial.swiftdoc : /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/AnyObserver.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsMaybe.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/AsSingle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/AsyncSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Bag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Cancelable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ConnectableObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debounce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DefaultIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Deprecated.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/Disposables.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Errors.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Event.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/GroupBy.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/GroupedObservable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/Lock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObservableType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/ObserverType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Optional.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Darwin.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/Platform.Linux.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence+Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Units/PrimitiveSequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/PriorityQueue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/DataStructures/Queue.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Reactive.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/Platform/RecursiveLock.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/RxMutableBox.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/SchedulerType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/SwitchIfEmpty.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Subjects/Variable.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+Collection.swift /Users/netnorimingconception/utils/GeoFence/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/Swift.swiftmodule /Users/netnorimingconception/utils/GeoFence/Pods/Target\ Support\ Files/RxSwift/RxSwift-umbrella.h /Users/netnorimingconception/utils/GeoFence/Build/Intermediates/Pods.build/Debug-iphonesimulator/RxSwift.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule
D
module android.java.android.media.tv.TvContract_PreviewPrograms_d_interface; import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers; static import arsd.jni; import import0 = android.java.java.lang.Class_d_interface; @JavaName("TvContract$PreviewPrograms") final class TvContract_PreviewPrograms : IJavaObject { static immutable string[] _d_canCastTo = [ "android/media/tv/TvContract$BaseTvColumns", ]; @Import import0.Class getClass(); @Import int hashCode(); @Import bool equals(IJavaObject); @Import @JavaName("toString") string toString_(); override string toString() { return arsd.jni.javaObjectToString(this); } @Import void notify(); @Import void notifyAll(); @Import void wait(long); @Import void wait(long, int); @Import void wait(); mixin IJavaObjectImplementation!(false); public static immutable string _javaParameterString = "Landroid/media/tv/TvContract$PreviewPrograms;"; }
D
/** Implements WebSocket support and fallbacks for older browsers. Standards: $(LINK2 https://tools.ietf.org/html/rfc6455, RFC6455) Copyright: © 2012-2014 Sönke Ludwig License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Jan Krüger */ module vibe.http.websockets; /// @safe unittest { void handleConn(scope WebSocket sock) { // simple echo server while (sock.connected) { auto msg = sock.receiveText(); sock.send(msg); } } void startServer() { import vibe.http.router; auto router = new URLRouter; router.get("/ws", handleWebSockets(&handleConn)); // Start HTTP server using listenHTTP()... } } import vibe.core.core; import vibe.core.log; import vibe.core.net; import vibe.core.sync; import vibe.stream.operations; import vibe.http.server; import vibe.http.client; import vibe.core.connectionpool; import vibe.utils.array; static import vibe.internal.exception; import core.time; import std.algorithm: equal, splitter; import std.array; import std.base64; import std.conv; import std.exception; import std.bitmanip; import std.digest.sha; import std.string; import std.functional; import std.uuid; import std.base64; import std.digest.sha; import std.uni: asLowerCase; import vibe.crypto.cryptorand; @safe: alias WebSocketHandshakeDelegate = void delegate(scope WebSocket) nothrow; /// Exception thrown by $(D vibe.http.websockets). class WebSocketException: Exception { @safe pure nothrow: /// this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) { super(msg, file, line, next); } /// this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) { super(msg, next, file, line); } } /** Establishes a WebSocket connection at the specified endpoint. */ WebSocket connectWebSocketEx(URL url, scope void delegate(scope HTTPClientRequest) @safe request_modifier, const(HTTPClientSettings) settings = defaultSettings) @safe { const use_tls = (url.schema == "wss" || url.schema == "https") ? true : false; url.schema = use_tls ? "https" : "http"; auto rng = secureRNG(); auto challengeKey = generateChallengeKey(rng); auto answerKey = computeAcceptKey(challengeKey); auto res = requestHTTP(url, (scope req){ req.method = HTTPMethod.GET; req.headers["Upgrade"] = "websocket"; req.headers["Connection"] = "Upgrade"; req.headers["Sec-WebSocket-Version"] = "13"; req.headers["Sec-WebSocket-Key"] = challengeKey; request_modifier(req); }, settings); enforce(res.statusCode == HTTPStatus.switchingProtocols, "Server didn't accept the protocol upgrade request."); auto key = "sec-websocket-accept" in res.headers; enforce(key !is null, "Response is missing the Sec-WebSocket-Accept header."); enforce(*key == answerKey, "Response has wrong accept key"); auto conn = res.switchProtocol("websocket"); return new WebSocket(conn, rng, res); } /// ditto void connectWebSocketEx(URL url, scope void delegate(scope HTTPClientRequest) @safe request_modifier, scope WebSocketHandshakeDelegate del, const(HTTPClientSettings) settings = defaultSettings) @safe { const use_tls = (url.schema == "wss" || url.schema == "https") ? true : false; url.schema = use_tls ? "https" : "http"; /*scope*/auto rng = secureRNG(); auto challengeKey = generateChallengeKey(rng); auto answerKey = computeAcceptKey(challengeKey); requestHTTP(url, (scope req) { req.method = HTTPMethod.GET; req.headers["Upgrade"] = "websocket"; req.headers["Connection"] = "Upgrade"; req.headers["Sec-WebSocket-Version"] = "13"; req.headers["Sec-WebSocket-Key"] = challengeKey; request_modifier(req); }, (scope res) { enforce(res.statusCode == HTTPStatus.switchingProtocols, "Server didn't accept the protocol upgrade request."); auto key = "sec-websocket-accept" in res.headers; enforce(key !is null, "Response is missing the Sec-WebSocket-Accept header."); enforce(*key == answerKey, "Response has wrong accept key"); res.switchProtocol("websocket", (scope conn) @trusted { scope ws = new WebSocket(conn, rng, res); del(ws); if (ws.connected) ws.close(); }); }, settings ); } /// ditto WebSocket connectWebSocket(URL url, const(HTTPClientSettings) settings = defaultSettings) @safe { return connectWebSocketEx(url, (scope req) {}, settings); } /// ditto void connectWebSocket(URL url, scope WebSocketHandshakeDelegate del, const(HTTPClientSettings) settings = defaultSettings) @safe { connectWebSocketEx(url, (scope req) {}, del, settings); } /// ditto void connectWebSocket(URL url, scope void delegate(scope WebSocket) @system del, const(HTTPClientSettings) settings = defaultSettings) @system { connectWebSocket(url, (scope ws) nothrow { try del(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }, settings); } /// Scheduled for deprecation - use a `@safe` callback instead. void connectWebSocket(URL url, scope void delegate(scope WebSocket) @system nothrow del, const(HTTPClientSettings) settings = defaultSettings) @system { connectWebSocket(url, (scope ws) @trusted => del(ws), settings); } /// Scheduled for deprecation - use a `nothrow` callback instead. void connectWebSocket(URL url, scope void delegate(scope WebSocket) @safe del, const(HTTPClientSettings) settings = defaultSettings) @safe { connectWebSocket(url, (scope ws) nothrow { try del(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }, settings); } /** Establishes a web socket conection and passes it to the $(D on_handshake) delegate. */ void handleWebSocket(scope WebSocketHandshakeDelegate on_handshake, scope HTTPServerRequest req, scope HTTPServerResponse res) @safe { auto pUpgrade = "Upgrade" in req.headers; auto pConnection = "Connection" in req.headers; auto pKey = "Sec-WebSocket-Key" in req.headers; //auto pProtocol = "Sec-WebSocket-Protocol" in req.headers; auto pVersion = "Sec-WebSocket-Version" in req.headers; auto isUpgrade = false; if( pConnection ) { auto connectionTypes = splitter(*pConnection, ","); foreach( t ; connectionTypes ) { if( t.strip().asLowerCase().equal("upgrade") ) { isUpgrade = true; break; } } } string req_error; if (!isUpgrade) req_error = "WebSocket endpoint only accepts \"Connection: upgrade\" requests."; else if (!pUpgrade || icmp(*pUpgrade, "websocket") != 0) req_error = "WebSocket endpoint requires \"Upgrade: websocket\" header."; else if (!pVersion || *pVersion != "13") req_error = "Only version 13 of the WebSocket protocol is supported."; else if (!pKey) req_error = "Missing \"Sec-WebSocket-Key\" header."; if (req_error.length) { logDebug("Browser sent invalid WebSocket request: %s", req_error); res.statusCode = HTTPStatus.badRequest; res.writeBody(req_error); return; } auto accept = () @trusted { return cast(string)Base64.encode(sha1Of(*pKey ~ s_webSocketGuid)); } (); res.headers["Sec-WebSocket-Accept"] = accept; res.headers["Connection"] = "Upgrade"; ConnectionStream conn = res.switchProtocol("websocket"); WebSocket socket = new WebSocket(conn, req, res); try { on_handshake(socket); } catch (Exception e) { logDiagnostic("WebSocket handler failed: %s", e.msg); } socket.close(); } /// Scheduled for deprecation - use a `@safe` callback instead. void handleWebSocket(scope void delegate(scope WebSocket) @system nothrow on_handshake, scope HTTPServerRequest req, scope HTTPServerResponse res) @system { handleWebSocket((scope ws) @trusted => on_handshake(ws), req, res); } /// Scheduled for deprecation - use a `nothrow` callback instead. void handleWebSocket(scope void delegate(scope WebSocket) @safe on_handshake, scope HTTPServerRequest req, scope HTTPServerResponse res) { handleWebSocket((scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }, req, res); } /// ditto void handleWebSocket(scope void delegate(scope WebSocket) @system on_handshake, scope HTTPServerRequest req, scope HTTPServerResponse res) @system { handleWebSocket((scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }, req, res); } /** Returns a HTTP request handler that establishes web socket conections. */ HTTPServerRequestDelegateS handleWebSockets(void function(scope WebSocket) @safe nothrow on_handshake) @safe { return handleWebSockets(() @trusted { return toDelegate(on_handshake); } ()); } /// ditto HTTPServerRequestDelegateS handleWebSockets(WebSocketHandshakeDelegate on_handshake) @safe { void callback(scope HTTPServerRequest req, scope HTTPServerResponse res) @safe { auto pUpgrade = "Upgrade" in req.headers; auto pConnection = "Connection" in req.headers; auto pKey = "Sec-WebSocket-Key" in req.headers; //auto pProtocol = "Sec-WebSocket-Protocol" in req.headers; auto pVersion = "Sec-WebSocket-Version" in req.headers; auto isUpgrade = false; if( pConnection ) { auto connectionTypes = splitter(*pConnection, ","); foreach( t ; connectionTypes ) { if( t.strip().asLowerCase().equal("upgrade") ) { isUpgrade = true; break; } } } if( !(isUpgrade && pUpgrade && icmp(*pUpgrade, "websocket") == 0 && pKey && pVersion && *pVersion == "13") ) { logDebug("Browser sent invalid WebSocket request."); res.statusCode = HTTPStatus.badRequest; res.writeVoidBody(); return; } auto accept = () @trusted { return cast(string)Base64.encode(sha1Of(*pKey ~ s_webSocketGuid)); } (); res.headers["Sec-WebSocket-Accept"] = accept; res.headers["Connection"] = "Upgrade"; res.switchProtocol("websocket", (scope conn) { // TODO: put back 'scope' once it is actually enforced by DMD /*scope*/ auto socket = new WebSocket(conn, req, res); try on_handshake(socket); catch (Exception e) { logDiagnostic("WebSocket handler failed: %s", e.msg); } socket.close(); }); } return &callback; } /// Scheduled for deprecation - use a `@safe` callback instead. HTTPServerRequestDelegateS handleWebSockets(void delegate(scope WebSocket) @system nothrow on_handshake) @system { return handleWebSockets(delegate (scope ws) @trusted => on_handshake(ws)); } /// Scheduled for deprecation - use a `@safe` callback instead. HTTPServerRequestDelegateS handleWebSockets(void function(scope WebSocket) @system nothrow on_handshake) @system { return handleWebSockets(delegate (scope ws) @trusted => on_handshake(ws)); } /// Scheduled for deprecation - use a `nothrow` callback instead. HTTPServerRequestDelegateS handleWebSockets(void delegate(scope WebSocket) @safe on_handshake) { return handleWebSockets(delegate (scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }); } /// ditto HTTPServerRequestDelegateS handleWebSockets(void function(scope WebSocket) @safe on_handshake) { return handleWebSockets(delegate (scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }); } /// ditto HTTPServerRequestDelegateS handleWebSockets(void delegate(scope WebSocket) @system on_handshake) @system { return handleWebSockets(delegate (scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }); } /// ditto HTTPServerRequestDelegateS handleWebSockets(void function(scope WebSocket) @system on_handshake) @system { return handleWebSockets(delegate (scope ws) nothrow { try on_handshake(ws); catch (Exception e) logWarn("WebSocket handler failed: %s", e.msg); }); } /** * Provides the reason that a websocket connection has closed. * * Further documentation for the WebSocket and it's codes can be found from: * https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent * * --- * * void echoSocket(scope WebSocket sock) * { * import std.datetime : seconds; * * while(sock.waitForData(3.seconds)) * { * string msg = sock.receiveText; * logInfo("Got a message: %s", msg); * sock.send(msg); * } * * if(sock.connected) * sock.close(WebSocketCloseReason.policyViolation, "timeout"); * } * --- */ enum WebSocketCloseReason : short { none = 0, normalClosure = 1000, goingAway = 1001, protocolError = 1002, unsupportedData = 1003, noStatusReceived = 1005, abnormalClosure = 1006, invalidFramePayloadData = 1007, policyViolation = 1008, messageTooBig = 1009, internalError = 1011, serviceRestart = 1012, tryAgainLater = 1013, badGateway = 1014, tlsHandshake = 1015 } string closeReasonString(WebSocketCloseReason reason) @nogc @safe { import std.math : floor; //round down to the nearest thousand to get category switch(cast(short)(cast(float)reason / 1000f).floor) { case 0: return "Reserved and Unused"; case 1: switch(reason) { case 1000: return "Normal Closure"; case 1001: return "Going Away"; case 1002: return "Protocol Error"; case 1003: return "Unsupported Data"; case 1004: return "RESERVED"; case 1005: return "No Status Recvd"; case 1006: return "Abnormal Closure"; case 1007: return "Invalid Frame Payload Data"; case 1008: return "Policy Violation"; case 1009: return "Message Too Big"; case 1010: return "Missing Extension"; case 1011: return "Internal Error"; case 1012: return "Service Restart"; case 1013: return "Try Again Later"; case 1014: return "Bad Gateway"; case 1015: return "TLS Handshake"; default: return "RESERVED"; } case 2: return "Reserved for extensions"; case 3: return "Available for frameworks and libraries"; case 4: return "Available for applications"; default: return "UNDEFINED - Nasal Demons"; } } unittest { assert((cast(WebSocketCloseReason) 0).closeReasonString == "Reserved and Unused"); assert((cast(WebSocketCloseReason) 1).closeReasonString == "Reserved and Unused"); assert(WebSocketCloseReason.normalClosure.closeReasonString == "Normal Closure"); assert(WebSocketCloseReason.abnormalClosure.closeReasonString == "Abnormal Closure"); assert((cast(WebSocketCloseReason)1020).closeReasonString == "RESERVED"); assert((cast(WebSocketCloseReason)2000).closeReasonString == "Reserved for extensions"); assert((cast(WebSocketCloseReason)3000).closeReasonString == "Available for frameworks and libraries"); assert((cast(WebSocketCloseReason)4000).closeReasonString == "Available for applications"); assert((cast(WebSocketCloseReason)5000).closeReasonString == "UNDEFINED - Nasal Demons"); assert((cast(WebSocketCloseReason) -1).closeReasonString == "UNDEFINED - Nasal Demons"); //check the other spec cases for(short i = 1000; i < 1017; i++) { if(i == 1004 || i > 1015) { assert( (cast(WebSocketCloseReason)i).closeReasonString == "RESERVED", "(incorrect) code %d = %s".format(i, closeReasonString(cast(WebSocketCloseReason)i)) ); } else assert( (cast(WebSocketCloseReason)i).closeReasonString != "RESERVED", "(incorrect) code %d = %s".format(i, closeReasonString(cast(WebSocketCloseReason)i)) ); } } /** * Represents a single _WebSocket connection. * * --- * shared static this () * { * runTask(() => connectToWS()); * } * * void connectToWS () * { * auto ws_url = URL("wss://websockets.example.com/websocket/auth_token"); * auto ws = connectWebSocket(ws_url); * logInfo("WebSocket connected"); * * while (ws.waitForData()) * { * auto txt = ws.receiveText; * logInfo("Received: %s", txt); * } * logFatal("Connection lost!"); * } * --- */ final class WebSocket { @safe: private { ConnectionStream m_conn; bool m_sentCloseFrame = false; IncomingWebSocketMessage m_nextMessage = null; const HTTPServerRequest m_request; HTTPServerResponse m_serverResponse; HTTPClientResponse m_clientResponse; Task m_reader; Task m_ownerTask; InterruptibleTaskMutex m_readMutex, m_writeMutex; InterruptibleTaskCondition m_readCondition; Timer m_pingTimer; uint m_lastPingIndex; bool m_pongReceived; short m_closeCode; const(char)[] m_closeReason; /// The entropy generator to use /// If not null, it means this is a server socket. RandomNumberStream m_rng; } /** * Private constructor, called from `connectWebSocket`. * * Params: * conn = Underlying connection string * request = HTTP request used to establish the connection * rng = Source of entropy to use. If null, assume we're a server socket * client_res = For client sockets, the response object (keeps the http client locked until the socket is done) */ private this(ConnectionStream conn, const HTTPServerRequest request, HTTPServerResponse server_res, RandomNumberStream rng, HTTPClientResponse client_res) { m_ownerTask = Task.getThis(); m_conn = conn; m_request = request; m_clientResponse = client_res; m_serverResponse = server_res; assert(m_conn); m_rng = rng; m_writeMutex = new InterruptibleTaskMutex; m_readMutex = new InterruptibleTaskMutex; m_readCondition = new InterruptibleTaskCondition(m_readMutex); m_readMutex.performLocked!({ m_reader = runTask(&startReader); if (request !is null && request.serverSettings.webSocketPingInterval != Duration.zero) { m_pongReceived = true; m_pingTimer = setTimer(request.serverSettings.webSocketPingInterval, &sendPing, true); } }); } private this(ConnectionStream conn, RandomNumberStream rng, HTTPClientResponse client_res) { this(conn, null, null, rng, client_res); } private this(ConnectionStream conn, in HTTPServerRequest request, HTTPServerResponse res) { this(conn, request, res, null, null); } /** Determines if the WebSocket connection is still alive and ready for sending. Note that for determining the ready state for $(EM reading), you need to use $(D waitForData) instead, because both methods can return different values while a disconnect is in proress. See_also: $(D waitForData) */ @property bool connected() { return m_conn && m_conn.connected && !m_sentCloseFrame; } /** Returns the close code sent by the remote end. Note if the connection was never opened, is still alive, or was closed locally this value will be 0. If no close code was given by the remote end in the close frame, the value will be 1005. If the connection was not closed cleanly by the remote end, this value will be 1006. */ @property short closeCode() { return m_closeCode; } /** Returns the close reason sent by the remote end. Note if the connection was never opened, is still alive, or was closed locally this value will be an empty string. */ @property const(char)[] closeReason() { return m_closeReason; } /** The HTTP request that established the web socket connection. */ @property const(HTTPServerRequest) request() const { return m_request; } /** Checks if data is readily available for read. */ @property bool dataAvailableForRead() { return m_conn.dataAvailableForRead || m_nextMessage !is null; } /** Waits until either a message arrives or until the connection is closed. This function can be used in a read loop to cleanly determine when to stop reading. */ bool waitForData() { if (m_nextMessage) return true; m_readMutex.performLocked!({ while (connected && m_nextMessage is null) m_readCondition.wait(); }); return m_nextMessage !is null; } /// ditto bool waitForData(Duration timeout) { import std.datetime; if (m_nextMessage) return true; immutable limit_time = Clock.currTime(UTC()) + timeout; m_readMutex.performLocked!({ while (connected && m_nextMessage is null && timeout > 0.seconds) { m_readCondition.wait(timeout); timeout = limit_time - Clock.currTime(UTC()); } }); return m_nextMessage !is null; } /** Sends a text message. On the JavaScript side, the text will be available as message.data (type string). Throws: A `WebSocketException` is thrown if the connection gets closed before or during the transfer of the message. */ void send(scope const(char)[] data) { send( (scope message) { message.write(cast(const ubyte[])data); }, FrameOpcode.text); } /** Sends a binary message. On the JavaScript side, the text will be available as message.data (type Blob). Throws: A `WebSocketException` is thrown if the connection gets closed before or during the transfer of the message. */ void send(in ubyte[] data) { send((scope message){ message.write(data); }, FrameOpcode.binary); } /** Sends a message using an output stream. Throws: A `WebSocketException` is thrown if the connection gets closed before or during the transfer of the message. */ void send(scope void delegate(scope OutgoingWebSocketMessage) @safe sender, FrameOpcode frameOpcode) { m_writeMutex.performLocked!({ vibe.internal.exception.enforce!WebSocketException(!m_sentCloseFrame, "WebSocket connection already actively closed."); /*scope*/auto message = new OutgoingWebSocketMessage(m_conn, frameOpcode, m_rng); scope(exit) message.finalize(); sender(message); }); } /// Compatibility overload - will be removed soon. deprecated("Call the overload which requires an explicit FrameOpcode.") void send(scope void delegate(scope OutgoingWebSocketMessage) @safe sender) { send(sender, FrameOpcode.text); } /** Actively closes the connection. Params: code = Numeric code indicating a termination reason. reason = Message describing why the connection was terminated. */ void close(short code = WebSocketCloseReason.normalClosure, scope const(char)[] reason = "") { import std.algorithm.comparison : min; if(reason !is null && reason.length == 0) reason = (cast(WebSocketCloseReason)code).closeReasonString; //control frame payloads are limited to 125 bytes version(assert) assert(reason.length <= 123); else reason = reason[0 .. min($, 123)]; if (connected) { try { send((scope msg) { m_sentCloseFrame = true; if (code != 0) { msg.write(std.bitmanip.nativeToBigEndian(code)); msg.write(cast(const ubyte[])reason); } }, FrameOpcode.close); } catch (Exception e) { logDiagnostic("Failed to send active web socket close frame: %s", e.msg); } } if (m_pingTimer) m_pingTimer.stop(); if (Task.getThis() == m_ownerTask) { m_writeMutex.performLocked!({ if (m_clientResponse) { m_clientResponse.disconnect(); m_clientResponse = HTTPClientResponse.init; } if (m_serverResponse) { m_serverResponse.finalize(); m_serverResponse = HTTPServerResponse.init; } }); m_reader.join(); () @trusted { destroy(m_conn); } (); m_conn = ConnectionStream.init; } } /** Receives a new message and returns its contents as a newly allocated data array. Params: strict = If set, ensures the exact frame type (text/binary) is received and throws an execption otherwise. Throws: WebSocketException if the connection is closed or if $(D strict == true) and the frame received is not the right type */ ubyte[] receiveBinary(bool strict = true) { ubyte[] ret; receive((scope message){ vibe.internal.exception.enforce!WebSocketException(!strict || message.frameOpcode == FrameOpcode.binary, "Expected a binary message, got "~message.frameOpcode.to!string()); ret = message.readAll(); }); return ret; } /// ditto string receiveText(bool strict = true) { string ret; receive((scope message){ vibe.internal.exception.enforce!WebSocketException(!strict || message.frameOpcode == FrameOpcode.text, "Expected a text message, got "~message.frameOpcode.to!string()); ret = message.readAllUTF8(); }); return ret; } /** Receives a new message using an InputStream. Throws: WebSocketException if the connection is closed. */ void receive(scope void delegate(scope IncomingWebSocketMessage) @safe receiver) { m_readMutex.performLocked!({ while (!m_nextMessage) { vibe.internal.exception.enforce!WebSocketException(connected, "Connection closed while reading message."); m_readCondition.wait(); } receiver(m_nextMessage); m_nextMessage = null; m_readCondition.notifyAll(); }); } private void startReader() { m_readMutex.performLocked!({}); //Wait until initialization scope (exit) { m_conn.close(); m_readCondition.notifyAll(); } try { while (!m_conn.empty) { assert(!m_nextMessage); /*scope*/auto msg = new IncomingWebSocketMessage(m_conn, m_rng); switch (msg.frameOpcode) { default: throw new WebSocketException("unknown frame opcode"); case FrameOpcode.ping: send((scope pong_msg) { pong_msg.write(msg.peek()); }, FrameOpcode.pong); break; case FrameOpcode.pong: // test if pong matches previous ping if (msg.peek.length != uint.sizeof || m_lastPingIndex != littleEndianToNative!uint(msg.peek()[0..uint.sizeof])) { logDebugV("Received PONG that doesn't match previous ping."); break; } logDebugV("Received matching PONG."); m_pongReceived = true; break; case FrameOpcode.close: logDebug("Got closing frame (%s)", m_sentCloseFrame); // If no close code was passed, we default to 1005 this.m_closeCode = WebSocketCloseReason.noStatusReceived; // If provided in the frame, attempt to parse the close code/reason if (msg.peek().length >= short.sizeof) { this.m_closeCode = bigEndianToNative!short(msg.peek()[0..short.sizeof]); if (msg.peek().length > short.sizeof) { this.m_closeReason = cast(const(char) [])msg.peek()[short.sizeof..$]; } } if(!m_sentCloseFrame) close(); logDebug("Terminating connection (%s)", m_sentCloseFrame); return; case FrameOpcode.text: case FrameOpcode.binary: case FrameOpcode.continuation: // FIXME: add proper support for continuation frames! m_readMutex.performLocked!({ m_nextMessage = msg; m_readCondition.notifyAll(); while (m_nextMessage) m_readCondition.wait(); }); break; } } } catch (Exception e) { logDiagnostic("Error while reading websocket message: %s", e.msg); logDiagnostic("Closing connection."); } // If no close code was passed, e.g. this was an unclean termination // of our websocket connection, set the close code to 1006. if (this.m_closeCode == 0) this.m_closeCode = WebSocketCloseReason.abnormalClosure; } private void sendPing() nothrow { try { if (!m_pongReceived) { logDebug("Pong skipped. Closing connection."); close(); m_pingTimer.stop(); return; } m_pongReceived = false; send((scope msg) { msg.write(nativeToLittleEndian(++m_lastPingIndex)); }, FrameOpcode.ping); logDebugV("Ping sent"); } catch (Exception e) { logError("Failed to acquire write mutex for sending a WebSocket ping frame: %s", e.msg); } } } /** Represents a single outgoing _WebSocket message as an OutputStream. */ final class OutgoingWebSocketMessage : OutputStream { @safe: private { RandomNumberStream m_rng; Stream m_conn; FrameOpcode m_frameOpcode; Appender!(ubyte[]) m_buffer; bool m_finalized = false; } private this(Stream conn, FrameOpcode frameOpcode, RandomNumberStream rng) { assert(conn !is null); m_conn = conn; m_frameOpcode = frameOpcode; m_rng = rng; } size_t write(in ubyte[] bytes, IOMode mode) { assert(!m_finalized); if (!m_buffer.data.length) { ubyte[Frame.maxHeaderSize] header_padding; m_buffer.put(header_padding[]); } m_buffer.put(bytes); return bytes.length; } void flush() { assert(!m_finalized); if (m_buffer.data.length > 0) sendFrame(false); } void finalize() { if (m_finalized) return; m_finalized = true; sendFrame(true); } private void sendFrame(bool fin) { if (!m_buffer.data.length) write(null, IOMode.once); assert(m_buffer.data.length >= Frame.maxHeaderSize); Frame frame; frame.fin = fin; frame.opcode = m_frameOpcode; frame.payload = m_buffer.data[Frame.maxHeaderSize .. $]; auto hsize = frame.getHeaderSize(m_rng !is null); auto msg = m_buffer.data[Frame.maxHeaderSize-hsize .. $]; frame.writeHeader(msg[0 .. hsize], m_rng); m_conn.write(msg); m_conn.flush(); m_buffer.clear(); } alias write = OutputStream.write; } /** Represents a single incoming _WebSocket message as an InputStream. */ final class IncomingWebSocketMessage : InputStream { @safe: private { RandomNumberStream m_rng; Stream m_conn; Frame m_currentFrame; } private this(Stream conn, RandomNumberStream rng) { assert(conn !is null); m_conn = conn; m_rng = rng; skipFrame(); // reads the first frame } @property bool empty() const { return m_currentFrame.payload.length == 0; } @property ulong leastSize() const { return m_currentFrame.payload.length; } @property bool dataAvailableForRead() { return true; } /// The frame type for this nessage; @property FrameOpcode frameOpcode() const { return m_currentFrame.opcode; } const(ubyte)[] peek() { return m_currentFrame.payload; } /** * Retrieve the next websocket frame of the stream and discard the current * one * * This function is helpful if one wish to process frames by frames, * or minimize memory allocation, as `peek` will only return the current * frame data, and read requires a pre-allocated buffer. * * Returns: * `false` if the current frame is the final one, `true` if a new frame * was read. */ bool skipFrame() { if (m_currentFrame.fin) return false; m_currentFrame = Frame.readFrame(m_conn); return true; } size_t read(scope ubyte[] dst, IOMode mode) { size_t nread = 0; while (dst.length > 0) { vibe.internal.exception.enforce!WebSocketException(!empty , "cannot read from empty stream"); vibe.internal.exception.enforce!WebSocketException(leastSize > 0, "no data available" ); import std.algorithm : min; auto sz = cast(size_t)min(leastSize, dst.length); dst[0 .. sz] = m_currentFrame.payload[0 .. sz]; dst = dst[sz .. $]; m_currentFrame.payload = m_currentFrame.payload[sz .. $]; nread += sz; if (leastSize == 0) { if (mode == IOMode.immediate || mode == IOMode.once && nread > 0) break; this.skipFrame(); } } return nread; } alias read = InputStream.read; } /// Magic string defined by the RFC for challenging the server during upgrade private static immutable s_webSocketGuid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; /** * The Opcode is 4 bits, as defined in Section 5.2 * * Values are defined in section 11.8 * Currently only 6 values are defined, however the opcode is defined as * taking 4 bits. */ private enum FrameOpcode : ubyte { continuation = 0x0, text = 0x1, binary = 0x2, close = 0x8, ping = 0x9, pong = 0xA } static assert(FrameOpcode.max < 0b1111, "FrameOpcode is only 4 bits"); private struct Frame { @safe: enum maxHeaderSize = 14; bool fin; FrameOpcode opcode; ubyte[] payload; /** * Return the header length encoded with the expected amount of bits * * The WebSocket RFC define a variable-length payload length. * In short, it means that: * - If the length is <= 125, it is stored as the 7 least significant * bits of the second header byte. The first bit is reserved for MASK. * - If the length is <= 65_536 (so it fits in 2 bytes), a magic value of * 126 is stored in the aforementioned 7 bits, and the actual length * is stored in the next two bytes, resulting in a 4 bytes header * ( + masking key, if any). * - If the length is > 65_536, a magic value of 127 will be used for * the 7-bit field, and the next 8 bytes are expected to be the length, * resulting in a 10 bytes header ( + masking key, if any). * * Those functions encapsulate all this logic and allow to just get the * length with the desired size. * * Return: * - For `ubyte`, the value to store in the 7 bits field, either the * length or a magic value (126 or 127). * - For `ushort`, a value in the range [126; 65_536]. * If payload.length is not in this bound, an assertion will be triggered. * - For `ulong`, a value in the range [65_537; size_t.max]. * If payload.length is not in this bound, an assertion will be triggered. */ size_t getHeaderSize(bool mask) { size_t ret = 1; if (payload.length < 126) ret += 1; else if (payload.length < 65536) ret += 3; else ret += 9; if (mask) ret += 4; return ret; } void writeHeader(ubyte[] dst, RandomNumberStream sys_rng) { ubyte[4] buff; ubyte firstByte = cast(ubyte)opcode; if (fin) firstByte |= 0x80; dst[0] = firstByte; dst = dst[1 .. $]; auto b1 = sys_rng ? 0x80 : 0x00; if (payload.length < 126) { dst[0] = cast(ubyte)(b1 | payload.length); dst = dst[1 .. $]; } else if (payload.length < 65536) { dst[0] = cast(ubyte) (b1 | 126); dst[1 .. 3] = std.bitmanip.nativeToBigEndian(cast(ushort)payload.length); dst = dst[3 .. $]; } else { dst[0] = cast(ubyte) (b1 | 127); dst[1 .. 9] = std.bitmanip.nativeToBigEndian(cast(ulong)payload.length); dst = dst[9 .. $]; } if (sys_rng) { sys_rng.read(dst[0 .. 4]); for (size_t i = 0; i < payload.length; i++) payload[i] ^= dst[i % 4]; } } static Frame readFrame(InputStream stream) { Frame frame; ubyte[8] data; stream.read(data[0 .. 2]); frame.fin = (data[0] & 0x80) != 0; frame.opcode = cast(FrameOpcode)(data[0] & 0x0F); bool masked = !!(data[1] & 0b1000_0000); //parsing length ulong length = data[1] & 0b0111_1111; if (length == 126) { stream.read(data[0 .. 2]); length = bigEndianToNative!ushort(data[0 .. 2]); } else if (length == 127) { stream.read(data); length = bigEndianToNative!ulong(data); // RFC 6455, 5.2, 'Payload length': If 127, the following 8 bytes // interpreted as a 64-bit unsigned integer (the most significant // bit MUST be 0) vibe.internal.exception.enforce!WebSocketException(!(length >> 63), "Received length has a non-zero most significant bit"); } logDebug("Read frame: %s %s %s length=%d", frame.opcode, frame.fin ? "final frame" : "continuation", masked ? "masked" : "not masked", length); // Masking key is 32 bits / uint if (masked) stream.read(data[0 .. 4]); // Read payload // TODO: Provide a way to limit the size read, easy // DOS for server code here (rejectedsoftware/vibe.d#1496). vibe.internal.exception.enforce!WebSocketException(length <= size_t.max); frame.payload = new ubyte[](cast(size_t)length); stream.read(frame.payload); //de-masking if (masked) foreach (size_t i; 0 .. cast(size_t)length) frame.payload[i] = frame.payload[i] ^ data[i % 4]; return frame; } } unittest { import std.algorithm.searching : all; final class DummyRNG : RandomNumberStream { @safe: @property bool empty() { return false; } @property ulong leastSize() { return ulong.max; } @property bool dataAvailableForRead() { return true; } const(ubyte)[] peek() { return null; } size_t read(scope ubyte[] buffer, IOMode mode) @trusted { buffer[] = 13; return buffer.length; } alias read = RandomNumberStream.read; } ubyte[14] hdrbuf; auto rng = new DummyRNG; Frame f; f.payload = new ubyte[125]; assert(f.getHeaderSize(false) == 2); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 2], null); assert(hdrbuf[0 .. 2] == [0, 125]); assert(f.getHeaderSize(true) == 6); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 6], rng); assert(hdrbuf[0 .. 2] == [0, 128|125]); assert(hdrbuf[2 .. 6].all!(b => b == 13)); f.payload = new ubyte[126]; assert(f.getHeaderSize(false) == 4); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 4], null); assert(hdrbuf[0 .. 4] == [0, 126, 0, 126]); assert(f.getHeaderSize(true) == 8); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 8], rng); assert(hdrbuf[0 .. 4] == [0, 128|126, 0, 126]); assert(hdrbuf[4 .. 8].all!(b => b == 13)); f.payload = new ubyte[65535]; assert(f.getHeaderSize(false) == 4); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 4], null); assert(hdrbuf[0 .. 4] == [0, 126, 255, 255]); assert(f.getHeaderSize(true) == 8); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 8], rng); assert(hdrbuf[0 .. 4] == [0, 128|126, 255, 255]); assert(hdrbuf[4 .. 8].all!(b => b == 13)); f.payload = new ubyte[65536]; assert(f.getHeaderSize(false) == 10); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 10], null); assert(hdrbuf[0 .. 10] == [0, 127, 0, 0, 0, 0, 0, 1, 0, 0]); assert(f.getHeaderSize(true) == 14); hdrbuf[] = 0; f.writeHeader(hdrbuf[0 .. 14], rng); assert(hdrbuf[0 .. 10] == [0, 128|127, 0, 0, 0, 0, 0, 1, 0, 0]); assert(hdrbuf[10 .. 14].all!(b => b == 13)); } /** * Generate a challenge key for the protocol upgrade phase. */ private string generateChallengeKey(scope RandomNumberStream rng) { ubyte[16] buffer; rng.read(buffer); return Base64.encode(buffer); } private string computeAcceptKey(string challengekey) { immutable(ubyte)[] b = challengekey.representation; immutable(ubyte)[] a = s_webSocketGuid.representation; SHA1 hash; hash.start(); hash.put(b); hash.put(a); auto result = Base64.encode(hash.finish()); return to!(string)(result); }
D
PGHERD_USER="{}" PGHERD_GROUP="{}" PGHERD_PID="{}"
D
/// Multiple precision integers (Z). module gmp.z; import std.algorithm.mutation : move, moveEmplace; import std.traits : isInstanceOf, Unsigned, Unqual; // used by expression templates import gmp.traits; /// Call unittests taking long to execute. enum unittestLong = false; /// Is `true` if type `T` can be evaluated to a `MpZ` value. enum isMpZExpr(T) = (is(Unqual!(typeof(T.eval())) == MpZ)); // which returns an `MpZ` /// Is `true` if type `T` is lazy (not yet evaluated) `MpZ`-expression. enum isLazyMpZExpr(T) = (!is(Unqual!T == MpZ) && // exclude direct value isMpZExpr!T); // TODO use these imports instead of the ones below // import deimos.gmp.gmp; // import deimos.gmp.integer; /** Arbitrary (multi) precision signed integer (Z). Wrapper for GNU MP (GMP)'s type `mpz_t` and functions `__gmpz_.*`. */ private struct _MpZ(bool copyable = false) { pure nothrow: /// Convert to `string` in base `base`. string toString(uint base = defaultBase, bool upperCaseDigits = false) const @trusted { if (isZero) { return `0`; } assert((base >= -2 && base <= -36) || (base >= 2 && base <= 62)); immutable size = sizeInBase(base); // NOTE: one too much for some values string str = new string(size + 1); // one extra for minus sign __gmpz_get_str(cast(char*)str.ptr, base, _ptr); // fill it // skip trailing garbage import std.ascii : isAlphaNum; while (str.length && !str[$ - 1].isAlphaNum) { str.length -= 1; } if (upperCaseDigits) { foreach (ref e; cast(char[])str) { import std.ascii : isLower, toUpper; if (e.isLower) { e = e.toUpper; } } } return str; } /// Returns: A unique hash of the `_MpZ` value suitable for use in a hash table. size_t toHash() const @trusted { version(LDC) pragma(inline, true); import core.internal.hash : hashOf; typeof(return) hash = _limbCount; foreach (immutable i; 0 .. _limbCount) { hash ^= _limbs[i].hashOf; } return hash; } @nogc: /** No default construction for now, because `mpz_init` initialize `__mpz_struct`-fields to non-zero values. TODO Allow default construction by delaying call to initialize(). */ // @disable this(); /// Construct empty (undefined) from explicit `null`. pragma(inline, true) this(typeof(null)) @trusted { initialize(); // TODO is there a faster way? assert(this == _MpZ.init); // if this is same as default } /// Construct from expression `expr`. this(Expr)(Expr expr) if (isLazyMpZExpr!Expr) { version(LDC) pragma(inline, true); // TODO ok to just assume zero-initialized contents at `_z` before... this = expr; // ...calling this.opAssign ?x } /** Construct from `value`. */ pragma(inline, true) this(T)(T value) @trusted if (isArithmetic!T) { version(ccc) { ++_ccc; } static if (isUnsigned!T) __gmpz_init_set_ui(_ptr, value); else static if (isFloating!T) __gmpz_init_set_d(_ptr, value); else // isSigned integral __gmpz_init_set_si(_ptr, value); } /** Construct from `value` in base `base`. If `base` is 0 it's guessed from contents of `value`. */ pragma(inline, false) this(in string value, uint base = 0) @trusted // TODO Use Optional/Nullable when value is nan, or inf { assert(base == 0 || (base >= 2 && base <= 62)); char* stringz = _allocStringzCopyOf(value); immutable int status = __gmpz_init_set_str(_ptr, stringz, base); version(ccc) { ++_ccc; } qualifiedFree(stringz); assert(status == 0, "Parameter `value` does not contain an integer"); } /// Returns: the Mersenne prime, M(p) = 2 ^^ p - 1 static _MpZ mersennePrime(Integral)(Integral p) if (isIntegral!Integral) { version(LDC) pragma(inline, true); return typeof(this).pow(2UL, p) - 1; } static if (copyable) { /// Construct copy of `value`. pragma(inline, true) this(this) @trusted { if (_z._mp_d) { // TODO this might be made faster __mpz_struct _z_copy = _z; __gmpz_init_set(&_z_copy, _ptr); version(ccc) { ++_ccc; } _z = _z_copy; } } // /// Construct copy of `value`. // this(ref const _MpZ value) @trusted // { // __gmpz_init_set(_ptr, value._ptr); version(ccc) { ++_ccc; } // } // /// Construct copy of `value`. // this(_MpZ value) @trusted // { // moveEmplace(value, this); // fast // } } else { /// No copy construction. @disable this(this); } /// Swap content of `this` with `rhs`. pragma(inline, true) void swap(ref _MpZ rhs) @safe { import std.algorithm.mutation : swap; swap(this, rhs); // faster than __gmpz_swap(_ptr, rhs._ptr); version(ccc) { ++_ccc; } } /// Returns: (duplicate) copy of `this`. _MpZ dup() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = void; __gmpz_init_set(y._ptr, _ptr); version(ccc) ++y._ccc; return y; } /// Assign from `rhs`. ref _MpZ opAssign()(auto ref const _MpZ rhs) @trusted return scope { version(LDC) pragma(inline, true); __gmpz_set(_ptr, rhs._ptr); version(ccc) { ++_ccc; } return this; } /// ditto ref _MpZ opAssign(Expr)(auto ref Expr rhs) @trusted return scope if (isLazyMpZExpr!Expr) { version(LDC) pragma(inline, true); static if (isInstanceOf!(MpzAddExpr, Expr)) { __gmpz_add(this._ptr, rhs.e1.eval()._ptr, rhs.e2.eval()._ptr); version(ccc) { ++_ccc; } } else static if (isInstanceOf!(MpzSubExpr, Expr)) { __gmpz_sub(this._ptr, rhs.e1.eval()._ptr, rhs.e2.eval()._ptr); version(ccc) { ++_ccc; } } else static if (isInstanceOf!(MpzMulExpr, Expr)) { __gmpz_mul(this._ptr, rhs.e1.eval()._ptr, rhs.e2.eval()._ptr); version(ccc) { ++_ccc; } } else static if (isInstanceOf!(MpzDivExpr, Expr)) { __gmpz_tdiv_q(this._ptr, rhs.e1.eval()._ptr, rhs.e2.eval()._ptr); version(ccc) { ++_ccc; } } else static if (isInstanceOf!(MpzModExpr, Expr)) { __gmpz_tdiv_r(this._ptr, rhs.e1.eval()._ptr, rhs.e2.eval()._ptr); version(ccc) { ++_ccc; } } else static if (isInstanceOf!(MpzNegExpr, Expr)) { __gmpz_neg(this._ptr, rhs.e1.eval()._ptr); version(ccc) { ++_ccc; } } else { this = rhs.eval(); // evaluate and move } return this; } /// ditto ref _MpZ opAssign(T)(T rhs) @trusted return scope if (isArithmetic!T) { version(LDC) pragma(inline, true); assertInitialized(); static if (isUnsigned!T) { __gmpz_set_ui(_ptr, rhs); } else static if (isFloating!T) { __gmpz_set_d(_ptr, rhs); } else static if (isSigned!T) { __gmpz_set_si(_ptr, rhs); } else { static assert(false); } version(ccc) { ++_ccc; } return this; } /** Assign `this` from `string` `rhs` interpreted in base `base`. If `base` is 0 it's guessed from contents of `value`. */ ref _MpZ fromString(in string rhs, uint base = 0) @trusted return { assert(base == 0 || (base >= 2 && base <= 62)); char* stringz = _allocStringzCopyOf(rhs); immutable int status = __gmpz_set_str(_ptr, stringz, base); version(ccc) { ++_ccc; } qualifiedFree(stringz); assert(status == 0, "Parameter `rhs` does not contain an integer"); return this; } /// Destruct `this`. pragma(inline, true) ~this() @trusted { if (_z._mp_d) { __gmpz_clear(_ptr); version(ccc) { ++_ccc; } _z._mp_d = null; // prevent GC from scanning this memory } } /// Returns: `true` iff `this` equals `rhs`. bool opEquals()(auto ref const _MpZ rhs) const @trusted { version(LDC) pragma(inline, true); if (_ptr == rhs._ptr) // fast equality { return true; // fast bailout } return __gmpz_cmp(_ptr, rhs._ptr) == 0; } /// ditto pragma(inline, true) bool opEquals(Rhs)(Rhs rhs) const @trusted if (isArithmetic!Rhs) { if (rhs == 0) { return isZero; // optimization } static if (isUnsigned!Rhs) { return __gmpz_cmp_ui(_ptr, cast(ulong)rhs) == 0; } else static if (isFloating!Rhs) { return __gmpz_cmp_d(_ptr, cast(double)rhs) == 0; // TODO correct to do this cast here? } else // isSigned integral { return __gmpz_cmp_si(_ptr, cast(long)rhs) == 0; } } /// Compare `this` to `rhs`. int opCmp()(auto ref const _MpZ rhs) const @trusted { version(LDC) pragma(inline, true); if (rhs == 0) { return sgn(); // optimization } return __gmpz_cmp(_ptr, rhs._ptr); } /// ditto pragma(inline, true) int opCmp(T)(T rhs) const @trusted if (isArithmetic!T) { if (rhs == 0) { return sgn(); // optimization } static if (isUnsigned!T) { return __gmpz_cmp_ui(_ptr, rhs); } else static if (isFloating!T) { return __gmpz_cmp_d(_ptr, rhs); } else // isSigned integral { return __gmpz_cmp_si(_ptr, rhs); } } /// Cast to `bool`. pragma(inline, true) bool opCast(T : bool)() const { return !isZero; } /// Cast to arithmetic type `T`. pragma(inline, true) T opCast(T)() const @trusted if (isArithmetic!T) { static if (isUnsigned!T) { return cast(T)__gmpz_get_ui(_ptr); } else static if (isFloating!T) { return cast(T)__gmpz_get_d(_ptr); } else // isSigned integral { return cast(T)__gmpz_get_si(_ptr); } } /** Returns: The value of this as a `long`, or +/- `long.max` if outside the representable range. */ long toLong() const @trusted { version(LDC) pragma(inline, true); // TODO can probably be optimized if (this <= long.min) { return long.min; } else if (this >= long.max) { return long.max; } else { return cast(long)__gmpz_get_si(_ptr); } } /** Returns: The value of this as a `int`, or +/- `int.max` if outside the representable range. */ int toInt() const @trusted { version(LDC) pragma(inline, true); // TODO can probably be optimized if (this <= int.min) { return int.min; } else if (this >= int.max) { return int.max; } else { return cast(int)__gmpz_get_si(_ptr); } } /** Returns: `this` `s` `rhs`. */ _MpZ opBinary(string s)(auto ref const _MpZ rhs) const @trusted // direct value if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "%" || s == "&" || s == "|" || s == "^")) { version(LDC) pragma(inline, true); static if (!__traits(isRef, rhs)) // r-value `rhs` { _MpZ* mut_rhs = (cast(_MpZ*)(&rhs)); // @trusted because `_MpZ` has no aliased indirections static if (s == "+") { __gmpz_add(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "-") { __gmpz_sub(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "*") { __gmpz_mul(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_q(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "%") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_r(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "&") { __gmpz_and(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "|") { __gmpz_ior(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else static if (s == "^") { __gmpz_xor(mut_rhs._ptr, _ptr, rhs._ptr); version(ccc) ++mut_rhs._ccc; } else { static assert(false); } return move(*mut_rhs); // TODO shouldn't have to call `move` here } else { typeof(return) y = null; static if (s == "+") { __gmpz_add(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "-") { __gmpz_sub(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "*") { __gmpz_mul(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_q(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "%") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_r(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "&") { __gmpz_and(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "|") { __gmpz_ior(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else static if (s == "^") { __gmpz_xor(y._ptr, _ptr, rhs._ptr); version(ccc) ++y._ccc; } else { static assert(false); } return y; } } /// ditto pragma(inline, true) _MpZ opBinary(string s, Rhs)(auto ref const Rhs rhs) const if (isLazyMpZExpr!Rhs && // lazy value (s == "+" || s == "-" || s == "*" || s == "/" || s == "%")) { static assert(false, "TODO"); } /// ditto _MpZ opBinary(string s, Rhs)(Rhs rhs) const @trusted if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "^^") && isUnsigned!Rhs) { version(LDC) pragma(inline, true); typeof(return) y = null; version(ccc) ++y._ccc; static if (s == "+") { __gmpz_add_ui(y._ptr, _ptr, rhs); } else static if (s == "-") { __gmpz_sub_ui(y._ptr, _ptr, rhs); } else static if (s == "*") { __gmpz_mul_ui(y._ptr, _ptr, rhs); } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_q_ui(y._ptr, _ptr, rhs); } else static if (s == "^^") { __gmpz_pow_ui(y._ptr, _ptr, rhs); } else { static assert(false); } return y; } /// ditto _MpZ opBinary(string s, Rhs)(Rhs rhs) const @trusted if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "^^") && isSigned!Rhs) { version(LDC) pragma(inline, true); typeof(return) y = null; version(ccc) ++y._ccc; static if (s == "+") { if (rhs < 0) // TODO handle `rhs == rhs.min` { immutable ulong pos_rhs = -rhs; // make it positive __gmpz_sub_ui(y._ptr, _ptr, pos_rhs); } else { __gmpz_add_ui(y._ptr, _ptr, rhs); } } else static if (s == "-") { if (rhs < 0) // TODO handle `rhs == rhs.min` { __gmpz_add_ui(y._ptr, _ptr, -rhs); // x - (-y) == x + y } else { __gmpz_sub_ui(y._ptr, _ptr, rhs); // rhs is positive } } else static if (s == "*") { __gmpz_mul_si(y._ptr, _ptr, rhs); } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); if (rhs < 0) // TODO handle `rhs == rhs.min` { immutable ulong pos_rhs = -rhs; // make it positive __gmpz_tdiv_q_ui(y._ptr, _ptr, pos_rhs); y.negate(); // negate result } else { __gmpz_tdiv_q_ui(y._ptr, _ptr, rhs); } } else static if (s == "^^") { assert(rhs >= 0, "TODO Negative power exponent needs MpQ return"); __gmpz_pow_ui(y._ptr, _ptr, rhs); } else { static assert(false); } return y; } /// Remainer propagates modulus type. Unqual!Rhs opBinary(string s, Rhs)(Rhs rhs) const @trusted if ((s == "%") && isIntegral!Rhs) { version(LDC) pragma(inline, true); assert(rhs != 0, "Divison by zero"); _MpZ y = null; version(ccc) ++y._ccc; static if (isSigned!Rhs) { if (rhs < 0) // TODO handle `rhs == rhs.min` { immutable ulong pos_rhs = -cast(int)rhs; // make it positive return cast(typeof(return))-__gmpz_tdiv_r_ui(y._ptr, _ptr, pos_rhs); } else { return cast(typeof(return))__gmpz_tdiv_r_ui(y._ptr, _ptr, rhs); } } else static if (isUnsigned!Rhs) { return cast(typeof(return))__gmpz_tdiv_r_ui(y._ptr, _ptr, rhs); } else { static assert(false); } } /// Returns: an unsigned type `lhs` divided by `this`. _MpZ opBinaryRight(string s, Lhs)(Lhs lhs) const @trusted if ((s == "+" || s == "-" || s == "*" || s == "%") && isUnsigned!Lhs) { version(LDC) pragma(inline, true); typeof(return) y = null; version(ccc) ++y._ccc; static if (s == "+") { __gmpz_add_ui(y._ptr, _ptr, lhs); // commutative } else static if (s == "-") { __gmpz_ui_sub(y._ptr, lhs, _ptr); } else static if (s == "*") { __gmpz_mul_ui(y._ptr, _ptr, lhs); // commutative } else static if (s == "%") { assert(this != 0, "Divison by zero"); __gmpz_tdiv_r(y._ptr, _MpZ(lhs)._ptr, _ptr); // convert `lhs` to _MpZ } else { static assert(false); } return y; } /// Returns: a signed type `lhs` divided by `this`. _MpZ opBinaryRight(string s, Lhs)(Lhs lhs) const @trusted if ((s == "+" || s == "-" || s == "*" || s == "%") && isSigned!Lhs) { version(LDC) pragma(inline, true); static if (s == "+" || s == "*") { return opBinary!s(lhs); // commutative reuse } else static if (s == "-") { typeof(return) y = null; version(ccc) ++y._ccc; if (lhs < 0) // TODO handle `lhs == lhs.min` { immutable ulong pos_rhs = -lhs; // make it positive __gmpz_add_ui(y._ptr, _ptr, pos_rhs); } else { __gmpz_sub_ui(y._ptr, _ptr, lhs); } y.negate(); return y; } else static if (s == "%") { typeof(return) y = null; version(ccc) ++y._ccc; assert(this != 0, "Divison by zero"); __gmpz_tdiv_r(y._ptr, _MpZ(lhs)._ptr, _ptr); // convert `lhs` to _MpZ return y; } else { static assert(false); } } /// Dividend propagates quotient type to signed. Unqual!Lhs opBinaryRight(string s, Lhs)(Lhs lhs) const @trusted if ((s == "/") && isIntegral!Lhs) { version(LDC) pragma(inline, true); _MpZ y = null; // TODO avoid if !__traits(isRef, this) version(ccc) ++y._ccc; assert(this != 0, "Divison by zero"); __gmpz_tdiv_q(y._ptr, _MpZ(lhs)._ptr, _ptr); static if (isSigned!Lhs) { return cast(typeof(return))y; } else static if (isUnsigned!Lhs) { import std.traits : Signed; return cast(Signed!(typeof(return)))y; } else { static assert(false); } } /// Exponentation. pragma(inline, true) _MpZ opBinaryRight(string s, Base)(Base base) const if ((s == "^^") && isIntegral!Base) { static assert(false, "Convert `this _MpZ` exponent to `ulong` and calculate power via static method `pow()`"); // _MpZ exp = null; // __gmpz_pow(); // return exp; } /// Operate-assign to `this` from `rhs`. ref _MpZ opOpAssign(string s)(auto ref const _MpZ rhs) @trusted return scope if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "%" || s == "&" || s == "|" || s == "^")) { version(LDC) pragma(inline, true); static if (s == "+") { __gmpz_add(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else static if (s == "-") { __gmpz_sub(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else static if (s == "*") { if (rhs == -1) { negate(); } else { __gmpz_mul(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); if (rhs == -1) { negate(); } else { __gmpz_tdiv_q(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } } else static if (s == "%") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_r(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else static if (s == "&") { __gmpz_and(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else static if (s == "|") { __gmpz_ior(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else static if (s == "^") { __gmpz_xor(_ptr, _ptr, rhs._ptr); version(ccc) { ++_ccc; } } else { static assert(false); } return this; } /// ditto ref _MpZ opOpAssign(string s, Rhs)(Rhs rhs) @trusted return scope if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "%" || s == "^^") && isUnsigned!Rhs) { version(LDC) pragma(inline, true); static if (s == "+") { __gmpz_add_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "-") { __gmpz_sub_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "*") { __gmpz_mul_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_q_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "%") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_r_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "^^") { __gmpz_pow_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else { static assert(false); } return this; } /// ditto ref _MpZ opOpAssign(string s, Rhs)(Rhs rhs) @trusted return scope if ((s == "+" || s == "-" || s == "*" || s == "/" || s == "%" || s == "^^") && isSigned!Rhs) { version(LDC) pragma(inline, true); static if (s == "+") { if (rhs < 0) // TODO handle `rhs == rhs.min` { assert(rhs != rhs.min); immutable ulong pos_rhs = -rhs; // make it positive __gmpz_sub_ui(_ptr, _ptr, pos_rhs); version(ccc) { ++_ccc; } } else { __gmpz_add_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } } else static if (s == "-") { if (rhs < 0) // TODO handle `rhs == rhs.min` { assert(rhs != rhs.min); immutable ulong pos_rhs = -rhs; // make it positive __gmpz_add_ui(_ptr, _ptr, pos_rhs); version(ccc) { ++_ccc; } } else { __gmpz_sub_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } } else static if (s == "*") { if (rhs == -1) { negate(); // optimization } else { __gmpz_mul_si(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } } else static if (s == "/") { assert(rhs != 0, "Divison by zero"); if (rhs < 0) // TODO handle `rhs == rhs.min` { immutable ulong pos_rhs = -rhs; // make it positive __gmpz_tdiv_q_ui(_ptr, _ptr, pos_rhs); version(ccc) { ++_ccc; } negate(); } else { __gmpz_tdiv_q_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } } else static if (s == "%") { assert(rhs != 0, "Divison by zero"); __gmpz_tdiv_r_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else static if (s == "^^") { assert(rhs >= 0, "Negative power exponent"); __gmpz_pow_ui(_ptr, _ptr, rhs); version(ccc) { ++_ccc; } } else { static assert(false); } return this; } /// Returns: `this`. pragma(inline, true) ref inout(_MpZ) opUnary(string s)() inout if (s == "+") { return this; } /// Returns: negation of `this`. _MpZ opUnary(string s)() const if (s == "-") { version(LDC) pragma(inline, true); typeof(return) y = this.dup; y.negate(); return y; } /// Returns: negation of `this`. _MpZ unaryMinus() const @safe { version(LDC) pragma(inline, true); // pragma(msg, "memberFun:", __traits(isRef, this) ? "ref" : "non-ref", " this"); typeof(return) y = this.dup; y.negate(); return y; } /** Negate `this` in-place. Returns: `void` to make it obvious that `this` is mutated. */ pragma(inline, true) void negate() @safe { _z._mp_size = -_z._mp_size; // fast C macro `mpz_neg` in gmp.h } /** Make `this` the absolute value of itself in-place. Returns: `void` to make it obvious that `this` is mutated. */ void absolute() @trusted { version(LDC) pragma(inline, true); if (isZero) { return; } // `__gmpz_abs` cannot handle default-constructed `this` __gmpz_abs(_ptr, _ptr); version(ccc) { ++_ccc; } } /** Make `this` the one's complement value of itself in-place. Returns: `void` to make it obvious that `this` is mutated. */ void onesComplement() @trusted { version(LDC) pragma(inline, true); if (isZero) { return; } // `__gmpz_co` cannot handle default-constructed `this` __gmpz_com(_ptr, _ptr); version(ccc) { ++_ccc; } } /// Increase `this` by one. ref _MpZ opUnary(string s)() @trusted return scope if (s == "++") { version(LDC) pragma(inline, true); if (isDefaultConstructed) // `__gmpz_add_ui` cannot handle default-constructed `this` { __gmpz_init_set_si(_ptr, 1); } else { __gmpz_add_ui(_ptr, _ptr, 1); version(ccc) { ++_ccc; } } return this; } /// Decrease `this` by one. ref _MpZ opUnary(string s)() @trusted return scope if (s == "--") { version(LDC) pragma(inline, true); if (isDefaultConstructed) // `__gmpz_sub_ui` cannot handle default-constructed `this` { __gmpz_init_set_si(_ptr, -1); } else { __gmpz_sub_ui(_ptr, _ptr, 1); version(ccc) { ++_ccc; } } return this; } /// Returns: `base` raised to the power of `exp`. static typeof(this) pow(Base, Exp)(Base base, Exp exp) @trusted if (isIntegral!Base && isIntegral!Exp) { version(LDC) pragma(inline, true); static if (isSigned!Base) { immutable bool negate = base < 0; immutable ubase = cast(ulong)(negate ? -base : base); } else { immutable bool negate = false; immutable ubase = base; } static if (isSigned!Exp) { assert(exp >= 0, "Negative power exponent"); // TODO return mpq? immutable uexp = cast(ulong)exp; } else { immutable uexp = exp; } typeof(return) y = null; __gmpz_ui_pow_ui(y._ptr, ubase, uexp); version(ccc) ++y._ccc; if (negate && exp & 1) // if negative odd exponent { y.negate(); } return y; } /// Returns: number of digits in base `base`. pragma(inline, true) size_t sizeInBase(uint base) const @trusted { if (isZero) { return 1; } else { return __gmpz_sizeinbase(_ptr, base); } } /// Returns: `true` iff `this` fits in a `T`. pragma(inline, true) bool fitsIn(T)() const @trusted if (isIntegral!T) { if (isZero) { return true; } // default-constructed `this` static if (is(T == ulong)) { return __gmpz_fits_ulong_p(_ptr) != 0; } else static if (is(T == long)) { return __gmpz_fits_slong_p(_ptr) != 0; } else static if (is(T == uint)) { return __gmpz_fits_uint_p(_ptr) != 0; } else static if (is(T == int)) { return __gmpz_fits_sint_p(_ptr) != 0; } else static if (is(T == ushort)) { return __gmpz_fits_ushort_p(_ptr) != 0; } else static if (is(T == short)) { return __gmpz_fits_sshort_p(_ptr) != 0; } else { static assert(false, "Unsupported type " ~ T.stringof); } } /** Returns: population count of `this`. If - `this` >= 0, number of 1 bits in the binary representation - otherwise, ??? */ pragma(inline, true) @property mp_bitcnt_t populationCount() const @trusted { if (isZero) { return 0; } // default-constructed `this` return __gmpz_popcount(this._ptr); // TODO use core.bitop `popcnt` inline here instead? } alias countOnes = populationCount; /// Set bit at 0-offset index `bitIndex` (to one). pragma(inline, true) void setBit(mp_bitcnt_t bitIndex) @trusted { __gmpz_setbit(_ptr, bitIndex); } /// Clear bit at 0-offset index `bitIndex` (to zero). pragma(inline, true) void clearBit(mp_bitcnt_t bitIndex) @trusted { __gmpz_clrbit(_ptr, bitIndex); } /// Complement bit at 0-offset index `bitIndex` (to zero). pragma(inline, true) void complementBit(mp_bitcnt_t bitIndex) @trusted { __gmpz_combit(_ptr, bitIndex); } /// Test/Get bit at 0-offset index `bitIndex`. pragma(inline, true) bool testBit(mp_bitcnt_t bitIndex) const @trusted { return __gmpz_tstbit(_ptr, bitIndex) != 0; } alias getBit = testBit; /** Check if `this` is default-constructed (in constrast to having been initialized via `__gmpz_...`-operations). Used to specially prepare avoid some `__gmpz_`-functions that cannot handle the case when the membere `_mp_alloc` is zero and, in turn, `_mp_d` is `null`. */ pragma(inline, true) @property bool isDefaultConstructed() const @safe { return _z._mp_alloc == 0; // fast, actually enough to just test this } /// Check if `this` is zero (either via default-construction or `__gmpz_...`-operations). pragma(inline, true) @property bool isZero() const @safe { return _z._mp_size == 0; // fast } /// Check if `this` is odd. pragma(inline, true) @property bool isOdd() const @safe { return ((_z._mp_alloc != 0) && // this is needed for default (zero) initialized `__mpz_structs` ((_z._mp_size != 0) & cast(int)(_z._mp_d[0]))); // fast C macro `mpz_odd_p` in gmp.h } /// Check if `this` is odd. pragma(inline, true) @property bool isEven() const @safe { return !isOdd; // fast C macro `mpz_even_p` in gmp.h } /// Check if `this` is negative. pragma(inline, true) @property bool isNegative() const @safe { return _z._mp_size < 0; // fast } /// Check if `this` is positive. pragma(inline, true) @property bool isPositive() const @safe { return !isNegative; // fast } /** Returns: sign as either - -1 (`this` < 0), - 0 (`this` == 0), or - +1 (`this` > 0). */ pragma(inline, true) @property int sgn() const @safe { return _z._mp_size < 0 ? -1 : _z._mp_size > 0; // fast C macro `mpz_sgn` in gmp.h } /// Number of significant `uint`s used for storing `this`. pragma(inline, true) @property size_t uintLength() const { assert(false, "TODO use mpz_size"); } /// Number of significant `ulong`s used for storing `this`. pragma(inline, true) @property size_t uintLong() const { assert(false, "TODO use mpz_size"); } private: /** Initialize internal struct. */ pragma(inline, true) void initialize() // cannot be called `init` as that will override builtin type property { __gmpz_init(_ptr); version(ccc) { ++_ccc; } } /** Initialize internal struct if needed. */ pragma(inline, true) void assertInitialized() { if (isDefaultConstructed) { __gmpz_init(_ptr); version(ccc) { ++_ccc; } } } /// Default conversion base. enum defaultBase = 10; /// Returns: evaluation of `this` expression which in this is a no-op. pragma(inline, true) ref inout(_MpZ) eval() @safe inout return { return this; } /// Type of limb in internal representation. alias Limb = __mp_limb_t; // GNU MP alias /** Returns: limbs. */ pragma(inline, true) inout(Limb)[] _limbs() inout return @system { // import std.math : abs; return _z._mp_d[0 .. _limbCount]; } /// Get number of limbs in internal representation. pragma(inline, true) @property uint _limbCount() const @safe { return _integralAbs(_z._mp_size); } /// Returns: pointer to internal C struct. pragma(inline, true) inout(__mpz_struct)* _ptr() inout return @system { return &_z; } __mpz_struct _z; // internal libgmp C struct version(ccc) { /** Number of calls made to `__gmpz`--functions that construct or changes this value. Used to verify correct lowering and evaluation of template expressions. For instance the `x` in `x = y + z` should be assigned only once inside a call to `mpz_add`. */ pragma(inline, true) @property size_t mutatingCallCount() const @safe { return _ccc; } size_t _ccc; // C mutation call count. number of calls to C GMP function calls that mutate this object } /// @nogc-variant of `toStringz` with heap allocation of null-terminated C-string `stringz`. pragma(inline, false) char* _allocStringzCopyOf(in char[] value) @trusted @nogc { import core.memory : pureMalloc; char* stringz = cast(char*)pureMalloc(value.length + 1); // maximum this many characters size_t i = 0; foreach (immutable char ch; value[]) { if (ch != '_') { stringz[i] = ch; i += 1; } } stringz[i] = '\0'; // set C null terminator return stringz; } // qualified C memory managment pragma(inline, false) static @trusted extern(C) // locally `@trusted` { pragma(mangle, "free") void qualifiedFree(void* ptr); } } /** Non-copyable MpZ. For reference counting semantics, use `RefCounted` as import std.typecons : RefCounted; alias RcMpZ = RefCounted!MpZ; RcMpZ x; */ alias MpZ = _MpZ!false; /** Copyable MpZ. */ alias CopyableMpZ = _MpZ!true; version(unittest) static assert(isMpZExpr!(MpZ)); pure nothrow: /** Instantiator for `MpZ`. */ _MpZ!copyable mpz(bool copyable = false, Args...)(Args args) @safe { version(LDC) pragma(inline, true); return typeof(return)(args); } /// Swap contents of `x` with contents of `y`. pragma(inline, true) void swap(bool copyable)(ref _MpZ!copyable x, ref _MpZ!copyable y) { import std.algorithm.mutation : swap; swap(x, y); // x.swap(y); } /// Returns: `x` as a `string` in decimal base. string toDecimalString(bool copyable)(auto ref const _MpZ!copyable x) // for `std.bigint.BigInt` compatibility { version(LDC) pragma(inline, true); return x.toString(10); } /// Returns: `x` as a uppercased `string` in hexadecimal base without any base prefix (0x). string toHex(bool copyable)(auto ref const _MpZ!copyable x) // for `std.bigint.BigInt` compatibility { version(LDC) pragma(inline, true); return x.toString(16, true); } /// Returns: the absolute value of `x` converted to the corresponding unsigned type. Unsigned!T absUnsign(T, bool copyable)(auto ref const _MpZ!copyable x) // for `std.bigint.BigInt` compatibility if (isIntegral!T) { version(LDC) pragma(inline, true); return _integralAbs(cast(T)x); } /** Returns: absolute value of `x`. Written as a free function instead of `MpZ`-member because `__traits(isRef, this)` cannot be used. */ _MpZ!copyable abs(bool copyable)(auto ref const _MpZ!copyable x) @trusted @nogc { version(LDC) pragma(inline, true); static if (__traits(isRef, x)) // l-value `x` { typeof(return) y = null; // must use temporary __gmpz_abs(y._ptr, x._ptr); version(ccc) ++y._ccc; return y; } else // r-value `x` { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections mut_x.absolute(); return move(*mut_x); // TODO shouldn't have to call `move` here } } /** Returns: one's complement of value of `x`. Written as a free function instead of `MpZ`-member because `__traits(isRef, this)` cannot be used. */ _MpZ!copyable onesComplement(bool copyable)(auto ref const _MpZ!copyable x) @trusted @nogc { version(LDC) pragma(inline, true); static if (__traits(isRef, x)) // l-value `x` { typeof(return) y = null; // must use temporary __gmpz_com(y._ptr, x._ptr); version(ccc) ++y._ccc; return y; } else // r-value `x` { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections mut_x.onesComplement(); return move(*mut_x); // TODO shouldn't have to call `move` here } } /// Returns: comparison of the absolute values of `x` and `y`. int cmpabs(bool copyable)(auto ref const _MpZ!copyable x, auto ref const _MpZ!copyable y) @trusted @nogc { version(LDC) pragma(inline, true); return __gmpz_cmpabs(x._ptr, y._ptr); } /// ditto int cmpabs(bool copyable)(auto ref const _MpZ!copyable x, double y) @trusted @nogc { version(LDC) pragma(inline, true); return __gmpz_cmpabs_d(x._ptr, y); } /// ditto int cmpabs(bool copyable)(auto ref const _MpZ!copyable x, ulong y) @trusted @nogc { version(LDC) pragma(inline, true); return __gmpz_cmpabs_ui(x._ptr, y); } /** Returns: next prime greater than `x`. Written as a free function instead of `MpZ`-member because `__traits(isRef, this)` cannot be used. */ _MpZ!copyable nextPrime(bool copyable)(auto ref const _MpZ!copyable x) @trusted @nogc { version(LDC) pragma(inline, true); static if (__traits(isRef, x)) // l-value `x` { typeof(return) y = null; // must use temporary __gmpz_nextprime(y._ptr, x._ptr); version(ccc) ++y._ccc; return y; } else // r-value `x` { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections __gmpz_nextprime(mut_x._ptr, x._ptr); version(ccc) ++mut_x._ccc; return move(*mut_x); // TODO shouldn't have to call `move` here } } /// Returns: greatest common divisor (gcd) of `x` and `y`. _MpZ!copyable gcd(bool copyable)(auto ref const _MpZ!copyable x, auto ref const _MpZ!copyable y) @trusted @nogc { version(LDC) pragma(inline, true); static if (!__traits(isRef, x)) // r-value `x` { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections __gmpz_gcd(mut_x._ptr, x._ptr, y._ptr); version(ccc) ++mut_x._ccc; return move(*mut_x); // TODO shouldn't have to call `move` here } else static if (!__traits(isRef, y)) // r-value `y` { typeof(return)* mut_y = (cast(typeof(return)*)(&y)); // @trusted because `MpZ` has no aliased indirections __gmpz_gcd(mut_y._ptr, x._ptr, y._ptr); version(ccc) ++mut_y._ccc; return move(*mut_y); // TODO shouldn't have to call `move` here } else // l-value `x` and `y` { typeof(return) z = null; __gmpz_gcd(z._ptr, x._ptr, y._ptr); version(ccc) ++z._ccc; return z; } } /// ditto _MpZ!copyable gcd(bool copyable)(auto ref const _MpZ!copyable x, ulong y) @trusted @nogc { version(LDC) pragma(inline, true); static if (__traits(isRef, x)) // l-value `x` { typeof(return) z = null; const z_ui = __gmpz_gcd_ui(z._ptr, x._ptr, y); version(ccc) ++z._ccc; return z; } else { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections const z_ui = __gmpz_gcd_ui(mut_x._ptr, x._ptr, y); version(ccc) ++mut_x._ccc; return move(*mut_x); // TODO shouldn't have to call `move` here } } /// Returns: least common multiple (lcm) of `x` and `y`. _MpZ!copyable lcm(bool copyable)(auto ref const _MpZ!copyable x, auto ref const _MpZ!copyable y) @trusted @nogc { version(LDC) pragma(inline, true); static if (!__traits(isRef, x)) // r-value `x` { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections __gmpz_lcm(mut_x._ptr, x._ptr, y._ptr); version(ccc) ++mut_x._ccc; return move(*mut_x); // TODO shouldn't have to call `move` here } else static if (!__traits(isRef, y)) // r-value `y` { typeof(return)* mut_y = (cast(typeof(return)*)(&y)); // @trusted because `MpZ` has no aliased indirections __gmpz_lcm(mut_y._ptr, x._ptr, y._ptr); version(ccc) ++mut_y._ccc; return move(*mut_y); // TODO shouldn't have to call `move` here } else // l-value `x` and `y` { typeof(return) z = null; __gmpz_lcm(z._ptr, x._ptr, y._ptr); version(ccc) ++z._ccc; return z; } } /// ditto _MpZ!copyable lcm(bool copyable)(auto ref const _MpZ!copyable x, ulong y) @trusted @nogc { version(LDC) pragma(inline, true); static if (__traits(isRef, x)) // l-value `x` { typeof(return) z = null; __gmpz_lcm_ui(z._ptr, x._ptr, y); return z; } else { typeof(return)* mut_x = (cast(typeof(return)*)(&x)); // @trusted because `MpZ` has no aliased indirections __gmpz_lcm_ui(mut_x._ptr, x._ptr, y); version(ccc) ++mut_x._ccc; return move(*mut_x); // TODO shouldn't have to call `move` here } } /** Returns: `base` ^^ `exp` (modulo `mod`). Parameter `exp` must be positive. */ _MpZ!copyable powm(bool copyable)(auto ref const _MpZ!copyable base, auto ref const _MpZ!copyable exp, auto ref const _MpZ!copyable mod) @trusted { version(LDC) pragma(inline, true); typeof(return) y = 0; // result, TODO reuse `exp` or `mod` if any is an r-value assert(exp >= 0, "Negative exponent"); __gmpz_powm(y._ptr, base._ptr, exp._ptr, mod._ptr); version(ccc) ++y._ccc; return y; } /// ditto _MpZ!copyable powm(bool copyable)(auto ref const _MpZ!copyable base, ulong exp, auto ref const _MpZ!copyable mod) @trusted { version(LDC) pragma(inline, true); typeof(return) y = 0; // result, TODO reuse `exp` or `mod` if any is an r-value __gmpz_powm_ui(y._ptr, base._ptr, exp, mod._ptr); version(ccc) ++y._ccc; return y; } /// default construction @safe nothrow @nogc unittest { Z x; Z y; assert(x == y); assert(x is y); // TODO is this correct behaviour? x = y; y = x; Z z = 42; x = z; assert(Z.init.dup == Z.init); assert(Z.init.dup == Z.init.dup); assert(Z.init.dup !is Z.init); assert(Z.init.dup !is Z.init.dup); Z w; w = 42; } /// operate on default-constructed instances @safe nothrow unittest { Z w; // should be zeroed assert(w._z._mp_alloc == 0); assert(w._z._mp_size == 0); assert(w._z._mp_d is null); assert(w == 0); assert(w == 0L); assert(w == 0UL); assert(w == 0.0f); assert(w == 0.0); assert(w.toString == `0`); assert(w.toHash == 0); assert(w.sizeInBase(10) == 1); assert(w.countOnes == 0); assert(w.isZero); assert(-w == w); assert(abs(w) == w); assert(w.fitsIn!ulong); assert(w.fitsIn!long); assert(w.fitsIn!uint); assert(w.fitsIn!int); assert(w.fitsIn!ushort); assert(w.fitsIn!short); assert(!w.isOdd); assert(w.isEven); assert(!w.isNegative); assert(w.isPositive); assert(w.sgn == 0); w.negate(); assert(w is Z.init); // should be unchanged w.negate(); assert(w is Z.init); // should be unchanged w = -w; assert(w is Z.init); // should be unchanged w = +w; assert(w is Z.init); // should be unchanged w.absolute(); assert(w is Z.init); // should be unchanged w.onesComplement(); assert(w is Z.init); // should be unchanged w.onesComplement(); assert(w is Z.init); // should be unchanged assert(w^^10 == 0); assert(w^^0 == 1); // TODO correct? // change it and check its contents w = 42; assert(w.toString == `42`); assert(w.toHash != 0); // should at least be non-zero { Z p; p.setBit(5); assert(p == 32); } { Z p; p.clearBit(5); assert(p == 0); } { Z p; p.complementBit(5); assert(p == 32); } { Z p; assert(p.testBit(5) == 0); } { Z p; ++p; assert(p == 1); } { Z p; --p; assert(p == -1); } assert(Z.init + Z.init == Z.init); assert(Z.init - Z.init == Z.init); assert(Z.init * Z.init == Z.init); assert(Z.init + 1 == 1); assert(Z.init - 1 == -1); assert(Z.init * 1 == 0); assert(Z.init / 1 == 0); assert(Z.init ^^ 1 == Z.init); assert(Z.init ^^ 0 == 1); assert(1 + Z.init == 1); assert(1 - Z.init == 1); assert(1 * Z.init == 0); } /// null construction @safe nothrow @nogc unittest { Z x = null; Z y = null; assert(x == y); assert(x !is y); } /// @safe @nogc unittest { const x = 42.Z; assert(x.unaryMinus() == -42); // l-value `this` assert(42.Z.unaryMinus() == -42); // r-value `this` } /// convert to string @safe unittest { assert(mpz( 42).toString == `42`); assert(mpz( -42).toString == `-42`); assert(mpz(`-101`).toString == `-101`); assert(mpz(-42).toDecimalString == `-42`); assert(mpz( 42).toDecimalString == `42`); assert(mpz( 0).toHex == `0`); assert(mpz( 1).toHex == `1`); assert(mpz( 9).toHex == `9`); assert(mpz(10).toHex == `A`); assert(mpz(14).toHex == `E`); assert(mpz(15).toHex == `F`); assert(mpz(16).toHex == `10`); assert(mpz(-42).absUnsign!ulong == 42); assert(mpz( 42).absUnsign!ulong == 42); } /// opBinary with r-value right-hand-side @safe @nogc unittest { Z a = 42; { Z b = a + 1.Z; // r-value `rhs` version(ccc) assert(b.mutatingCallCount == 2); assert(b == 43); } { Z b = a - 1.Z; // r-value `rhs` version(ccc) assert(b.mutatingCallCount == 2); assert(b == 41); } { Z b = a * 2.Z; // r-value `rhs` version(ccc) assert(b.mutatingCallCount == 2); assert(b == 84); } { Z b = a / 2.Z; // r-value `rhs` version(ccc) assert(b.mutatingCallCount == 2); assert(b == 21); } { Z b = a % 10.Z; // r-value `rhs` version(ccc) assert(b.mutatingCallCount == 2); assert(b == 2); } } /// @safe @nogc unittest { const _ = (cast(uint)42).Z; const a = 42.Z; const b = 43UL.Z; const c = 43.0.Z; const z = 0.Z; // `opOpAssign` with `Unsigned` auto w = 42.Z; assert(w == 42); w += 100UL; assert(w == 142); w -= 100.Z; assert(w == 42); w += 100UL; assert(w == 142); w -= 100UL; assert(w == 42); w *= 100UL; assert(w == 4200); w /= 100UL; assert(w == 42); w %= 10UL; assert(w == 2); w ^^= 6UL; assert(w == 64); w = 42; assert(w == 42); w += 100; assert(w == 142); w -= 100; assert(w == 42); w *= 100; assert(w == 4200); w /= 100; assert(w == 42); w *= 100; assert(w == 4200); w /= -100; assert(w == -42); w *= -1; assert(w == 42); w %= 10; assert(w == 2); w = 2; w ^^= 6; assert(w == 64); w = 32.0; assert(w == 32); w = 42UL; assert(w == 42); w /= 2.Z; assert(w == 21); w /= -2.Z; assert(w == -10); w *= -2.Z; assert(w == 20); w %= 3.Z; assert(w == 2); w *= -1.Z; assert(w == -2); w /= -1.Z; assert(w == 2); // equality assert(z == 0); assert(z == cast(uint)0); assert(z == 0L); assert(z == 0UL); assert(z == 0.0f); assert(z == 0.0); // eval cast assert(a); assert(cast(ulong)a == a); assert(cast(ulong)a == 42); assert(cast(long)a == a); assert(cast(long)a == 42); assert(cast(double)a == 42.0); // binary assert(`0b11`.Z == 3); assert(`0B11`.Z == 3); // octal assert(`07`.Z == 7); assert(`010`.Z == 8); // hexadecimal assert(`0x10`.Z == 16); assert(`0X10`.Z == 16); // decimal assert(`101`.Z == 101); assert(`101`.Z == 101); immutable ic = 101UL.Z; assert(a == a.dup); assert(ic == ic.dup); // equality assert(a == a); assert(a == 42.Z); assert(a == 42.0); assert(a == 42); assert(a == cast(uint)42); assert(a == 42UL); assert(_ == 42); assert(c == 43.0); // non-equality assert(a != b); // less than assert(a < b); assert(a < 43.Z); assert(a < 43); assert(a < cast(uint)43); assert(a < 43UL); assert(a < 43.0); assert(-1.Z < 0.Z); assert(-1.Z < 0L); assert(-1.Z < 0UL); assert(-1.Z < 0.0); // greater than assert(b > a); assert(b > 42.Z); assert(b > 42); assert(b > cast(uint)42); assert(b > 42UL); assert(b > 42.0); assert(+1.Z > 0.Z); assert(+1.Z > 0L); assert(+1.Z > 0UL); assert(+1.Z > 0.0); // absolute value assert(abs(a) == a); // free function assert(a.abs == a); // UFCS assert(abs(-42.Z) == 42); assert(abs(-a) == a); // absolute value comparison assert(cmpabs(-43.Z, 44.Z) == -1); assert(cmpabs(-43.Z, -44.Z) == -1); assert(cmpabs(-44.Z, -43.Z) == +1); assert(cmpabs(-43.Z, -43.Z) == 0); assert(cmpabs(-43.Z, 44.0) == -1); assert(cmpabs(-43.Z, -44.0) == -1); assert(cmpabs(-44.Z, -43.0) == +1); assert(cmpabs(-43.Z, -43.0) == 0); assert(cmpabs(-43.Z, 44) == -1); assert(cmpabs( 43.Z, 44) == -1); assert(cmpabs(-44.Z, 43) == +1); assert(cmpabs( 44.Z, 43) == +1); assert(cmpabs(-43.Z, 43) == 0); Z _43 = 43; Z _4 = 4; Z _24 = 24; // next prime assert(nextPrime(_4) == 5); assert(nextPrime(24.Z) == 29); assert(nextPrime(_24) == 29); assert(nextPrime(24.Z) == 29); assert(24.Z.nextPrime() == 29); assert(nextPrime(_43) == 47); assert(nextPrime(43.Z) == 47); assert(43.Z.nextPrime() == 47); // greatest common divisor assert(gcd(43.Z, 44.Z) == 1); assert(gcd(4.Z, 24.Z) == 4); assert(gcd(6.Z, 24.Z) == 6); assert(gcd(10.Z, 100.Z) == 10); assert(gcd(43.Z, 44) == 1); assert(gcd(4.Z, 24) == 4); assert(gcd(6.Z, 24) == 6); assert(gcd(10.Z, 100) == 10); assert(gcd(_43, 44) == 1); assert(gcd(_4, 24) == 4); assert(gcd(_4, _24) == 4); assert(gcd(_4, 24.Z) == 4); // least common multiple assert(lcm(43.Z, 44.Z) == 1892); assert(lcm(4.Z, 24.Z) == 24); assert(lcm(6.Z, 24.Z) == 24); assert(lcm(10.Z, 100.Z) == 100); assert(lcm(43.Z, 44) == 1892); assert(lcm(4.Z, 24) == 24); assert(lcm(6.Z, 24) == 24); assert(lcm(10.Z, 100) == 100); assert(lcm(_43, 44) == 1892); assert(lcm(_4, 24) == 24); assert(lcm(_4, _24) == 24); assert(lcm(_4, 24.Z) == 24); // negated value assert(-a == -42); assert(-(-a) == a); auto n = 42.Z; n.negate(); assert(n == -42); n.negate(); assert(n == 42); n.negate(); assert(n == -42); n.absolute(); assert(n == 42); n.absolute(); assert(n == 42); n.onesComplement(); assert(n == -43); assert(onesComplement(n) == 42); assert(onesComplement(-43.Z) == 42); // addition assert(a + b == b + a); // commutative assert(a + 43.Z == b + a); assert(a - 43.Z == -(43.Z - a)); assert(a + 0 == a); assert(a + 1 != a); assert(0 + a == a); assert(1 + a != a); assert(a + 0UL == a); assert(a + 1UL != a); assert(a + b == 42 + 43); assert(1 + a == 43); assert(a + (-1) == 41); assert(1UL + a == 43); assert(a + 1 == 1 + a); // commutative assert(a + (-1) == (-1) + a); // commutative assert(1UL + a == a + 1UL); // commutative // subtraction assert(a - 2 == 40); assert(2 - a == -40); assert(-2 - a == -44); assert(a - 2 == -(2 - a)); // commutative assert(a - (-2) == 44); assert(44UL - 42.Z == 2); // multiplication assert(a * 1UL == a); assert(a * 1 == a); assert(1 * a == a); assert(1UL * a == a); assert((-1) * a == -a); assert(a * 2 != a); assert(a * -2 == -(2*a)); assert(a * b == b * a); assert(a * b == 42UL * 43UL); // division assert(27.Z / 3.Z == 9); assert(27.Z / 3 == 9); assert(27.Z / 10.Z == 2); assert(27.Z / 10 == 2); assert(27.Z / 10UL == 2); assert(27.Z / -3 == -9); assert(27.Z / 3UL == 9); assert(27.Z / -10 == -2); assert(28 / 3.Z == 9); assert(28UL / 3.Z == 9); assert(28 / -3.Z == -9); assert(28UL / -3.Z == -9); // modulo/remainder assert(27.Z % 3.Z == 0); assert(27.Z % 10.Z == 7); assert(27.Z % 3 == 0); assert(-27.Z % 3 == 0); assert(27.Z % 10 == 7); assert(27.Z % 10 == 7); assert(28 % 3.Z == 1); assert(28UL % 3.Z == 1); assert( 28.Z % -3 == -1); // negative divisor gives negative remainder according to https://en.wikipedia.org/wiki/Remainder assert(-28.Z % 3 == 1); // dividend sign doesn't affect remainder // assert( 28.Z % -3.Z == 1); // TODO should be -1 assert(-28.Z % 3.Z == -1); // TODO should be 1 assert( 28 % -3.Z == 1); // TODO should be -1 assert(-28 % 3.Z == -1); // TODO should be 1 // modulo/remainder immutable one = 1.Z; const two = 2.Z; immutable three = 3.Z; const four = 4.Z; immutable five = 5.Z; const six = 6.Z; assert(six % one == 0); assert(six % two == 0); assert(six % three == 0); assert(six % four == 2); assert(six % five == 1); assert(six % six == 0); // subtraction assert(six - one == 5); assert(six - 1UL == 5); assert(six - 1 == 5); assert(1 - six == -5); assert(1L - six == -5); assert(1UL - six == -5); // exponentiation assert(0.Z^^0 == 1); assert(3.Z^^3 == 27); assert(3.Z^^3L == 27); assert(2.Z^^8 == 256); assert(2.Z^^8L == 256); assert(2.Z^^8UL == 256); assert(Z.pow(2UL, 8UL) == 256); assert(Z.pow(2UL, 8) == 256); assert(Z.pow(2UL, 8) == 256); assert(Z.pow(2, 8) == 256); assert(Z.pow(-2, 8) == 256); assert(Z.pow(-2, 7) == -128); // disallow power exponent to be an `MpZ` assert(!__traits(compiles, 2^^8.Z == 256)); assert(!__traits(compiles, 2L^^8.Z == 256)); assert(!__traits(compiles, 2UL^^8.Z == 256)); // exponentiation plus modulus assert(2.Z.powm(8.Z, 8.Z) == 0.Z); assert(2.Z.powm(3.Z, 16.Z) == 8.Z); assert(3.Z.powm(3.Z, 16.Z) == 11.Z); assert(2.Z.powm(8, 8.Z) == 0.Z); assert(2.Z.powm(3, 16.Z) == 8.Z); assert(3.Z.powm(3, 16.Z) == 11.Z); // bitwise and, or and xor { foreach (immutable i; 0 .. 10) { foreach (immutable j; 0 .. 10) { assert((i.Z & j.Z) == (i & j)); assert((i.Z | j.Z) == (i | j)); assert((i.Z ^ j.Z) == (i ^ j)); Z x = null; x = i.Z; x &= j.Z; assert(x == (i & j)); x = i.Z; x |= j.Z; assert(x == (i | j)); x = i.Z; x ^= j.Z; assert(x == (i ^ j)); } } } // swap auto x = 42.Z; auto y = 43.Z; assert(x == 42); assert(y == 43); x.swap(y); assert(y == 42); assert(x == 43); swap(x, y); assert(x == 42); assert(y == 43); assert(null.Z.fromString("42") == 42.Z); assert(null.Z.fromString("42") < 43.Z); assert(null.Z.fromString("42") > 41.Z); assert(null.Z.fromString("42") == 42); assert(null.Z.fromString("11", 2) == 3); assert(null.Z.fromString("7", 8) == 7); assert(null.Z.fromString("7") == 7); assert(null.Z.fromString("e", 16) == 14); assert(null.Z.fromString("f", 16) == 15); assert(null.Z.fromString("0xe") == 14); assert(null.Z.fromString("0xf") == 15); assert(null.Z.fromString("10", 16) == 16); assert(null.Z.fromString("10", 32) == 32); // odd and even assert(0.Z.isEven); assert(1.Z.isOdd); assert(2.Z.isEven); assert(3.Z.isOdd); assert((-1).Z.isOdd); assert((-2).Z.isEven); assert((-3).Z.isOdd); assert("300000000000000000000000000000000000000".Z.isEven); assert("300000000000000000000000000000000000001".Z.isOdd); assert("300000000000000000000000000000000000002".Z.isEven); assert("300000000000000000000000000000000000003".Z.isOdd); // negative and positive assert(0.Z.isPositive); assert(1.Z.isPositive); assert(2.Z.isPositive); assert(3.Z.isPositive); assert((-1).Z.isNegative); assert((-2).Z.isNegative); assert((-3).Z.isNegative); // sign function (sgn) assert(long.min.Z.sgn == -1); assert(int.min.Z.sgn == -1); assert(-2.Z.sgn == -1); assert(-1.Z.sgn == -1); assert( 0.Z.sgn == 0); assert( 1.Z.sgn == 1); assert( 2.Z.sgn == 1); assert(int.max.Z.sgn == 1); assert(long.max.Z.sgn == 1); assert(!long.min.Z.isZero); assert(!int.min.Z.isZero); assert(!(-2).Z.isZero); assert(!(-1).Z.isZero); assert( 0.Z.isZero); assert(! 1.Z.isZero); assert(! 2.Z.isZero); assert(!int.max.Z.isZero); assert(!long.max.Z.isZero); assert(1.Z.populationCount == 1); assert(2.Z.populationCount == 1); assert(3.Z.populationCount == 2); assert(4.Z.populationCount == 1); assert(5.Z.populationCount == 2); assert(6.Z.populationCount == 2); assert(7.Z.populationCount == 3); // TODO // { // Z g = null; // assert(!b.testBit(0)); // g.setBit(0); // assert(b.testBit(0)); // g.clearBit(0); // assert(!b.testBit(0)); // } // fits in type foreach (Integral; AliasSeq!(short, int, long, ushort, uint, ulong)) { assert(Integral.min.Z.fitsIn!Integral); assert(Integral.max.Z.fitsIn!Integral); } // TODO // assert(short.min.Z.fitsIn!short); // assert(short.max.Z.fitsIn!short); // assert(ushort.min.Z.fitsIn!ushort); // assert(ushort.max.Z.fitsIn!ushort); // internal limb count assert(0.Z._limbCount == 0); assert(1.Z._limbCount == 1); assert(2.Z._limbCount == 1); assert(Z.pow(2UL, 32UL)._limbCount == 1); assert(Z.pow(2UL, 63UL)._limbCount == 1); assert(Z.pow(2UL, 63UL + 1)._limbCount == 2); assert(Z.pow(2UL, 127UL)._limbCount == 2); assert(Z.pow(2UL, 127UL + 1)._limbCount == 3); assert(Z.pow(2UL, 255UL)._limbCount == 4); assert(Z.pow(2UL, 255UL + 1)._limbCount == 5); } /// generators @safe @nogc unittest { assert(Z.mersennePrime(15) == 2^^15 - 1); assert(Z.mersennePrime(15UL) == 2^^15 - 1); } /// Phobos unittests @safe @nogc unittest { alias bigInt = mpz; alias BigInt = Z; // Phobos naming convention { const BigInt a = "9588669891916142"; const BigInt b = "7452469135154800"; const c = a * b; assert(c == BigInt("71459266416693160362545788781600")); auto d = b * a; assert(d == BigInt("71459266416693160362545788781600")); assert(d == c); d = c * BigInt("794628672112"); assert(d == BigInt("56783581982794522489042432639320434378739200")); auto e = c + d; assert(e == BigInt("56783581982865981755459125799682980167520800")); const f = d + c; assert(f == e); auto g = f - c; assert(g == d); g = f - d; assert(g == c); e = 12_345_678; g = c + e; immutable h = g / b; const i = g % b; assert(h == a); assert(i == e); BigInt j = "-0x9A56_57f4_7B83_AB78"; j ^^= 11UL; j ^^= 2L; j ^^= 2; } { auto b = BigInt("1_000_000_000"); b += 12_345; assert(b == 1_000_012_345); b += -12_345; assert(b == 1_000_000_000); b -= -12_345; assert(b == 1_000_012_345); b -= +12_345; assert(b == 1_000_000_000); b += 12_345; assert(b == 1_000_012_345); b /= 5UL; assert(b == 200_002_469); } { auto x = BigInt("123"); const y = BigInt("321"); x += y; assert(x == 444); } { const x = BigInt("123"); const y = BigInt("456"); const BigInt z = x * y; assert(z == 56_088); } { auto x = BigInt("123"); x *= 300; assert(x == 36_900); } { auto x = BigInt("123"); x *= -1; assert(x == -123); } { const x = BigInt("1_000_000_500"); immutable ulong ul = 2_000_000UL; immutable uint ui = 500_000; immutable ushort us = 30_000; immutable ubyte ub = 50; immutable long l = 1_000_000L; immutable int i = 500_000; immutable short s = 30_000; immutable byte b = 50; static assert(is(typeof(x % ul) == ulong)); static assert(is(typeof(x % ui) == uint)); static assert(is(typeof(x % us) == ushort)); static assert(is(typeof(x % ub) == ubyte)); static assert(is(typeof(x % l) == long)); static assert(is(typeof(x % i) == int)); // TODO static assert(is(typeof(x % s) == short)); // TODO static assert(is(typeof(x % b) == byte)); assert(x % ul == 500); assert(x % ui == 500); assert(x % us == 10_500); assert(x % ub == 0); assert(x % l == 500L); assert(x % i == 500); assert(x % s == 10_500); assert(x % b == 0); } { const x = BigInt("100"); const BigInt y = 123 + x; assert(y == BigInt("223")); const BigInt z = 123 - x; assert(z == BigInt("23")); // Dividing a built-in integer type by BigInt always results in // something that fits in a built-in type, so the built-in type is // returned, not BigInt. static assert(is(typeof(1000 / x) == int)); assert(1000 / x == 10); } { auto x = BigInt("1234"); assert(+x == BigInt(" 1234")); assert(-x == BigInt("-1234")); ++x; assert(x == BigInt("1235")); --x; assert(x == BigInt("1234")); } { const x = BigInt("12345"); const y = BigInt("12340"); immutable int z = 12_345; immutable int w = 54_321; assert(x == x); assert(x != y); assert(x == y + 5); assert(x == z); assert(x != w); } { // non-zero values are regarded as `true` const x = BigInt("1"); const y = BigInt("10"); assert(x); assert(y); // zero value is regarded as `false` const z = BigInt("0"); assert(!z); } { assert(cast(int)BigInt("0") == 0); assert(cast(ubyte)BigInt("0") == 0); assert(cast(ubyte)BigInt(255) == 255); assert(cast(ushort)BigInt(65_535) == 65_535); assert(cast(uint)BigInt(uint.max) == uint.max); assert(cast(ulong)BigInt(ulong.max) == ulong.max); assert(cast(byte)BigInt(-128) == -128); assert(cast(short)BigInt(-32_768) == -32_768); assert(cast(int)BigInt(int.min) == int.min); assert(cast(long)BigInt(long.min) == long.min); assert(cast(byte)BigInt(127) == 127); assert(cast(short)BigInt(32_767) == 32_767); assert(cast(int)BigInt(int.max) == int.max); assert(cast(long)BigInt(long.max) == long.max); // TODO: // import std.conv : to, ConvOverflowException; // import std.exception : assertThrown; // assertThrown!ConvOverflowException(BigInt("256").to!ubyte); // assertThrown!ConvOverflowException(BigInt("-1").to!ubyte); } { // TODO // segfaults because with double free // const(BigInt) x = BigInt("123"); // BigInt y = cast()x; // cast away const // assert(y == x); } { const x = BigInt("100"); const y = BigInt("10"); const int z = 50; const int w = 200; assert(y < x); assert(x > z); assert(z > y); assert(x < w); } { assert(BigInt("12345").toLong() == 12_345); assert(BigInt("-123450000000000000000000000000").toLong() == long.min); assert(BigInt("12345000000000000000000000000000").toLong() == long.max); } { assert(BigInt("12345").toInt() == 12_345); assert(BigInt("-123450000000000000000000000000").toInt() == int.min); assert(BigInt("12345000000000000000000000000000").toInt() == int.max); } } // Fermats Little Theorem @safe @nogc unittest { if (unittestLong) // compile but not run unless flagged for because running is slow { /* Fermats little theorem: a ^ p ≡ a (mod p) ∀ prime p check Fermats little theorem for a ≤ 100000 and all mersene primes M(p) : p ≤ 127 */ foreach (immutable ulong i; [2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127]) { foreach (immutable ulong j; 2 .. 100_000) { const p = Z.mersennePrime(i); // power const a = Z(j); // base const amp = a % p; const b = a.powm(p, p); // result assert(b == amp); } } } } // Euler's Sum of Powers Conjecture counter example pure @nogc unittest { /* a^5 + b^5 + c^5 + d^5 = e^5 Lander & Parkin, 1966 found the first counter example: 27^5 + 84^5 + 110^5 + 133^5 = 144^5. This test searches for this counter example by brute force for all positive a, b, c, d ≤ 144 */ enum LIMIT = 144 + 1; enum POWER = 5; if (unittestLong) // compile but not run unless flagged for because running is slow { bool found = false; Z r1 = 0; outermost: foreach (immutable ulong a; 1 .. LIMIT) { foreach (immutable ulong b; a .. LIMIT) { foreach (immutable ulong c; b .. LIMIT) { foreach (immutable ulong d; c .. LIMIT) { r1 = ((Z(a) ^^ POWER) + (Z(b) ^^ POWER) + (Z(c) ^^ POWER) + (Z(d) ^^ POWER)); Z rem = 0; __gmpz_rootrem(r1._ptr, rem._ptr, r1._ptr, POWER); version(ccc) ++r1._ccc; if (rem == 0UL) { debug printf("Counter Example Found: %lu^5 + %lu^5 + %lu^5 + %lu^5 = %lu^5\n", a, b, c, d, cast(ulong)r1); found = true; break outermost; } } } } } assert(found); } } /// expression template types /// `MpZ`-`MpZ` adding expression. struct MpzAddExpr(T1, T2) if (isMpZExpr!T1 && isMpZExpr!T2) { T1 e1; // first term T2 e2; // second term MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_add(y._ptr, e1.eval()._ptr, e2.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzAddExpr!(MpZ, MpZ))); /// Instantiator for `MpzAddExpr`. pragma(inline, true) MpzAddExpr!(T1, T2) mpzAddExpr(T1, T2)(T1 t1, T2 t2) if (isMpZExpr!T1 && isMpZExpr!T2) { // TODO don't eval certain type combinations of t1 and t2 return MpzAddExpr!(T1, T2)(t1.eval(), t2.eval()); } @safe @nogc unittest { assert(MpzAddExpr!(Z, Z)(3.Z, 4.Z).eval() == 3 + 4); const Z x = MpzAddExpr!(Z, Z)(3.Z, 4.Z); version(ccc) assert(x.mutatingCallCount == 1); // lower to `mpz_add` assert(x == 7); Z y = null; y = MpzAddExpr!(Z, Z)(3.Z, 4.Z); version(ccc) assert(y.mutatingCallCount == 2); // lowers to `mpz_init`, `mpz_add` assert(y == 7); } /// `MpZ`-`MpZ` subtraction expression. struct MpzSubExpr(T1, T2) if (isMpZExpr!T1 && isMpZExpr!T2) { T1 e1; // first term T2 e2; // second term MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_sub(y._ptr, e1.eval()._ptr, e2.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzSubExpr!(MpZ, MpZ))); @safe @nogc unittest { assert(MpzSubExpr!(Z, Z)(3.Z, 4.Z).eval() == 3 - 4); const Z x = MpzSubExpr!(Z, Z)(3.Z, 4.Z); version(ccc) assert(x.mutatingCallCount == 1); // lowers to `mpz_sub` assert(x == -1); } /// `MpZ`-`MpZ` multiplication expression. struct MpzMulExpr(F1, F2) if (isMpZExpr!F1 && isMpZExpr!F2) { F1 e1; // first factor F2 e2; // second factor MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_mul(y._ptr, e1.eval()._ptr, e2.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzMulExpr!(MpZ, MpZ))); @safe @nogc unittest { assert(MpzMulExpr!(Z, Z)(3.Z, 4.Z).eval() == 3 * 4); const Z x = MpzMulExpr!(Z, Z)(3.Z, 4.Z); assert(x == 12); version(ccc) assert(x.mutatingCallCount == 1); // lowers to `mpz_mul` } /// `MpZ`-`MpZ` division expression. struct MpzDivExpr(P, Q) if (isMpZExpr!P && isMpZExpr!Q) { P e1; // divisor Q e2; // dividend MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_tdiv_q(y._ptr, e1.eval()._ptr, e2.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzDivExpr!(MpZ, MpZ))); @safe @nogc unittest { assert(MpzDivExpr!(Z, Z)(27.Z, 3.Z).eval() == 27 / 3); assert(MpzDivExpr!(Z, Z)(28.Z, 3.Z).eval() == 28 / 3); assert(MpzDivExpr!(Z, Z)(29.Z, 3.Z).eval() == 29 / 3); assert(MpzDivExpr!(Z, Z)(30.Z, 3.Z).eval() == 30 / 3); const Z x = MpzDivExpr!(Z, Z)(28.Z, 3.Z); assert(x == 9); version(ccc) assert(x.mutatingCallCount == 1); // lowers to `mpz_tdiv_q` } /// `MpZ`-`MpZ` modulus expression. struct MpzModExpr(P, Q) if (isMpZExpr!P && isMpZExpr!Q) { P e1; // divisor Q e2; // dividend MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_tdiv_r(y._ptr, e1.eval()._ptr, e2.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzModExpr!(MpZ, MpZ))); @safe @nogc unittest { assert(MpzModExpr!(Z, Z)(27.Z, 3.Z).eval() == 27 % 3); assert(MpzModExpr!(Z, Z)(28.Z, 3.Z).eval() == 28 % 3); assert(MpzModExpr!(Z, Z)(29.Z, 3.Z).eval() == 29 % 3); assert(MpzModExpr!(Z, Z)(30.Z, 3.Z).eval() == 30 % 3); const Z x = MpzModExpr!(Z, Z)(29.Z, 3.Z); assert(x == 2); version(ccc) assert(x.mutatingCallCount == 1); // lowers to `mpz_tdiv_r` } /// `MpZ`-`ulong` power expression. struct MpzPowUExpr(P, Q) if (isMpZExpr!P && isUnsigned!Q) { P e1; // base Q e2; // exponent MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_pow_ui(y._ptr, e1.eval()._ptr, e2); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzPowUExpr!(MpZ, ulong))); @safe @nogc unittest { assert(MpzPowUExpr!(Z, ulong)(3.Z, 3).eval() == 3^^3); } /// `MpZ`-`ulong`-`MpZ` power-modulo expression. struct MpzPowMUExpr(P, Q, M) if (isMpZExpr!P && isUnsigned!Q && isMpZExpr!M) { P base; // base Q exp; // exponent M mod; // modulo MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_powm_ui(y._ptr, base.eval()._ptr, exp, mod._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzPowMUExpr!(MpZ, ulong, MpZ))); @safe @nogc unittest { assert(MpzPowMUExpr!(Z, ulong, Z)(3.Z, 3, 20.Z).eval() == 3^^3 % 20); } /// `MpZ` negation expression. struct MpzNegExpr(A) if (isMpZExpr!A) { A e1; MpZ eval() const @trusted { version(LDC) pragma(inline, true); typeof(return) y = null; __gmpz_neg(y._ptr, e1.eval()._ptr); version(ccc) ++y._ccc; return y; } } version(unittest) static assert(isMpZExpr!(MpzNegExpr!(MpZ))); @safe @nogc unittest { assert(MpzNegExpr!(Z)(27.Z).eval() == -27); const Z x = MpzNegExpr!(Z)(27.Z); version(ccc) assert(x.mutatingCallCount == 1); // lowers to `mpz_neg` assert(x == -27); } /// Copied from `std.numeric` to prevent unnecessary Phobos deps. pragma(inline, true) T _integralAbs(T)(T x) if (isIntegral!T) { return x >= 0 ? x : -x; } /// as hash table key @safe unittest { // TODO disabled until non-copyable types work in AA's // string[Z] aa; // aa[123.Z] = "abc"; // aa[456.Z] = "def"; // assert(aa[123.Z] == "abc"); // assert(aa[456.Z] == "def"); } /// copyable integer @trusted unittest { alias CZ = CopyableMpZ; CZ a = 42; CZ b = a; // copy assert(a == b); // should equal assert(a !is b); // but not the same CZ c = null; // other value assert(a != c); // should diff } /// to string conversion @safe pure nothrow unittest { for (int i = -100; i < 100; ++i) { import std.conv : to; assert(i.Z.toString == i.to!string); } } version(unittest) { import dbgio : dln; alias Z = MpZ; debug import core.stdc.stdio : printf; // version = ccc; // do C mutation call count static assert(!isMpZExpr!int); import std.meta : AliasSeq; } version(unittest) { alias CZ = _MpZ!true; } // C API extern(C) pragma(inline, false) { alias __mp_limb_t = ulong; // see `mp_limb_t` gmp.h. TODO detect when it is `uint` instead struct __mpz_struct { int _mp_alloc; /* Number of *limbs* allocated and pointed to by the _mp_d field. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ __mp_limb_t* _mp_d; /* Pointer to the limbs. */ } static assert(__mpz_struct.sizeof == 16); // fits in two 64-bit words alias mpz_srcptr = const(__mpz_struct)*; alias mpz_ptr = __mpz_struct*; alias mp_bitcnt_t = ulong; pure nothrow @nogc: void __gmpz_init (mpz_ptr); void __gmpz_init_set (mpz_ptr, mpz_srcptr); void __gmpz_init_set_d (mpz_ptr, double); void __gmpz_init_set_si (mpz_ptr, long); void __gmpz_init_set_ui (mpz_ptr, ulong); int __gmpz_init_set_str (mpz_ptr, const char*, int); void __gmpz_set (mpz_ptr rop, mpz_srcptr op); void __gmpz_set_ui (mpz_ptr rop, ulong op); void __gmpz_set_si (mpz_ptr rop, long op); void __gmpz_set_d (mpz_ptr rop, double op); int __gmpz_set_str (mpz_ptr, const char*, int); void __gmpz_clear (mpz_ptr); void __gmpz_abs (mpz_ptr, mpz_srcptr); void __gmpz_neg (mpz_ptr, mpz_srcptr); void __gmpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_add_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_addmul_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_sub_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_ui_sub (mpz_ptr, ulong, mpz_srcptr); void __gmpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); void __gmpz_mul_si (mpz_ptr, mpz_srcptr, long); void __gmpz_mul_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, ulong); ulong __gmpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, ulong); void __gmpz_cdiv_ui (mpz_srcptr, ulong); void __gmpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, ulong); ulong __gmpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, ulong); void __gmpz_fdiv_ui (mpz_srcptr, ulong); void __gmpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, ulong); ulong __gmpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, ulong); void __gmpz_tdiv_ui (mpz_srcptr, ulong); void __gmpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_pow_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_ui_pow_ui (mpz_ptr, ulong, ulong); void __gmpz_swap (mpz_ptr, mpz_ptr); int __gmpz_cmp (mpz_srcptr, mpz_srcptr); int __gmpz_cmp_d (mpz_srcptr, double); int __gmpz_cmp_si (mpz_srcptr, long); int __gmpz_cmp_ui (mpz_srcptr, ulong); int __gmpz_cmpabs (mpz_srcptr, mpz_srcptr); int __gmpz_cmpabs_d (mpz_srcptr, double); int __gmpz_cmpabs_ui (mpz_srcptr, ulong); void __gmpz_nextprime (mpz_ptr, mpz_srcptr); void __gmpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); ulong __gmpz_gcd_ui (mpz_ptr, mpz_srcptr, ulong); void __gmpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_lcm_ui (mpz_ptr, mpz_srcptr, ulong); char *__gmpz_get_str (char*, int, mpz_srcptr); size_t __gmpz_sizeinbase (mpz_srcptr, int); void __gmpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); void __gmpz_powm_ui (mpz_ptr, mpz_srcptr, ulong, mpz_srcptr); ulong __gmpz_get_ui (mpz_srcptr); long __gmpz_get_si (mpz_srcptr); double __gmpz_get_d (mpz_srcptr); int __gmpz_fits_ulong_p(mpz_srcptr); int __gmpz_fits_slong_p(mpz_srcptr); int __gmpz_fits_uint_p(mpz_srcptr); int __gmpz_fits_sint_p(mpz_srcptr); int __gmpz_fits_ushort_p(mpz_srcptr); int __gmpz_fits_sshort_p(mpz_srcptr); void __gmpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); void __gmpz_com (mpz_ptr, mpz_srcptr); void __gmpz_setbit (mpz_ptr, mp_bitcnt_t); void __gmpz_clrbit (mpz_ptr, mp_bitcnt_t); void __gmpz_combit (mpz_ptr, mp_bitcnt_t); int __gmpz_tstbit (mpz_srcptr, mp_bitcnt_t); mp_bitcnt_t __gmpz_popcount (mpz_srcptr); // TODO wrap: void __gmpz_root (mpz_ptr, mpz_srcptr, ulong); void __gmpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, ulong); void __gmpz_sqrt (mpz_ptr, mpz_srcptr); void __gmpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); void __gmpz_perfect_power_p (mpz_ptr, mpz_srcptr); } pragma(lib, "gmp"); pragma(lib, "c"); // needed by `malloc` and `free`
D
/* Copyright (c) 2014-2023 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. */ /** * Lens distortion filter * * Copyright: Timur Gafarov 2014-2023. * License: $(LINK2 boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Timur Gafarov */ module dlib.image.filters.lens; import std.math; import dlib.image.image; /// Apply lens distortion filter SuperImage lensDistortion( SuperImage img, SuperImage outp, float strength, float zoom, bool interpolation = true) { SuperImage res; if (outp) res = outp; else res = img.dup; float halfWidth = cast(float)img.width / 2.0f; float halfHeight = cast(float)img.height / 2.0f; float correctionRadius = sqrt(cast(float)(img.width ^^ 2 + img.height ^^ 2)) / strength; foreach(y; 0..img.height) foreach(x; 0..img.width) { float newX = x - halfWidth; float newY = y - halfHeight; float distance = sqrt(newX ^^ 2 + newY ^^ 2); float r = distance / correctionRadius; float theta; if (r == 0) theta = 1; else theta = atan(r) / r; float sourceX = (halfWidth + theta * newX * zoom); float sourceY = (halfHeight + theta * newY * zoom); if (interpolation) res[x, y] = img.bilinearPixel(sourceX, sourceY); else res[x, y] = img[cast(int)sourceX, cast(int)sourceY]; } return res; } /// ditto SuperImage lensDistortion( SuperImage img, float strength, float zoom, bool interpolation = true) { return lensDistortion(img, null, strength, zoom, interpolation); }
D
import autowrap; enum str = wrapDlang!( LibraryName("std_stdint"), Modules( Yes.alwaysExport, "std.stdint", ) ); // pragma(msg, str); mixin(str);
D
module rocl.controls.settings; import std.meta, std.array, std.algorithm, perfontain, perfontain.opengl, ro.conv.gui, rocl, rocl.rofs, rocl.game, rocl.controls; final class WinSettings : GUIWindow { this(bool viewer = false) { super(MSG_SETTINGS, Vector2s(340, 255)); struct S { string caption, var; string[] values; string cond = `true`; } enum Arr = [ S(`MSG_SHADOWS`, `PE.settings.shadows`, [ `MSG_NO`, `MSG_LOW`, `MSG_MIDDLE`, `MSG_HIGH`, `MSG_HIGHEST` ]), S(`MSG_LIGHTING`, `PE.settings.lights`, [ `MSG_NO`, `MSG_DIFFUSE`, `MSG_FULL` ]), S(`MSG_RENDER_QUALITY`, `PE.settings.useBindless`, [`MSG_MIDDLE`, `MSG_HIGH`], `GL_ARB_bindless_texture`), S(`MSG_FOG`, `PE.settings.fog`), S(`MSG_FULLSCREEN`, `PE.settings.fullscreen`), S(`MSG_ANTIALIASING`, `PE.settings.msaa`), S(`MSG_VSYNC`, `PE.settings.vsync`), ]; addLayout(new DynamicRowLayout(2)); foreach (i, c; aliasSeqOf!Arr) { if (mixin(c.cond)) { //t.add(new GUIStaticText(null, mixin(c.caption))); static if (c.values) { string[] arr; foreach (u; aliasSeqOf!(Arr[i].values)) { arr ~= mixin(u); } new GUIStaticText(curLayout, mixin(c.caption)); auto e = new TextCombo(curLayout, arr, mixin(c.var)); } else { auto e = new CheckBox(curLayout, mixin(c.caption), mixin(c.var)); } e.onChange = (a) { mixin(c.var ~ `= cast(typeof( ` ~ c.var ~ `))a;`); return true; }; } } if (viewer) { GUIElement[] arr; // auto maps = (cast(RoFileSystem)PEfs).grfs // .map!(a => a.files.byKey) // .joiner // .filter!(a => a.startsWith(`data/`) && a.endsWith(`.rsw`)) // .map!(a => a[5 .. $ - 4]) // .array // .sort().uniq.array; //if (maps.length) // TODO: FIX { /*auto e = new TextCombo(curLayout, maps, cast(short) maps.countUntil(`prontera`)); e.onChange = (a) { try { ROres.load(maps[a]); } catch (Exception e) { e.logger; } return true; };*/ } } else { //auto e = new Button(this, MSG_HOTKEYS, () => RO.gui.createHotkeySettings); // TODO: DELEGATE //e.move(POS_MIN, 4, POS_CENTER); } } /*override void poseDefault() { center; }*/ }
D
<?xml version="1.0" encoding="UTF-8"?> <di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi"> <pageList> <availablePage> <emfPageIdentifier href="openetcs.profile.notation#_9X5UIBM8EeSV2dE26Bo1ow"/> </availablePage> </pageList> <sashModel currentSelection="//@sashModel/@windows.0/@children.0"> <windows> <children xsi:type="di:TabFolder"> <children> <emfPageIdentifier href="openetcs.profile.notation#_9X5UIBM8EeSV2dE26Bo1ow"/> </children> </children> </windows> </sashModel> </di:SashWindowsMngr>
D
void main() { problem(); } void problem() { auto A = scan!long; auto B = scan!long; auto X = scan!long; void solve() { const moddable = (long n, long x) => n < 0 ? 0 : n / x + 1; writeln(moddable(B, X) - moddable(A-1, X)); } solve(); } // ---------------------------------------------- import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric; T[][] combinations(T)(T[] s, in int m) { if (!m) return [[]]; if (s.empty) return []; return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); } string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } T scan(T)(){ return scan.to!T; } T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; } void deb(T ...)(T t){ debug writeln(t); } alias Point = Tuple!(long, "x", long, "y"); // -----------------------------------------------
D
module perfontain.nodes.sprite; import std.math, std.stdio, std.range, perfontain, perfontain.math, perfontain.nodes, perfontain.misc; enum { SPR_BODY, SPR_HEAD, SPR_HEAD_BOTTOM, SPR_HEAD_MIDDLE, SPR_HEAD_TOP, SPR_SHIELD, SPR_WEAPON, SPR_MAX } enum { SPR_STANDING, SPR_MOVING, SPR_ATTACK, SPR_DAMAGING, SPR_DEAD, } struct SpriteImage { ushort mesh; Color color; } struct SpriteFrame { @ArrayLength!ubyte SpriteImage[] images; Vector4 size; Vector2 extra; byte event; } struct SpriteAction { @ArrayLength!ushort SpriteFrame[] frames; ushort delay; } struct SpriteEvent { @ArrayLength!ubyte const(ubyte)[] audio; } struct Sprite { @ArrayLength!ubyte SpriteEvent[] events; @ArrayLength!ubyte SpriteAction[] actions; } final class SpriteObject : RCounted { Sprite spr; RC!MeshHolder mh; } final class SpriteNode : Node // TODO: BBOX ON CREATION { override void draw(in DrawInfo* di) // TODO: move in onTick { SpriteObject spr = sprites[0]; //if(!spr) return; auto cam = PEscene.camera; auto mat = cam._inversed * matrix; // * Matrix4.translate(0, 0.8, 0); if (!PE.scene.shadowPass) // FIXME: ?????? { auto v = cam.view; auto k = mat * cam.view; auto u = 1f; k[1][2] += 0.5f / u; k[1][3] += u / 50; mat = k * cam.view.inversed; } auto tm = PE._tick - _start; if (_time > 0 && tm > _time) { _action = _next; _start = PE._tick; tm = _time = 0; } auto fdir = (direction + cam._udir) % 8; auto aa = (_action * 8 + fdir); auto a = &spr.spr.actions[aa % $]; auto frame = _time > 0 ? tm * cast(uint)a.frames.length / _time : tm / (_factor ? a.delay * _factor / 100 : a.delay); auto fs = &a.frames[(directionHead < 0 || _action ? frame : directionHead) % $]; // TODO: OPTIMIZE bbox = BBox(Vector3(fs.size.xy, 0), Vector3(fs.size.zw, 0)) * mat; foreach (ref im; fs.images) { DrawInfo m; auto c = im.color; m.mh = spr.mh; m.color = c; m.matrix = mat; m.id = im.mesh; m.blendingMode = c.a == 255 ? noBlending : blendingNormal; PE.render.toQueue(m); } foreach_reverse (i, SpriteObject s; sprites[1 .. $]) { if (!s) { continue; } if (fdir >= 3 && fdir <= 5 && (i == SPR_HEAD_MIDDLE - 1 || i == SPR_HEAD_BOTTOM - 1)) { continue; } auto sa = &s.spr.actions[aa % $]; auto cnt = cast(ushort)sa.frames.length / 3; auto u = &sa.frames[cnt > 1 ? directionHead * 3 + frame % cnt : directionHead]; auto m2 = u.extra.x.isNaN ? mat : Matrix4.translate(Vector3(fs.extra - u.extra, 0)) * mat; bbox += BBox(Vector3(u.size.xy, 0), Vector3(u.size.zw, 0)) * m2; foreach (ref im; u.images) { DrawInfo m; m.mh = s.mh; m.color = im.color; m.matrix = m2; m.id = im.mesh; PE.render.toQueue(m); } } if (_event != fs.event) { _event = fs.event; if (_event >= 0) { auto name = spr.spr.events[_event].audio; if (name != `atk`) // ??? { // TODO: FIX FIX FIX //PEaudio.play(`data/wav/` ~ name); } } } } void doAction(ubyte cur, byte next = -1, ushort time = 0, ushort factor = 0) // TODO: SEPARATE { if (_action != cur) { _action = cur; _start = PE._tick; } _next = next; _time = time; _factor = factor; } RC!SpriteObject[SPR_MAX] sprites; ubyte direction; byte directionHead = -1; private: uint _start; ushort _time, _factor; byte _action = -1, _next = -1, _event = -1; }
D
// Written in the D programming language. /** * Templates which extract information about types and symbols at compile time. * * $(SCRIPT inhibitQuickIndex = 1;) * * $(DIVC quickindex, * $(BOOKTABLE , * $(TR $(TH Category) $(TH Templates)) * $(TR $(TD Symbol Name _traits) $(TD * $(LREF fullyQualifiedName) * $(LREF moduleName) * $(LREF packageName) * )) * $(TR $(TD Function _traits) $(TD * $(LREF isFunction) * $(LREF arity) * $(LREF functionAttributes) * $(LREF hasFunctionAttributes) * $(LREF functionLinkage) * $(LREF FunctionTypeOf) * $(LREF isSafe) * $(LREF isUnsafe) * $(LREF isFinal) * $(LREF ParameterDefaults) * $(LREF ParameterIdentifierTuple) * $(LREF ParameterStorageClassTuple) * $(LREF Parameters) * $(LREF ReturnType) * $(LREF SetFunctionAttributes) * $(LREF variadicFunctionStyle) * )) * $(TR $(TD Aggregate Type _traits) $(TD * $(LREF BaseClassesTuple) * $(LREF BaseTypeTuple) * $(LREF classInstanceAlignment) * $(LREF EnumMembers) * $(LREF FieldNameTuple) * $(LREF Fields) * $(LREF hasAliasing) * $(LREF hasElaborateAssign) * $(LREF hasElaborateCopyConstructor) * $(LREF hasElaborateDestructor) * $(LREF hasIndirections) * $(LREF hasMember) * $(LREF hasStaticMember) * $(LREF hasNested) * $(LREF hasUnsharedAliasing) * $(LREF InterfacesTuple) * $(LREF isInnerClass) * $(LREF isNested) * $(LREF MemberFunctionsTuple) * $(LREF RepresentationTypeTuple) * $(LREF TemplateArgsOf) * $(LREF TemplateOf) * $(LREF TransitiveBaseTypeTuple) * )) * $(TR $(TD Type Conversion) $(TD * $(LREF CommonType) * $(LREF ImplicitConversionTargets) * $(LREF CopyTypeQualifiers) * $(LREF CopyConstness) * $(LREF isAssignable) * $(LREF isCovariantWith) * $(LREF isImplicitlyConvertible) * )) * $(TR $(TD SomethingTypeOf) $(TD * $(LREF rvalueOf) * $(LREF lvalueOf) * $(LREF InoutOf) * $(LREF ConstOf) * $(LREF SharedOf) * $(LREF SharedInoutOf) * $(LREF SharedConstOf) * $(LREF ImmutableOf) * $(LREF QualifierOf) * )) * $(TR $(TD Categories of types) $(TD * $(LREF allSameType) * $(LREF ifTestable) * $(LREF isType) * $(LREF isAggregateType) * $(LREF isArray) * $(LREF isAssociativeArray) * $(LREF isAutodecodableString) * $(LREF isBasicType) * $(LREF isBoolean) * $(LREF isBuiltinType) * $(LREF isCopyable) * $(LREF isDynamicArray) * $(LREF isEqualityComparable) * $(LREF isFloatingPoint) * $(LREF isIntegral) * $(LREF isNarrowString) * $(LREF isConvertibleToString) * $(LREF isNumeric) * $(LREF isOrderingComparable) * $(LREF isPointer) * $(LREF isScalarType) * $(LREF isSigned) * $(LREF isSIMDVector) * $(LREF isSomeChar) * $(LREF isSomeString) * $(LREF isStaticArray) * $(LREF isUnsigned) * )) * $(TR $(TD Type behaviours) $(TD * $(LREF isAbstractClass) * $(LREF isAbstractFunction) * $(LREF isCallable) * $(LREF isDelegate) * $(LREF isExpressions) * $(LREF isFinalClass) * $(LREF isFinalFunction) * $(LREF isFunctionPointer) * $(LREF isInstanceOf) * $(LREF isIterable) * $(LREF isMutable) * $(LREF isSomeFunction) * $(LREF isTypeTuple) * )) * $(TR $(TD General Types) $(TD * $(LREF ForeachType) * $(LREF KeyType) * $(LREF Largest) * $(LREF mostNegative) * $(LREF OriginalType) * $(LREF PointerTarget) * $(LREF Signed) * $(LREF Unqual) * $(LREF Unsigned) * $(LREF ValueType) * $(LREF Promoted) * )) * $(TR $(TD Misc) $(TD * $(LREF mangledName) * $(LREF Select) * $(LREF select) * )) * $(TR $(TD User-Defined Attributes) $(TD * $(LREF hasUDA) * $(LREF getUDAs) * $(LREF getSymbolsByUDA) * )) * ) * ) * * Copyright: Copyright Digital Mars 2005 - 2009. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: $(HTTP digitalmars.com, Walter Bright), * Tomasz Stachowiak ($(D isExpressions)), * $(HTTP erdani.org, Andrei Alexandrescu), * Shin Fujishiro, * $(HTTP octarineparrot.com, Robert Clipsham), * $(HTTP klickverbot.at, David Nadlinger), * Kenji Hara, * Shoichi Kato * Source: $(PHOBOSSRC std/_traits.d) */ /* Copyright Digital Mars 2005 - 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) */ module std.traits; import std.meta : AliasSeq, allSatisfy; import std.functional : unaryFun; // Legacy inheritance from std.typetuple // See also: https://github.com/dlang/phobos/pull/5484#discussion_r122602797 import std.meta : staticMapMeta = staticMap; // TODO: find a way to trigger deprecation warnings //deprecated("staticMap is part of std.meta: Please import std.meta") alias staticMap = staticMapMeta; /////////////////////////////////////////////////////////////////////////////// // Functions /////////////////////////////////////////////////////////////////////////////// // Petit demangler // (this or similar thing will eventually go to std.demangle if necessary // ctfe stuffs are available) private { struct Demangle(T) { T value; // extracted information string rest; } /* Demangles mstr as the storage class part of Argument. */ Demangle!uint demangleParameterStorageClass(string mstr) { uint pstc = 0; // parameter storage class // Argument --> Argument2 | M Argument2 if (mstr.length > 0 && mstr[0] == 'M') { pstc |= ParameterStorageClass.scope_; mstr = mstr[1 .. $]; } // Argument2 --> Type | J Type | K Type | L Type ParameterStorageClass stc2; switch (mstr.length ? mstr[0] : char.init) { case 'J': stc2 = ParameterStorageClass.out_; break; case 'K': stc2 = ParameterStorageClass.ref_; break; case 'L': stc2 = ParameterStorageClass.lazy_; break; case 'N': if (mstr.length >= 2 && mstr[1] == 'k') stc2 = ParameterStorageClass.return_; break; default : break; } if (stc2 != ParameterStorageClass.init) { pstc |= stc2; mstr = mstr[1 .. $]; if (stc2 & ParameterStorageClass.return_) mstr = mstr[1 .. $]; } return Demangle!uint(pstc, mstr); } /* Demangles mstr as FuncAttrs. */ Demangle!uint demangleFunctionAttributes(string mstr) { immutable LOOKUP_ATTRIBUTE = [ 'a': FunctionAttribute.pure_, 'b': FunctionAttribute.nothrow_, 'c': FunctionAttribute.ref_, 'd': FunctionAttribute.property, 'e': FunctionAttribute.trusted, 'f': FunctionAttribute.safe, 'i': FunctionAttribute.nogc, 'j': FunctionAttribute.return_, 'l': FunctionAttribute.scope_ ]; uint atts = 0; // FuncAttrs --> FuncAttr | FuncAttr FuncAttrs // FuncAttr --> empty | Na | Nb | Nc | Nd | Ne | Nf | Ni | Nj // except 'Ng' == inout, because it is a qualifier of function type while (mstr.length >= 2 && mstr[0] == 'N' && mstr[1] != 'g' && mstr[1] != 'k') { if (FunctionAttribute att = LOOKUP_ATTRIBUTE[ mstr[1] ]) { atts |= att; mstr = mstr[2 .. $]; } else assert(0); } return Demangle!uint(atts, mstr); } static if (is(ucent)) { alias CentTypeList = AliasSeq!(cent, ucent); alias SignedCentTypeList = AliasSeq!(cent); alias UnsignedCentTypeList = AliasSeq!(ucent); } else { alias CentTypeList = AliasSeq!(); alias SignedCentTypeList = AliasSeq!(); alias UnsignedCentTypeList = AliasSeq!(); } alias IntegralTypeList = AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong, CentTypeList); alias SignedIntTypeList = AliasSeq!(byte, short, int, long, SignedCentTypeList); alias UnsignedIntTypeList = AliasSeq!(ubyte, ushort, uint, ulong, UnsignedCentTypeList); alias FloatingPointTypeList = AliasSeq!(float, double, real); alias ImaginaryTypeList = AliasSeq!(ifloat, idouble, ireal); alias ComplexTypeList = AliasSeq!(cfloat, cdouble, creal); alias NumericTypeList = AliasSeq!(IntegralTypeList, FloatingPointTypeList); alias CharTypeList = AliasSeq!(char, wchar, dchar); } package { // Add the mutable qualifier to the given type T. template MutableOf(T) { alias MutableOf = T ; } } /// Add the inout qualifier to the given type T. template InoutOf(T) { alias InoutOf = inout(T) ; } /// Add the const qualifier to the given type T. template ConstOf(T) { alias ConstOf = const(T) ; } /// Add the shared qualifier to the given type T. template SharedOf(T) { alias SharedOf = shared(T) ; } /// Add the shared and inout qualifiers to the given type T. template SharedInoutOf(T) { alias SharedInoutOf = shared(inout(T)); } /// Add the shared and const qualifiers to the given type T. template SharedConstOf(T) { alias SharedConstOf = shared(const(T)); } /// Add the immutable qualifier to the given type T. template ImmutableOf(T) { alias ImmutableOf = immutable(T) ; } @safe unittest { static assert(is( MutableOf!int == int)); static assert(is( InoutOf!int == inout int)); static assert(is( ConstOf!int == const int)); static assert(is( SharedOf!int == shared int)); static assert(is(SharedInoutOf!int == shared inout int)); static assert(is(SharedConstOf!int == shared const int)); static assert(is( ImmutableOf!int == immutable int)); } /// Get qualifier template from the given type T template QualifierOf(T) { static if (is(T == shared(const U), U)) alias QualifierOf = SharedConstOf; else static if (is(T == const U , U)) alias QualifierOf = ConstOf; else static if (is(T == shared(inout U), U)) alias QualifierOf = SharedInoutOf; else static if (is(T == inout U , U)) alias QualifierOf = InoutOf; else static if (is(T == immutable U , U)) alias QualifierOf = ImmutableOf; else static if (is(T == shared U , U)) alias QualifierOf = SharedOf; else alias QualifierOf = MutableOf; } @safe unittest { alias Qual1 = QualifierOf!( int); static assert(is(Qual1!long == long)); alias Qual2 = QualifierOf!( inout int); static assert(is(Qual2!long == inout long)); alias Qual3 = QualifierOf!( const int); static assert(is(Qual3!long == const long)); alias Qual4 = QualifierOf!(shared int); static assert(is(Qual4!long == shared long)); alias Qual5 = QualifierOf!(shared inout int); static assert(is(Qual5!long == shared inout long)); alias Qual6 = QualifierOf!(shared const int); static assert(is(Qual6!long == shared const long)); alias Qual7 = QualifierOf!( immutable int); static assert(is(Qual7!long == immutable long)); } version(unittest) { alias TypeQualifierList = AliasSeq!(MutableOf, ConstOf, SharedOf, SharedConstOf, ImmutableOf); struct SubTypeOf(T) { T val; alias val this; } } private alias parentOf(alias sym) = Identity!(__traits(parent, sym)); private alias parentOf(alias sym : T!Args, alias T, Args...) = Identity!(__traits(parent, T)); /** * Get the full package name for the given symbol. */ template packageName(alias T) { import std.algorithm.searching : startsWith; static if (__traits(compiles, parentOf!T)) enum parent = packageName!(parentOf!T); else enum string parent = null; static if (T.stringof.startsWith("package ")) enum packageName = (parent.length ? parent ~ '.' : "") ~ T.stringof[8 .. $]; else static if (parent) enum packageName = parent; else static assert(false, T.stringof ~ " has no parent"); } /// @safe unittest { static assert(packageName!packageName == "std"); } @safe unittest { import std.array; // Commented out because of dmd @@@BUG8922@@@ // static assert(packageName!std == "std"); // this package (currently: "std.std") static assert(packageName!(std.traits) == "std"); // this module static assert(packageName!packageName == "std"); // symbol in this module static assert(packageName!(std.array) == "std"); // other module from same package import core.sync.barrier; // local import static assert(packageName!core == "core"); static assert(packageName!(core.sync) == "core.sync"); static assert(packageName!Barrier == "core.sync"); struct X12287(T) { T i; } static assert(packageName!(X12287!int.i) == "std"); } version (none) version(unittest) //Please uncomment me when changing packageName to test global imports { import core.sync.barrier; // global import static assert(packageName!core == "core"); static assert(packageName!(core.sync) == "core.sync"); static assert(packageName!Barrier == "core.sync"); } /** * Get the module name (including package) for the given symbol. */ template moduleName(alias T) { import std.algorithm.searching : startsWith; static assert(!T.stringof.startsWith("package "), "cannot get the module name for a package"); static if (T.stringof.startsWith("module ")) { static if (__traits(compiles, packageName!T)) enum packagePrefix = packageName!T ~ '.'; else enum packagePrefix = ""; enum moduleName = packagePrefix ~ T.stringof[7..$]; } else alias moduleName = moduleName!(parentOf!T); // If you use enum, it will cause compiler ICE } /// @safe unittest { static assert(moduleName!moduleName == "std.traits"); } @safe unittest { import std.array; static assert(!__traits(compiles, moduleName!std)); static assert(moduleName!(std.traits) == "std.traits"); // this module static assert(moduleName!moduleName == "std.traits"); // symbol in this module static assert(moduleName!(std.array) == "std.array"); // other module static assert(moduleName!(std.array.array) == "std.array"); // symbol in other module import core.sync.barrier; // local import static assert(!__traits(compiles, moduleName!(core.sync))); static assert(moduleName!(core.sync.barrier) == "core.sync.barrier"); static assert(moduleName!Barrier == "core.sync.barrier"); struct X12287(T) { T i; } static assert(moduleName!(X12287!int.i) == "std.traits"); } version (none) version(unittest) //Please uncomment me when changing moduleName to test global imports { import core.sync.barrier; // global import static assert(!__traits(compiles, moduleName!(core.sync))); static assert(moduleName!(core.sync.barrier) == "core.sync.barrier"); static assert(moduleName!Barrier == "core.sync.barrier"); } /*** * Get the fully qualified name of a type or a symbol. Can act as an intelligent type/symbol to string converter. Example: ----------------- module myModule; struct MyStruct {} static assert(fullyQualifiedName!(const MyStruct[]) == "const(myModule.MyStruct[])"); ----------------- */ template fullyQualifiedName(T...) if (T.length == 1) { static if (is(T)) enum fullyQualifiedName = fqnType!(T[0], false, false, false, false); else enum fullyQualifiedName = fqnSym!(T[0]); } /// @safe unittest { static assert(fullyQualifiedName!fullyQualifiedName == "std.traits.fullyQualifiedName"); } version(unittest) { // Used for both fqnType and fqnSym unittests private struct QualifiedNameTests { struct Inner { bool value; } ref const(Inner[string]) func( ref Inner var1, lazy scope string var2 ); ref const(Inner[string]) retfunc( return ref Inner var1 ); Inner inoutFunc(inout Inner) inout; shared(const(Inner[string])[]) data; const Inner delegate(double, string) @safe nothrow deleg; inout(int) delegate(inout int) inout inoutDeleg; Inner function(out double, string) funcPtr; extern(C) Inner function(double, string) cFuncPtr; extern(C) void cVarArg(int, ...); void dVarArg(...); void dVarArg2(int, ...); void typesafeVarArg(int[] ...); Inner[] array; Inner[16] sarray; Inner[Inner] aarray; const(Inner[const(Inner)]) qualAarray; shared(immutable(Inner) delegate(ref double, scope string) const shared @trusted nothrow) attrDeleg; struct Data(T) { int x; } void tfunc(T...)(T args) {} template Inst(alias A) { int x; } class Test12309(T, int x, string s) {} } private enum QualifiedEnum { a = 42 } } private template fqnSym(alias T : X!A, alias X, A...) { template fqnTuple(T...) { static if (T.length == 0) enum fqnTuple = ""; else static if (T.length == 1) { static if (isExpressionTuple!T) enum fqnTuple = T[0].stringof; else enum fqnTuple = fullyQualifiedName!(T[0]); } else enum fqnTuple = fqnTuple!(T[0]) ~ ", " ~ fqnTuple!(T[1 .. $]); } enum fqnSym = fqnSym!(__traits(parent, X)) ~ '.' ~ __traits(identifier, X) ~ "!(" ~ fqnTuple!A ~ ")"; } private template fqnSym(alias T) { static if (__traits(compiles, __traits(parent, T)) && !__traits(isSame, T, __traits(parent, T))) enum parentPrefix = fqnSym!(__traits(parent, T)) ~ "."; else enum parentPrefix = null; static string adjustIdent(string s) { import std.algorithm.searching : findSplit, skipOver; if (s.skipOver("package ") || s.skipOver("module ")) return s; return s.findSplit("(")[0]; } enum fqnSym = parentPrefix ~ adjustIdent(__traits(identifier, T)); } @safe unittest { alias fqn = fullyQualifiedName; // Make sure those 2 are the same static assert(fqnSym!fqn == fqn!fqn); static assert(fqn!fqn == "std.traits.fullyQualifiedName"); alias qnTests = QualifiedNameTests; enum prefix = "std.traits.QualifiedNameTests."; static assert(fqn!(qnTests.Inner) == prefix ~ "Inner"); static assert(fqn!(qnTests.func) == prefix ~ "func"); static assert(fqn!(qnTests.Data!int) == prefix ~ "Data!(int)"); static assert(fqn!(qnTests.Data!int.x) == prefix ~ "Data!(int).x"); static assert(fqn!(qnTests.tfunc!(int[])) == prefix ~ "tfunc!(int[])"); static assert(fqn!(qnTests.Inst!(Object)) == prefix ~ "Inst!(object.Object)"); static assert(fqn!(qnTests.Inst!(Object).x) == prefix ~ "Inst!(object.Object).x"); static assert(fqn!(qnTests.Test12309!(int, 10, "str")) == prefix ~ "Test12309!(int, 10, \"str\")"); import core.sync.barrier; static assert(fqn!Barrier == "core.sync.barrier.Barrier"); } @safe unittest { struct TemplatedStruct() { enum foo = 0; } alias TemplatedStructAlias = TemplatedStruct; assert("TemplatedStruct.foo" == fullyQualifiedName!(TemplatedStructAlias!().foo)); } private template fqnType(T, bool alreadyConst, bool alreadyImmutable, bool alreadyShared, bool alreadyInout) { import std.format : format; // Convenience tags enum { _const = 0, _immutable = 1, _shared = 2, _inout = 3 } alias qualifiers = AliasSeq!(is(T == const), is(T == immutable), is(T == shared), is(T == inout)); alias noQualifiers = AliasSeq!(false, false, false, false); string storageClassesString(uint psc)() @property { alias PSC = ParameterStorageClass; return format("%s%s%s%s%s", psc & PSC.scope_ ? "scope " : "", psc & PSC.return_ ? "return " : "", psc & PSC.out_ ? "out " : "", psc & PSC.ref_ ? "ref " : "", psc & PSC.lazy_ ? "lazy " : "" ); } string parametersTypeString(T)() @property { alias parameters = Parameters!(T); alias parameterStC = ParameterStorageClassTuple!(T); enum variadic = variadicFunctionStyle!T; static if (variadic == Variadic.no) enum variadicStr = ""; else static if (variadic == Variadic.c) enum variadicStr = ", ..."; else static if (variadic == Variadic.d) enum variadicStr = parameters.length ? ", ..." : "..."; else static if (variadic == Variadic.typesafe) enum variadicStr = " ..."; else static assert(0, "New variadic style has been added, please update fullyQualifiedName implementation"); static if (parameters.length) { import std.algorithm.iteration : map; import std.array : join; import std.meta : staticMap; import std.range : zip; string result = join( map!(a => format("%s%s", a[0], a[1]))( zip([staticMap!(storageClassesString, parameterStC)], [staticMap!(fullyQualifiedName, parameters)]) ), ", " ); return result ~= variadicStr; } else return variadicStr; } string linkageString(T)() @property { enum linkage = functionLinkage!T; if (linkage != "D") return format("extern(%s) ", linkage); else return ""; } string functionAttributeString(T)() @property { alias FA = FunctionAttribute; enum attrs = functionAttributes!T; static if (attrs == FA.none) return ""; else return format("%s%s%s%s%s%s%s%s", attrs & FA.pure_ ? " pure" : "", attrs & FA.nothrow_ ? " nothrow" : "", attrs & FA.ref_ ? " ref" : "", attrs & FA.property ? " @property" : "", attrs & FA.trusted ? " @trusted" : "", attrs & FA.safe ? " @safe" : "", attrs & FA.nogc ? " @nogc" : "", attrs & FA.return_ ? " return" : "" ); } string addQualifiers(string typeString, bool addConst, bool addImmutable, bool addShared, bool addInout) { auto result = typeString; if (addShared) { result = format("shared(%s)", result); } if (addConst || addImmutable || addInout) { result = format("%s(%s)", addConst ? "const" : addImmutable ? "immutable" : "inout", result ); } return result; } // Convenience template to avoid copy-paste template chain(string current) { enum chain = addQualifiers(current, qualifiers[_const] && !alreadyConst, qualifiers[_immutable] && !alreadyImmutable, qualifiers[_shared] && !alreadyShared, qualifiers[_inout] && !alreadyInout); } static if (is(T == string)) { enum fqnType = "string"; } else static if (is(T == wstring)) { enum fqnType = "wstring"; } else static if (is(T == dstring)) { enum fqnType = "dstring"; } else static if (isBasicType!T && !is(T == enum)) { enum fqnType = chain!((Unqual!T).stringof); } else static if (isAggregateType!T || is(T == enum)) { enum fqnType = chain!(fqnSym!T); } else static if (isStaticArray!T) { enum fqnType = chain!( format("%s[%s]", fqnType!(typeof(T.init[0]), qualifiers), T.length) ); } else static if (isArray!T) { enum fqnType = chain!( format("%s[]", fqnType!(typeof(T.init[0]), qualifiers)) ); } else static if (isAssociativeArray!T) { enum fqnType = chain!( format("%s[%s]", fqnType!(ValueType!T, qualifiers), fqnType!(KeyType!T, noQualifiers)) ); } else static if (isSomeFunction!T) { static if (is(T F == delegate)) { enum qualifierString = format("%s%s", is(F == shared) ? " shared" : "", is(F == inout) ? " inout" : is(F == immutable) ? " immutable" : is(F == const) ? " const" : "" ); enum formatStr = "%s%s delegate(%s)%s%s"; enum fqnType = chain!( format(formatStr, linkageString!T, fqnType!(ReturnType!T, noQualifiers), parametersTypeString!(T), functionAttributeString!T, qualifierString) ); } else { static if (isFunctionPointer!T) enum formatStr = "%s%s function(%s)%s"; else enum formatStr = "%s%s(%s)%s"; enum fqnType = chain!( format(formatStr, linkageString!T, fqnType!(ReturnType!T, noQualifiers), parametersTypeString!(T), functionAttributeString!T) ); } } else static if (isPointer!T) { enum fqnType = chain!( format("%s*", fqnType!(PointerTarget!T, qualifiers)) ); } else static if (is(T : __vector(V[N]), V, size_t N)) { enum fqnType = chain!( format("__vector(%s[%s])", fqnType!(V, qualifiers), N) ); } else // In case something is forgotten static assert(0, "Unrecognized type " ~ T.stringof ~ ", can't convert to fully qualified string"); } @safe unittest { import std.format : format; alias fqn = fullyQualifiedName; // Verify those 2 are the same for simple case alias Ambiguous = const(QualifiedNameTests.Inner); static assert(fqn!Ambiguous == fqnType!(Ambiguous, false, false, false, false)); // Main tests enum inner_name = "std.traits.QualifiedNameTests.Inner"; with (QualifiedNameTests) { // Special cases static assert(fqn!(string) == "string"); static assert(fqn!(wstring) == "wstring"); static assert(fqn!(dstring) == "dstring"); static assert(fqn!(void) == "void"); static assert(fqn!(const(void)) == "const(void)"); static assert(fqn!(shared(void)) == "shared(void)"); static assert(fqn!(shared const(void)) == "const(shared(void))"); static assert(fqn!(shared inout(void)) == "inout(shared(void))"); static assert(fqn!(shared inout const(void)) == "const(shared(void))"); static assert(fqn!(inout(void)) == "inout(void)"); static assert(fqn!(inout const(void)) == "const(void)"); static assert(fqn!(immutable(void)) == "immutable(void)"); // Basic qualified name static assert(fqn!(Inner) == inner_name); static assert(fqn!(QualifiedEnum) == "std.traits.QualifiedEnum"); // type static assert(fqn!(QualifiedEnum.a) == "std.traits.QualifiedEnum.a"); // symbol // Array types static assert(fqn!(typeof(array)) == format("%s[]", inner_name)); static assert(fqn!(typeof(sarray)) == format("%s[16]", inner_name)); static assert(fqn!(typeof(aarray)) == format("%s[%s]", inner_name, inner_name)); // qualified key for AA static assert(fqn!(typeof(qualAarray)) == format("const(%s[const(%s)])", inner_name, inner_name)); // Qualified composed data types static assert(fqn!(typeof(data)) == format("shared(const(%s[string])[])", inner_name)); // Function types + function attributes static assert(fqn!(typeof(func)) == format("const(%s[string])(ref %s, scope lazy string) ref", inner_name, inner_name)); static assert(fqn!(typeof(retfunc)) == format("const(%s[string])(return %s) ref", inner_name, inner_name)); static assert(fqn!(typeof(inoutFunc)) == format("inout(%s(inout(%s)))", inner_name, inner_name)); static assert(fqn!(typeof(deleg)) == format("const(%s delegate(double, string) nothrow @safe)", inner_name)); static assert(fqn!(typeof(inoutDeleg)) == "inout(int) delegate(inout(int)) inout"); static assert(fqn!(typeof(funcPtr)) == format("%s function(out double, string)", inner_name)); static assert(fqn!(typeof(cFuncPtr)) == format("extern(C) %s function(double, string)", inner_name)); // Delegate type with qualified function type static assert(fqn!(typeof(attrDeleg)) == format("shared(immutable(%s) "~ "delegate(ref double, scope string) nothrow @trusted shared const)", inner_name)); // Variable argument function types static assert(fqn!(typeof(cVarArg)) == "extern(C) void(int, ...)"); static assert(fqn!(typeof(dVarArg)) == "void(...)"); static assert(fqn!(typeof(dVarArg2)) == "void(int, ...)"); static assert(fqn!(typeof(typesafeVarArg)) == "void(int[] ...)"); // SIMD vector static if (is(__vector(float[4]))) { static assert(fqn!(__vector(float[4])) == "__vector(float[4])"); } } } /*** * Get the type of the return value from a function, * a pointer to function, a delegate, a struct * with an opCall, a pointer to a struct with an opCall, * or a class with an $(D opCall). Please note that $(D_KEYWORD ref) * is not part of a type, but the attribute of the function * (see template $(LREF functionAttributes)). */ template ReturnType(func...) if (func.length == 1 && isCallable!func) { static if (is(FunctionTypeOf!func R == return)) alias ReturnType = R; else static assert(0, "argument has no return type"); } /// @safe unittest { int foo(); ReturnType!foo x; // x is declared as int } @safe unittest { struct G { int opCall (int i) { return 1;} } alias ShouldBeInt = ReturnType!G; static assert(is(ShouldBeInt == int)); G g; static assert(is(ReturnType!g == int)); G* p; alias pg = ReturnType!p; static assert(is(pg == int)); class C { int opCall (int i) { return 1;} } static assert(is(ReturnType!C == int)); C c; static assert(is(ReturnType!c == int)); class Test { int prop() @property { return 0; } } alias R_Test_prop = ReturnType!(Test.prop); static assert(is(R_Test_prop == int)); alias R_dglit = ReturnType!((int a) { return a; }); static assert(is(R_dglit == int)); } /*** Get, as a tuple, the types of the parameters to a function, a pointer to function, a delegate, a struct with an $(D opCall), a pointer to a struct with an $(D opCall), or a class with an $(D opCall). */ template Parameters(func...) if (func.length == 1 && isCallable!func) { static if (is(FunctionTypeOf!func P == function)) alias Parameters = P; else static assert(0, "argument has no parameters"); } /// @safe unittest { int foo(int, long); void bar(Parameters!foo); // declares void bar(int, long); void abc(Parameters!foo[1]); // declares void abc(long); } /** * Alternate name for $(LREF Parameters), kept for legacy compatibility. */ alias ParameterTypeTuple = Parameters; @safe unittest { int foo(int i, bool b) { return 0; } static assert(is(ParameterTypeTuple!foo == AliasSeq!(int, bool))); static assert(is(ParameterTypeTuple!(typeof(&foo)) == AliasSeq!(int, bool))); struct S { real opCall(real r, int i) { return 0.0; } } S s; static assert(is(ParameterTypeTuple!S == AliasSeq!(real, int))); static assert(is(ParameterTypeTuple!(S*) == AliasSeq!(real, int))); static assert(is(ParameterTypeTuple!s == AliasSeq!(real, int))); class Test { int prop() @property { return 0; } } alias P_Test_prop = ParameterTypeTuple!(Test.prop); static assert(P_Test_prop.length == 0); alias P_dglit = ParameterTypeTuple!((int a){}); static assert(P_dglit.length == 1); static assert(is(P_dglit[0] == int)); } /** Returns the number of arguments of function $(D func). arity is undefined for variadic functions. */ template arity(func...) if (func.length == 1 && isCallable!func && variadicFunctionStyle!func == Variadic.no) { enum size_t arity = Parameters!func.length; } /// @safe unittest { void foo(){} static assert(arity!foo == 0); void bar(uint){} static assert(arity!bar == 1); void variadicFoo(uint...){} static assert(!__traits(compiles, arity!variadicFoo)); } @safe unittest // issue 11389 { alias TheType = size_t function( string[] ); static assert(arity!TheType == 1); } /** Get tuple, one per function parameter, of the storage classes of the parameters. Params: func = function symbol or type of function, delegate, or pointer to function Returns: A tuple of ParameterStorageClass bits */ enum ParameterStorageClass : uint { /** * These flags can be bitwise OR-ed together to represent complex storage * class. */ none = 0, scope_ = 1, /// ditto out_ = 2, /// ditto ref_ = 4, /// ditto lazy_ = 8, /// ditto return_ = 0x10, /// ditto } /// ditto template ParameterStorageClassTuple(func...) if (func.length == 1 && isCallable!func) { alias Func = FunctionTypeOf!func; static if (is(Func PT == __parameters)) { template StorageClass(size_t i) { static if (i < PT.length) { alias StorageClass = AliasSeq!( extractParameterStorageClassFlags!(__traits(getParameterStorageClasses, Func, i)), StorageClass!(i + 1)); } else alias StorageClass = AliasSeq!(); } alias ParameterStorageClassTuple = StorageClass!0; } else { static assert(0, func[0].stringof ~ " is not a function"); alias ParameterStorageClassTuple = AliasSeq!(); } } /// @safe unittest { alias STC = ParameterStorageClass; // shorten the enum name void func(ref int ctx, out real result, real param) { } alias pstc = ParameterStorageClassTuple!func; static assert(pstc.length == 3); // three parameters static assert(pstc[0] == STC.ref_); static assert(pstc[1] == STC.out_); static assert(pstc[2] == STC.none); } /***************** * Convert string tuple Attribs to ParameterStorageClass bits * Params: * Attribs = string tuple * Returns: * ParameterStorageClass bits */ template extractParameterStorageClassFlags(Attribs...) { enum ParameterStorageClass extractParameterStorageClassFlags = () { auto result = ParameterStorageClass.none; static if (Attribs.length > 0) { static foreach (attrib; Attribs) { final switch (attrib) with (ParameterStorageClass) { case "scope": result |= scope_; break; case "out": result |= out_; break; case "ref": result |= ref_; break; case "lazy": result |= lazy_; break; case "return": result |= return_; break; } } /* Mimic behavor of original version of ParameterStorageClassTuple() * to avoid breaking existing code. */ if (result == (ParameterStorageClass.ref_ | ParameterStorageClass.return_)) result = ParameterStorageClass.return_; } return result; }(); } @safe unittest { alias STC = ParameterStorageClass; void noparam() {} static assert(ParameterStorageClassTuple!noparam.length == 0); ref int test(scope int*, ref int, out int, lazy int, int, return ref int i) { return i; } alias test_pstc = ParameterStorageClassTuple!test; static assert(test_pstc.length == 6); static assert(test_pstc[0] == STC.scope_); static assert(test_pstc[1] == STC.ref_); static assert(test_pstc[2] == STC.out_); static assert(test_pstc[3] == STC.lazy_); static assert(test_pstc[4] == STC.none); static assert(test_pstc[5] == STC.return_); interface Test { void test_const(int) const; void test_sharedconst(int) shared const; } Test testi; alias test_const_pstc = ParameterStorageClassTuple!(Test.test_const); static assert(test_const_pstc.length == 1); static assert(test_const_pstc[0] == STC.none); alias test_sharedconst_pstc = ParameterStorageClassTuple!(testi.test_sharedconst); static assert(test_sharedconst_pstc.length == 1); static assert(test_sharedconst_pstc[0] == STC.none); alias dglit_pstc = ParameterStorageClassTuple!((ref int a) {}); static assert(dglit_pstc.length == 1); static assert(dglit_pstc[0] == STC.ref_); // Bugzilla 9317 static inout(int) func(inout int param) { return param; } static assert(ParameterStorageClassTuple!(typeof(func))[0] == STC.none); } @safe unittest { // Bugzilla 14253 static struct Foo { ref Foo opAssign(ref Foo rhs) return { return this; } } alias tup = ParameterStorageClassTuple!(__traits(getOverloads, Foo, "opAssign")[0]); } /** Get, as a tuple, the identifiers of the parameters to a function symbol. */ template ParameterIdentifierTuple(func...) if (func.length == 1 && isCallable!func) { static if (is(FunctionTypeOf!func PT == __parameters)) { template Get(size_t i) { static if (!isFunctionPointer!func && !isDelegate!func // Unnamed parameters yield CT error. && is(typeof(__traits(identifier, PT[i .. i+1])))) { enum Get = __traits(identifier, PT[i .. i+1]); } else { enum Get = ""; } } } else { static assert(0, func[0].stringof ~ "is not a function"); // Define dummy entities to avoid pointless errors template Get(size_t i) { enum Get = ""; } alias PT = AliasSeq!(); } template Impl(size_t i = 0) { static if (i == PT.length) alias Impl = AliasSeq!(); else alias Impl = AliasSeq!(Get!i, Impl!(i+1)); } alias ParameterIdentifierTuple = Impl!(); } /// @safe unittest { int foo(int num, string name, int); static assert([ParameterIdentifierTuple!foo] == ["num", "name", ""]); } @safe unittest { alias PIT = ParameterIdentifierTuple; void bar(int num, string name, int[] array){} static assert([PIT!bar] == ["num", "name", "array"]); // might be changed in the future? void function(int num, string name) fp; static assert([PIT!fp] == ["", ""]); // might be changed in the future? void delegate(int num, string name, int[long] aa) dg; static assert([PIT!dg] == ["", "", ""]); interface Test { @property string getter(); @property void setter(int a); Test method(int a, long b, string c); } static assert([PIT!(Test.getter)] == []); static assert([PIT!(Test.setter)] == ["a"]); static assert([PIT!(Test.method)] == ["a", "b", "c"]); /+ // depends on internal void baw(int, string, int[]){} static assert([PIT!baw] == ["_param_0", "_param_1", "_param_2"]); // depends on internal void baz(AliasSeq!(int, string, int[]) args){} static assert([PIT!baz] == ["_param_0", "_param_1", "_param_2"]); +/ } /** Get, as a tuple, the default value of the parameters to a function symbol. If a parameter doesn't have the default value, $(D void) is returned instead. */ template ParameterDefaults(func...) if (func.length == 1 && isCallable!func) { alias param_names = ParameterIdentifierTuple!func; static if (is(FunctionTypeOf!(func[0]) PT == __parameters)) { template Get(size_t i) { // `PT[i .. i+1]` declares a parameter with an arbitrary name. // To avoid a name clash, generate local names that are distinct // from the parameter name, and mix them in. enum name = param_names[i]; enum args = "args" ~ (name == "args" ? "_" : ""); enum val = "val" ~ (name == "val" ? "_" : ""); enum ptr = "ptr" ~ (name == "ptr" ? "_" : ""); mixin(" // workaround scope escape check, see // https://issues.dlang.org/show_bug.cgi?id=16582 // should use return scope once available enum get = (PT[i .. i+1] " ~ args ~ ") @trusted { // If the parameter is lazy, we force it to be evaluated // like this. auto " ~ val ~ " = " ~ args ~ "[0]; auto " ~ ptr ~ " = &" ~ val ~ "; // workaround Bugzilla 16582 return *" ~ ptr ~ "; }; "); static if (is(typeof(get()))) enum Get = get(); else alias Get = void; // If default arg doesn't exist, returns void instead. } } else { static assert(0, func[0].stringof ~ "is not a function"); // Define dummy entities to avoid pointless errors template Get(size_t i) { enum Get = ""; } alias PT = AliasSeq!(); } template Impl(size_t i = 0) { static if (i == PT.length) alias Impl = AliasSeq!(); else alias Impl = AliasSeq!(Get!i, Impl!(i+1)); } alias ParameterDefaults = Impl!(); } /// @safe unittest { int foo(int num, string name = "hello", int[] = [1,2,3], lazy int x = 0); static assert(is(ParameterDefaults!foo[0] == void)); static assert( ParameterDefaults!foo[1] == "hello"); static assert( ParameterDefaults!foo[2] == [1,2,3]); static assert( ParameterDefaults!foo[3] == 0); } @safe unittest // issue 17192 { static void func(int i, int PT, int __pd_value, int __pd_val, int __args, int name, int args, int val, int ptr, int args_, int val_, int ptr_) { } alias Voids = ParameterDefaults!func; static assert(Voids.length == 12); static foreach (V; Voids) static assert(is(V == void)); } /** * Alternate name for $(LREF ParameterDefaults), kept for legacy compatibility. */ alias ParameterDefaultValueTuple = ParameterDefaults; @safe unittest { alias PDVT = ParameterDefaultValueTuple; void bar(int n = 1, string s = "hello"){} static assert(PDVT!bar.length == 2); static assert(PDVT!bar[0] == 1); static assert(PDVT!bar[1] == "hello"); static assert(is(typeof(PDVT!bar) == typeof(AliasSeq!(1, "hello")))); void baz(int x, int n = 1, string s = "hello"){} static assert(PDVT!baz.length == 3); static assert(is(PDVT!baz[0] == void)); static assert( PDVT!baz[1] == 1); static assert( PDVT!baz[2] == "hello"); static assert(is(typeof(PDVT!baz) == typeof(AliasSeq!(void, 1, "hello")))); // bug 10800 - property functions return empty string @property void foo(int x = 3) { } static assert(PDVT!foo.length == 1); static assert(PDVT!foo[0] == 3); static assert(is(typeof(PDVT!foo) == typeof(AliasSeq!(3)))); struct Colour { ubyte a,r,g,b; static immutable Colour white = Colour(255,255,255,255); } void bug8106(Colour c = Colour.white) {} //pragma(msg, PDVT!bug8106); static assert(PDVT!bug8106[0] == Colour.white); void bug16582(scope int* val = null) {} static assert(PDVT!bug16582[0] is null); } /** Returns the FunctionAttribute mask for function $(D func). See_Also: $(LREF hasFunctionAttributes) */ enum FunctionAttribute : uint { /** * These flags can be bitwise OR-ed together to represent a complex attribute. */ none = 0, pure_ = 1 << 0, /// ditto nothrow_ = 1 << 1, /// ditto ref_ = 1 << 2, /// ditto property = 1 << 3, /// ditto trusted = 1 << 4, /// ditto safe = 1 << 5, /// ditto nogc = 1 << 6, /// ditto system = 1 << 7, /// ditto const_ = 1 << 8, /// ditto immutable_ = 1 << 9, /// ditto inout_ = 1 << 10, /// ditto shared_ = 1 << 11, /// ditto return_ = 1 << 12, /// ditto scope_ = 1 << 13, /// ditto } /// ditto template functionAttributes(func...) if (func.length == 1 && isCallable!func) { // @bug: workaround for opCall alias FuncSym = Select!(is(typeof(__traits(getFunctionAttributes, func))), func, Unqual!(FunctionTypeOf!func)); enum FunctionAttribute functionAttributes = extractAttribFlags!(__traits(getFunctionAttributes, FuncSym))(); } /// @safe unittest { alias FA = FunctionAttribute; // shorten the enum name real func(real x) pure nothrow @safe { return x; } static assert(functionAttributes!func & FA.pure_); static assert(functionAttributes!func & FA.safe); static assert(!(functionAttributes!func & FA.trusted)); // not @trusted } @system unittest { alias FA = FunctionAttribute; struct S { int noF() { return 0; } int constF() const { return 0; } int immutableF() immutable { return 0; } int inoutF() inout { return 0; } int sharedF() shared { return 0; } int x; ref int refF() return { return x; } int propertyF() @property { return 0; } int nothrowF() nothrow { return 0; } int nogcF() @nogc { return 0; } int systemF() @system { return 0; } int trustedF() @trusted { return 0; } int safeF() @safe { return 0; } int pureF() pure { return 0; } } static assert(functionAttributes!(S.noF) == FA.system); static assert(functionAttributes!(typeof(S.noF)) == FA.system); static assert(functionAttributes!(S.constF) == (FA.const_ | FA.system)); static assert(functionAttributes!(typeof(S.constF)) == (FA.const_ | FA.system)); static assert(functionAttributes!(S.immutableF) == (FA.immutable_ | FA.system)); static assert(functionAttributes!(typeof(S.immutableF)) == (FA.immutable_ | FA.system)); static assert(functionAttributes!(S.inoutF) == (FA.inout_ | FA.system)); static assert(functionAttributes!(typeof(S.inoutF)) == (FA.inout_ | FA.system)); static assert(functionAttributes!(S.sharedF) == (FA.shared_ | FA.system)); static assert(functionAttributes!(typeof(S.sharedF)) == (FA.shared_ | FA.system)); static assert(functionAttributes!(S.refF) == (FA.ref_ | FA.system | FA.return_)); static assert(functionAttributes!(typeof(S.refF)) == (FA.ref_ | FA.system | FA.return_)); static assert(functionAttributes!(S.propertyF) == (FA.property | FA.system)); static assert(functionAttributes!(typeof(&S.propertyF)) == (FA.property | FA.system)); static assert(functionAttributes!(S.nothrowF) == (FA.nothrow_ | FA.system)); static assert(functionAttributes!(typeof(S.nothrowF)) == (FA.nothrow_ | FA.system)); static assert(functionAttributes!(S.nogcF) == (FA.nogc | FA.system)); static assert(functionAttributes!(typeof(S.nogcF)) == (FA.nogc | FA.system)); static assert(functionAttributes!(S.systemF) == FA.system); static assert(functionAttributes!(typeof(S.systemF)) == FA.system); static assert(functionAttributes!(S.trustedF) == FA.trusted); static assert(functionAttributes!(typeof(S.trustedF)) == FA.trusted); static assert(functionAttributes!(S.safeF) == FA.safe); static assert(functionAttributes!(typeof(S.safeF)) == FA.safe); static assert(functionAttributes!(S.pureF) == (FA.pure_ | FA.system)); static assert(functionAttributes!(typeof(S.pureF)) == (FA.pure_ | FA.system)); int pure_nothrow() nothrow pure; void safe_nothrow() @safe nothrow; static ref int static_ref_property() @property; ref int ref_property() @property; static assert(functionAttributes!(pure_nothrow) == (FA.pure_ | FA.nothrow_ | FA.system)); static assert(functionAttributes!(typeof(pure_nothrow)) == (FA.pure_ | FA.nothrow_ | FA.system)); static assert(functionAttributes!(safe_nothrow) == (FA.safe | FA.nothrow_)); static assert(functionAttributes!(typeof(safe_nothrow)) == (FA.safe | FA.nothrow_)); static assert(functionAttributes!(static_ref_property) == (FA.property | FA.ref_ | FA.system)); static assert(functionAttributes!(typeof(&static_ref_property)) == (FA.property | FA.ref_ | FA.system)); static assert(functionAttributes!(ref_property) == (FA.property | FA.ref_ | FA.system)); static assert(functionAttributes!(typeof(&ref_property)) == (FA.property | FA.ref_ | FA.system)); struct S2 { int pure_const() const pure { return 0; } int pure_sharedconst() const shared pure { return 0; } } static assert(functionAttributes!(S2.pure_const) == (FA.const_ | FA.pure_ | FA.system)); static assert(functionAttributes!(typeof(S2.pure_const)) == (FA.const_ | FA.pure_ | FA.system)); static assert(functionAttributes!(S2.pure_sharedconst) == (FA.const_ | FA.shared_ | FA.pure_ | FA.system)); static assert(functionAttributes!(typeof(S2.pure_sharedconst)) == (FA.const_ | FA.shared_ | FA.pure_ | FA.system)); static assert(functionAttributes!((int a) { }) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.safe)); static assert(functionAttributes!(typeof((int a) { })) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.safe)); auto safeDel = delegate() @safe { }; static assert(functionAttributes!(safeDel) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.safe)); static assert(functionAttributes!(typeof(safeDel)) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.safe)); auto trustedDel = delegate() @trusted { }; static assert(functionAttributes!(trustedDel) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.trusted)); static assert(functionAttributes!(typeof(trustedDel)) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.trusted)); auto systemDel = delegate() @system { }; static assert(functionAttributes!(systemDel) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.system)); static assert(functionAttributes!(typeof(systemDel)) == (FA.pure_ | FA.nothrow_ | FA.nogc | FA.system)); } private FunctionAttribute extractAttribFlags(Attribs...)() { auto res = FunctionAttribute.none; static foreach (attrib; Attribs) { switch (attrib) with (FunctionAttribute) { case "pure": res |= pure_; break; case "nothrow": res |= nothrow_; break; case "ref": res |= ref_; break; case "@property": res |= property; break; case "@trusted": res |= trusted; break; case "@safe": res |= safe; break; case "@nogc": res |= nogc; break; case "@system": res |= system; break; case "const": res |= const_; break; case "immutable": res |= immutable_; break; case "inout": res |= inout_; break; case "shared": res |= shared_; break; case "return": res |= return_; break; case "scope": res |= scope_; break; default: assert(0, attrib); } } return res; } /** Checks whether a function has the given attributes attached. Params: args = Function to check, followed by a variadic number of function attributes as strings Returns: `true`, if the function has the list of attributes attached and `false` otherwise. See_Also: $(LREF functionAttributes) */ template hasFunctionAttributes(args...) if (args.length > 0 && isCallable!(args[0]) && allSatisfy!(isSomeString, typeof(args[1 .. $]))) { enum bool hasFunctionAttributes = { import std.algorithm.searching : canFind; import std.range : only; enum funcAttribs = only(__traits(getFunctionAttributes, args[0])); static foreach (attribute; args[1 .. $]) { if (!funcAttribs.canFind(attribute)) return false; } return true; }(); } /// @safe unittest { real func(real x) pure nothrow @safe; static assert(hasFunctionAttributes!(func, "@safe", "pure")); static assert(!hasFunctionAttributes!(func, "@trusted")); // for templates attributes are automatically inferred bool myFunc(T)(T b) { return !b; } static assert(hasFunctionAttributes!(myFunc!bool, "@safe", "pure", "@nogc", "nothrow")); static assert(!hasFunctionAttributes!(myFunc!bool, "shared")); } @system unittest { struct S { int noF(); int constF() const; int immutableF() immutable; int inoutF() inout; int sharedF() shared; ref int refF() return; int propertyF() @property; int nothrowF() nothrow; int nogcF() @nogc; int systemF() @system; int trustedF() @trusted; int safeF() @safe; int pureF() pure; } // true if no args passed static assert(hasFunctionAttributes!(S.noF)); static assert(hasFunctionAttributes!(S.noF, "@system")); static assert(hasFunctionAttributes!(typeof(S.noF), "@system")); static assert(!hasFunctionAttributes!(S.noF, "@system", "pure")); static assert(hasFunctionAttributes!(S.constF, "const", "@system")); static assert(hasFunctionAttributes!(typeof(S.constF), "const", "@system")); static assert(!hasFunctionAttributes!(S.constF, "const", "@system", "@nogc")); static assert(hasFunctionAttributes!(S.immutableF, "immutable", "@system")); static assert(hasFunctionAttributes!(typeof(S.immutableF), "immutable", "@system")); static assert(!hasFunctionAttributes!(S.immutableF, "immutable", "@system", "pure")); static assert(hasFunctionAttributes!(S.inoutF, "inout", "@system")); static assert(hasFunctionAttributes!(typeof(S.inoutF), "inout", "@system")); static assert(!hasFunctionAttributes!(S.inoutF, "inout", "@system", "pure")); static assert(hasFunctionAttributes!(S.sharedF, "shared", "@system")); static assert(hasFunctionAttributes!(typeof(S.sharedF), "shared", "@system")); static assert(!hasFunctionAttributes!(S.sharedF, "shared", "@system", "@trusted")); static assert(hasFunctionAttributes!(S.refF, "ref", "@system", "return")); static assert(hasFunctionAttributes!(typeof(S.refF), "ref", "@system", "return")); static assert(!hasFunctionAttributes!(S.refF, "ref", "@system", "return", "pure")); static assert(hasFunctionAttributes!(S.propertyF, "@property", "@system")); static assert(hasFunctionAttributes!(typeof(&S.propertyF), "@property", "@system")); static assert(!hasFunctionAttributes!(S.propertyF, "@property", "@system", "ref")); static assert(hasFunctionAttributes!(S.nothrowF, "nothrow", "@system")); static assert(hasFunctionAttributes!(typeof(S.nothrowF), "nothrow", "@system")); static assert(!hasFunctionAttributes!(S.nothrowF, "nothrow", "@system", "@trusted")); static assert(hasFunctionAttributes!(S.nogcF, "@nogc", "@system")); static assert(hasFunctionAttributes!(typeof(S.nogcF), "@nogc", "@system")); static assert(!hasFunctionAttributes!(S.nogcF, "@nogc", "@system", "ref")); static assert(hasFunctionAttributes!(S.systemF, "@system")); static assert(hasFunctionAttributes!(typeof(S.systemF), "@system")); static assert(!hasFunctionAttributes!(S.systemF, "@system", "ref")); static assert(hasFunctionAttributes!(S.trustedF, "@trusted")); static assert(hasFunctionAttributes!(typeof(S.trustedF), "@trusted")); static assert(!hasFunctionAttributes!(S.trustedF, "@trusted", "@safe")); static assert(hasFunctionAttributes!(S.safeF, "@safe")); static assert(hasFunctionAttributes!(typeof(S.safeF), "@safe")); static assert(!hasFunctionAttributes!(S.safeF, "@safe", "nothrow")); static assert(hasFunctionAttributes!(S.pureF, "pure", "@system")); static assert(hasFunctionAttributes!(typeof(S.pureF), "pure", "@system")); static assert(!hasFunctionAttributes!(S.pureF, "pure", "@system", "ref")); int pure_nothrow() nothrow pure { return 0; } void safe_nothrow() @safe nothrow { } static ref int static_ref_property() @property { return *(new int); } ref int ref_property() @property { return *(new int); } static assert(hasFunctionAttributes!(pure_nothrow, "pure", "nothrow", "@safe")); static assert(hasFunctionAttributes!(typeof(pure_nothrow), "pure", "nothrow", "@safe")); static assert(!hasFunctionAttributes!(pure_nothrow, "pure", "nothrow", "@safe", "@trusted")); static assert(hasFunctionAttributes!(safe_nothrow, "@safe", "nothrow")); static assert(hasFunctionAttributes!(typeof(safe_nothrow), "@safe", "nothrow")); static assert(hasFunctionAttributes!(safe_nothrow, "@safe", "nothrow", "pure")); static assert(!hasFunctionAttributes!(safe_nothrow, "@safe", "nothrow", "pure", "@trusted")); static assert(hasFunctionAttributes!(static_ref_property, "@property", "ref", "@safe")); static assert(hasFunctionAttributes!(typeof(&static_ref_property), "@property", "ref", "@safe")); static assert(hasFunctionAttributes!(static_ref_property, "@property", "ref", "@safe", "nothrow")); static assert(!hasFunctionAttributes!(static_ref_property, "@property", "ref", "@safe", "nothrow", "@nogc")); static assert(hasFunctionAttributes!(ref_property, "@property", "ref", "@safe")); static assert(hasFunctionAttributes!(typeof(&ref_property), "@property", "ref", "@safe")); static assert(!hasFunctionAttributes!(ref_property, "@property", "ref", "@safe", "@nogc")); struct S2 { int pure_const() const pure { return 0; } int pure_sharedconst() const shared pure { return 0; } } static assert(hasFunctionAttributes!(S2.pure_const, "const", "pure", "@system")); static assert(hasFunctionAttributes!(typeof(S2.pure_const), "const", "pure", "@system")); static assert(!hasFunctionAttributes!(S2.pure_const, "const", "pure", "@system", "ref")); static assert(hasFunctionAttributes!(S2.pure_sharedconst, "const", "shared", "pure", "@system")); static assert(hasFunctionAttributes!(typeof(S2.pure_sharedconst), "const", "shared", "pure", "@system")); static assert(!hasFunctionAttributes!(S2.pure_sharedconst, "const", "shared", "pure", "@system", "@nogc")); static assert(hasFunctionAttributes!((int a) { }, "pure", "nothrow", "@nogc", "@safe")); static assert(hasFunctionAttributes!(typeof((int a) { }), "pure", "nothrow", "@nogc", "@safe")); static assert(!hasFunctionAttributes!((int a) { }, "pure", "nothrow", "@nogc", "@safe", "ref")); auto safeDel = delegate() @safe { }; static assert(hasFunctionAttributes!(safeDel, "pure", "nothrow", "@nogc", "@safe")); static assert(hasFunctionAttributes!(typeof(safeDel), "pure", "nothrow", "@nogc", "@safe")); static assert(!hasFunctionAttributes!(safeDel, "pure", "nothrow", "@nogc", "@safe", "@system")); auto trustedDel = delegate() @trusted { }; static assert(hasFunctionAttributes!(trustedDel, "pure", "nothrow", "@nogc", "@trusted")); static assert(hasFunctionAttributes!(typeof(trustedDel), "pure", "nothrow", "@nogc", "@trusted")); static assert(!hasFunctionAttributes!(trustedDel, "pure", "nothrow", "@nogc", "@trusted", "ref")); auto systemDel = delegate() @system { }; static assert(hasFunctionAttributes!(systemDel, "pure", "nothrow", "@nogc", "@system")); static assert(hasFunctionAttributes!(typeof(systemDel), "pure", "nothrow", "@nogc", "@system")); static assert(!hasFunctionAttributes!(systemDel, "pure", "nothrow", "@nogc", "@system", "@property")); // call functions to make CodeCov happy { assert(pure_nothrow == 0); safe_nothrow; assert(static_ref_property == 0); assert(ref_property == 0); assert(S2().pure_const == 0); assert((shared S2()).pure_sharedconst == 0); cast(void) safeDel; cast(void) trustedDel; cast(void) systemDel; } } /** $(D true) if $(D func) is $(D @safe) or $(D @trusted). */ template isSafe(alias func) if (isCallable!func) { enum isSafe = (functionAttributes!func & FunctionAttribute.safe) != 0 || (functionAttributes!func & FunctionAttribute.trusted) != 0; } /// @safe unittest { @safe int add(int a, int b) {return a+b;} @trusted int sub(int a, int b) {return a-b;} @system int mul(int a, int b) {return a*b;} static assert( isSafe!add); static assert( isSafe!sub); static assert(!isSafe!mul); } @safe unittest { //Member functions interface Set { int systemF() @system; int trustedF() @trusted; int safeF() @safe; } static assert( isSafe!(Set.safeF)); static assert( isSafe!(Set.trustedF)); static assert(!isSafe!(Set.systemF)); //Functions @safe static safeFunc() {} @trusted static trustedFunc() {} @system static systemFunc() {} static assert( isSafe!safeFunc); static assert( isSafe!trustedFunc); static assert(!isSafe!systemFunc); //Delegates auto safeDel = delegate() @safe {}; auto trustedDel = delegate() @trusted {}; auto systemDel = delegate() @system {}; static assert( isSafe!safeDel); static assert( isSafe!trustedDel); static assert(!isSafe!systemDel); //Lambdas static assert( isSafe!({safeDel();})); static assert( isSafe!({trustedDel();})); static assert(!isSafe!({systemDel();})); //Static opCall struct SafeStatic { @safe static SafeStatic opCall() { return SafeStatic.init; } } struct TrustedStatic { @trusted static TrustedStatic opCall() { return TrustedStatic.init; } } struct SystemStatic { @system static SystemStatic opCall() { return SystemStatic.init; } } static assert( isSafe!(SafeStatic())); static assert( isSafe!(TrustedStatic())); static assert(!isSafe!(SystemStatic())); //Non-static opCall struct Safe { @safe Safe opCall() { return Safe.init; } } struct Trusted { @trusted Trusted opCall() { return Trusted.init; } } struct System { @system System opCall() { return System.init; } } static assert( isSafe!(Safe.init())); static assert( isSafe!(Trusted.init())); static assert(!isSafe!(System.init())); } /** $(D true) if $(D func) is $(D @system). */ template isUnsafe(alias func) { enum isUnsafe = !isSafe!func; } /// @safe unittest { @safe int add(int a, int b) {return a+b;} @trusted int sub(int a, int b) {return a-b;} @system int mul(int a, int b) {return a*b;} static assert(!isUnsafe!add); static assert(!isUnsafe!sub); static assert( isUnsafe!mul); } @safe unittest { //Member functions interface Set { int systemF() @system; int trustedF() @trusted; int safeF() @safe; } static assert(!isUnsafe!(Set.safeF)); static assert(!isUnsafe!(Set.trustedF)); static assert( isUnsafe!(Set.systemF)); //Functions @safe static safeFunc() {} @trusted static trustedFunc() {} @system static systemFunc() {} static assert(!isUnsafe!safeFunc); static assert(!isUnsafe!trustedFunc); static assert( isUnsafe!systemFunc); //Delegates auto safeDel = delegate() @safe {}; auto trustedDel = delegate() @trusted {}; auto systemDel = delegate() @system {}; static assert(!isUnsafe!safeDel); static assert(!isUnsafe!trustedDel); static assert( isUnsafe!systemDel); //Lambdas static assert(!isUnsafe!({safeDel();})); static assert(!isUnsafe!({trustedDel();})); static assert( isUnsafe!({systemDel();})); //Static opCall struct SafeStatic { @safe static SafeStatic opCall() { return SafeStatic.init; } } struct TrustedStatic { @trusted static TrustedStatic opCall() { return TrustedStatic.init; } } struct SystemStatic { @system static SystemStatic opCall() { return SystemStatic.init; } } static assert(!isUnsafe!(SafeStatic())); static assert(!isUnsafe!(TrustedStatic())); static assert( isUnsafe!(SystemStatic())); //Non-static opCall struct Safe { @safe Safe opCall() { return Safe.init; } } struct Trusted { @trusted Trusted opCall() { return Trusted.init; } } struct System { @system System opCall() { return System.init; } } static assert(!isUnsafe!(Safe.init())); static assert(!isUnsafe!(Trusted.init())); static assert( isUnsafe!(System.init())); } /** Determine the linkage attribute of the function. Params: func = the function symbol, or the type of a function, delegate, or pointer to function Returns: one of the strings "D", "C", "Windows", "Pascal", or "Objective-C" */ template functionLinkage(func...) if (func.length == 1 && isCallable!func) { enum string functionLinkage = __traits(getLinkage, FunctionTypeOf!func); } /// @safe unittest { extern(D) void Dfunc() {} extern(C) void Cfunc() {} static assert(functionLinkage!Dfunc == "D"); static assert(functionLinkage!Cfunc == "C"); string a = functionLinkage!Dfunc; assert(a == "D"); auto fp = &Cfunc; string b = functionLinkage!fp; assert(b == "C"); } @safe unittest { interface Test { void const_func() const; void sharedconst_func() shared const; } static assert(functionLinkage!(Test.const_func) == "D"); static assert(functionLinkage!(Test.sharedconst_func) == "D"); static assert(functionLinkage!((int a){}) == "D"); } /** Determines what kind of variadic parameters function has. Params: func = function symbol or type of function, delegate, or pointer to function Returns: enum Variadic */ enum Variadic { no, /// Function is not variadic. c, /// Function is a _C-style variadic function, which uses /// core.stdc.stdarg /// Function is a _D-style variadic function, which uses d, /// __argptr and __arguments. typesafe, /// Function is a typesafe variadic function. } /// ditto template variadicFunctionStyle(func...) if (func.length == 1 && isCallable!func) { enum string varargs = __traits(getFunctionVariadicStyle, FunctionTypeOf!func); enum Variadic variadicFunctionStyle = (varargs == "stdarg") ? Variadic.c : (varargs == "argptr") ? Variadic.d : (varargs == "typesafe") ? Variadic.typesafe : (varargs == "none") ? Variadic.no : Variadic.no; } /// @safe unittest { void func() {} static assert(variadicFunctionStyle!func == Variadic.no); extern(C) int printf(in char*, ...); static assert(variadicFunctionStyle!printf == Variadic.c); } @safe unittest { import core.vararg; extern(D) void novar() {} extern(C) void cstyle(int, ...) {} extern(D) void dstyle(...) {} extern(D) void typesafe(int[]...) {} static assert(variadicFunctionStyle!novar == Variadic.no); static assert(variadicFunctionStyle!cstyle == Variadic.c); static assert(variadicFunctionStyle!dstyle == Variadic.d); static assert(variadicFunctionStyle!typesafe == Variadic.typesafe); static assert(variadicFunctionStyle!((int[] a...) {}) == Variadic.typesafe); } /** Get the function type from a callable object $(D func). Using builtin $(D typeof) on a property function yields the types of the property value, not of the property function itself. Still, $(D FunctionTypeOf) is able to obtain function types of properties. Note: Do not confuse function types with function pointer types; function types are usually used for compile-time reflection purposes. */ template FunctionTypeOf(func...) if (func.length == 1 && isCallable!func) { static if (is(typeof(& func[0]) Fsym : Fsym*) && is(Fsym == function) || is(typeof(& func[0]) Fsym == delegate)) { alias FunctionTypeOf = Fsym; // HIT: (nested) function symbol } else static if (is(typeof(& func[0].opCall) Fobj == delegate)) { alias FunctionTypeOf = Fobj; // HIT: callable object } else static if (is(typeof(& func[0].opCall) Ftyp : Ftyp*) && is(Ftyp == function)) { alias FunctionTypeOf = Ftyp; // HIT: callable type } else static if (is(func[0] T) || is(typeof(func[0]) T)) { static if (is(T == function)) alias FunctionTypeOf = T; // HIT: function else static if (is(T Fptr : Fptr*) && is(Fptr == function)) alias FunctionTypeOf = Fptr; // HIT: function pointer else static if (is(T Fdlg == delegate)) alias FunctionTypeOf = Fdlg; // HIT: delegate else static assert(0); } else static assert(0); } /// @safe unittest { class C { int value() @property { return 0; } } static assert(is( typeof(C.value) == int )); static assert(is( FunctionTypeOf!(C.value) == function )); } @system unittest { int test(int a); int propGet() @property; int propSet(int a) @property; int function(int) test_fp; int delegate(int) test_dg; static assert(is( typeof(test) == FunctionTypeOf!(typeof(test)) )); static assert(is( typeof(test) == FunctionTypeOf!test )); static assert(is( typeof(test) == FunctionTypeOf!test_fp )); static assert(is( typeof(test) == FunctionTypeOf!test_dg )); alias int GetterType() @property; alias int SetterType(int) @property; static assert(is( FunctionTypeOf!propGet == GetterType )); static assert(is( FunctionTypeOf!propSet == SetterType )); interface Prop { int prop() @property; } Prop prop; static assert(is( FunctionTypeOf!(Prop.prop) == GetterType )); static assert(is( FunctionTypeOf!(prop.prop) == GetterType )); class Callable { int opCall(int) { return 0; } } auto call = new Callable; static assert(is( FunctionTypeOf!call == typeof(test) )); struct StaticCallable { static int opCall(int) { return 0; } } StaticCallable stcall_val; StaticCallable* stcall_ptr; static assert(is( FunctionTypeOf!stcall_val == typeof(test) )); static assert(is( FunctionTypeOf!stcall_ptr == typeof(test) )); interface Overloads { void test(string); real test(real); int test(int); int test() @property; } alias ov = AliasSeq!(__traits(getVirtualFunctions, Overloads, "test")); alias F_ov0 = FunctionTypeOf!(ov[0]); alias F_ov1 = FunctionTypeOf!(ov[1]); alias F_ov2 = FunctionTypeOf!(ov[2]); alias F_ov3 = FunctionTypeOf!(ov[3]); static assert(is(F_ov0* == void function(string))); static assert(is(F_ov1* == real function(real))); static assert(is(F_ov2* == int function(int))); static assert(is(F_ov3* == int function() @property)); alias F_dglit = FunctionTypeOf!((int a){ return a; }); static assert(is(F_dglit* : int function(int))); } /** * Constructs a new function or delegate type with the same basic signature * as the given one, but different attributes (including linkage). * * This is especially useful for adding/removing attributes to/from types in * generic code, where the actual type name cannot be spelt out. * * Params: * T = The base type. * linkage = The desired linkage of the result type. * attrs = The desired $(LREF FunctionAttribute)s of the result type. */ template SetFunctionAttributes(T, string linkage, uint attrs) if (isFunctionPointer!T || isDelegate!T) { mixin({ import std.algorithm.searching : canFind; static assert(!(attrs & FunctionAttribute.trusted) || !(attrs & FunctionAttribute.safe), "Cannot have a function/delegate that is both trusted and safe."); static immutable linkages = ["D", "C", "Windows", "Pascal", "C++", "System"]; static assert(canFind(linkages, linkage), "Invalid linkage '" ~ linkage ~ "', must be one of " ~ linkages.stringof ~ "."); string result = "alias "; static if (linkage != "D") result ~= "extern(" ~ linkage ~ ") "; static if (attrs & FunctionAttribute.ref_) result ~= "ref "; result ~= "ReturnType!T"; static if (isDelegate!T) result ~= " delegate"; else result ~= " function"; result ~= "("; static if (Parameters!T.length > 0) result ~= "Parameters!T"; enum varStyle = variadicFunctionStyle!T; static if (varStyle == Variadic.c) result ~= ", ..."; else static if (varStyle == Variadic.d) result ~= "..."; else static if (varStyle == Variadic.typesafe) result ~= "..."; result ~= ")"; static if (attrs & FunctionAttribute.pure_) result ~= " pure"; static if (attrs & FunctionAttribute.nothrow_) result ~= " nothrow"; static if (attrs & FunctionAttribute.property) result ~= " @property"; static if (attrs & FunctionAttribute.trusted) result ~= " @trusted"; static if (attrs & FunctionAttribute.safe) result ~= " @safe"; static if (attrs & FunctionAttribute.nogc) result ~= " @nogc"; static if (attrs & FunctionAttribute.system) result ~= " @system"; static if (attrs & FunctionAttribute.const_) result ~= " const"; static if (attrs & FunctionAttribute.immutable_) result ~= " immutable"; static if (attrs & FunctionAttribute.inout_) result ~= " inout"; static if (attrs & FunctionAttribute.shared_) result ~= " shared"; static if (attrs & FunctionAttribute.return_) result ~= " return"; result ~= " SetFunctionAttributes;"; return result; }()); } /// Ditto template SetFunctionAttributes(T, string linkage, uint attrs) if (is(T == function)) { // To avoid a lot of syntactic headaches, we just use the above version to // operate on the corresponding function pointer type and then remove the // indirection again. alias SetFunctionAttributes = FunctionTypeOf!(SetFunctionAttributes!(T*, linkage, attrs)); } /// @safe unittest { alias ExternC(T) = SetFunctionAttributes!(T, "C", functionAttributes!T); auto assumePure(T)(T t) if (isFunctionPointer!T || isDelegate!T) { enum attrs = functionAttributes!T | FunctionAttribute.pure_; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } } version(unittest) { // Some function types to test. int sc(scope int, ref int, out int, lazy int, int); extern(System) int novar(); extern(C) int cstyle(int, ...); extern(D) int dstyle(...); extern(D) int typesafe(int[]...); } @safe unittest { import std.algorithm.iteration : reduce; alias FA = FunctionAttribute; static foreach (BaseT; AliasSeq!(typeof(&sc), typeof(&novar), typeof(&cstyle), typeof(&dstyle), typeof(&typesafe))) { static foreach (T; AliasSeq!(BaseT, FunctionTypeOf!BaseT)) {{ enum linkage = functionLinkage!T; enum attrs = functionAttributes!T; static assert(is(SetFunctionAttributes!(T, linkage, attrs) == T), "Identity check failed for: " ~ T.stringof); // Check that all linkage types work (D-style variadics require D linkage). static if (variadicFunctionStyle!T != Variadic.d) { static foreach (newLinkage; AliasSeq!("D", "C", "Windows", "Pascal", "C++")) {{ alias New = SetFunctionAttributes!(T, newLinkage, attrs); static assert(functionLinkage!New == newLinkage, "Linkage test failed for: " ~ T.stringof ~ ", " ~ newLinkage ~ " (got " ~ New.stringof ~ ")"); }} } // Add @safe. alias T1 = SetFunctionAttributes!(T, functionLinkage!T, FA.safe); static assert(functionAttributes!T1 == FA.safe); // Add all known attributes, excluding conflicting ones. enum allAttrs = reduce!"a | b"([EnumMembers!FA]) & ~FA.safe & ~FA.property & ~FA.const_ & ~FA.immutable_ & ~FA.inout_ & ~FA.shared_ & ~FA.system & ~FA.return_ & ~FA.scope_; alias T2 = SetFunctionAttributes!(T1, functionLinkage!T, allAttrs); static assert(functionAttributes!T2 == allAttrs); // Strip all attributes again. alias T3 = SetFunctionAttributes!(T2, functionLinkage!T, FA.none); static assert(is(T3 == T)); }} } } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // Aggregate Types //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /** Determines whether `T` is a class nested inside another class and that `T.outer` is the implicit reference to the outer class (i.e. `outer` has not been used as a field or method name) Params: T = type to test Returns: `true` if `T` is a class nested inside another, with the conditions described above; `false` otherwise */ template isInnerClass(T) if (is(T == class)) { import std.meta : staticIndexOf; static if (is(typeof(T.outer))) enum isInnerClass = __traits(isSame, typeof(T.outer), __traits(parent, T)) && (staticIndexOf!(__traits(allMembers, T), "outer") == -1); else enum isInnerClass = false; } /// @safe unittest { class C { int outer; } static assert(!isInnerClass!C); class Outer1 { class Inner1 { } class Inner2 { int outer; } } static assert(isInnerClass!(Outer1.Inner1)); static assert(!isInnerClass!(Outer1.Inner2)); static class Outer2 { static class Inner { int outer; } } static assert(!isInnerClass!(Outer2.Inner)); } /** Determines whether $(D T) has its own context pointer. $(D T) must be either $(D class), $(D struct), or $(D union). */ template isNested(T) if (is(T == class) || is(T == struct) || is(T == union)) { enum isNested = __traits(isNested, T); } /// @safe unittest { static struct S { } static assert(!isNested!S); int i; struct NestedStruct { void f() { ++i; } } static assert(isNested!NestedStruct); } /** Determines whether $(D T) or any of its representation types have a context pointer. */ template hasNested(T) { import std.meta : anySatisfy, Filter; static if (isStaticArray!T && T.length) enum hasNested = hasNested!(typeof(T.init[0])); else static if (is(T == class) || is(T == struct) || is(T == union)) { // prevent infinite recursion for class with member of same type enum notSame(U) = !is(Unqual!T == Unqual!U); enum hasNested = isNested!T || anySatisfy!(.hasNested, Filter!(notSame, Fields!T)); } else enum hasNested = false; } /// @safe unittest { static struct S { } int i; struct NS { void f() { ++i; } } static assert(!hasNested!(S[2])); static assert(hasNested!(NS[2])); } @safe unittest { static assert(!__traits(compiles, isNested!int)); static assert(!hasNested!int); static struct StaticStruct { } static assert(!isNested!StaticStruct); static assert(!hasNested!StaticStruct); int i; struct NestedStruct { void f() { ++i; } } static assert( isNested!NestedStruct); static assert( hasNested!NestedStruct); static assert( isNested!(immutable NestedStruct)); static assert( hasNested!(immutable NestedStruct)); static assert(!__traits(compiles, isNested!(NestedStruct[1]))); static assert( hasNested!(NestedStruct[1])); static assert(!hasNested!(NestedStruct[0])); struct S1 { NestedStruct nested; } static assert(!isNested!S1); static assert( hasNested!S1); static struct S2 { NestedStruct nested; } static assert(!isNested!S2); static assert( hasNested!S2); static struct S3 { NestedStruct[0] nested; } static assert(!isNested!S3); static assert(!hasNested!S3); static union U { NestedStruct nested; } static assert(!isNested!U); static assert( hasNested!U); static class StaticClass { } static assert(!isNested!StaticClass); static assert(!hasNested!StaticClass); class NestedClass { void f() { ++i; } } static assert( isNested!NestedClass); static assert( hasNested!NestedClass); static assert( isNested!(immutable NestedClass)); static assert( hasNested!(immutable NestedClass)); static assert(!__traits(compiles, isNested!(NestedClass[1]))); static assert( hasNested!(NestedClass[1])); static assert(!hasNested!(NestedClass[0])); static class A { A a; } static assert(!hasNested!A); } /*** * Get as a tuple the types of the fields of a struct, class, or union. * This consists of the fields that take up memory space, * excluding the hidden fields like the virtual function * table pointer or a context pointer for nested types. * If $(D T) isn't a struct, class, or union returns a tuple * with one element $(D T). */ template Fields(T) { static if (is(T == struct) || is(T == union)) alias Fields = typeof(T.tupleof[0 .. $ - isNested!T]); else static if (is(T == class)) alias Fields = typeof(T.tupleof); else alias Fields = AliasSeq!T; } /// @safe unittest { import std.meta : AliasSeq; struct S { int x; float y; } static assert(is(Fields!S == AliasSeq!(int, float))); } /** * Alternate name for $(LREF Fields), kept for legacy compatibility. */ alias FieldTypeTuple = Fields; @safe unittest { static assert(is(FieldTypeTuple!int == AliasSeq!int)); static struct StaticStruct1 { } static assert(is(FieldTypeTuple!StaticStruct1 == AliasSeq!())); static struct StaticStruct2 { int a, b; } static assert(is(FieldTypeTuple!StaticStruct2 == AliasSeq!(int, int))); int i; struct NestedStruct1 { void f() { ++i; } } static assert(is(FieldTypeTuple!NestedStruct1 == AliasSeq!())); struct NestedStruct2 { int a; void f() { ++i; } } static assert(is(FieldTypeTuple!NestedStruct2 == AliasSeq!int)); class NestedClass { int a; void f() { ++i; } } static assert(is(FieldTypeTuple!NestedClass == AliasSeq!int)); } //Required for FieldNameTuple private enum NameOf(alias T) = T.stringof; /** * Get as an expression tuple the names of the fields of a struct, class, or * union. This consists of the fields that take up memory space, excluding the * hidden fields like the virtual function table pointer or a context pointer * for nested types. * Inherited fields (for classes) are not included. * If $(D T) isn't a struct, class, or union, an * expression tuple with an empty string is returned. */ template FieldNameTuple(T) { import std.meta : staticMap; static if (is(T == struct) || is(T == union)) alias FieldNameTuple = staticMap!(NameOf, T.tupleof[0 .. $ - isNested!T]); else static if (is(T == class)) alias FieldNameTuple = staticMap!(NameOf, T.tupleof); else alias FieldNameTuple = AliasSeq!""; } /// @safe unittest { import std.meta : AliasSeq; struct S { int x; float y; } static assert(FieldNameTuple!S == AliasSeq!("x", "y")); static assert(FieldNameTuple!int == AliasSeq!""); } @safe unittest { static assert(FieldNameTuple!int == AliasSeq!""); static struct StaticStruct1 { } static assert(is(FieldNameTuple!StaticStruct1 == AliasSeq!())); static struct StaticStruct2 { int a, b; } static assert(FieldNameTuple!StaticStruct2 == AliasSeq!("a", "b")); static class StaticClass1 { } static assert(is(FieldNameTuple!StaticClass1 == AliasSeq!())); static class StaticClass2 : StaticClass1 { int a, b; } static assert(FieldNameTuple!StaticClass2 == AliasSeq!("a", "b")); static class StaticClass3 : StaticClass2 { int c; } static assert(FieldNameTuple!StaticClass3 == AliasSeq!("c")); int i; struct NestedStruct1 { void f() { ++i; } } static assert(is(FieldNameTuple!NestedStruct1 == AliasSeq!())); struct NestedStruct2 { int a; void f() { ++i; } } static assert(FieldNameTuple!NestedStruct2 == AliasSeq!"a"); class NestedClass { int a; void f() { ++i; } } static assert(FieldNameTuple!NestedClass == AliasSeq!"a"); } /*** Get the primitive types of the fields of a struct or class, in topological order. */ template RepresentationTypeTuple(T) { template Impl(T...) { static if (T.length == 0) { alias Impl = AliasSeq!(); } else { import std.typecons : Rebindable; static if (is(T[0] R: Rebindable!R)) { alias Impl = Impl!(Impl!R, T[1 .. $]); } else static if (is(T[0] == struct) || is(T[0] == union)) { // @@@BUG@@@ this should work //alias .RepresentationTypes!(T[0].tupleof) // RepresentationTypes; alias Impl = Impl!(FieldTypeTuple!(T[0]), T[1 .. $]); } else { alias Impl = AliasSeq!(T[0], Impl!(T[1 .. $])); } } } static if (is(T == struct) || is(T == union) || is(T == class)) { alias RepresentationTypeTuple = Impl!(FieldTypeTuple!T); } else { alias RepresentationTypeTuple = Impl!T; } } /// @safe unittest { struct S1 { int a; float b; } struct S2 { char[] a; union { S1 b; S1 * c; } } alias R = RepresentationTypeTuple!S2; assert(R.length == 4 && is(R[0] == char[]) && is(R[1] == int) && is(R[2] == float) && is(R[3] == S1*)); } @safe unittest { alias S1 = RepresentationTypeTuple!int; static assert(is(S1 == AliasSeq!int)); struct S2 { int a; } struct S3 { int a; char b; } struct S4 { S1 a; int b; S3 c; } static assert(is(RepresentationTypeTuple!S2 == AliasSeq!int)); static assert(is(RepresentationTypeTuple!S3 == AliasSeq!(int, char))); static assert(is(RepresentationTypeTuple!S4 == AliasSeq!(int, int, int, char))); struct S11 { int a; float b; } struct S21 { char[] a; union { S11 b; S11 * c; } } alias R = RepresentationTypeTuple!S21; assert(R.length == 4 && is(R[0] == char[]) && is(R[1] == int) && is(R[2] == float) && is(R[3] == S11*)); class C { int a; float b; } alias R1 = RepresentationTypeTuple!C; static assert(R1.length == 2 && is(R1[0] == int) && is(R1[1] == float)); /* Issue 6642 */ import std.typecons : Rebindable; struct S5 { int a; Rebindable!(immutable Object) b; } alias R2 = RepresentationTypeTuple!S5; static assert(R2.length == 2 && is(R2[0] == int) && is(R2[1] == immutable(Object))); } /* Statically evaluates to $(D true) if and only if $(D T)'s representation contains at least one field of pointer or array type. Members of class types are not considered raw pointers. Pointers to immutable objects are not considered raw aliasing. */ private template hasRawAliasing(T...) { template Impl(T...) { static if (T.length == 0) { enum Impl = false; } else { static if (is(T[0] foo : U*, U) && !isFunctionPointer!(T[0])) enum has = !is(U == immutable); else static if (is(T[0] foo : U[], U) && !isStaticArray!(T[0])) enum has = !is(U == immutable); else static if (isAssociativeArray!(T[0])) enum has = !is(T[0] == immutable); else enum has = false; enum Impl = has || Impl!(T[1 .. $]); } } enum hasRawAliasing = Impl!(RepresentationTypeTuple!T); } // @safe unittest { // simple types static assert(!hasRawAliasing!int); static assert( hasRawAliasing!(char*)); // references aren't raw pointers static assert(!hasRawAliasing!Object); // built-in arrays do contain raw pointers static assert( hasRawAliasing!(int[])); // aggregate of simple types struct S1 { int a; double b; } static assert(!hasRawAliasing!S1); // indirect aggregation struct S2 { S1 a; double b; } static assert(!hasRawAliasing!S2); } @safe unittest { // struct with a pointer member struct S3 { int a; double * b; } static assert( hasRawAliasing!S3); // struct with an indirect pointer member struct S4 { S3 a; double b; } static assert( hasRawAliasing!S4); struct S5 { int a; Object z; int c; } static assert( hasRawAliasing!S3); static assert( hasRawAliasing!S4); static assert(!hasRawAliasing!S5); union S6 { int a; int b; } union S7 { int a; int * b; } static assert(!hasRawAliasing!S6); static assert( hasRawAliasing!S7); static assert(!hasRawAliasing!(void delegate())); static assert(!hasRawAliasing!(void delegate() const)); static assert(!hasRawAliasing!(void delegate() immutable)); static assert(!hasRawAliasing!(void delegate() shared)); static assert(!hasRawAliasing!(void delegate() shared const)); static assert(!hasRawAliasing!(const(void delegate()))); static assert(!hasRawAliasing!(immutable(void delegate()))); struct S8 { void delegate() a; int b; Object c; } class S12 { typeof(S8.tupleof) a; } class S13 { typeof(S8.tupleof) a; int* b; } static assert(!hasRawAliasing!S8); static assert(!hasRawAliasing!S12); static assert( hasRawAliasing!S13); enum S9 { a } static assert(!hasRawAliasing!S9); // indirect members struct S10 { S7 a; int b; } struct S11 { S6 a; int b; } static assert( hasRawAliasing!S10); static assert(!hasRawAliasing!S11); static assert( hasRawAliasing!(int[string])); static assert(!hasRawAliasing!(immutable(int[string]))); } /* Statically evaluates to $(D true) if and only if $(D T)'s representation contains at least one non-shared field of pointer or array type. Members of class types are not considered raw pointers. Pointers to immutable objects are not considered raw aliasing. */ private template hasRawUnsharedAliasing(T...) { template Impl(T...) { static if (T.length == 0) { enum Impl = false; } else { static if (is(T[0] foo : U*, U) && !isFunctionPointer!(T[0])) enum has = !is(U == immutable) && !is(U == shared); else static if (is(T[0] foo : U[], U) && !isStaticArray!(T[0])) enum has = !is(U == immutable) && !is(U == shared); else static if (isAssociativeArray!(T[0])) enum has = !is(T[0] == immutable) && !is(T[0] == shared); else enum has = false; enum Impl = has || Impl!(T[1 .. $]); } } enum hasRawUnsharedAliasing = Impl!(RepresentationTypeTuple!T); } // @safe unittest { // simple types static assert(!hasRawUnsharedAliasing!int); static assert( hasRawUnsharedAliasing!(char*)); static assert(!hasRawUnsharedAliasing!(shared char*)); // references aren't raw pointers static assert(!hasRawUnsharedAliasing!Object); // built-in arrays do contain raw pointers static assert( hasRawUnsharedAliasing!(int[])); static assert(!hasRawUnsharedAliasing!(shared int[])); // aggregate of simple types struct S1 { int a; double b; } static assert(!hasRawUnsharedAliasing!S1); // indirect aggregation struct S2 { S1 a; double b; } static assert(!hasRawUnsharedAliasing!S2); // struct with a pointer member struct S3 { int a; double * b; } static assert( hasRawUnsharedAliasing!S3); struct S4 { int a; shared double * b; } static assert(!hasRawUnsharedAliasing!S4); } @safe unittest { // struct with a pointer member struct S3 { int a; double * b; } static assert( hasRawUnsharedAliasing!S3); struct S4 { int a; shared double * b; } static assert(!hasRawUnsharedAliasing!S4); // struct with an indirect pointer member struct S5 { S3 a; double b; } static assert( hasRawUnsharedAliasing!S5); struct S6 { S4 a; double b; } static assert(!hasRawUnsharedAliasing!S6); struct S7 { int a; Object z; int c; } static assert( hasRawUnsharedAliasing!S5); static assert(!hasRawUnsharedAliasing!S6); static assert(!hasRawUnsharedAliasing!S7); union S8 { int a; int b; } union S9 { int a; int* b; } union S10 { int a; shared int* b; } static assert(!hasRawUnsharedAliasing!S8); static assert( hasRawUnsharedAliasing!S9); static assert(!hasRawUnsharedAliasing!S10); static assert(!hasRawUnsharedAliasing!(void delegate())); static assert(!hasRawUnsharedAliasing!(void delegate() const)); static assert(!hasRawUnsharedAliasing!(void delegate() immutable)); static assert(!hasRawUnsharedAliasing!(void delegate() shared)); static assert(!hasRawUnsharedAliasing!(void delegate() shared const)); static assert(!hasRawUnsharedAliasing!(const(void delegate()))); static assert(!hasRawUnsharedAliasing!(const(void delegate() const))); static assert(!hasRawUnsharedAliasing!(const(void delegate() immutable))); static assert(!hasRawUnsharedAliasing!(const(void delegate() shared))); static assert(!hasRawUnsharedAliasing!(const(void delegate() shared const))); static assert(!hasRawUnsharedAliasing!(immutable(void delegate()))); static assert(!hasRawUnsharedAliasing!(immutable(void delegate() const))); static assert(!hasRawUnsharedAliasing!(immutable(void delegate() immutable))); static assert(!hasRawUnsharedAliasing!(immutable(void delegate() shared))); static assert(!hasRawUnsharedAliasing!(immutable(void delegate() shared const))); static assert(!hasRawUnsharedAliasing!(shared(void delegate()))); static assert(!hasRawUnsharedAliasing!(shared(void delegate() const))); static assert(!hasRawUnsharedAliasing!(shared(void delegate() immutable))); static assert(!hasRawUnsharedAliasing!(shared(void delegate() shared))); static assert(!hasRawUnsharedAliasing!(shared(void delegate() shared const))); static assert(!hasRawUnsharedAliasing!(shared(const(void delegate())))); static assert(!hasRawUnsharedAliasing!(shared(const(void delegate() const)))); static assert(!hasRawUnsharedAliasing!(shared(const(void delegate() immutable)))); static assert(!hasRawUnsharedAliasing!(shared(const(void delegate() shared)))); static assert(!hasRawUnsharedAliasing!(shared(const(void delegate() shared const)))); static assert(!hasRawUnsharedAliasing!(void function())); enum S13 { a } static assert(!hasRawUnsharedAliasing!S13); // indirect members struct S14 { S9 a; int b; } struct S15 { S10 a; int b; } struct S16 { S6 a; int b; } static assert( hasRawUnsharedAliasing!S14); static assert(!hasRawUnsharedAliasing!S15); static assert(!hasRawUnsharedAliasing!S16); static assert( hasRawUnsharedAliasing!(int[string])); static assert(!hasRawUnsharedAliasing!(shared(int[string]))); static assert(!hasRawUnsharedAliasing!(immutable(int[string]))); struct S17 { void delegate() shared a; void delegate() immutable b; void delegate() shared const c; shared(void delegate()) d; shared(void delegate() shared) e; shared(void delegate() immutable) f; shared(void delegate() shared const) g; immutable(void delegate()) h; immutable(void delegate() shared) i; immutable(void delegate() immutable) j; immutable(void delegate() shared const) k; shared(const(void delegate())) l; shared(const(void delegate() shared)) m; shared(const(void delegate() immutable)) n; shared(const(void delegate() shared const)) o; } struct S18 { typeof(S17.tupleof) a; void delegate() p; } struct S19 { typeof(S17.tupleof) a; Object p; } struct S20 { typeof(S17.tupleof) a; int* p; } class S21 { typeof(S17.tupleof) a; } class S22 { typeof(S17.tupleof) a; void delegate() p; } class S23 { typeof(S17.tupleof) a; Object p; } class S24 { typeof(S17.tupleof) a; int* p; } static assert(!hasRawUnsharedAliasing!S17); static assert(!hasRawUnsharedAliasing!(immutable(S17))); static assert(!hasRawUnsharedAliasing!(shared(S17))); static assert(!hasRawUnsharedAliasing!S18); static assert(!hasRawUnsharedAliasing!(immutable(S18))); static assert(!hasRawUnsharedAliasing!(shared(S18))); static assert(!hasRawUnsharedAliasing!S19); static assert(!hasRawUnsharedAliasing!(immutable(S19))); static assert(!hasRawUnsharedAliasing!(shared(S19))); static assert( hasRawUnsharedAliasing!S20); static assert(!hasRawUnsharedAliasing!(immutable(S20))); static assert(!hasRawUnsharedAliasing!(shared(S20))); static assert(!hasRawUnsharedAliasing!S21); static assert(!hasRawUnsharedAliasing!(immutable(S21))); static assert(!hasRawUnsharedAliasing!(shared(S21))); static assert(!hasRawUnsharedAliasing!S22); static assert(!hasRawUnsharedAliasing!(immutable(S22))); static assert(!hasRawUnsharedAliasing!(shared(S22))); static assert(!hasRawUnsharedAliasing!S23); static assert(!hasRawUnsharedAliasing!(immutable(S23))); static assert(!hasRawUnsharedAliasing!(shared(S23))); static assert( hasRawUnsharedAliasing!S24); static assert(!hasRawUnsharedAliasing!(immutable(S24))); static assert(!hasRawUnsharedAliasing!(shared(S24))); struct S25 {} class S26 {} interface S27 {} union S28 {} static assert(!hasRawUnsharedAliasing!S25); static assert(!hasRawUnsharedAliasing!S26); static assert(!hasRawUnsharedAliasing!S27); static assert(!hasRawUnsharedAliasing!S28); } /* Statically evaluates to $(D true) if and only if $(D T)'s representation includes at least one non-immutable object reference. */ private template hasObjects(T...) { static if (T.length == 0) { enum hasObjects = false; } else static if (is(T[0] == struct)) { enum hasObjects = hasObjects!( RepresentationTypeTuple!(T[0]), T[1 .. $]); } else { enum hasObjects = ((is(T[0] == class) || is(T[0] == interface)) && !is(T[0] == immutable)) || hasObjects!(T[1 .. $]); } } /* Statically evaluates to $(D true) if and only if $(D T)'s representation includes at least one non-immutable non-shared object reference. */ private template hasUnsharedObjects(T...) { static if (T.length == 0) { enum hasUnsharedObjects = false; } else static if (is(T[0] == struct)) { enum hasUnsharedObjects = hasUnsharedObjects!( RepresentationTypeTuple!(T[0]), T[1 .. $]); } else { enum hasUnsharedObjects = ((is(T[0] == class) || is(T[0] == interface)) && !is(T[0] == immutable) && !is(T[0] == shared)) || hasUnsharedObjects!(T[1 .. $]); } } /** Returns $(D true) if and only if $(D T)'s representation includes at least one of the following: $(OL $(LI a raw pointer $(D U*) and $(D U) is not immutable;) $(LI an array $(D U[]) and $(D U) is not immutable;) $(LI a reference to a class or interface type $(D C) and $(D C) is not immutable.) $(LI an associative array that is not immutable.) $(LI a delegate.)) */ template hasAliasing(T...) { import std.meta : anySatisfy; import std.typecons : Rebindable; static if (T.length && is(T[0] : Rebindable!R, R)) { enum hasAliasing = hasAliasing!(R, T[1 .. $]); } else { template isAliasingDelegate(T) { enum isAliasingDelegate = isDelegate!T && !is(T == immutable) && !is(FunctionTypeOf!T == immutable); } enum hasAliasing = hasRawAliasing!T || hasObjects!T || anySatisfy!(isAliasingDelegate, T, RepresentationTypeTuple!T); } } /// @safe unittest { struct S1 { int a; Object b; } struct S2 { string a; } struct S3 { int a; immutable Object b; } struct S4 { float[3] vals; } static assert( hasAliasing!S1); static assert(!hasAliasing!S2); static assert(!hasAliasing!S3); static assert(!hasAliasing!S4); } @safe unittest { static assert( hasAliasing!(uint[uint])); static assert(!hasAliasing!(immutable(uint[uint]))); static assert( hasAliasing!(void delegate())); static assert( hasAliasing!(void delegate() const)); static assert(!hasAliasing!(void delegate() immutable)); static assert( hasAliasing!(void delegate() shared)); static assert( hasAliasing!(void delegate() shared const)); static assert( hasAliasing!(const(void delegate()))); static assert( hasAliasing!(const(void delegate() const))); static assert(!hasAliasing!(const(void delegate() immutable))); static assert( hasAliasing!(const(void delegate() shared))); static assert( hasAliasing!(const(void delegate() shared const))); static assert(!hasAliasing!(immutable(void delegate()))); static assert(!hasAliasing!(immutable(void delegate() const))); static assert(!hasAliasing!(immutable(void delegate() immutable))); static assert(!hasAliasing!(immutable(void delegate() shared))); static assert(!hasAliasing!(immutable(void delegate() shared const))); static assert( hasAliasing!(shared(const(void delegate())))); static assert( hasAliasing!(shared(const(void delegate() const)))); static assert(!hasAliasing!(shared(const(void delegate() immutable)))); static assert( hasAliasing!(shared(const(void delegate() shared)))); static assert( hasAliasing!(shared(const(void delegate() shared const)))); static assert(!hasAliasing!(void function())); interface I; static assert( hasAliasing!I); import std.typecons : Rebindable; static assert( hasAliasing!(Rebindable!(const Object))); static assert(!hasAliasing!(Rebindable!(immutable Object))); static assert( hasAliasing!(Rebindable!(shared Object))); static assert( hasAliasing!(Rebindable!Object)); struct S5 { void delegate() immutable b; shared(void delegate() immutable) f; immutable(void delegate() immutable) j; shared(const(void delegate() immutable)) n; } struct S6 { typeof(S5.tupleof) a; void delegate() p; } static assert(!hasAliasing!S5); static assert( hasAliasing!S6); struct S7 { void delegate() a; int b; Object c; } class S8 { int a; int b; } class S9 { typeof(S8.tupleof) a; } class S10 { typeof(S8.tupleof) a; int* b; } static assert( hasAliasing!S7); static assert( hasAliasing!S8); static assert( hasAliasing!S9); static assert( hasAliasing!S10); struct S11 {} class S12 {} interface S13 {} union S14 {} static assert(!hasAliasing!S11); static assert( hasAliasing!S12); static assert( hasAliasing!S13); static assert(!hasAliasing!S14); } /** Returns $(D true) if and only if $(D T)'s representation includes at least one of the following: $(OL $(LI a raw pointer $(D U*);) $(LI an array $(D U[]);) $(LI a reference to a class type $(D C).) $(LI an associative array.) $(LI a delegate.)) */ template hasIndirections(T) { import std.meta : anySatisfy; static if (is(T == struct) || is(T == union)) enum hasIndirections = anySatisfy!(.hasIndirections, FieldTypeTuple!T); else static if (isStaticArray!T && is(T : E[N], E, size_t N)) enum hasIndirections = is(E == void) ? true : hasIndirections!E; else static if (isFunctionPointer!T) enum hasIndirections = false; else enum hasIndirections = isPointer!T || isDelegate!T || isDynamicArray!T || isAssociativeArray!T || is (T == class) || is(T == interface); } /// @safe unittest { static assert( hasIndirections!(int[string])); static assert( hasIndirections!(void delegate())); static assert( hasIndirections!(void delegate() immutable)); static assert( hasIndirections!(immutable(void delegate()))); static assert( hasIndirections!(immutable(void delegate() immutable))); static assert(!hasIndirections!(void function())); static assert( hasIndirections!(void*[1])); static assert(!hasIndirections!(byte[1])); } @safe unittest { // void static array hides actual type of bits, so "may have indirections". static assert( hasIndirections!(void[1])); interface I {} struct S1 {} struct S2 { int a; } struct S3 { int a; int b; } struct S4 { int a; int* b; } struct S5 { int a; Object b; } struct S6 { int a; string b; } struct S7 { int a; immutable Object b; } struct S8 { int a; immutable I b; } struct S9 { int a; void delegate() b; } struct S10 { int a; immutable(void delegate()) b; } struct S11 { int a; void delegate() immutable b; } struct S12 { int a; immutable(void delegate() immutable) b; } class S13 {} class S14 { int a; } class S15 { int a; int b; } class S16 { int a; Object b; } class S17 { string a; } class S18 { int a; immutable Object b; } class S19 { int a; immutable(void delegate() immutable) b; } union S20 {} union S21 { int a; } union S22 { int a; int b; } union S23 { int a; Object b; } union S24 { string a; } union S25 { int a; immutable Object b; } union S26 { int a; immutable(void delegate() immutable) b; } static assert( hasIndirections!I); static assert(!hasIndirections!S1); static assert(!hasIndirections!S2); static assert(!hasIndirections!S3); static assert( hasIndirections!S4); static assert( hasIndirections!S5); static assert( hasIndirections!S6); static assert( hasIndirections!S7); static assert( hasIndirections!S8); static assert( hasIndirections!S9); static assert( hasIndirections!S10); static assert( hasIndirections!S12); static assert( hasIndirections!S13); static assert( hasIndirections!S14); static assert( hasIndirections!S15); static assert( hasIndirections!S16); static assert( hasIndirections!S17); static assert( hasIndirections!S18); static assert( hasIndirections!S19); static assert(!hasIndirections!S20); static assert(!hasIndirections!S21); static assert(!hasIndirections!S22); static assert( hasIndirections!S23); static assert( hasIndirections!S24); static assert( hasIndirections!S25); static assert( hasIndirections!S26); } @safe unittest //12000 { static struct S(T) { static assert(hasIndirections!T); } static class A(T) { S!A a; } A!int dummy; } /** Returns $(D true) if and only if $(D T)'s representation includes at least one of the following: $(OL $(LI a raw pointer $(D U*) and $(D U) is not immutable or shared;) $(LI an array $(D U[]) and $(D U) is not immutable or shared;) $(LI a reference to a class type $(D C) and $(D C) is not immutable or shared.) $(LI an associative array that is not immutable or shared.) $(LI a delegate that is not shared.)) */ template hasUnsharedAliasing(T...) { import std.meta : anySatisfy; import std.typecons : Rebindable; static if (!T.length) { enum hasUnsharedAliasing = false; } else static if (is(T[0] R: Rebindable!R)) { enum hasUnsharedAliasing = hasUnsharedAliasing!R; } else { template unsharedDelegate(T) { enum bool unsharedDelegate = isDelegate!T && !is(T == shared) && !is(T == shared) && !is(T == immutable) && !is(FunctionTypeOf!T == shared) && !is(FunctionTypeOf!T == immutable); } enum hasUnsharedAliasing = hasRawUnsharedAliasing!(T[0]) || anySatisfy!(unsharedDelegate, RepresentationTypeTuple!(T[0])) || hasUnsharedObjects!(T[0]) || hasUnsharedAliasing!(T[1..$]); } } /// @safe unittest { struct S1 { int a; Object b; } struct S2 { string a; } struct S3 { int a; immutable Object b; } static assert( hasUnsharedAliasing!S1); static assert(!hasUnsharedAliasing!S2); static assert(!hasUnsharedAliasing!S3); struct S4 { int a; shared Object b; } struct S5 { char[] a; } struct S6 { shared char[] b; } struct S7 { float[3] vals; } static assert(!hasUnsharedAliasing!S4); static assert( hasUnsharedAliasing!S5); static assert(!hasUnsharedAliasing!S6); static assert(!hasUnsharedAliasing!S7); } @safe unittest { /* Issue 6642 */ import std.typecons : Rebindable; struct S8 { int a; Rebindable!(immutable Object) b; } static assert(!hasUnsharedAliasing!S8); static assert( hasUnsharedAliasing!(uint[uint])); static assert( hasUnsharedAliasing!(void delegate())); static assert( hasUnsharedAliasing!(void delegate() const)); static assert(!hasUnsharedAliasing!(void delegate() immutable)); static assert(!hasUnsharedAliasing!(void delegate() shared)); static assert(!hasUnsharedAliasing!(void delegate() shared const)); } @safe unittest { import std.typecons : Rebindable; static assert( hasUnsharedAliasing!(const(void delegate()))); static assert( hasUnsharedAliasing!(const(void delegate() const))); static assert(!hasUnsharedAliasing!(const(void delegate() immutable))); static assert(!hasUnsharedAliasing!(const(void delegate() shared))); static assert(!hasUnsharedAliasing!(const(void delegate() shared const))); static assert(!hasUnsharedAliasing!(immutable(void delegate()))); static assert(!hasUnsharedAliasing!(immutable(void delegate() const))); static assert(!hasUnsharedAliasing!(immutable(void delegate() immutable))); static assert(!hasUnsharedAliasing!(immutable(void delegate() shared))); static assert(!hasUnsharedAliasing!(immutable(void delegate() shared const))); static assert(!hasUnsharedAliasing!(shared(void delegate()))); static assert(!hasUnsharedAliasing!(shared(void delegate() const))); static assert(!hasUnsharedAliasing!(shared(void delegate() immutable))); static assert(!hasUnsharedAliasing!(shared(void delegate() shared))); static assert(!hasUnsharedAliasing!(shared(void delegate() shared const))); static assert(!hasUnsharedAliasing!(shared(const(void delegate())))); static assert(!hasUnsharedAliasing!(shared(const(void delegate() const)))); static assert(!hasUnsharedAliasing!(shared(const(void delegate() immutable)))); static assert(!hasUnsharedAliasing!(shared(const(void delegate() shared)))); static assert(!hasUnsharedAliasing!(shared(const(void delegate() shared const)))); static assert(!hasUnsharedAliasing!(void function())); interface I {} static assert(hasUnsharedAliasing!I); static assert( hasUnsharedAliasing!(Rebindable!(const Object))); static assert(!hasUnsharedAliasing!(Rebindable!(immutable Object))); static assert(!hasUnsharedAliasing!(Rebindable!(shared Object))); static assert( hasUnsharedAliasing!(Rebindable!Object)); /* Issue 6979 */ static assert(!hasUnsharedAliasing!(int, shared(int)*)); static assert( hasUnsharedAliasing!(int, int*)); static assert( hasUnsharedAliasing!(int, const(int)[])); static assert( hasUnsharedAliasing!(int, shared(int)*, Rebindable!Object)); static assert(!hasUnsharedAliasing!(shared(int)*, Rebindable!(shared Object))); static assert(!hasUnsharedAliasing!()); struct S9 { void delegate() shared a; void delegate() immutable b; void delegate() shared const c; shared(void delegate()) d; shared(void delegate() shared) e; shared(void delegate() immutable) f; shared(void delegate() shared const) g; immutable(void delegate()) h; immutable(void delegate() shared) i; immutable(void delegate() immutable) j; immutable(void delegate() shared const) k; shared(const(void delegate())) l; shared(const(void delegate() shared)) m; shared(const(void delegate() immutable)) n; shared(const(void delegate() shared const)) o; } struct S10 { typeof(S9.tupleof) a; void delegate() p; } struct S11 { typeof(S9.tupleof) a; Object p; } struct S12 { typeof(S9.tupleof) a; int* p; } class S13 { typeof(S9.tupleof) a; } class S14 { typeof(S9.tupleof) a; void delegate() p; } class S15 { typeof(S9.tupleof) a; Object p; } class S16 { typeof(S9.tupleof) a; int* p; } static assert(!hasUnsharedAliasing!S9); static assert(!hasUnsharedAliasing!(immutable(S9))); static assert(!hasUnsharedAliasing!(shared(S9))); static assert( hasUnsharedAliasing!S10); static assert(!hasUnsharedAliasing!(immutable(S10))); static assert(!hasUnsharedAliasing!(shared(S10))); static assert( hasUnsharedAliasing!S11); static assert(!hasUnsharedAliasing!(immutable(S11))); static assert(!hasUnsharedAliasing!(shared(S11))); static assert( hasUnsharedAliasing!S12); static assert(!hasUnsharedAliasing!(immutable(S12))); static assert(!hasUnsharedAliasing!(shared(S12))); static assert( hasUnsharedAliasing!S13); static assert(!hasUnsharedAliasing!(immutable(S13))); static assert(!hasUnsharedAliasing!(shared(S13))); static assert( hasUnsharedAliasing!S14); static assert(!hasUnsharedAliasing!(immutable(S14))); static assert(!hasUnsharedAliasing!(shared(S14))); static assert( hasUnsharedAliasing!S15); static assert(!hasUnsharedAliasing!(immutable(S15))); static assert(!hasUnsharedAliasing!(shared(S15))); static assert( hasUnsharedAliasing!S16); static assert(!hasUnsharedAliasing!(immutable(S16))); static assert(!hasUnsharedAliasing!(shared(S16))); struct S17 {} class S18 {} interface S19 {} union S20 {} static assert(!hasUnsharedAliasing!S17); static assert( hasUnsharedAliasing!S18); static assert( hasUnsharedAliasing!S19); static assert(!hasUnsharedAliasing!S20); } /** True if $(D S) or any type embedded directly in the representation of $(D S) defines an elaborate copy constructor. Elaborate copy constructors are introduced by defining $(D this(this)) for a $(D struct). Classes and unions never have elaborate copy constructors. */ template hasElaborateCopyConstructor(S) { import std.meta : anySatisfy; static if (isStaticArray!S && S.length) { enum bool hasElaborateCopyConstructor = hasElaborateCopyConstructor!(typeof(S.init[0])); } else static if (is(S == struct)) { enum hasElaborateCopyConstructor = hasMember!(S, "__xpostblit"); } else { enum bool hasElaborateCopyConstructor = false; } } /// @safe unittest { static assert(!hasElaborateCopyConstructor!int); static struct S1 { } static struct S2 { this(this) {} } static struct S3 { S2 field; } static struct S4 { S3[1] field; } static struct S5 { S3[] field; } static struct S6 { S3[0] field; } static struct S7 { @disable this(); S3 field; } static assert(!hasElaborateCopyConstructor!S1); static assert( hasElaborateCopyConstructor!S2); static assert( hasElaborateCopyConstructor!(immutable S2)); static assert( hasElaborateCopyConstructor!S3); static assert( hasElaborateCopyConstructor!(S3[1])); static assert(!hasElaborateCopyConstructor!(S3[0])); static assert( hasElaborateCopyConstructor!S4); static assert(!hasElaborateCopyConstructor!S5); static assert(!hasElaborateCopyConstructor!S6); static assert( hasElaborateCopyConstructor!S7); } /** True if $(D S) or any type directly embedded in the representation of $(D S) defines an elaborate assignment. Elaborate assignments are introduced by defining $(D opAssign(typeof(this))) or $(D opAssign(ref typeof(this))) for a $(D struct) or when there is a compiler-generated $(D opAssign). A type $(D S) gets compiler-generated $(D opAssign) in case it has an elaborate copy constructor or elaborate destructor. Classes and unions never have elaborate assignments. Note: Structs with (possibly nested) postblit operator(s) will have a hidden yet elaborate compiler generated assignment operator (unless explicitly disabled). */ template hasElaborateAssign(S) { import std.meta : anySatisfy; static if (isStaticArray!S && S.length) { enum bool hasElaborateAssign = hasElaborateAssign!(typeof(S.init[0])); } else static if (is(S == struct)) { enum hasElaborateAssign = is(typeof(S.init.opAssign(rvalueOf!S))) || is(typeof(S.init.opAssign(lvalueOf!S))) || anySatisfy!(.hasElaborateAssign, FieldTypeTuple!S); } else { enum bool hasElaborateAssign = false; } } /// @safe unittest { static assert(!hasElaborateAssign!int); static struct S { void opAssign(S) {} } static assert( hasElaborateAssign!S); static assert(!hasElaborateAssign!(const(S))); static struct S1 { void opAssign(ref S1) {} } static struct S2 { void opAssign(int) {} } static struct S3 { S s; } static assert( hasElaborateAssign!S1); static assert(!hasElaborateAssign!S2); static assert( hasElaborateAssign!S3); static assert( hasElaborateAssign!(S3[1])); static assert(!hasElaborateAssign!(S3[0])); } @safe unittest { static struct S { void opAssign(S) {} } static struct S4 { void opAssign(U)(U u) {} @disable void opAssign(U)(ref U u); } static assert( hasElaborateAssign!S4); static struct S41 { void opAssign(U)(ref U u) {} @disable void opAssign(U)(U u); } static assert( hasElaborateAssign!S41); static struct S5 { @disable this(); this(int n){ s = S(); } S s; } static assert( hasElaborateAssign!S5); static struct S6 { this(this) {} } static struct S7 { this(this) {} @disable void opAssign(S7); } static struct S8 { this(this) {} @disable void opAssign(S8); void opAssign(int) {} } static struct S9 { this(this) {} void opAssign(int) {} } static struct S10 { ~this() { } } static assert( hasElaborateAssign!S6); static assert(!hasElaborateAssign!S7); static assert(!hasElaborateAssign!S8); static assert( hasElaborateAssign!S9); static assert( hasElaborateAssign!S10); static struct SS6 { S6 s; } static struct SS7 { S7 s; } static struct SS8 { S8 s; } static struct SS9 { S9 s; } static assert( hasElaborateAssign!SS6); static assert(!hasElaborateAssign!SS7); static assert(!hasElaborateAssign!SS8); static assert( hasElaborateAssign!SS9); } /** True if $(D S) or any type directly embedded in the representation of $(D S) defines an elaborate destructor. Elaborate destructors are introduced by defining $(D ~this()) for a $(D struct). Classes and unions never have elaborate destructors, even though classes may define $(D ~this()). */ template hasElaborateDestructor(S) { import std.meta : anySatisfy; static if (isStaticArray!S && S.length) { enum bool hasElaborateDestructor = hasElaborateDestructor!(typeof(S.init[0])); } else static if (is(S == struct)) { enum hasElaborateDestructor = hasMember!(S, "__dtor") || anySatisfy!(.hasElaborateDestructor, FieldTypeTuple!S); } else { enum bool hasElaborateDestructor = false; } } /// @safe unittest { static assert(!hasElaborateDestructor!int); static struct S1 { } static struct S2 { ~this() {} } static struct S3 { S2 field; } static struct S4 { S3[1] field; } static struct S5 { S3[] field; } static struct S6 { S3[0] field; } static struct S7 { @disable this(); S3 field; } static assert(!hasElaborateDestructor!S1); static assert( hasElaborateDestructor!S2); static assert( hasElaborateDestructor!(immutable S2)); static assert( hasElaborateDestructor!S3); static assert( hasElaborateDestructor!(S3[1])); static assert(!hasElaborateDestructor!(S3[0])); static assert( hasElaborateDestructor!S4); static assert(!hasElaborateDestructor!S5); static assert(!hasElaborateDestructor!S6); static assert( hasElaborateDestructor!S7); } package alias Identity(alias A) = A; /** Yields $(D true) if and only if $(D T) is an aggregate that defines a symbol called $(D name). */ enum hasMember(T, string name) = __traits(hasMember, T, name); /// @safe unittest { static assert(!hasMember!(int, "blah")); struct S1 { int blah; } struct S2 { int blah(){ return 0; } } class C1 { int blah; } class C2 { int blah(){ return 0; } } static assert(hasMember!(S1, "blah")); static assert(hasMember!(S2, "blah")); static assert(hasMember!(C1, "blah")); static assert(hasMember!(C2, "blah")); } @safe unittest { // 8321 struct S { int x; void f(){} void t()(){} template T(){} } struct R1(T) { T t; alias t this; } struct R2(T) { T t; @property ref inout(T) payload() inout { return t; } alias t this; } static assert(hasMember!(S, "x")); static assert(hasMember!(S, "f")); static assert(hasMember!(S, "t")); static assert(hasMember!(S, "T")); static assert(hasMember!(R1!S, "x")); static assert(hasMember!(R1!S, "f")); static assert(hasMember!(R1!S, "t")); static assert(hasMember!(R1!S, "T")); static assert(hasMember!(R2!S, "x")); static assert(hasMember!(R2!S, "f")); static assert(hasMember!(R2!S, "t")); static assert(hasMember!(R2!S, "T")); } @safe unittest { static struct S { void opDispatch(string n, A)(A dummy) {} } static assert(hasMember!(S, "foo")); } /** * Whether the symbol represented by the string, member, exists and is a static member of T. * * Params: * T = Type containing symbol $(D member). * member = Name of symbol to test that resides in $(D T). * * Returns: * $(D true) iff $(D member) exists and is static. */ template hasStaticMember(T, string member) { static if (__traits(hasMember, T, member)) { import std.meta : Alias; alias sym = Alias!(__traits(getMember, T, member)); static if (__traits(getOverloads, T, member).length == 0) enum bool hasStaticMember = __traits(compiles, &sym); else enum bool hasStaticMember = __traits(isStaticFunction, sym); } else { enum bool hasStaticMember = false; } } /// @safe unittest { static struct S { static void sf() {} void f() {} static int si; int i; } static assert( hasStaticMember!(S, "sf")); static assert(!hasStaticMember!(S, "f")); static assert( hasStaticMember!(S, "si")); static assert(!hasStaticMember!(S, "i")); static assert(!hasStaticMember!(S, "hello")); } @safe unittest { static struct S { enum X = 10; enum Y { i = 10 } struct S {} class C {} static int sx = 0; __gshared int gx = 0; Y y; static Y sy; static void f(); static void f2() pure nothrow @nogc @safe; shared void g(); static void function() fp; __gshared void function() gfp; void function() fpm; void delegate() dm; static void delegate() sd; void m(); void m2() const pure nothrow @nogc @safe; inout(int) iom() inout; static inout(int) iosf(inout int x); @property int p(); static @property int sp(); } static class C { enum X = 10; enum Y { i = 10 } struct S {} class C {} static int sx = 0; __gshared int gx = 0; Y y; static Y sy; static void f(); static void f2() pure nothrow @nogc @safe; shared void g() { } static void function() fp; __gshared void function() gfp; void function() fpm; void delegate() dm; static void delegate() sd; void m() {} final void m2() const pure nothrow @nogc @safe; inout(int) iom() inout { return 10; } static inout(int) iosf(inout int x); @property int p() { return 10; } static @property int sp(); } static assert(!hasStaticMember!(S, "X")); static assert(!hasStaticMember!(S, "Y")); static assert(!hasStaticMember!(S, "Y.i")); static assert(!hasStaticMember!(S, "S")); static assert(!hasStaticMember!(S, "C")); static assert( hasStaticMember!(S, "sx")); static assert( hasStaticMember!(S, "gx")); static assert(!hasStaticMember!(S, "y")); static assert( hasStaticMember!(S, "sy")); static assert( hasStaticMember!(S, "f")); static assert( hasStaticMember!(S, "f2")); static assert(!hasStaticMember!(S, "dm")); static assert( hasStaticMember!(S, "sd")); static assert(!hasStaticMember!(S, "g")); static assert( hasStaticMember!(S, "fp")); static assert( hasStaticMember!(S, "gfp")); static assert(!hasStaticMember!(S, "fpm")); static assert(!hasStaticMember!(S, "m")); static assert(!hasStaticMember!(S, "m2")); static assert(!hasStaticMember!(S, "iom")); static assert( hasStaticMember!(S, "iosf")); static assert(!hasStaticMember!(S, "p")); static assert( hasStaticMember!(S, "sp")); static assert(!hasStaticMember!(C, "X")); static assert(!hasStaticMember!(C, "Y")); static assert(!hasStaticMember!(C, "Y.i")); static assert(!hasStaticMember!(C, "S")); static assert(!hasStaticMember!(C, "C")); static assert( hasStaticMember!(C, "sx")); static assert( hasStaticMember!(C, "gx")); static assert(!hasStaticMember!(C, "y")); static assert( hasStaticMember!(C, "sy")); static assert( hasStaticMember!(C, "f")); static assert( hasStaticMember!(C, "f2")); static assert(!hasStaticMember!(S, "dm")); static assert( hasStaticMember!(S, "sd")); static assert(!hasStaticMember!(C, "g")); static assert( hasStaticMember!(C, "fp")); static assert( hasStaticMember!(C, "gfp")); static assert(!hasStaticMember!(C, "fpm")); static assert(!hasStaticMember!(C, "m")); static assert(!hasStaticMember!(C, "m2")); static assert(!hasStaticMember!(C, "iom")); static assert( hasStaticMember!(C, "iosf")); static assert(!hasStaticMember!(C, "p")); static assert( hasStaticMember!(C, "sp")); } /** Retrieves the members of an enumerated type $(D enum E). Params: E = An enumerated type. $(D E) may have duplicated values. Returns: Static tuple composed of the members of the enumerated type $(D E). The members are arranged in the same order as declared in $(D E). Note: An enum can have multiple members which have the same value. If you want to use EnumMembers to e.g. generate switch cases at compile-time, you should use the $(REF NoDuplicates, std,meta) template to avoid generating duplicate switch cases. Note: Returned values are strictly typed with $(D E). Thus, the following code does not work without the explicit cast: -------------------- enum E : int { a, b, c } int[] abc = cast(int[]) [ EnumMembers!E ]; -------------------- Cast is not necessary if the type of the variable is inferred. See the example below. Example: Creating an array of enumerated values: -------------------- enum Sqrts : real { one = 1, two = 1.41421, three = 1.73205, } auto sqrts = [ EnumMembers!Sqrts ]; assert(sqrts == [ Sqrts.one, Sqrts.two, Sqrts.three ]); -------------------- A generic function $(D rank(v)) in the following example uses this template for finding a member $(D e) in an enumerated type $(D E). -------------------- // Returns i if e is the i-th enumerator of E. size_t rank(E)(E e) if (is(E == enum)) { static foreach (i, member; EnumMembers!E) { if (e == member) return i; } assert(0, "Not an enum member"); } enum Mode { read = 1, write = 2, map = 4, } assert(rank(Mode.read ) == 0); assert(rank(Mode.write) == 1); assert(rank(Mode.map ) == 2); -------------------- */ template EnumMembers(E) if (is(E == enum)) { import std.meta : AliasSeq; // Supply the specified identifier to an constant value. template WithIdentifier(string ident) { static if (ident == "Symbolize") { template Symbolize(alias value) { enum Symbolize = value; } } else { mixin("template Symbolize(alias "~ ident ~")" ~"{" ~"alias Symbolize = "~ ident ~";" ~"}"); } } template EnumSpecificMembers(names...) { static if (names.length == 1) { alias EnumSpecificMembers = AliasSeq!(WithIdentifier!(names[0]) .Symbolize!(__traits(getMember, E, names[0]))); } else static if (names.length > 0) { alias EnumSpecificMembers = AliasSeq!( WithIdentifier!(names[0]) .Symbolize!(__traits(getMember, E, names[0])), EnumSpecificMembers!(names[1 .. $/2]), EnumSpecificMembers!(names[$/2..$]) ); } else { alias EnumSpecificMembers = AliasSeq!(); } } alias EnumMembers = EnumSpecificMembers!(__traits(allMembers, E)); } @safe unittest { enum A { a } static assert([ EnumMembers!A ] == [ A.a ]); enum B { a, b, c, d, e } static assert([ EnumMembers!B ] == [ B.a, B.b, B.c, B.d, B.e ]); } @safe unittest // typed enums { enum A : string { a = "alpha", b = "beta" } static assert([ EnumMembers!A ] == [ A.a, A.b ]); static struct S { int value; int opCmp(S rhs) const nothrow { return value - rhs.value; } } enum B : S { a = S(1), b = S(2), c = S(3) } static assert([ EnumMembers!B ] == [ B.a, B.b, B.c ]); } @safe unittest // duplicated values { enum A { a = 0, b = 0, c = 1, d = 1, e } static assert([ EnumMembers!A ] == [ A.a, A.b, A.c, A.d, A.e ]); } @safe unittest // Bugzilla 14561: huge enums { string genEnum() { string result = "enum TLAs {"; foreach (c0; '0'..'2'+1) foreach (c1; '0'..'9'+1) foreach (c2; '0'..'9'+1) foreach (c3; '0'..'9'+1) { result ~= '_'; result ~= c0; result ~= c1; result ~= c2; result ~= c3; result ~= ','; } result ~= '}'; return result; } mixin(genEnum); static assert(EnumMembers!TLAs[0] == TLAs._0000); static assert(EnumMembers!TLAs[$-1] == TLAs._2999); } @safe unittest { enum E { member, a = 0, b = 0 } static assert(__traits(identifier, EnumMembers!E[0]) == "member"); static assert(__traits(identifier, EnumMembers!E[1]) == "a"); static assert(__traits(identifier, EnumMembers!E[2]) == "b"); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // Classes and Interfaces //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /*** * Get a $(D_PARAM AliasSeq) of the base class and base interfaces of * this class or interface. $(D_PARAM BaseTypeTuple!Object) returns * the empty type tuple. */ template BaseTypeTuple(A) { static if (is(A P == super)) alias BaseTypeTuple = P; else static assert(0, "argument is not a class or interface"); } /// @safe unittest { import std.meta : AliasSeq; interface I1 { } interface I2 { } interface I12 : I1, I2 { } static assert(is(BaseTypeTuple!I12 == AliasSeq!(I1, I2))); interface I3 : I1 { } interface I123 : I1, I2, I3 { } static assert(is(BaseTypeTuple!I123 == AliasSeq!(I1, I2, I3))); } @safe unittest { interface I1 { } interface I2 { } class A { } class C : A, I1, I2 { } alias TL = BaseTypeTuple!C; assert(TL.length == 3); assert(is (TL[0] == A)); assert(is (TL[1] == I1)); assert(is (TL[2] == I2)); assert(BaseTypeTuple!Object.length == 0); } /** * Get a $(D_PARAM AliasSeq) of $(I all) base classes of this class, * in decreasing order. Interfaces are not included. $(D_PARAM * BaseClassesTuple!Object) yields the empty type tuple. */ template BaseClassesTuple(T) if (is(T == class)) { static if (is(T == Object)) { alias BaseClassesTuple = AliasSeq!(); } else static if (is(BaseTypeTuple!T[0] == Object)) { alias BaseClassesTuple = AliasSeq!Object; } else { alias BaseClassesTuple = AliasSeq!(BaseTypeTuple!T[0], BaseClassesTuple!(BaseTypeTuple!T[0])); } } /// @safe unittest { import std.meta : AliasSeq; class C1 { } class C2 : C1 { } class C3 : C2 { } static assert(!BaseClassesTuple!Object.length); static assert(is(BaseClassesTuple!C1 == AliasSeq!(Object))); static assert(is(BaseClassesTuple!C2 == AliasSeq!(C1, Object))); static assert(is(BaseClassesTuple!C3 == AliasSeq!(C2, C1, Object))); } @safe unittest { struct S { } static assert(!__traits(compiles, BaseClassesTuple!S)); interface I { } static assert(!__traits(compiles, BaseClassesTuple!I)); class C4 : I { } class C5 : C4, I { } static assert(is(BaseClassesTuple!C5 == AliasSeq!(C4, Object))); } /** * Get a $(D_PARAM AliasSeq) of $(I all) interfaces directly or * indirectly inherited by this class or interface. Interfaces do not * repeat if multiply implemented. $(D_PARAM InterfacesTuple!Object) * yields the empty type tuple. */ template InterfacesTuple(T) { import std.meta : NoDuplicates; template Flatten(H, T...) { static if (T.length) { alias Flatten = AliasSeq!(Flatten!H, Flatten!T); } else { static if (is(H == interface)) alias Flatten = AliasSeq!(H, InterfacesTuple!H); else alias Flatten = InterfacesTuple!H; } } static if (is(T S == super) && S.length) alias InterfacesTuple = NoDuplicates!(Flatten!S); else alias InterfacesTuple = AliasSeq!(); } @safe unittest { // doc example interface I1 {} interface I2 {} class A : I1, I2 { } class B : A, I1 { } class C : B { } alias TL = InterfacesTuple!C; static assert(is(TL[0] == I1) && is(TL[1] == I2)); } @safe unittest { interface Iaa {} interface Iab {} interface Iba {} interface Ibb {} interface Ia : Iaa, Iab {} interface Ib : Iba, Ibb {} interface I : Ia, Ib {} interface J {} class B2 : J {} class C2 : B2, Ia, Ib {} static assert(is(InterfacesTuple!I == AliasSeq!(Ia, Iaa, Iab, Ib, Iba, Ibb))); static assert(is(InterfacesTuple!C2 == AliasSeq!(J, Ia, Iaa, Iab, Ib, Iba, Ibb))); } /** * Get a $(D_PARAM AliasSeq) of $(I all) base classes of $(D_PARAM * T), in decreasing order, followed by $(D_PARAM T)'s * interfaces. $(D_PARAM TransitiveBaseTypeTuple!Object) yields the * empty type tuple. */ template TransitiveBaseTypeTuple(T) { static if (is(T == Object)) alias TransitiveBaseTypeTuple = AliasSeq!(); else alias TransitiveBaseTypeTuple = AliasSeq!(BaseClassesTuple!T, InterfacesTuple!T); } /// @safe unittest { interface J1 {} interface J2 {} class B1 {} class B2 : B1, J1, J2 {} class B3 : B2, J1 {} alias TL = TransitiveBaseTypeTuple!B3; assert(TL.length == 5); assert(is (TL[0] == B2)); assert(is (TL[1] == B1)); assert(is (TL[2] == Object)); assert(is (TL[3] == J1)); assert(is (TL[4] == J2)); assert(TransitiveBaseTypeTuple!Object.length == 0); } /** Returns a tuple of non-static functions with the name $(D name) declared in the class or interface $(D C). Covariant duplicates are shrunk into the most derived one. */ template MemberFunctionsTuple(C, string name) if (is(C == class) || is(C == interface)) { static if (__traits(hasMember, C, name)) { /* * First, collect all overloads in the class hierarchy. */ template CollectOverloads(Node) { static if (__traits(hasMember, Node, name) && __traits(compiles, __traits(getMember, Node, name))) { // Get all overloads in sight (not hidden). alias inSight = AliasSeq!(__traits(getVirtualFunctions, Node, name)); // And collect all overloads in ancestor classes to reveal hidden // methods. The result may contain duplicates. template walkThru(Parents...) { static if (Parents.length > 0) alias walkThru = AliasSeq!( CollectOverloads!(Parents[0]), walkThru!(Parents[1 .. $]) ); else alias walkThru = AliasSeq!(); } static if (is(Node Parents == super)) alias CollectOverloads = AliasSeq!(inSight, walkThru!Parents); else alias CollectOverloads = AliasSeq!inSight; } else alias CollectOverloads = AliasSeq!(); // no overloads in this hierarchy } // duplicates in this tuple will be removed by shrink() alias overloads = CollectOverloads!C; // shrinkOne!args[0] = the most derived one in the covariant siblings of target // shrinkOne!args[1..$] = non-covariant others template shrinkOne(/+ alias target, rest... +/ args...) { import std.meta : AliasSeq; alias target = args[0 .. 1]; // prevent property functions from being evaluated alias rest = args[1 .. $]; static if (rest.length > 0) { alias Target = FunctionTypeOf!target; alias Rest0 = FunctionTypeOf!(rest[0]); static if (isCovariantWith!(Target, Rest0) && isCovariantWith!(Rest0, Target)) { // One of these overrides the other. Choose the one from the most derived parent. static if (is(AliasSeq!(__traits(parent, target))[0] : AliasSeq!(__traits(parent, rest[0]))[0])) alias shrinkOne = shrinkOne!(target, rest[1 .. $]); else alias shrinkOne = shrinkOne!(rest[0], rest[1 .. $]); } else static if (isCovariantWith!(Target, Rest0)) // target overrides rest[0] -- erase rest[0]. alias shrinkOne = shrinkOne!(target, rest[1 .. $]); else static if (isCovariantWith!(Rest0, Target)) // rest[0] overrides target -- erase target. alias shrinkOne = shrinkOne!(rest[0], rest[1 .. $]); else // target and rest[0] are distinct. alias shrinkOne = AliasSeq!( shrinkOne!(target, rest[1 .. $]), rest[0] // keep ); } else alias shrinkOne = AliasSeq!target; // done } /* * Now shrink covariant overloads into one. */ template shrink(overloads...) { static if (overloads.length > 0) { alias temp = shrinkOne!overloads; alias shrink = AliasSeq!(temp[0], shrink!(temp[1 .. $])); } else alias shrink = AliasSeq!(); // done } // done. alias MemberFunctionsTuple = shrink!overloads; } else alias MemberFunctionsTuple = AliasSeq!(); } /// @safe unittest { interface I { I foo(); } class B { real foo(real v) { return v; } } class C : B, I { override C foo() { return this; } // covariant overriding of I.foo() } alias foos = MemberFunctionsTuple!(C, "foo"); static assert(foos.length == 2); static assert(__traits(isSame, foos[0], C.foo)); static assert(__traits(isSame, foos[1], B.foo)); } @safe unittest // Issue 15920 { import std.meta : AliasSeq; class A { void f(){} void f(int){} } class B : A { override void f(){} override void f(int){} } alias fs = MemberFunctionsTuple!(B, "f"); alias bfs = AliasSeq!(__traits(getOverloads, B, "f")); assert(__traits(isSame, fs[0], bfs[0]) || __traits(isSame, fs[0], bfs[1])); assert(__traits(isSame, fs[1], bfs[0]) || __traits(isSame, fs[1], bfs[1])); } @safe unittest { interface I { I test(); } interface J : I { J test(); } interface K { K test(int); } class B : I, K { K test(int) { return this; } B test() { return this; } static void test(string) { } } class C : B, J { override C test() { return this; } } alias test =MemberFunctionsTuple!(C, "test"); static assert(test.length == 2); static assert(is(FunctionTypeOf!(test[0]) == FunctionTypeOf!(C.test))); static assert(is(FunctionTypeOf!(test[1]) == FunctionTypeOf!(K.test))); alias noexist = MemberFunctionsTuple!(C, "noexist"); static assert(noexist.length == 0); interface L { int prop() @property; } alias prop = MemberFunctionsTuple!(L, "prop"); static assert(prop.length == 1); interface Test_I { void foo(); void foo(int); void foo(int, int); } interface Test : Test_I {} alias Test_foo = MemberFunctionsTuple!(Test, "foo"); static assert(Test_foo.length == 3); static assert(is(typeof(&Test_foo[0]) == void function())); static assert(is(typeof(&Test_foo[2]) == void function(int))); static assert(is(typeof(&Test_foo[1]) == void function(int, int))); } /** Returns an alias to the template that $(D T) is an instance of. It will return `void` if a symbol without a template is given. */ template TemplateOf(alias T : Base!Args, alias Base, Args...) { alias TemplateOf = Base; } /// ditto template TemplateOf(T : Base!Args, alias Base, Args...) { alias TemplateOf = Base; } /// ditto template TemplateOf(T) { alias TemplateOf = void; } /// @safe unittest { struct Foo(T, U) {} static assert(__traits(isSame, TemplateOf!(Foo!(int, real)), Foo)); } @safe unittest { template Foo1(A) {} template Foo2(A, B) {} template Foo3(alias A) {} template Foo4(string A) {} struct Foo5(A) {} struct Foo6(A, B) {} struct Foo7(alias A) {} template Foo8(A) { template Foo9(B) {} } template Foo10() {} static assert(__traits(isSame, TemplateOf!(Foo1!(int)), Foo1)); static assert(__traits(isSame, TemplateOf!(Foo2!(int, int)), Foo2)); static assert(__traits(isSame, TemplateOf!(Foo3!(123)), Foo3)); static assert(__traits(isSame, TemplateOf!(Foo4!("123")), Foo4)); static assert(__traits(isSame, TemplateOf!(Foo5!(int)), Foo5)); static assert(__traits(isSame, TemplateOf!(Foo6!(int, int)), Foo6)); static assert(__traits(isSame, TemplateOf!(Foo7!(123)), Foo7)); static assert(__traits(isSame, TemplateOf!(Foo8!(int).Foo9!(real)), Foo8!(int).Foo9)); static assert(__traits(isSame, TemplateOf!(Foo10!()), Foo10)); } // https://issues.dlang.org/show_bug.cgi?id=18214 @safe unittest { static assert(is(TemplateOf!(int[]) == void)); static assert(is(TemplateOf!bool == void)); } /** Returns a $(D AliasSeq) of the template arguments used to instantiate $(D T). */ template TemplateArgsOf(alias T : Base!Args, alias Base, Args...) { alias TemplateArgsOf = Args; } /// ditto template TemplateArgsOf(T : Base!Args, alias Base, Args...) { alias TemplateArgsOf = Args; } /// @safe unittest { import std.meta : AliasSeq; struct Foo(T, U) {} static assert(is(TemplateArgsOf!(Foo!(int, real)) == AliasSeq!(int, real))); } @safe unittest { template Foo1(A) {} template Foo2(A, B) {} template Foo3(alias A) {} template Foo4(string A) {} struct Foo5(A) {} struct Foo6(A, B) {} struct Foo7(alias A) {} template Foo8(A) { template Foo9(B) {} } template Foo10() {} enum x = 123; enum y = "123"; static assert(is(TemplateArgsOf!(Foo1!(int)) == AliasSeq!(int))); static assert(is(TemplateArgsOf!(Foo2!(int, int)) == AliasSeq!(int, int))); static assert(__traits(isSame, TemplateArgsOf!(Foo3!(x)), AliasSeq!(x))); static assert(TemplateArgsOf!(Foo4!(y)) == AliasSeq!(y)); static assert(is(TemplateArgsOf!(Foo5!(int)) == AliasSeq!(int))); static assert(is(TemplateArgsOf!(Foo6!(int, int)) == AliasSeq!(int, int))); static assert(__traits(isSame, TemplateArgsOf!(Foo7!(x)), AliasSeq!(x))); static assert(is(TemplateArgsOf!(Foo8!(int).Foo9!(real)) == AliasSeq!(real))); static assert(is(TemplateArgsOf!(Foo10!()) == AliasSeq!())); } private template maxAlignment(U...) if (isTypeTuple!U) { import std.meta : staticMap; static if (U.length == 0) static assert(0); else static if (U.length == 1) enum maxAlignment = U[0].alignof; else { import std.algorithm.comparison : max; enum maxAlignment = max(staticMap!(.maxAlignment, U)); } } /** Returns class instance alignment. */ template classInstanceAlignment(T) if (is(T == class)) { alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof)); } /// @safe unittest { class A { byte b; } class B { long l; } // As class instance always has a hidden pointer static assert(classInstanceAlignment!A == (void*).alignof); static assert(classInstanceAlignment!B == long.alignof); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // Type Conversion //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /** Get the type that all types can be implicitly converted to. Useful e.g. in figuring out an array type from a bunch of initializing values. Returns $(D_PARAM void) if passed an empty list, or if the types have no common type. */ template CommonType(T...) { static if (!T.length) { alias CommonType = void; } else static if (T.length == 1) { static if (is(typeof(T[0]))) { alias CommonType = typeof(T[0]); } else { alias CommonType = T[0]; } } else static if (is(typeof(true ? T[0].init : T[1].init) U)) { alias CommonType = CommonType!(U, T[2 .. $]); } else alias CommonType = void; } /// @safe unittest { alias X = CommonType!(int, long, short); assert(is(X == long)); alias Y = CommonType!(int, char[], short); assert(is(Y == void)); } @safe unittest { static assert(is(CommonType!(3) == int)); static assert(is(CommonType!(double, 4, float) == double)); static assert(is(CommonType!(string, char[]) == const(char)[])); static assert(is(CommonType!(3, 3U) == uint)); } /** * Returns a tuple with all possible target types of an implicit * conversion of a value of type $(D_PARAM T). * * Important note: * * The possible targets are computed more conservatively than the D * 2.005 compiler does, eliminating all dangerous conversions. For * example, $(D_PARAM ImplicitConversionTargets!double) does not * include $(D_PARAM float). */ template ImplicitConversionTargets(T) { static if (is(T == bool)) alias ImplicitConversionTargets = AliasSeq!(byte, ubyte, short, ushort, int, uint, long, ulong, CentTypeList, float, double, real, char, wchar, dchar); else static if (is(T == byte)) alias ImplicitConversionTargets = AliasSeq!(short, ushort, int, uint, long, ulong, CentTypeList, float, double, real, char, wchar, dchar); else static if (is(T == ubyte)) alias ImplicitConversionTargets = AliasSeq!(short, ushort, int, uint, long, ulong, CentTypeList, float, double, real, char, wchar, dchar); else static if (is(T == short)) alias ImplicitConversionTargets = AliasSeq!(int, uint, long, ulong, CentTypeList, float, double, real); else static if (is(T == ushort)) alias ImplicitConversionTargets = AliasSeq!(int, uint, long, ulong, CentTypeList, float, double, real); else static if (is(T == int)) alias ImplicitConversionTargets = AliasSeq!(long, ulong, CentTypeList, float, double, real); else static if (is(T == uint)) alias ImplicitConversionTargets = AliasSeq!(long, ulong, CentTypeList, float, double, real); else static if (is(T == long)) alias ImplicitConversionTargets = AliasSeq!(float, double, real); else static if (is(T == ulong)) alias ImplicitConversionTargets = AliasSeq!(float, double, real); else static if (is(cent) && is(T == cent)) alias ImplicitConversionTargets = AliasSeq!(float, double, real); else static if (is(ucent) && is(T == ucent)) alias ImplicitConversionTargets = AliasSeq!(float, double, real); else static if (is(T == float)) alias ImplicitConversionTargets = AliasSeq!(double, real); else static if (is(T == double)) alias ImplicitConversionTargets = AliasSeq!real; else static if (is(T == char)) alias ImplicitConversionTargets = AliasSeq!(wchar, dchar, byte, ubyte, short, ushort, int, uint, long, ulong, CentTypeList, float, double, real); else static if (is(T == wchar)) alias ImplicitConversionTargets = AliasSeq!(dchar, short, ushort, int, uint, long, ulong, CentTypeList, float, double, real); else static if (is(T == dchar)) alias ImplicitConversionTargets = AliasSeq!(int, uint, long, ulong, CentTypeList, float, double, real); else static if (is(T : typeof(null))) alias ImplicitConversionTargets = AliasSeq!(typeof(null)); else static if (is(T : Object)) alias ImplicitConversionTargets = TransitiveBaseTypeTuple!(T); else static if (isDynamicArray!T && !is(typeof(T.init[0]) == const)) { static if (is(typeof(T.init[0]) == shared)) alias ImplicitConversionTargets = AliasSeq!(const(shared(Unqual!(typeof(T.init[0]))))[]); else alias ImplicitConversionTargets = AliasSeq!(const(Unqual!(typeof(T.init[0])))[]); } else static if (is(T : void*)) alias ImplicitConversionTargets = AliasSeq!(void*); else alias ImplicitConversionTargets = AliasSeq!(); } @safe unittest { static assert(is(ImplicitConversionTargets!(double)[0] == real)); static assert(is(ImplicitConversionTargets!(string)[0] == const(char)[])); } /** Is $(D From) implicitly convertible to $(D To)? */ template isImplicitlyConvertible(From, To) { enum bool isImplicitlyConvertible = is(typeof({ void fun(ref From v) { void gun(To) {} gun(v); } })); } /// @safe unittest { static assert( isImplicitlyConvertible!(immutable(char), char)); static assert( isImplicitlyConvertible!(const(char), char)); static assert( isImplicitlyConvertible!(char, wchar)); static assert(!isImplicitlyConvertible!(wchar, char)); static assert(!isImplicitlyConvertible!(const(ushort), ubyte)); static assert(!isImplicitlyConvertible!(const(uint), ubyte)); static assert(!isImplicitlyConvertible!(const(ulong), ubyte)); static assert(!isImplicitlyConvertible!(const(char)[], string)); static assert( isImplicitlyConvertible!(string, const(char)[])); } /** Returns $(D true) iff a value of type $(D Rhs) can be assigned to a variable of type $(D Lhs). $(D isAssignable) returns whether both an lvalue and rvalue can be assigned. If you omit $(D Rhs), $(D isAssignable) will check identity assignable of $(D Lhs). */ enum isAssignable(Lhs, Rhs = Lhs) = isRvalueAssignable!(Lhs, Rhs) && isLvalueAssignable!(Lhs, Rhs); /// @safe unittest { static assert( isAssignable!(long, int)); static assert(!isAssignable!(int, long)); static assert( isAssignable!(const(char)[], string)); static assert(!isAssignable!(string, char[])); // int is assignable to int static assert( isAssignable!int); // immutable int is not assignable to immutable int static assert(!isAssignable!(immutable int)); } // ditto private enum isRvalueAssignable(Lhs, Rhs = Lhs) = __traits(compiles, lvalueOf!Lhs = rvalueOf!Rhs); // ditto private enum isLvalueAssignable(Lhs, Rhs = Lhs) = __traits(compiles, lvalueOf!Lhs = lvalueOf!Rhs); @safe unittest { static assert(!isAssignable!(immutable int, int)); static assert( isAssignable!(int, immutable int)); static assert(!isAssignable!(inout int, int)); static assert( isAssignable!(int, inout int)); static assert(!isAssignable!(inout int)); static assert( isAssignable!(shared int, int)); static assert( isAssignable!(int, shared int)); static assert( isAssignable!(shared int)); static assert( isAssignable!(void[1], void[1])); struct S { @disable this(); this(int n){} } static assert( isAssignable!(S, S)); struct S2 { this(int n){} } static assert( isAssignable!(S2, S2)); static assert(!isAssignable!(S2, int)); struct S3 { @disable void opAssign(); } static assert( isAssignable!(S3, S3)); struct S3X { @disable void opAssign(S3X); } static assert(!isAssignable!(S3X, S3X)); struct S4 { void opAssign(int); } static assert( isAssignable!(S4, S4)); static assert( isAssignable!(S4, int)); static assert( isAssignable!(S4, immutable int)); struct S5 { @disable this(); @disable this(this); } struct S6 { void opAssign(in ref S5); } static assert(!isAssignable!(S6, S5)); static assert(!isRvalueAssignable!(S6, S5)); static assert( isLvalueAssignable!(S6, S5)); static assert( isLvalueAssignable!(S6, immutable S5)); } // Equivalent with TypeStruct::isAssignable in compiler code. package template isBlitAssignable(T) { static if (is(OriginalType!T U) && !is(T == U)) { enum isBlitAssignable = isBlitAssignable!U; } else static if (isStaticArray!T && is(T == E[n], E, size_t n)) // Workaround for issue 11499 : isStaticArray!T should not be necessary. { enum isBlitAssignable = isBlitAssignable!E; } else static if (is(T == struct) || is(T == union)) { enum isBlitAssignable = isMutable!T && { size_t offset = 0; bool assignable = true; foreach (i, F; FieldTypeTuple!T) { static if (i == 0) { } else { if (T.tupleof[i].offsetof == offset) { if (assignable) continue; } else { if (!assignable) return false; } } assignable = isBlitAssignable!(typeof(T.tupleof[i])); offset = T.tupleof[i].offsetof; } return assignable; }(); } else enum isBlitAssignable = isMutable!T; } @safe unittest { static assert( isBlitAssignable!int); static assert(!isBlitAssignable!(const int)); class C{ const int i; } static assert( isBlitAssignable!C); struct S1{ int i; } struct S2{ const int i; } static assert( isBlitAssignable!S1); static assert(!isBlitAssignable!S2); struct S3X { union { int x; int y; } } struct S3Y { union { int x; const int y; } } struct S3Z { union { const int x; const int y; } } static assert( isBlitAssignable!(S3X)); static assert( isBlitAssignable!(S3Y)); static assert(!isBlitAssignable!(S3Z)); static assert(!isBlitAssignable!(const S3X)); static assert(!isBlitAssignable!(inout S3Y)); static assert(!isBlitAssignable!(immutable S3Z)); static assert( isBlitAssignable!(S3X[3])); static assert( isBlitAssignable!(S3Y[3])); static assert(!isBlitAssignable!(S3Z[3])); enum ES3X : S3X { a = S3X() } enum ES3Y : S3Y { a = S3Y() } enum ES3Z : S3Z { a = S3Z() } static assert( isBlitAssignable!(ES3X)); static assert( isBlitAssignable!(ES3Y)); static assert(!isBlitAssignable!(ES3Z)); static assert(!isBlitAssignable!(const ES3X)); static assert(!isBlitAssignable!(inout ES3Y)); static assert(!isBlitAssignable!(immutable ES3Z)); static assert( isBlitAssignable!(ES3X[3])); static assert( isBlitAssignable!(ES3Y[3])); static assert(!isBlitAssignable!(ES3Z[3])); union U1X { int x; int y; } union U1Y { int x; const int y; } union U1Z { const int x; const int y; } static assert( isBlitAssignable!(U1X)); static assert( isBlitAssignable!(U1Y)); static assert(!isBlitAssignable!(U1Z)); static assert(!isBlitAssignable!(const U1X)); static assert(!isBlitAssignable!(inout U1Y)); static assert(!isBlitAssignable!(immutable U1Z)); static assert( isBlitAssignable!(U1X[3])); static assert( isBlitAssignable!(U1Y[3])); static assert(!isBlitAssignable!(U1Z[3])); enum EU1X : U1X { a = U1X() } enum EU1Y : U1Y { a = U1Y() } enum EU1Z : U1Z { a = U1Z() } static assert( isBlitAssignable!(EU1X)); static assert( isBlitAssignable!(EU1Y)); static assert(!isBlitAssignable!(EU1Z)); static assert(!isBlitAssignable!(const EU1X)); static assert(!isBlitAssignable!(inout EU1Y)); static assert(!isBlitAssignable!(immutable EU1Z)); static assert( isBlitAssignable!(EU1X[3])); static assert( isBlitAssignable!(EU1Y[3])); static assert(!isBlitAssignable!(EU1Z[3])); struct SA { @property int[3] foo() { return [1,2,3]; } alias foo this; const int x; // SA is not blit assignable } static assert(!isStaticArray!SA); static assert(!isBlitAssignable!(SA[3])); } /* Works like $(D isImplicitlyConvertible), except this cares only about storage classes of the arguments. */ private template isStorageClassImplicitlyConvertible(From, To) { alias Pointify(T) = void*; enum isStorageClassImplicitlyConvertible = isImplicitlyConvertible!( ModifyTypePreservingTQ!(Pointify, From), ModifyTypePreservingTQ!(Pointify, To) ); } @safe unittest { static assert( isStorageClassImplicitlyConvertible!( int, const int)); static assert( isStorageClassImplicitlyConvertible!(immutable int, const int)); static assert(!isStorageClassImplicitlyConvertible!(const int, int)); static assert(!isStorageClassImplicitlyConvertible!(const int, immutable int)); static assert(!isStorageClassImplicitlyConvertible!(int, shared int)); static assert(!isStorageClassImplicitlyConvertible!(shared int, int)); } /** Determines whether the function type $(D F) is covariant with $(D G), i.e., functions of the type $(D F) can override ones of the type $(D G). */ template isCovariantWith(F, G) if (is(F == function) && is(G == function) || is(F == delegate) && is(G == delegate) || isFunctionPointer!F && isFunctionPointer!G) { static if (is(F : G)) enum isCovariantWith = true; else { alias Upr = F; alias Lwr = G; /* * Check for calling convention: require exact match. */ template checkLinkage() { enum ok = functionLinkage!Upr == functionLinkage!Lwr; } /* * Check for variadic parameter: require exact match. */ template checkVariadicity() { enum ok = variadicFunctionStyle!Upr == variadicFunctionStyle!Lwr; } /* * Check for function storage class: * - overrider can have narrower storage class than base */ template checkSTC() { // Note the order of arguments. The convertion order Lwr -> Upr is // correct since Upr should be semantically 'narrower' than Lwr. enum ok = isStorageClassImplicitlyConvertible!(Lwr, Upr); } /* * Check for function attributes: * - require exact match for ref and @property * - overrider can add pure and nothrow, but can't remove them * - @safe and @trusted are covariant with each other, unremovable */ template checkAttributes() { alias FA = FunctionAttribute; enum uprAtts = functionAttributes!Upr; enum lwrAtts = functionAttributes!Lwr; // enum wantExact = FA.ref_ | FA.property; enum safety = FA.safe | FA.trusted; enum ok = ( (uprAtts & wantExact) == (lwrAtts & wantExact)) && ( (uprAtts & FA.pure_ ) >= (lwrAtts & FA.pure_ )) && ( (uprAtts & FA.nothrow_) >= (lwrAtts & FA.nothrow_)) && (!!(uprAtts & safety ) >= !!(lwrAtts & safety )) ; } /* * Check for return type: usual implicit convertion. */ template checkReturnType() { enum ok = is(ReturnType!Upr : ReturnType!Lwr); } /* * Check for parameters: * - require exact match for types (cf. bugzilla 3075) * - require exact match for in, out, ref and lazy * - overrider can add scope, but can't remove */ template checkParameters() { alias STC = ParameterStorageClass; alias UprParams = Parameters!Upr; alias LwrParams = Parameters!Lwr; alias UprPSTCs = ParameterStorageClassTuple!Upr; alias LwrPSTCs = ParameterStorageClassTuple!Lwr; // template checkNext(size_t i) { static if (i < UprParams.length) { enum uprStc = UprPSTCs[i]; enum lwrStc = LwrPSTCs[i]; // enum wantExact = STC.out_ | STC.ref_ | STC.lazy_ | STC.return_; enum ok = ((uprStc & wantExact ) == (lwrStc & wantExact )) && ((uprStc & STC.scope_) >= (lwrStc & STC.scope_)) && checkNext!(i + 1).ok; } else enum ok = true; // done } static if (UprParams.length == LwrParams.length) enum ok = is(UprParams == LwrParams) && checkNext!(0).ok; else enum ok = false; } /* run all the checks */ enum isCovariantWith = checkLinkage !().ok && checkVariadicity!().ok && checkSTC !().ok && checkAttributes !().ok && checkReturnType !().ok && checkParameters !().ok ; } } /// @safe unittest { interface I { I clone(); } interface J { J clone(); } class C : I { override C clone() // covariant overriding of I.clone() { return new C; } } // C.clone() can override I.clone(), indeed. static assert(isCovariantWith!(typeof(C.clone), typeof(I.clone))); // C.clone() can't override J.clone(); the return type C is not implicitly // convertible to J. static assert(!isCovariantWith!(typeof(C.clone), typeof(J.clone))); } @safe unittest { enum bool isCovariantWith(alias f, alias g) = .isCovariantWith!(typeof(f), typeof(g)); // covariant return type interface I {} interface J : I {} interface BaseA { const(I) test(int); } interface DerivA_1 : BaseA { override const(J) test(int); } interface DerivA_2 : BaseA { override J test(int); } static assert( isCovariantWith!(DerivA_1.test, BaseA.test)); static assert( isCovariantWith!(DerivA_2.test, BaseA.test)); static assert(!isCovariantWith!(BaseA.test, DerivA_1.test)); static assert(!isCovariantWith!(BaseA.test, DerivA_2.test)); static assert( isCovariantWith!(BaseA.test, BaseA.test)); static assert( isCovariantWith!(DerivA_1.test, DerivA_1.test)); static assert( isCovariantWith!(DerivA_2.test, DerivA_2.test)); // function, function pointer and delegate J function() derived_function; I function() base_function; J delegate() derived_delegate; I delegate() base_delegate; static assert(.isCovariantWith!(typeof(derived_function), typeof(base_function))); static assert(.isCovariantWith!(typeof(*derived_function), typeof(*base_function))); static assert(.isCovariantWith!(typeof(derived_delegate), typeof(base_delegate))); // scope parameter interface BaseB { void test( int*, int*); } interface DerivB_1 : BaseB { override void test(scope int*, int*); } interface DerivB_2 : BaseB { override void test( int*, scope int*); } interface DerivB_3 : BaseB { override void test(scope int*, scope int*); } static assert( isCovariantWith!(DerivB_1.test, BaseB.test)); static assert( isCovariantWith!(DerivB_2.test, BaseB.test)); static assert( isCovariantWith!(DerivB_3.test, BaseB.test)); static assert(!isCovariantWith!(BaseB.test, DerivB_1.test)); static assert(!isCovariantWith!(BaseB.test, DerivB_2.test)); static assert(!isCovariantWith!(BaseB.test, DerivB_3.test)); // function storage class interface BaseC { void test() ; } interface DerivC_1 : BaseC { override void test() const; } static assert( isCovariantWith!(DerivC_1.test, BaseC.test)); static assert(!isCovariantWith!(BaseC.test, DerivC_1.test)); // increasing safety interface BaseE { void test() ; } interface DerivE_1 : BaseE { override void test() @safe ; } interface DerivE_2 : BaseE { override void test() @trusted; } static assert( isCovariantWith!(DerivE_1.test, BaseE.test)); static assert( isCovariantWith!(DerivE_2.test, BaseE.test)); static assert(!isCovariantWith!(BaseE.test, DerivE_1.test)); static assert(!isCovariantWith!(BaseE.test, DerivE_2.test)); // @safe and @trusted interface BaseF { void test1() @safe; void test2() @trusted; } interface DerivF : BaseF { override void test1() @trusted; override void test2() @safe; } static assert( isCovariantWith!(DerivF.test1, BaseF.test1)); static assert( isCovariantWith!(DerivF.test2, BaseF.test2)); } // Needed for rvalueOf/lvalueOf because "inout on return means // inout must be on a parameter as well" private struct __InoutWorkaroundStruct{} /** Creates an lvalue or rvalue of type $(D T) for $(D typeof(...)) and $(D __traits(compiles, ...)) purposes. No actual value is returned. Note: Trying to use returned value will result in a "Symbol Undefined" error at link time. Example: --- // Note that `f` doesn't have to be implemented // as is isn't called. int f(int); bool f(ref int); static assert(is(typeof(f(rvalueOf!int)) == int)); static assert(is(typeof(f(lvalueOf!int)) == bool)); int i = rvalueOf!int; // error, no actual value is returned --- */ @property T rvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); /// ditto @property ref T lvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); // Note: unittest can't be used as an example here as function overloads // aren't allowed inside functions. @system unittest { void needLvalue(T)(ref T); static struct S { } int i; struct Nested { void f() { ++i; } } static foreach (T; AliasSeq!(int, immutable int, inout int, string, S, Nested, Object)) { static assert(!__traits(compiles, needLvalue(rvalueOf!T))); static assert( __traits(compiles, needLvalue(lvalueOf!T))); static assert(is(typeof(rvalueOf!T) == T)); static assert(is(typeof(lvalueOf!T) == T)); } static assert(!__traits(compiles, rvalueOf!int = 1)); static assert( __traits(compiles, lvalueOf!byte = 127)); static assert(!__traits(compiles, lvalueOf!byte = 128)); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // SomethingTypeOf //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// private template AliasThisTypeOf(T) if (isAggregateType!T) { alias members = AliasSeq!(__traits(getAliasThis, T)); static if (members.length == 1) { alias AliasThisTypeOf = typeof(__traits(getMember, T.init, members[0])); } else static assert(0, T.stringof~" does not have alias this type"); } /* */ template BooleanTypeOf(T) { static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = BooleanTypeOf!AT; else alias X = OriginalType!T; static if (is(Unqual!X == bool)) { alias BooleanTypeOf = X; } else static assert(0, T.stringof~" is not boolean type"); } @safe unittest { // unexpected failure, maybe dmd type-merging bug static foreach (T; AliasSeq!bool) static foreach (Q; TypeQualifierList) { static assert( is(Q!T == BooleanTypeOf!( Q!T ))); static assert( is(Q!T == BooleanTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(void, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(BooleanTypeOf!( Q!T )), Q!T.stringof); static assert(!is(BooleanTypeOf!( SubTypeOf!(Q!T) ))); } } @safe unittest { struct B { bool val; alias val this; } struct S { B b; alias b this; } static assert(is(BooleanTypeOf!B == bool)); static assert(is(BooleanTypeOf!S == bool)); } /* */ template IntegralTypeOf(T) { import std.meta : staticIndexOf; static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = IntegralTypeOf!AT; else alias X = OriginalType!T; static if (staticIndexOf!(Unqual!X, IntegralTypeList) >= 0) { alias IntegralTypeOf = X; } else static assert(0, T.stringof~" is not an integral type"); } @safe unittest { static foreach (T; IntegralTypeList) static foreach (Q; TypeQualifierList) { static assert( is(Q!T == IntegralTypeOf!( Q!T ))); static assert( is(Q!T == IntegralTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(void, bool, FloatingPointTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(IntegralTypeOf!( Q!T ))); static assert(!is(IntegralTypeOf!( SubTypeOf!(Q!T) ))); } } /* */ template FloatingPointTypeOf(T) { import std.meta : staticIndexOf; static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = FloatingPointTypeOf!AT; else alias X = OriginalType!T; static if (staticIndexOf!(Unqual!X, FloatingPointTypeList) >= 0) { alias FloatingPointTypeOf = X; } else static assert(0, T.stringof~" is not a floating point type"); } @safe unittest { static foreach (T; FloatingPointTypeList) static foreach (Q; TypeQualifierList) { static assert( is(Q!T == FloatingPointTypeOf!( Q!T ))); static assert( is(Q!T == FloatingPointTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(void, bool, IntegralTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(FloatingPointTypeOf!( Q!T ))); static assert(!is(FloatingPointTypeOf!( SubTypeOf!(Q!T) ))); } } /* */ template NumericTypeOf(T) { static if (is(IntegralTypeOf!T X) || is(FloatingPointTypeOf!T X)) { alias NumericTypeOf = X; } else static assert(0, T.stringof~" is not a numeric type"); } @safe unittest { static foreach (T; NumericTypeList) static foreach (Q; TypeQualifierList) { static assert( is(Q!T == NumericTypeOf!( Q!T ))); static assert( is(Q!T == NumericTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(void, bool, CharTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; TypeQualifierList) { static assert(!is(NumericTypeOf!( Q!T ))); static assert(!is(NumericTypeOf!( SubTypeOf!(Q!T) ))); } } /* */ template UnsignedTypeOf(T) { import std.meta : staticIndexOf; static if (is(IntegralTypeOf!T X) && staticIndexOf!(Unqual!X, UnsignedIntTypeList) >= 0) alias UnsignedTypeOf = X; else static assert(0, T.stringof~" is not an unsigned type."); } /* */ template SignedTypeOf(T) { import std.meta : staticIndexOf; static if (is(IntegralTypeOf!T X) && staticIndexOf!(Unqual!X, SignedIntTypeList) >= 0) alias SignedTypeOf = X; else static if (is(FloatingPointTypeOf!T X)) alias SignedTypeOf = X; else static assert(0, T.stringof~" is not an signed type."); } /* */ template CharTypeOf(T) { import std.meta : staticIndexOf; static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = CharTypeOf!AT; else alias X = OriginalType!T; static if (staticIndexOf!(Unqual!X, CharTypeList) >= 0) { alias CharTypeOf = X; } else static assert(0, T.stringof~" is not a character type"); } @safe unittest { static foreach (T; CharTypeList) static foreach (Q; TypeQualifierList) { static assert( is(CharTypeOf!( Q!T ))); static assert( is(CharTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(void, bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; TypeQualifierList) { static assert(!is(CharTypeOf!( Q!T ))); static assert(!is(CharTypeOf!( SubTypeOf!(Q!T) ))); } static foreach (T; AliasSeq!(string, wstring, dstring, char[4])) static foreach (Q; TypeQualifierList) { static assert(!is(CharTypeOf!( Q!T ))); static assert(!is(CharTypeOf!( SubTypeOf!(Q!T) ))); } } /* */ template StaticArrayTypeOf(T) { static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = StaticArrayTypeOf!AT; else alias X = OriginalType!T; static if (is(X : E[n], E, size_t n)) alias StaticArrayTypeOf = X; else static assert(0, T.stringof~" is not a static array type"); } @safe unittest { static foreach (T; AliasSeq!(bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) { static assert(is( Q!( T[1] ) == StaticArrayTypeOf!( Q!( T[1] ) ) )); static foreach (P; TypeQualifierList) { // SubTypeOf cannot have inout type static assert(is( Q!(P!(T[1])) == StaticArrayTypeOf!( Q!(SubTypeOf!(P!(T[1]))) ) )); } } static foreach (T; AliasSeq!void) static foreach (Q; AliasSeq!TypeQualifierList) { static assert(is( StaticArrayTypeOf!( Q!(void[1]) ) == Q!(void[1]) )); } } /* */ template DynamicArrayTypeOf(T) { static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = DynamicArrayTypeOf!AT; else alias X = OriginalType!T; static if (is(Unqual!X : E[], E) && !is(typeof({ enum n = X.length; }))) { alias DynamicArrayTypeOf = X; } else static assert(0, T.stringof~" is not a dynamic array"); } @safe unittest { static foreach (T; AliasSeq!(/*void, */bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) { static assert(is( Q!T[] == DynamicArrayTypeOf!( Q!T[] ) )); static assert(is( Q!(T[]) == DynamicArrayTypeOf!( Q!(T[]) ) )); static foreach (P; AliasSeq!(MutableOf, ConstOf, ImmutableOf)) { static assert(is( Q!(P!T[]) == DynamicArrayTypeOf!( Q!(SubTypeOf!(P!T[])) ) )); static assert(is( Q!(P!(T[])) == DynamicArrayTypeOf!( Q!(SubTypeOf!(P!(T[]))) ) )); } } static assert(!is(DynamicArrayTypeOf!(int[3]))); static assert(!is(DynamicArrayTypeOf!(void[3]))); static assert(!is(DynamicArrayTypeOf!(typeof(null)))); } /* */ template ArrayTypeOf(T) { static if (is(StaticArrayTypeOf!T X) || is(DynamicArrayTypeOf!T X)) { alias ArrayTypeOf = X; } else static assert(0, T.stringof~" is not an array type"); } /* Always returns the Dynamic Array version. */ template StringTypeOf(T) { static if (is(T == typeof(null))) { // It is impossible to determine exact string type from typeof(null) - // it means that StringTypeOf!(typeof(null)) is undefined. // Then this behavior is convenient for template constraint. static assert(0, T.stringof~" is not a string type"); } else static if (is(T : const char[]) || is(T : const wchar[]) || is(T : const dchar[])) { static if (is(T : U[], U)) alias StringTypeOf = U[]; else static assert(0); } else static assert(0, T.stringof~" is not a string type"); } @safe unittest { static foreach (T; CharTypeList) static foreach (Q; AliasSeq!(MutableOf, ConstOf, ImmutableOf, InoutOf)) { static assert(is(Q!T[] == StringTypeOf!( Q!T[] ))); static if (!__traits(isSame, Q, InoutOf)) {{ static assert(is(Q!T[] == StringTypeOf!( SubTypeOf!(Q!T[]) ))); alias Str = Q!T[]; class C(S) { S val; alias val this; } static assert(is(StringTypeOf!(C!Str) == Str)); }} } static foreach (T; CharTypeList) static foreach (Q; AliasSeq!(SharedOf, SharedConstOf, SharedInoutOf)) { static assert(!is(StringTypeOf!( Q!T[] ))); } } @safe unittest { static assert(is(StringTypeOf!(char[4]) == char[])); } /* */ template AssocArrayTypeOf(T) { static if (is(AliasThisTypeOf!T AT) && !is(AT[] == AT)) alias X = AssocArrayTypeOf!AT; else alias X = OriginalType!T; static if (is(Unqual!X : V[K], K, V)) { alias AssocArrayTypeOf = X; } else static assert(0, T.stringof~" is not an associative array type"); } @safe unittest { static foreach (T; AliasSeq!(int/*bool, CharTypeList, NumericTypeList, ImaginaryTypeList, ComplexTypeList*/)) static foreach (P; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) static foreach (Q; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) static foreach (R; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) { static assert(is( P!(Q!T[R!T]) == AssocArrayTypeOf!( P!(Q!T[R!T]) ) )); } static foreach (T; AliasSeq!(int/*bool, CharTypeList, NumericTypeList, ImaginaryTypeList, ComplexTypeList*/)) static foreach (O; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) static foreach (P; AliasSeq!TypeQualifierList) static foreach (Q; AliasSeq!TypeQualifierList) static foreach (R; AliasSeq!TypeQualifierList) { static assert(is( O!(P!(Q!T[R!T])) == AssocArrayTypeOf!( O!(SubTypeOf!(P!(Q!T[R!T]))) ) )); } } /* */ template BuiltinTypeOf(T) { static if (is(T : void)) alias BuiltinTypeOf = void; else static if (is(BooleanTypeOf!T X)) alias BuiltinTypeOf = X; else static if (is(IntegralTypeOf!T X)) alias BuiltinTypeOf = X; else static if (is(FloatingPointTypeOf!T X))alias BuiltinTypeOf = X; else static if (is(T : const(ireal))) alias BuiltinTypeOf = ireal; //TODO else static if (is(T : const(creal))) alias BuiltinTypeOf = creal; //TODO else static if (is(CharTypeOf!T X)) alias BuiltinTypeOf = X; else static if (is(ArrayTypeOf!T X)) alias BuiltinTypeOf = X; else static if (is(AssocArrayTypeOf!T X)) alias BuiltinTypeOf = X; else static assert(0); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // isSomething //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /** * Detect whether $(D T) is a built-in boolean type. */ enum bool isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; /// @safe unittest { static assert( isBoolean!bool); enum EB : bool { a = true } static assert( isBoolean!EB); static assert(!isBoolean!(SubTypeOf!bool)); } @safe unittest { static struct S(T) { T t; alias t this; } static assert(!isIntegral!(S!bool)); } /** * Detect whether $(D T) is a built-in integral type. Types $(D bool), * $(D char), $(D wchar), and $(D dchar) are not considered integral. */ enum bool isIntegral(T) = is(IntegralTypeOf!T) && !isAggregateType!T; /// @safe unittest { static assert( isIntegral!byte && isIntegral!short && isIntegral!int && isIntegral!long && isIntegral!(const(long)) && isIntegral!(immutable(long)) ); static assert( !isIntegral!bool && !isIntegral!char && !isIntegral!double ); // types which act as integral values do not pass struct S { int val; alias val this; } static assert(!isIntegral!S); } @safe unittest { static foreach (T; IntegralTypeList) { static foreach (Q; TypeQualifierList) { static assert( isIntegral!(Q!T)); static assert(!isIntegral!(SubTypeOf!(Q!T))); } } static assert(!isIntegral!float); enum EU : uint { a = 0, b = 1, c = 2 } // base type is unsigned enum EI : int { a = -1, b = 0, c = 1 } // base type is signed (bug 7909) static assert(isIntegral!EU && isUnsigned!EU && !isSigned!EU); static assert(isIntegral!EI && !isUnsigned!EI && isSigned!EI); } /** * Detect whether $(D T) is a built-in floating point type. */ enum bool isFloatingPoint(T) = __traits(isFloating, T) && !(is(Unqual!T == cfloat) || is(Unqual!T == cdouble) || is(Unqual!T == creal) || is(Unqual!T == ifloat) || is(Unqual!T == idouble) || is(Unqual!T == ireal)); /// @safe unittest { static assert( isFloatingPoint!float && isFloatingPoint!double && isFloatingPoint!real && isFloatingPoint!(const(real)) && isFloatingPoint!(immutable(real)) ); static assert(!isFloatingPoint!int); // complex and imaginary numbers do not pass static assert( !isFloatingPoint!cfloat && !isFloatingPoint!ifloat ); // types which act as floating point values do not pass struct S { float val; alias val this; } static assert(!isFloatingPoint!S); } @safe unittest { enum EF : real { a = 1.414, b = 1.732, c = 2.236 } static foreach (T; AliasSeq!(FloatingPointTypeList, EF)) { static foreach (Q; TypeQualifierList) { static assert( isFloatingPoint!(Q!T)); static assert(!isFloatingPoint!(SubTypeOf!(Q!T))); } } static foreach (T; IntegralTypeList) { static foreach (Q; TypeQualifierList) { static assert(!isFloatingPoint!(Q!T)); } } } // https://issues.dlang.org/show_bug.cgi?id=17195 @safe unittest { static assert(!isFloatingPoint!cfloat); static assert(!isFloatingPoint!cdouble); static assert(!isFloatingPoint!creal); static assert(!isFloatingPoint!ifloat); static assert(!isFloatingPoint!idouble); static assert(!isFloatingPoint!ireal); } /** * Detect whether $(D T) is a built-in numeric type (integral or floating * point). */ enum bool isNumeric(T) = __traits(isArithmetic, T) && !(is(Unqual!T == bool) || is(Unqual!T == char) || is(Unqual!T == wchar) || is(Unqual!T == dchar)); /// @safe unittest { static assert( isNumeric!byte && isNumeric!short && isNumeric!int && isNumeric!long && isNumeric!float && isNumeric!double && isNumeric!real && isNumeric!(const(real)) && isNumeric!(immutable(real)) ); static assert( !isNumeric!void && !isNumeric!bool && !isNumeric!char && !isNumeric!wchar && !isNumeric!dchar ); // types which act as numeric values do not pass struct S { int val; alias val this; } static assert(!isIntegral!S); } @safe unittest { static foreach (T; AliasSeq!(NumericTypeList)) { static foreach (Q; TypeQualifierList) { static assert( isNumeric!(Q!T)); static assert(!isNumeric!(SubTypeOf!(Q!T))); } } static struct S(T) { T t; alias t this; } static assert(!isNumeric!(S!int)); } /** * Detect whether $(D T) is a scalar type (a built-in numeric, character or * boolean type). */ enum bool isScalarType(T) = is(T : real) && !isAggregateType!T; /// @safe unittest { static assert(!isScalarType!void); static assert( isScalarType!(immutable(byte))); static assert( isScalarType!(immutable(ushort))); static assert( isScalarType!(immutable(int))); static assert( isScalarType!(ulong)); static assert( isScalarType!(shared(float))); static assert( isScalarType!(shared(const bool))); static assert( isScalarType!(const(char))); static assert( isScalarType!(wchar)); static assert( isScalarType!(const(dchar))); static assert( isScalarType!(const(double))); static assert( isScalarType!(const(real))); } @safe unittest { static struct S(T) { T t; alias t this; } static assert(!isScalarType!(S!int)); } /** * Detect whether $(D T) is a basic type (scalar type or void). */ enum bool isBasicType(T) = isScalarType!T || is(Unqual!T == void); /// @safe unittest { static assert(isBasicType!void); static assert(isBasicType!(const(void))); static assert(isBasicType!(shared(void))); static assert(isBasicType!(immutable(void))); static assert(isBasicType!(shared const(void))); static assert(isBasicType!(shared inout(void))); static assert(isBasicType!(shared inout const(void))); static assert(isBasicType!(inout(void))); static assert(isBasicType!(inout const(void))); static assert(isBasicType!(immutable(int))); static assert(isBasicType!(shared(float))); static assert(isBasicType!(shared(const bool))); static assert(isBasicType!(const(dchar))); } /** * Detect whether $(D T) is a built-in unsigned numeric type. */ enum bool isUnsigned(T) = __traits(isUnsigned, T) && !(is(Unqual!T == char) || is(Unqual!T == wchar) || is(Unqual!T == dchar) || is(Unqual!T == bool)); /// @safe unittest { static assert( isUnsigned!uint && isUnsigned!ulong ); static assert( !isUnsigned!char && !isUnsigned!int && !isUnsigned!long && !isUnsigned!char && !isUnsigned!wchar && !isUnsigned!dchar ); } @safe unittest { static foreach (T; AliasSeq!(UnsignedIntTypeList)) { static foreach (Q; TypeQualifierList) { static assert( isUnsigned!(Q!T)); static assert(!isUnsigned!(SubTypeOf!(Q!T))); } } static struct S(T) { T t; alias t this; } static assert(!isUnsigned!(S!uint)); } /** * Detect whether $(D T) is a built-in signed numeric type. */ enum bool isSigned(T) = __traits(isArithmetic, T) && !__traits(isUnsigned, T); /// @safe unittest { static assert( isSigned!int && isSigned!long ); static assert( !isSigned!uint && !isSigned!ulong ); } @safe unittest { enum E { e1 = 0 } static assert(isSigned!E); enum Eubyte : ubyte { e1 = 0 } static assert(!isSigned!Eubyte); static foreach (T; AliasSeq!(SignedIntTypeList)) { static foreach (Q; TypeQualifierList) { static assert( isSigned!(Q!T)); static assert(!isSigned!(SubTypeOf!(Q!T))); } } static struct S(T) { T t; alias t this; } static assert(!isSigned!(S!uint)); } // https://issues.dlang.org/show_bug.cgi?id=17196 @safe unittest { static assert(isUnsigned!bool == false); static assert(isSigned!bool == false); } /** * Detect whether $(D T) is one of the built-in character types. * * The built-in char types are any of $(D char), $(D wchar) or $(D dchar), with * or without qualifiers. */ enum bool isSomeChar(T) = is(CharTypeOf!T) && !isAggregateType!T; /// @safe unittest { //Char types static assert( isSomeChar!char); static assert( isSomeChar!wchar); static assert( isSomeChar!dchar); static assert( isSomeChar!(typeof('c'))); static assert( isSomeChar!(immutable char)); static assert( isSomeChar!(const dchar)); //Non char types static assert(!isSomeChar!int); static assert(!isSomeChar!byte); static assert(!isSomeChar!string); static assert(!isSomeChar!wstring); static assert(!isSomeChar!dstring); static assert(!isSomeChar!(char[4])); } @safe unittest { enum EC : char { a = 'x', b = 'y' } static foreach (T; AliasSeq!(CharTypeList, EC)) { static foreach (Q; TypeQualifierList) { static assert( isSomeChar!( Q!T )); static assert(!isSomeChar!( SubTypeOf!(Q!T) )); } } // alias-this types are not allowed static struct S(T) { T t; alias t this; } static assert(!isSomeChar!(S!char)); } /** Detect whether $(D T) is one of the built-in string types. The built-in string types are $(D Char[]), where $(D Char) is any of $(D char), $(D wchar) or $(D dchar), with or without qualifiers. Static arrays of characters (like $(D char[80])) are not considered built-in string types. */ enum bool isSomeString(T) = is(StringTypeOf!T) && !isAggregateType!T && !isStaticArray!T && !is(T == enum); /// @safe unittest { //String types static assert( isSomeString!string); static assert( isSomeString!(wchar[])); static assert( isSomeString!(dchar[])); static assert( isSomeString!(typeof("aaa"))); static assert( isSomeString!(const(char)[])); //Non string types static assert(!isSomeString!int); static assert(!isSomeString!(int[])); static assert(!isSomeString!(byte[])); static assert(!isSomeString!(typeof(null))); static assert(!isSomeString!(char[4])); enum ES : string { a = "aaa", b = "bbb" } static assert(!isSomeString!ES); static struct Stringish { string str; alias str this; } static assert(!isSomeString!Stringish); } @safe unittest { static foreach (T; AliasSeq!(char[], dchar[], string, wstring, dstring)) { static assert( isSomeString!( T )); static assert(!isSomeString!(SubTypeOf!(T))); } } /** * Detect whether type $(D T) is a narrow string. * * All arrays that use char, wchar, and their qualified versions are narrow * strings. (Those include string and wstring). */ enum bool isNarrowString(T) = isSomeString!T && !is(T : const dchar[]); /// @safe unittest { static assert(isNarrowString!string); static assert(isNarrowString!wstring); static assert(isNarrowString!(char[])); static assert(isNarrowString!(wchar[])); static assert(!isNarrowString!dstring); static assert(!isNarrowString!(dchar[])); static assert(!isNarrowString!(typeof(null))); static assert(!isNarrowString!(char[4])); enum ES : string { a = "aaa", b = "bbb" } static assert(!isNarrowString!ES); static struct Stringish { string str; alias str this; } static assert(!isNarrowString!Stringish); } @safe unittest { static foreach (T; AliasSeq!(char[], string, wstring)) { static foreach (Q; AliasSeq!(MutableOf, ConstOf, ImmutableOf)/*TypeQualifierList*/) { static assert( isNarrowString!( Q!T )); static assert(!isNarrowString!( SubTypeOf!(Q!T) )); } } static foreach (T; AliasSeq!(int, int[], byte[], dchar[], dstring, char[4])) { static foreach (Q; TypeQualifierList) { static assert(!isNarrowString!( Q!T )); static assert(!isNarrowString!( SubTypeOf!(Q!T) )); } } } /** * Detects whether `T` is a comparable type. Basic types and structs and * classes that implement opCmp are ordering comparable. */ enum bool isOrderingComparable(T) = ifTestable!(T, unaryFun!"a < a"); /// @safe unittest { static assert(isOrderingComparable!int); static assert(isOrderingComparable!string); static assert(!isOrderingComparable!creal); static struct Foo {} static assert(!isOrderingComparable!Foo); static struct Bar { int a; auto opCmp(Bar b1) const { return a - b1.a; } } Bar b1 = Bar(5); Bar b2 = Bar(7); assert(isOrderingComparable!Bar && b2 > b1); } /// ditto enum bool isEqualityComparable(T) = ifTestable!(T, unaryFun!"a == a"); @safe unittest { static assert(isEqualityComparable!int); static assert(isEqualityComparable!string); static assert(!isEqualityComparable!void); struct Foo {} static assert(isEqualityComparable!Foo); struct Bar { int a; auto opEquals(Bar b1) const { return a == b1.a; } } Bar b1 = Bar(5); Bar b2 = Bar(5); Bar b3 = Bar(7); static assert(isEqualityComparable!Bar); assert(b1 == b2); assert(b1 != b3); } version(TestComplex) deprecated @safe unittest { static assert(isEqualityComparable!creal); } /** $(RED Warning: This trait will be deprecated as soon as it is no longer used in Phobos. For a function parameter to safely accept a type that implicitly converts to string as a string, the conversion needs to happen at the callsite; otherwise, the conversion is done inside the function, and in many cases, that means that local memory is sliced (e.g. if a static array is passed to the function, then it's copied, and the resulting dynamic array will be a slice of a local variable). So, if the resulting string escapes the function, the string refers to invalid memory, and accessing it would mean accessing invalid memory. As such, the only safe way for a function to accept types that implicitly convert to string is for the implicit conversion to be done at the callsite, and that can only occur if the parameter is explicitly typed as an array, whereas using isConvertibleToString in a template constraint would result in the conversion being done inside the function. As such, isConvertibleToString is inherently unsafe and is going to be deprecated.) Detect whether $(D T) is a struct, static array, or enum that is implicitly convertible to a string. */ template isConvertibleToString(T) { enum isConvertibleToString = (isAggregateType!T || isStaticArray!T || is(T == enum)) && is(StringTypeOf!T); } /// @safe unittest { static struct AliasedString { string s; alias s this; } enum StringEnum { a = "foo" } assert(!isConvertibleToString!string); assert(isConvertibleToString!AliasedString); assert(isConvertibleToString!StringEnum); assert(isConvertibleToString!(char[25])); assert(!isConvertibleToString!(char[])); } @safe unittest // Bugzilla 16573 { enum I : int { foo = 1 } enum S : string { foo = "foo" } assert(!isConvertibleToString!I); assert(isConvertibleToString!S); } package template convertToString(T) { static if (isConvertibleToString!T) alias convertToString = StringTypeOf!T; else alias convertToString = T; } /** * Detect whether type $(D T) is a string that will be autodecoded. * * All arrays that use char, wchar, and their qualified versions are narrow * strings. (Those include string and wstring). * Aggregates that implicitly cast to narrow strings are included. * * Params: * T = type to be tested * * Returns: * true if T represents a string that is subject to autodecoding * * See Also: * $(LREF isNarrowString) */ enum bool isAutodecodableString(T) = (is(T : const char[]) || is(T : const wchar[])) && !isStaticArray!T; /// @safe unittest { static struct Stringish { string s; alias s this; } assert(isAutodecodableString!wstring); assert(isAutodecodableString!Stringish); assert(!isAutodecodableString!dstring); } /** * Detect whether type $(D T) is a static array. */ enum bool isStaticArray(T) = __traits(isStaticArray, T); /// @safe unittest { static assert( isStaticArray!(int[3])); static assert( isStaticArray!(const(int)[5])); static assert( isStaticArray!(const(int)[][5])); static assert(!isStaticArray!(const(int)[])); static assert(!isStaticArray!(immutable(int)[])); static assert(!isStaticArray!(const(int)[4][])); static assert(!isStaticArray!(int[])); static assert(!isStaticArray!(int[char])); static assert(!isStaticArray!(int[1][])); static assert(!isStaticArray!(int[int])); static assert(!isStaticArray!int); } @safe unittest { static foreach (T; AliasSeq!(int[51], int[][2], char[][int][11], immutable char[13u], const(real)[1], const(real)[1][1], void[0])) { static foreach (Q; TypeQualifierList) { static assert( isStaticArray!( Q!T )); static assert(!isStaticArray!( SubTypeOf!(Q!T) )); } } //enum ESA : int[1] { a = [1], b = [2] } //static assert( isStaticArray!ESA); } /** * Detect whether type $(D T) is a dynamic array. */ enum bool isDynamicArray(T) = is(DynamicArrayTypeOf!T) && !isAggregateType!T; /// @safe unittest { static assert( isDynamicArray!(int[])); static assert( isDynamicArray!(string)); static assert( isDynamicArray!(long[3][])); static assert(!isDynamicArray!(int[5])); static assert(!isDynamicArray!(typeof(null))); } @safe unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(int[], char[], string, long[3][], double[string][])) { static foreach (Q; TypeQualifierList) { static assert( isDynamicArray!( Q!T )); static assert(!isDynamicArray!( SubTypeOf!(Q!T) )); } } } /** * Detect whether type $(D T) is an array (static or dynamic; for associative * arrays see $(LREF isAssociativeArray)). */ enum bool isArray(T) = isStaticArray!T || isDynamicArray!T; /// @safe unittest { static assert( isArray!(int[])); static assert( isArray!(int[5])); static assert( isArray!(string)); static assert(!isArray!uint); static assert(!isArray!(uint[uint])); static assert(!isArray!(typeof(null))); } @safe unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(int[], int[5], void[])) { static foreach (Q; TypeQualifierList) { static assert( isArray!(Q!T)); static assert(!isArray!(SubTypeOf!(Q!T))); } } } /** * Detect whether $(D T) is an associative array type */ enum bool isAssociativeArray(T) = __traits(isAssociativeArray, T); @safe unittest { struct Foo { @property uint[] keys() { return null; } @property uint[] values() { return null; } } static foreach (T; AliasSeq!(int[int], int[string], immutable(char[5])[int])) { static foreach (Q; TypeQualifierList) { static assert( isAssociativeArray!(Q!T)); static assert(!isAssociativeArray!(SubTypeOf!(Q!T))); } } static assert(!isAssociativeArray!Foo); static assert(!isAssociativeArray!int); static assert(!isAssociativeArray!(int[])); static assert(!isAssociativeArray!(typeof(null))); //enum EAA : int[int] { a = [1:1], b = [2:2] } //static assert( isAssociativeArray!EAA); } /** * Detect whether type $(D T) is a builtin type. */ enum bool isBuiltinType(T) = is(BuiltinTypeOf!T) && !isAggregateType!T; /// @safe unittest { class C; union U; struct S; interface I; static assert( isBuiltinType!void); static assert( isBuiltinType!string); static assert( isBuiltinType!(int[])); static assert( isBuiltinType!(C[string])); static assert(!isBuiltinType!C); static assert(!isBuiltinType!U); static assert(!isBuiltinType!S); static assert(!isBuiltinType!I); static assert(!isBuiltinType!(void delegate(int))); } /** * Detect whether type $(D T) is a SIMD vector type. */ enum bool isSIMDVector(T) = is(T : __vector(V[N]), V, size_t N); @safe unittest { static if (is(__vector(float[4]))) { alias SimdVec = __vector(float[4]); static assert(isSIMDVector!(__vector(float[4]))); static assert(isSIMDVector!SimdVec); } static assert(!isSIMDVector!uint); static assert(!isSIMDVector!(float[4])); } /** * Detect whether type $(D T) is a pointer. */ enum bool isPointer(T) = is(T == U*, U) && !isAggregateType!T; @safe unittest { static foreach (T; AliasSeq!(int*, void*, char[]*)) { static foreach (Q; TypeQualifierList) { static assert( isPointer!(Q!T)); static assert(!isPointer!(SubTypeOf!(Q!T))); } } static assert(!isPointer!uint); static assert(!isPointer!(uint[uint])); static assert(!isPointer!(char[])); static assert(!isPointer!(typeof(null))); } /** Returns the target type of a pointer. */ alias PointerTarget(T : T*) = T; /// @safe unittest { static assert(is(PointerTarget!(int*) == int)); static assert(is(PointerTarget!(void*) == void)); } /** * Detect whether type $(D T) is an aggregate type. */ enum bool isAggregateType(T) = is(T == struct) || is(T == union) || is(T == class) || is(T == interface); /// @safe unittest { class C; union U; struct S; interface I; static assert( isAggregateType!C); static assert( isAggregateType!U); static assert( isAggregateType!S); static assert( isAggregateType!I); static assert(!isAggregateType!void); static assert(!isAggregateType!string); static assert(!isAggregateType!(int[])); static assert(!isAggregateType!(C[string])); static assert(!isAggregateType!(void delegate(int))); } /** * Returns $(D true) if T can be iterated over using a $(D foreach) loop with * a single loop variable of automatically inferred type, regardless of how * the $(D foreach) loop is implemented. This includes ranges, structs/classes * that define $(D opApply) with a single loop variable, and builtin dynamic, * static and associative arrays. */ enum bool isIterable(T) = is(typeof({ foreach (elem; T.init) {} })); /// @safe unittest { struct OpApply { int opApply(scope int delegate(ref uint) dg) { assert(0); } } struct Range { @property uint front() { assert(0); } void popFront() { assert(0); } enum bool empty = false; } static assert( isIterable!(uint[])); static assert( isIterable!OpApply); static assert( isIterable!(uint[string])); static assert( isIterable!Range); static assert(!isIterable!uint); } /** * Returns true if T is not const or immutable. Note that isMutable is true for * string, or immutable(char)[], because the 'head' is mutable. */ enum bool isMutable(T) = !is(T == const) && !is(T == immutable) && !is(T == inout); /// @safe unittest { static assert( isMutable!int); static assert( isMutable!string); static assert( isMutable!(shared int)); static assert( isMutable!(shared const(int)[])); static assert(!isMutable!(const int)); static assert(!isMutable!(inout int)); static assert(!isMutable!(shared(const int))); static assert(!isMutable!(shared(inout int))); static assert(!isMutable!(immutable string)); } /** * Returns true if T is an instance of the template S. */ enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...); /// ditto template isInstanceOf(alias S, alias T) { enum impl(alias T : S!Args, Args...) = true; enum impl(alias T) = false; enum isInstanceOf = impl!T; } /// @safe unittest { static struct Foo(T...) { } static struct Bar(T...) { } static struct Doo(T) { } static struct ABC(int x) { } static void fun(T)() { } template templ(T) { } static assert(isInstanceOf!(Foo, Foo!int)); static assert(!isInstanceOf!(Foo, Bar!int)); static assert(!isInstanceOf!(Foo, int)); static assert(isInstanceOf!(Doo, Doo!int)); static assert(isInstanceOf!(ABC, ABC!1)); static assert(!isInstanceOf!(Foo, Foo)); static assert(isInstanceOf!(fun, fun!int)); static assert(isInstanceOf!(templ, templ!int)); } /** * To use `isInstanceOf` to check the identity of a template while inside of said * template, use $(LREF TemplateOf). */ @safe unittest { static struct A(T = void) { // doesn't work as expected, only accepts A when T = void void func(B)(B b) if (isInstanceOf!(A, B)) {} // correct behavior void method(B)(B b) if (isInstanceOf!(TemplateOf!(A), B)) {} } A!(void) a1; A!(void) a2; A!(int) a3; static assert(!__traits(compiles, a1.func(a3))); static assert( __traits(compiles, a1.method(a2))); static assert( __traits(compiles, a1.method(a3))); } @safe unittest { static void fun1(T)() { } static void fun2(T)() { } template templ1(T) { } template templ2(T) { } static assert(!isInstanceOf!(fun1, fun2!int)); static assert(!isInstanceOf!(templ1, templ2!int)); } /** * Check whether the tuple T is an expression tuple. * An expression tuple only contains expressions. * * See_Also: $(LREF isTypeTuple). */ template isExpressions(T ...) { static if (T.length >= 2) enum bool isExpressions = isExpressions!(T[0 .. $/2]) && isExpressions!(T[$/2 .. $]); else static if (T.length == 1) enum bool isExpressions = !is(T[0]) && __traits(compiles, { auto ex = T[0]; }); else enum bool isExpressions = true; // default } /// @safe unittest { static assert(isExpressions!(1, 2.0, "a")); static assert(!isExpressions!(int, double, string)); static assert(!isExpressions!(int, 2.0, "a")); } /** * Alternate name for $(LREF isExpressions), kept for legacy compatibility. */ alias isExpressionTuple = isExpressions; @safe unittest { void foo(); static int bar() { return 42; } immutable aa = [ 1: -1 ]; alias myint = int; static assert( isExpressionTuple!(42)); static assert( isExpressionTuple!aa); static assert( isExpressionTuple!("cattywampus", 2.7, aa)); static assert( isExpressionTuple!(bar())); static assert(!isExpressionTuple!isExpressionTuple); static assert(!isExpressionTuple!foo); static assert(!isExpressionTuple!( (a) { } )); static assert(!isExpressionTuple!int); static assert(!isExpressionTuple!myint); } /** * Check whether the tuple $(D T) is a type tuple. * A type tuple only contains types. * * See_Also: $(LREF isExpressions). */ template isTypeTuple(T...) { static if (T.length >= 2) enum bool isTypeTuple = isTypeTuple!(T[0 .. $/2]) && isTypeTuple!(T[$/2 .. $]); else static if (T.length == 1) enum bool isTypeTuple = is(T[0]); else enum bool isTypeTuple = true; // default } /// @safe unittest { static assert(isTypeTuple!(int, float, string)); static assert(!isTypeTuple!(1, 2.0, "a")); static assert(!isTypeTuple!(1, double, string)); } @safe unittest { class C {} void func(int) {} auto c = new C; enum CONST = 42; static assert( isTypeTuple!int); static assert( isTypeTuple!string); static assert( isTypeTuple!C); static assert( isTypeTuple!(typeof(func))); static assert( isTypeTuple!(int, char, double)); static assert(!isTypeTuple!c); static assert(!isTypeTuple!isTypeTuple); static assert(!isTypeTuple!CONST); } /** Detect whether symbol or type $(D T) is a function pointer. */ template isFunctionPointer(T...) if (T.length == 1) { static if (is(T[0] U) || is(typeof(T[0]) U)) { static if (is(U F : F*) && is(F == function)) enum bool isFunctionPointer = true; else enum bool isFunctionPointer = false; } else enum bool isFunctionPointer = false; } /// @safe unittest { static void foo() {} void bar() {} auto fpfoo = &foo; static assert( isFunctionPointer!fpfoo); static assert( isFunctionPointer!(void function())); auto dgbar = &bar; static assert(!isFunctionPointer!dgbar); static assert(!isFunctionPointer!(void delegate())); static assert(!isFunctionPointer!foo); static assert(!isFunctionPointer!bar); static assert( isFunctionPointer!((int a) {})); } /** Detect whether symbol or type $(D T) is a delegate. */ template isDelegate(T...) if (T.length == 1) { static if (is(typeof(& T[0]) U : U*) && is(typeof(& T[0]) U == delegate)) { // T is a (nested) function symbol. enum bool isDelegate = true; } else static if (is(T[0] W) || is(typeof(T[0]) W)) { // T is an expression or a type. Take the type of it and examine. enum bool isDelegate = is(W == delegate); } else enum bool isDelegate = false; } /// @safe unittest { static void sfunc() { } int x; void func() { x++; } int delegate() dg; assert(isDelegate!dg); assert(isDelegate!(int delegate())); assert(isDelegate!(typeof(&func))); int function() fp; assert(!isDelegate!fp); assert(!isDelegate!(int function())); assert(!isDelegate!(typeof(&sfunc))); } /** Detect whether symbol or type $(D T) is a function, a function pointer or a delegate. */ template isSomeFunction(T...) if (T.length == 1) { static if (is(typeof(& T[0]) U : U*) && is(U == function) || is(typeof(& T[0]) U == delegate)) { // T is a (nested) function symbol. enum bool isSomeFunction = true; } else static if (is(T[0] W) || is(typeof(T[0]) W)) { // T is an expression or a type. Take the type of it and examine. static if (is(W F : F*) && is(F == function)) enum bool isSomeFunction = true; // function pointer else enum bool isSomeFunction = is(W == function) || is(W == delegate); } else enum bool isSomeFunction = false; } @safe unittest { static real func(ref int) { return 0; } static void prop() @property { } void nestedFunc() { } void nestedProp() @property { } class C { real method(ref int) { return 0; } real prop() @property { return 0; } } auto c = new C; auto fp = &func; auto dg = &c.method; real val; static assert( isSomeFunction!func); static assert( isSomeFunction!prop); static assert( isSomeFunction!nestedFunc); static assert( isSomeFunction!nestedProp); static assert( isSomeFunction!(C.method)); static assert( isSomeFunction!(C.prop)); static assert( isSomeFunction!(c.prop)); static assert( isSomeFunction!(c.prop)); static assert( isSomeFunction!fp); static assert( isSomeFunction!dg); static assert( isSomeFunction!(typeof(func))); static assert( isSomeFunction!(real function(ref int))); static assert( isSomeFunction!(real delegate(ref int))); static assert( isSomeFunction!((int a) { return a; })); static assert(!isSomeFunction!int); static assert(!isSomeFunction!val); static assert(!isSomeFunction!isSomeFunction); } /** Detect whether $(D T) is a callable object, which can be called with the function call operator $(D $(LPAREN)...$(RPAREN)). */ template isCallable(T...) if (T.length == 1) { static if (is(typeof(& T[0].opCall) == delegate)) // T is a object which has a member function opCall(). enum bool isCallable = true; else static if (is(typeof(& T[0].opCall) V : V*) && is(V == function)) // T is a type which has a static member function opCall(). enum bool isCallable = true; else enum bool isCallable = isSomeFunction!T; } /// @safe unittest { interface I { real value() @property; } struct S { static int opCall(int) { return 0; } } class C { int opCall(int) { return 0; } } auto c = new C; static assert( isCallable!c); static assert( isCallable!S); static assert( isCallable!(c.opCall)); static assert( isCallable!(I.value)); static assert( isCallable!((int a) { return a; })); static assert(!isCallable!I); } /** * Detect whether $(D T) is an abstract function. */ template isAbstractFunction(T...) if (T.length == 1) { enum bool isAbstractFunction = __traits(isAbstractFunction, T[0]); } @safe unittest { struct S { void foo() { } } class C { void foo() { } } class AC { abstract void foo(); } static assert(!isAbstractFunction!(int)); static assert(!isAbstractFunction!(S.foo)); static assert(!isAbstractFunction!(C.foo)); static assert( isAbstractFunction!(AC.foo)); } /** * Detect whether $(D T) is a final function. */ template isFinalFunction(T...) if (T.length == 1) { enum bool isFinalFunction = __traits(isFinalFunction, T[0]); } /// @safe unittest { struct S { void bar() { } } final class FC { void foo(); } class C { void bar() { } final void foo(); } static assert(!isFinalFunction!(int)); static assert(!isFinalFunction!(S.bar)); static assert( isFinalFunction!(FC.foo)); static assert(!isFinalFunction!(C.bar)); static assert( isFinalFunction!(C.foo)); } /** Determines whether function $(D f) requires a context pointer. */ template isNestedFunction(alias f) { enum isNestedFunction = __traits(isNested, f); } @safe unittest { static void f() { } void g() { } static assert(!isNestedFunction!f); static assert( isNestedFunction!g); } /** * Detect whether $(D T) is an abstract class. */ template isAbstractClass(T...) if (T.length == 1) { enum bool isAbstractClass = __traits(isAbstractClass, T[0]); } /// @safe unittest { struct S { } class C { } abstract class AC { } static assert(!isAbstractClass!S); static assert(!isAbstractClass!C); static assert( isAbstractClass!AC); C c; static assert(!isAbstractClass!c); AC ac; static assert( isAbstractClass!ac); } /** * Detect whether $(D T) is a final class. */ template isFinalClass(T...) if (T.length == 1) { enum bool isFinalClass = __traits(isFinalClass, T[0]); } /// @safe unittest { class C { } abstract class AC { } final class FC1 : C { } final class FC2 { } static assert(!isFinalClass!C); static assert(!isFinalClass!AC); static assert( isFinalClass!FC1); static assert( isFinalClass!FC2); C c; static assert(!isFinalClass!c); FC1 fc1; static assert( isFinalClass!fc1); } //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // General Types //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /** Removes all qualifiers, if any, from type $(D T). */ template Unqual(T) { version (none) // Error: recursive alias declaration @@@BUG1308@@@ { static if (is(T U == const U)) alias Unqual = Unqual!U; else static if (is(T U == immutable U)) alias Unqual = Unqual!U; else static if (is(T U == inout U)) alias Unqual = Unqual!U; else static if (is(T U == shared U)) alias Unqual = Unqual!U; else alias Unqual = T; } else // workaround { static if (is(T U == immutable U)) alias Unqual = U; else static if (is(T U == shared inout const U)) alias Unqual = U; else static if (is(T U == shared inout U)) alias Unqual = U; else static if (is(T U == shared const U)) alias Unqual = U; else static if (is(T U == shared U)) alias Unqual = U; else static if (is(T U == inout const U)) alias Unqual = U; else static if (is(T U == inout U)) alias Unqual = U; else static if (is(T U == const U)) alias Unqual = U; else alias Unqual = T; } } /// @safe unittest { static assert(is(Unqual!int == int)); static assert(is(Unqual!(const int) == int)); static assert(is(Unqual!(immutable int) == int)); static assert(is(Unqual!(shared int) == int)); static assert(is(Unqual!(shared(const int)) == int)); } @safe unittest { static assert(is(Unqual!( int) == int)); static assert(is(Unqual!( const int) == int)); static assert(is(Unqual!( inout int) == int)); static assert(is(Unqual!( inout const int) == int)); static assert(is(Unqual!(shared int) == int)); static assert(is(Unqual!(shared const int) == int)); static assert(is(Unqual!(shared inout int) == int)); static assert(is(Unqual!(shared inout const int) == int)); static assert(is(Unqual!( immutable int) == int)); alias ImmIntArr = immutable(int[]); static assert(is(Unqual!ImmIntArr == immutable(int)[])); } // [For internal use] package template ModifyTypePreservingTQ(alias Modifier, T) { static if (is(T U == immutable U)) alias ModifyTypePreservingTQ = immutable Modifier!U; else static if (is(T U == shared inout const U)) alias ModifyTypePreservingTQ = shared inout const Modifier!U; else static if (is(T U == shared inout U)) alias ModifyTypePreservingTQ = shared inout Modifier!U; else static if (is(T U == shared const U)) alias ModifyTypePreservingTQ = shared const Modifier!U; else static if (is(T U == shared U)) alias ModifyTypePreservingTQ = shared Modifier!U; else static if (is(T U == inout const U)) alias ModifyTypePreservingTQ = inout const Modifier!U; else static if (is(T U == inout U)) alias ModifyTypePreservingTQ = inout Modifier!U; else static if (is(T U == const U)) alias ModifyTypePreservingTQ = const Modifier!U; else alias ModifyTypePreservingTQ = Modifier!T; } @safe unittest { alias Intify(T) = int; static assert(is(ModifyTypePreservingTQ!(Intify, real) == int)); static assert(is(ModifyTypePreservingTQ!(Intify, const real) == const int)); static assert(is(ModifyTypePreservingTQ!(Intify, inout real) == inout int)); static assert(is(ModifyTypePreservingTQ!(Intify, inout const real) == inout const int)); static assert(is(ModifyTypePreservingTQ!(Intify, shared real) == shared int)); static assert(is(ModifyTypePreservingTQ!(Intify, shared const real) == shared const int)); static assert(is(ModifyTypePreservingTQ!(Intify, shared inout real) == shared inout int)); static assert(is(ModifyTypePreservingTQ!(Intify, shared inout const real) == shared inout const int)); static assert(is(ModifyTypePreservingTQ!(Intify, immutable real) == immutable int)); } /** * Copies type qualifiers from $(D FromType) to $(D ToType). * * Supported type qualifiers: * $(UL * $(LI $(D const)) * $(LI $(D inout)) * $(LI $(D immutable)) * $(LI $(D shared)) * ) */ template CopyTypeQualifiers(FromType, ToType) { alias T(U) = ToType; alias CopyTypeQualifiers = ModifyTypePreservingTQ!(T, FromType); } /// @safe unittest { static assert(is(CopyTypeQualifiers!(inout const real, int) == inout const int)); } @safe unittest { static assert(is(CopyTypeQualifiers!( real, int) == int)); static assert(is(CopyTypeQualifiers!( const real, int) == const int)); static assert(is(CopyTypeQualifiers!( inout real, int) == inout int)); static assert(is(CopyTypeQualifiers!( inout const real, int) == inout const int)); static assert(is(CopyTypeQualifiers!(shared real, int) == shared int)); static assert(is(CopyTypeQualifiers!(shared const real, int) == shared const int)); static assert(is(CopyTypeQualifiers!(shared inout real, int) == shared inout int)); static assert(is(CopyTypeQualifiers!(shared inout const real, int) == shared inout const int)); static assert(is(CopyTypeQualifiers!( immutable real, int) == immutable int)); } /** Returns the type of `Target` with the "constness" of `Source`. A type's $(B constness) refers to whether it is `const`, `immutable`, or `inout`. If `source` has no constness, the returned type will be the same as `Target`. */ template CopyConstness(FromType, ToType) { alias Unshared(T) = T; alias Unshared(T: shared U, U) = U; alias CopyConstness = Unshared!(CopyTypeQualifiers!(FromType, ToType)); } /// @safe unittest { const(int) i; CopyConstness!(typeof(i), float) f; assert( is(typeof(f) == const float)); CopyConstness!(char, uint) u; assert( is(typeof(u) == uint)); //The 'shared' qualifier will not be copied assert(!is(CopyConstness!(shared bool, int) == shared int)); //But the constness will be assert( is(CopyConstness!(shared const real, double) == const double)); //Careful, const(int)[] is a mutable array of const(int) alias MutT = CopyConstness!(const(int)[], int); assert(!is(MutT == const(int))); //Okay, const(int[]) applies to array and contained ints alias CstT = CopyConstness!(const(int[]), int); assert( is(CstT == const(int))); } @safe unittest { struct Test { void method1() {} void method2() const {} void method3() immutable {} } assert(is(CopyConstness!(typeof(Test.method1), real) == real)); assert(is(CopyConstness!(typeof(Test.method2), byte) == const(byte))); assert(is(CopyConstness!(typeof(Test.method3), string) == immutable(string))); } @safe unittest { assert(is(CopyConstness!(inout(int)[], int[]) == int[])); assert(is(CopyConstness!(inout(int[]), int[]) == inout(int[]))); } @safe unittest { static assert(is(CopyConstness!( int, real) == real)); static assert(is(CopyConstness!(const int, real) == const real)); static assert(is(CopyConstness!(inout int, real) == inout real)); static assert(is(CopyConstness!(inout const int, real) == inout const real)); static assert(is(CopyConstness!(shared int, real) == real)); static assert(is(CopyConstness!(shared const int, real) == const real)); static assert(is(CopyConstness!(shared inout int, real) == inout real)); static assert(is(CopyConstness!(shared inout const int, real) == inout const real)); static assert(is(CopyConstness!(immutable int, real) == immutable real)); } /** Returns the inferred type of the loop variable when a variable of type T is iterated over using a $(D foreach) loop with a single loop variable and automatically inferred return type. Note that this may not be the same as $(D std.range.ElementType!Range) in the case of narrow strings, or if T has both opApply and a range interface. */ template ForeachType(T) { alias ForeachType = ReturnType!(typeof( (inout int x = 0) { foreach (elem; T.init) { return elem; } assert(0); })); } /// @safe unittest { static assert(is(ForeachType!(uint[]) == uint)); static assert(is(ForeachType!string == immutable(char))); static assert(is(ForeachType!(string[string]) == string)); static assert(is(ForeachType!(inout(int)[]) == inout(int))); } /** * Strips off all $(D enum)s from type $(D T). */ template OriginalType(T) { template Impl(T) { static if (is(T U == enum)) alias Impl = OriginalType!U; else alias Impl = T; } alias OriginalType = ModifyTypePreservingTQ!(Impl, T); } /// @safe unittest { enum E : real { a } enum F : E { a = E.a } alias G = const(F); static assert(is(OriginalType!E == real)); static assert(is(OriginalType!F == real)); static assert(is(OriginalType!G == const real)); } /** * Get the Key type of an Associative Array. */ alias KeyType(V : V[K], K) = K; /// @safe unittest { alias Hash = int[string]; static assert(is(KeyType!Hash == string)); static assert(is(ValueType!Hash == int)); KeyType!Hash str = "a"; // str is declared as string ValueType!Hash num = 1; // num is declared as int } /** * Get the Value type of an Associative Array. */ alias ValueType(V : V[K], K) = V; /// @safe unittest { alias Hash = int[string]; static assert(is(KeyType!Hash == string)); static assert(is(ValueType!Hash == int)); KeyType!Hash str = "a"; // str is declared as string ValueType!Hash num = 1; // num is declared as int } /** * Returns the corresponding unsigned type for T. T must be a numeric * integral type, otherwise a compile-time error occurs. */ template Unsigned(T) { template Impl(T) { static if (is(T : __vector(V[N]), V, size_t N)) alias Impl = __vector(Impl!V[N]); else static if (isUnsigned!T) alias Impl = T; else static if (isSigned!T && !isFloatingPoint!T) { static if (is(T == byte )) alias Impl = ubyte; static if (is(T == short)) alias Impl = ushort; static if (is(T == int )) alias Impl = uint; static if (is(T == long )) alias Impl = ulong; static if (is(ucent) && is(T == cent )) alias Impl = ucent; } else static assert(false, "Type " ~ T.stringof ~ " does not have an Unsigned counterpart"); } alias Unsigned = ModifyTypePreservingTQ!(Impl, OriginalType!T); } @safe unittest { alias U1 = Unsigned!int; alias U2 = Unsigned!(const(int)); alias U3 = Unsigned!(immutable(int)); static assert(is(U1 == uint)); static assert(is(U2 == const(uint))); static assert(is(U3 == immutable(uint))); static if (is(__vector(int[4])) && is(__vector(uint[4]))) { alias UV1 = Unsigned!(__vector(int[4])); alias UV2 = Unsigned!(const(__vector(int[4]))); static assert(is(UV1 == __vector(uint[4]))); static assert(is(UV2 == const(__vector(uint[4])))); } //struct S {} //alias U2 = Unsigned!S; //alias U3 = Unsigned!double; static if (is(ucent)) { alias U4 = Unsigned!cent; alias U5 = Unsigned!(const(cent)); alias U6 = Unsigned!(immutable(cent)); static assert(is(U4 == ucent)); static assert(is(U5 == const(ucent))); static assert(is(U6 == immutable(ucent))); } } /** Returns the largest type, i.e. T such that T.sizeof is the largest. If more than one type is of the same size, the leftmost argument of these in will be returned. */ template Largest(T...) if (T.length >= 1) { static if (T.length == 1) { alias Largest = T[0]; } else static if (T.length == 2) { static if (T[0].sizeof >= T[1].sizeof) { alias Largest = T[0]; } else { alias Largest = T[1]; } } else { alias Largest = Largest!(Largest!(T[0 .. $/2]), Largest!(T[$/2 .. $])); } } /// @safe unittest { static assert(is(Largest!(uint, ubyte, ushort, real) == real)); static assert(is(Largest!(ulong, double) == ulong)); static assert(is(Largest!(double, ulong) == double)); static assert(is(Largest!(uint, byte, double, short) == double)); static if (is(ucent)) static assert(is(Largest!(uint, ubyte, ucent, ushort) == ucent)); } /** Returns the corresponding signed type for T. T must be a numeric integral type, otherwise a compile-time error occurs. */ template Signed(T) { template Impl(T) { static if (is(T : __vector(V[N]), V, size_t N)) alias Impl = __vector(Impl!V[N]); else static if (isSigned!T) alias Impl = T; else static if (isUnsigned!T) { static if (is(T == ubyte )) alias Impl = byte; static if (is(T == ushort)) alias Impl = short; static if (is(T == uint )) alias Impl = int; static if (is(T == ulong )) alias Impl = long; static if (is(ucent) && is(T == ucent )) alias Impl = cent; } else static assert(false, "Type " ~ T.stringof ~ " does not have an Signed counterpart"); } alias Signed = ModifyTypePreservingTQ!(Impl, OriginalType!T); } /// @safe unittest { alias S1 = Signed!uint; static assert(is(S1 == int)); alias S2 = Signed!(const(uint)); static assert(is(S2 == const(int))); alias S3 = Signed!(immutable(uint)); static assert(is(S3 == immutable(int))); static if (is(ucent)) { alias S4 = Signed!ucent; static assert(is(S4 == cent)); } } @safe unittest { static assert(is(Signed!float == float)); static if (is(__vector(int[4])) && is(__vector(uint[4]))) { alias SV1 = Signed!(__vector(uint[4])); alias SV2 = Signed!(const(__vector(uint[4]))); static assert(is(SV1 == __vector(int[4]))); static assert(is(SV2 == const(__vector(int[4])))); } } /** Returns the most negative value of the numeric type T. */ template mostNegative(T) if (isNumeric!T || isSomeChar!T || isBoolean!T) { static if (is(typeof(T.min_normal))) enum mostNegative = -T.max; else static if (T.min == 0) enum byte mostNegative = 0; else enum mostNegative = T.min; } /// @safe unittest { static assert(mostNegative!float == -float.max); static assert(mostNegative!double == -double.max); static assert(mostNegative!real == -real.max); static assert(mostNegative!bool == false); } /// @safe unittest { import std.meta : AliasSeq; static foreach (T; AliasSeq!(bool, byte, short, int, long)) static assert(mostNegative!T == T.min); static foreach (T; AliasSeq!(ubyte, ushort, uint, ulong, char, wchar, dchar)) static assert(mostNegative!T == 0); } /** Get the type that a scalar type `T` will $(LINK2 $(ROOT_DIR)spec/type.html#integer-promotions, promote) to in multi-term arithmetic expressions. */ template Promoted(T) if (isScalarType!T) { alias Promoted = CopyTypeQualifiers!(T, typeof(T.init + T.init)); } /// @safe unittest { ubyte a = 3, b = 5; static assert(is(typeof(a * b) == Promoted!ubyte)); static assert(is(Promoted!ubyte == int)); static assert(is(Promoted!(shared(bool)) == shared(int))); static assert(is(Promoted!(const(int)) == const(int))); static assert(is(Promoted!double == double)); } @safe unittest { // promote to int: static foreach (T; AliasSeq!(bool, byte, ubyte, short, ushort, char, wchar)) { static assert(is(Promoted!T == int)); static assert(is(Promoted!(shared(const T)) == shared(const int))); } // already promoted: static foreach (T; AliasSeq!(int, uint, long, ulong, float, double, real)) { static assert(is(Promoted!T == T)); static assert(is(Promoted!(immutable(T)) == immutable(T))); } } //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// // Misc. //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// /** Returns the mangled name of symbol or type $(D sth). $(D mangledName) is the same as builtin $(D .mangleof) property, but might be more convenient in generic code, e.g. as a template argument when invoking staticMap. */ template mangledName(sth...) if (sth.length == 1) { enum string mangledName = sth[0].mangleof; } /// @safe unittest { import std.meta : AliasSeq; alias TL = staticMap!(mangledName, int, const int, immutable int); static assert(TL == AliasSeq!("i", "xi", "yi")); } version(unittest) void freeFunc(string); @safe unittest { class C { int value() @property { return 0; } } static assert(mangledName!int == int.mangleof); static assert(mangledName!C == C.mangleof); static assert(mangledName!(C.value) == C.value.mangleof); static assert(mangledName!(C.value)[$ - 12 .. $] == "5valueMFNdZi"); static assert(mangledName!mangledName == "3std6traits11mangledName"); static assert(mangledName!freeFunc == "_D3std6traits8freeFuncFAyaZv"); int x; static if (is(typeof({ return x; }) : int delegate() pure)) // issue 9148 static assert(mangledName!((int a) { return a+x; }) == "DFNaNbNiNfiZi"); // pure nothrow @safe @nogc else static assert(mangledName!((int a) { return a+x; }) == "DFNbNiNfiZi"); // nothrow @safe @nnogc } @system unittest { // @system due to demangle // Test for bug 5718 import std.demangle : demangle; int foo; auto foo_demangled = demangle(mangledName!foo); assert(foo_demangled[0 .. 4] == "int " && foo_demangled[$-3 .. $] == "foo", foo_demangled); void bar(); auto bar_demangled = demangle(mangledName!bar); assert(bar_demangled[0 .. 5] == "void " && bar_demangled[$-5 .. $] == "bar()"); } // XXX Select & select should go to another module. (functional or algorithm?) /** Aliases itself to $(D T[0]) if the boolean $(D condition) is $(D true) and to $(D T[1]) otherwise. */ template Select(bool condition, T...) if (T.length == 2) { import std.meta : Alias; alias Select = Alias!(T[!condition]); } /// @safe unittest { // can select types static assert(is(Select!(true, int, long) == int)); static assert(is(Select!(false, int, long) == long)); static struct Foo {} static assert(is(Select!(false, const(int), const(Foo)) == const(Foo))); // can select symbols int a = 1; int b = 2; alias selA = Select!(true, a, b); alias selB = Select!(false, a, b); assert(selA == 1); assert(selB == 2); // can select (compile-time) expressions enum val = Select!(false, -4, 9 - 6); static assert(val == 3); } /** If $(D cond) is $(D true), returns $(D a) without evaluating $(D b). Otherwise, returns $(D b) without evaluating $(D a). */ A select(bool cond : true, A, B)(A a, lazy B b) { return a; } /// Ditto B select(bool cond : false, A, B)(lazy A a, B b) { return b; } @safe unittest { real pleasecallme() { return 0; } int dontcallme() { assert(0); } auto a = select!true(pleasecallme(), dontcallme()); auto b = select!false(dontcallme(), pleasecallme()); static assert(is(typeof(a) == real)); static assert(is(typeof(b) == real)); } /++ Determine if a symbol has a given $(DDSUBLINK spec/attribute, uda, user-defined attribute). See_Also: $(LREF getUDAs) +/ template hasUDA(alias symbol, alias attribute) { enum hasUDA = getUDAs!(symbol, attribute).length != 0; } /// @safe unittest { enum E; struct S {} @("alpha") int a; static assert(hasUDA!(a, "alpha")); static assert(!hasUDA!(a, S)); static assert(!hasUDA!(a, E)); @(E) int b; static assert(!hasUDA!(b, "alpha")); static assert(!hasUDA!(b, S)); static assert(hasUDA!(b, E)); @E int c; static assert(!hasUDA!(c, "alpha")); static assert(!hasUDA!(c, S)); static assert(hasUDA!(c, E)); @(S, E) int d; static assert(!hasUDA!(d, "alpha")); static assert(hasUDA!(d, S)); static assert(hasUDA!(d, E)); @S int e; static assert(!hasUDA!(e, "alpha")); static assert(hasUDA!(e, S)); static assert(!hasUDA!(e, S())); static assert(!hasUDA!(e, E)); @S() int f; static assert(!hasUDA!(f, "alpha")); static assert(hasUDA!(f, S)); static assert(hasUDA!(f, S())); static assert(!hasUDA!(f, E)); @(S, E, "alpha") int g; static assert(hasUDA!(g, "alpha")); static assert(hasUDA!(g, S)); static assert(hasUDA!(g, E)); @(100) int h; static assert(hasUDA!(h, 100)); struct Named { string name; } @Named("abc") int i; static assert(hasUDA!(i, Named)); static assert(hasUDA!(i, Named("abc"))); static assert(!hasUDA!(i, Named("def"))); struct AttrT(T) { string name; T value; } @AttrT!int("answer", 42) int j; static assert(hasUDA!(j, AttrT)); static assert(hasUDA!(j, AttrT!int)); static assert(!hasUDA!(j, AttrT!string)); @AttrT!string("hello", "world") int k; static assert(hasUDA!(k, AttrT)); static assert(!hasUDA!(k, AttrT!int)); static assert(hasUDA!(k, AttrT!string)); struct FuncAttr(alias f) { alias func = f; } static int fourtyTwo() { return 42; } static size_t getLen(string s) { return s.length; } @FuncAttr!getLen int l; static assert(hasUDA!(l, FuncAttr)); static assert(!hasUDA!(l, FuncAttr!fourtyTwo)); static assert(hasUDA!(l, FuncAttr!getLen)); static assert(!hasUDA!(l, FuncAttr!fourtyTwo())); static assert(!hasUDA!(l, FuncAttr!getLen())); @FuncAttr!getLen() int m; static assert(hasUDA!(m, FuncAttr)); static assert(!hasUDA!(m, FuncAttr!fourtyTwo)); static assert(hasUDA!(m, FuncAttr!getLen)); static assert(!hasUDA!(m, FuncAttr!fourtyTwo())); static assert(hasUDA!(m, FuncAttr!getLen())); } /++ Gets the matching $(DDSUBLINK spec/attribute, uda, user-defined attributes) from the given symbol. If the UDA is a type, then any UDAs of the same type on the symbol will match. If the UDA is a template for a type, then any UDA which is an instantiation of that template will match. And if the UDA is a value, then any UDAs on the symbol which are equal to that value will match. See_Also: $(LREF hasUDA) +/ template getUDAs(alias symbol, alias attribute) { import std.meta : Filter; alias getUDAs = Filter!(isDesiredUDA!attribute, __traits(getAttributes, symbol)); } /// @safe unittest { struct Attr { string name; int value; } @Attr("Answer", 42) int a; static assert(getUDAs!(a, Attr).length == 1); static assert(getUDAs!(a, Attr)[0].name == "Answer"); static assert(getUDAs!(a, Attr)[0].value == 42); @(Attr("Answer", 42), "string", 9999) int b; static assert(getUDAs!(b, Attr).length == 1); static assert(getUDAs!(b, Attr)[0].name == "Answer"); static assert(getUDAs!(b, Attr)[0].value == 42); @Attr("Answer", 42) @Attr("Pi", 3) int c; static assert(getUDAs!(c, Attr).length == 2); static assert(getUDAs!(c, Attr)[0].name == "Answer"); static assert(getUDAs!(c, Attr)[0].value == 42); static assert(getUDAs!(c, Attr)[1].name == "Pi"); static assert(getUDAs!(c, Attr)[1].value == 3); static assert(getUDAs!(c, Attr("Answer", 42)).length == 1); static assert(getUDAs!(c, Attr("Answer", 42))[0].name == "Answer"); static assert(getUDAs!(c, Attr("Answer", 42))[0].value == 42); static assert(getUDAs!(c, Attr("Answer", 99)).length == 0); struct AttrT(T) { string name; T value; } @AttrT!uint("Answer", 42) @AttrT!int("Pi", 3) @AttrT int d; static assert(getUDAs!(d, AttrT).length == 2); static assert(getUDAs!(d, AttrT)[0].name == "Answer"); static assert(getUDAs!(d, AttrT)[0].value == 42); static assert(getUDAs!(d, AttrT)[1].name == "Pi"); static assert(getUDAs!(d, AttrT)[1].value == 3); static assert(getUDAs!(d, AttrT!uint).length == 1); static assert(getUDAs!(d, AttrT!uint)[0].name == "Answer"); static assert(getUDAs!(d, AttrT!uint)[0].value == 42); static assert(getUDAs!(d, AttrT!int).length == 1); static assert(getUDAs!(d, AttrT!int)[0].name == "Pi"); static assert(getUDAs!(d, AttrT!int)[0].value == 3); struct SimpleAttr {} @SimpleAttr int e; static assert(getUDAs!(e, SimpleAttr).length == 1); static assert(is(getUDAs!(e, SimpleAttr)[0] == SimpleAttr)); @SimpleAttr() int f; static assert(getUDAs!(f, SimpleAttr).length == 1); static assert(is(typeof(getUDAs!(f, SimpleAttr)[0]) == SimpleAttr)); struct FuncAttr(alias f) { alias func = f; } static int add42(int v) { return v + 42; } static string concat(string l, string r) { return l ~ r; } @FuncAttr!add42 int g; static assert(getUDAs!(g, FuncAttr).length == 1); static assert(getUDAs!(g, FuncAttr)[0].func(5) == 47); static assert(getUDAs!(g, FuncAttr!add42).length == 1); static assert(getUDAs!(g, FuncAttr!add42)[0].func(5) == 47); static assert(getUDAs!(g, FuncAttr!add42()).length == 0); static assert(getUDAs!(g, FuncAttr!concat).length == 0); static assert(getUDAs!(g, FuncAttr!concat()).length == 0); @FuncAttr!add42() int h; static assert(getUDAs!(h, FuncAttr).length == 1); static assert(getUDAs!(h, FuncAttr)[0].func(5) == 47); static assert(getUDAs!(h, FuncAttr!add42).length == 1); static assert(getUDAs!(h, FuncAttr!add42)[0].func(5) == 47); static assert(getUDAs!(h, FuncAttr!add42()).length == 1); static assert(getUDAs!(h, FuncAttr!add42())[0].func(5) == 47); static assert(getUDAs!(h, FuncAttr!concat).length == 0); static assert(getUDAs!(h, FuncAttr!concat()).length == 0); @("alpha") @(42) int i; static assert(getUDAs!(i, "alpha").length == 1); static assert(getUDAs!(i, "alpha")[0] == "alpha"); static assert(getUDAs!(i, 42).length == 1); static assert(getUDAs!(i, 42)[0] == 42); static assert(getUDAs!(i, 'c').length == 0); } private template isDesiredUDA(alias attribute) { template isDesiredUDA(alias toCheck) { static if (is(typeof(attribute)) && !__traits(isTemplate, attribute)) { static if (__traits(compiles, toCheck == attribute)) enum isDesiredUDA = toCheck == attribute; else enum isDesiredUDA = false; } else static if (is(typeof(toCheck))) { static if (__traits(isTemplate, attribute)) enum isDesiredUDA = isInstanceOf!(attribute, typeof(toCheck)); else enum isDesiredUDA = is(typeof(toCheck) == attribute); } else static if (__traits(isTemplate, attribute)) enum isDesiredUDA = isInstanceOf!(attribute, toCheck); else enum isDesiredUDA = is(toCheck == attribute); } } /** * Gets all symbols within `symbol` that have the given user-defined attribute. * This is not recursive; it will not search for symbols within symbols such as * nested structs or unions. */ template getSymbolsByUDA(alias symbol, alias attribute) { alias membersWithUDA = getSymbolsByUDAImpl!(symbol, attribute, __traits(allMembers, symbol)); // if the symbol itself has the UDA, tack it on to the front of the list static if (hasUDA!(symbol, attribute)) alias getSymbolsByUDA = AliasSeq!(symbol, membersWithUDA); else alias getSymbolsByUDA = membersWithUDA; } private template getSymbolsByUDAImpl(alias symbol, alias attribute, names...) { import std.meta : Alias, AliasSeq, Filter; static if (names.length == 0) { alias getSymbolsByUDAImpl = AliasSeq!(); } else { alias tail = getSymbolsByUDAImpl!(symbol, attribute, names[1 .. $]); // Filtering inaccessible members. static if (!__traits(compiles, __traits(getMember, symbol, names[0]))) { alias getSymbolsByUDAImpl = tail; } else { alias member = Alias!(__traits(getMember, symbol, names[0])); // Filtering not compiled members such as alias of basic types. static if (!__traits(compiles, hasUDA!(member, attribute))) { alias getSymbolsByUDAImpl = tail; } // Get overloads for functions, in case different overloads have different sets of UDAs. else static if (isFunction!member) { enum hasSpecificUDA(alias member) = hasUDA!(member, attribute); alias getSymbolsByUDAImpl = Filter!(hasSpecificUDA, __traits(getOverloads, symbol, names[0])); } else static if (hasUDA!(member, attribute)) { alias getSymbolsByUDAImpl = AliasSeq!(member, tail); } else { alias getSymbolsByUDAImpl = tail; } } } } /// @safe unittest { enum Attr; static struct A { @Attr int a; int b; @Attr void doStuff() {} void doOtherStuff() {} static struct Inner { // Not found by getSymbolsByUDA @Attr int c; } } // Finds both variables and functions with the attribute, but // doesn't include the variables and functions without it. static assert(getSymbolsByUDA!(A, Attr).length == 2); // Can access attributes on the symbols returned by getSymbolsByUDA. static assert(hasUDA!(getSymbolsByUDA!(A, Attr)[0], Attr)); static assert(hasUDA!(getSymbolsByUDA!(A, Attr)[1], Attr)); static struct UDA { string name; } static struct B { @UDA("X") int x; @UDA("Y") int y; @(100) int z; } // Finds both UDA attributes. static assert(getSymbolsByUDA!(B, UDA).length == 2); // Finds one `100` attribute. static assert(getSymbolsByUDA!(B, 100).length == 1); // Can get the value of the UDA from the return value static assert(getUDAs!(getSymbolsByUDA!(B, UDA)[0], UDA)[0].name == "X"); @UDA("A") static struct C { @UDA("B") int d; } // Also checks the symbol itself static assert(getSymbolsByUDA!(C, UDA).length == 2); static assert(getSymbolsByUDA!(C, UDA)[0].stringof == "C"); static assert(getSymbolsByUDA!(C, UDA)[1].stringof == "d"); static struct D { int x; } //Finds nothing if there is no member with specific UDA static assert(getSymbolsByUDA!(D,UDA).length == 0); } // Issue 18314 @safe unittest { enum attr1; enum attr2; struct A { @attr1 int n; // Removed due to Issue 16206 //@attr1 //void foo()(string){} @attr1 void foo(); @attr2 void foo(int a); } static assert(getSymbolsByUDA!(A, attr1).length == 2); static assert(getSymbolsByUDA!(A, attr2).length == 1); } // #15335: getSymbolsByUDA fails if type has private members @safe unittest { // HasPrivateMembers has, well, private members, one of which has a UDA. import std.internal.test.uda : Attr, HasPrivateMembers; // Trying access to private member from another file therefore we do not have access // for this otherwise we get deprecation warning - not visible from module static assert(getSymbolsByUDA!(HasPrivateMembers, Attr).length == 1); static assert(hasUDA!(getSymbolsByUDA!(HasPrivateMembers, Attr)[0], Attr)); } /// @safe unittest { enum Attr; struct A { alias INT = int; alias void function(INT) SomeFunction; @Attr int a; int b; } static assert(getSymbolsByUDA!(A, Attr).length == 1); static assert(hasUDA!(getSymbolsByUDA!(A, Attr)[0], Attr)); } // #16387: getSymbolsByUDA works with structs but fails with classes @safe unittest { enum Attr; class A { @Attr uint a; } alias res = getSymbolsByUDA!(A, Attr); static assert(res.length == 1); static assert(res[0].stringof == "a"); } /** Returns: $(D true) iff all types $(D T) are the same. */ template allSameType(T...) { static if (T.length <= 1) { enum bool allSameType = true; } else { enum bool allSameType = is(T[0] == T[1]) && allSameType!(T[1..$]); } } /// @safe unittest { static assert(allSameType!(int, int)); static assert(allSameType!(int, int, int)); static assert(allSameType!(float, float, float)); static assert(!allSameType!(int, double)); static assert(!allSameType!(int, float, double)); static assert(!allSameType!(int, float, double, real)); static assert(!allSameType!(short, int, float, double, real)); } /** Returns: $(D true) iff the type $(D T) can be tested in an $(D if)-expression, that is if $(D if (pred(T.init)) {}) is compilable. */ enum ifTestable(T, alias pred = a => a) = __traits(compiles, { if (pred(T.init)) {} }); @safe unittest { import std.meta : AliasSeq, allSatisfy; static assert(allSatisfy!(ifTestable, AliasSeq!(bool, int, float, double, string))); struct BoolWrapper { bool value; } static assert(!ifTestable!(bool, a => BoolWrapper(a))); } /** * Detect whether `X` is a type. Analogous to `is(X)`. This is useful when used * in conjunction with other templates, e.g. `allSatisfy!(isType, X)`. * * Returns: * `true` if `X` is a type, `false` otherwise */ template isType(X...) if (X.length == 1) { enum isType = is(X[0]); } /// @safe unittest { struct S { template Test() {} } class C {} interface I {} union U {} static assert(isType!int); static assert(isType!string); static assert(isType!(int[int])); static assert(isType!S); static assert(isType!C); static assert(isType!I); static assert(isType!U); int n; void func(){} static assert(!isType!n); static assert(!isType!func); static assert(!isType!(S.Test)); static assert(!isType!(S.Test!())); } /** * Detect whether symbol or type `X` is a function. This is different that finding * if a symbol is callable or satisfying `is(X == function)`, it finds * specifically if the symbol represents a normal function declaration, i.e. * not a delegate or a function pointer. * * Returns: * `true` if `X` is a function, `false` otherwise * * See_Also: * Use $(LREF isFunctionPointer) or $(LREF isDelegate) for detecting those types * respectively. */ template isFunction(X...) if (X.length == 1) { static if (is(typeof(&X[0]) U : U*) && is(U == function) || is(typeof(&X[0]) U == delegate)) { // x is a (nested) function symbol. enum isFunction = true; } else static if (is(X[0] T)) { // x is a type. Take the type of it and examine. enum isFunction = is(T == function); } else enum isFunction = false; } /// @safe unittest { static void func(){} static assert(isFunction!func); struct S { void func(){} } static assert(isFunction!(S.func)); } /** * Detect whether `X` is a final method or class. * * Returns: * `true` if `X` is final, `false` otherwise */ template isFinal(X...) if (X.length == 1) { static if (is(X[0] == class)) enum isFinal = __traits(isFinalClass, X[0]); else static if (isFunction!X) enum isFinal = __traits(isFinalFunction, X[0]); else enum isFinal = false; } /// @safe unittest { class C { void nf() {} static void sf() {} final void ff() {} } final class FC { } static assert(!isFinal!(C)); static assert( isFinal!(FC)); static assert(!isFinal!(C.nf)); static assert(!isFinal!(C.sf)); static assert( isFinal!(C.ff)); } /++ + Determines whether the type `S` can be copied. + If a type cannot be copied, then code such as `MyStruct x; auto y = x;` will fail to compile. + Copying for structs can be disabled by using `@disable this(this)`. + + Params: + S = The type to check. + + Returns: + `true` if `S` can be copied. `false` otherwise. + ++/ enum isCopyable(S) = is(typeof( { S foo = S.init; S copy = foo; } )); /// @safe unittest { struct S1 {} // Fine. Can be copied struct S2 { this(this) {}} // Fine. Can be copied struct S3 {@disable this(this) {}} // Not fine. Copying is disabled. struct S4 {S3 s;} // Not fine. A field has copying disabled. class C1 {} static assert( isCopyable!S1); static assert( isCopyable!S2); static assert(!isCopyable!S3); static assert(!isCopyable!S4); static assert(isCopyable!C1); static assert(isCopyable!int); static assert(isCopyable!(int[])); }
D
/* 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 derelict.sdl2.sdl; public { import derelict.sdl2.types; import derelict.sdl2.functions; } private { import derelict.util.loader; import derelict.util.exception; } /* This function is not part of the public interface, but SDL expects it to be called before any subsystems have been intiailized. Normally, this happens via linking with libSDLmain, but since that doesn't happen when using Derelict, then the loader must load this function and call it before the load method returns. Otherwise, bad things can happen. */ private extern(C) alias nothrow void function() da_SDL_SetMainReady; class DerelictSDL2Loader : SharedLibLoader { public: this() { super( "sdl2.dll", "libSDL2.so, libSDL2.so.0, libSDL2-2.0.so, libSDL2-2.0.so.0", "/usr/local/lib/libSDL2.dylib, ../Frameworks/SDL2.framework/SDL2, /Library/Frameworks/SDL2.framework/SDL2, /System/Library/Frameworks/SDL2.framework/SDL2" ); } protected { override void loadSymbols() { bindFunc(cast(void**)&SDL_Init, "SDL_Init"); bindFunc(cast(void**)&SDL_InitSubSystem, "SDL_InitSubSystem"); bindFunc(cast(void**)&SDL_QuitSubSystem, "SDL_QuitSubSystem"); bindFunc(cast(void**)&SDL_WasInit, "SDL_WasInit"); bindFunc(cast(void**)&SDL_Quit, "SDL_Quit"); bindFunc(cast(void**)&SDL_GetNumAudioDrivers, "SDL_GetNumAudioDrivers"); bindFunc(cast(void**)&SDL_GetAudioDriver, "SDL_GetAudioDriver"); bindFunc(cast(void**)&SDL_AudioInit, "SDL_AudioInit"); bindFunc(cast(void**)&SDL_AudioQuit, "SDL_AudioQuit"); bindFunc(cast(void**)&SDL_GetCurrentAudioDriver, "SDL_GetCurrentAudioDriver"); bindFunc(cast(void**)&SDL_OpenAudio, "SDL_OpenAudio"); bindFunc(cast(void**)&SDL_GetNumAudioDevices, "SDL_GetNumAudioDevices"); bindFunc(cast(void**)&SDL_GetAudioDeviceName, "SDL_GetAudioDeviceName"); bindFunc(cast(void**)&SDL_OpenAudioDevice, "SDL_OpenAudioDevice"); bindFunc(cast(void**)&SDL_GetAudioStatus, "SDL_GetAudioStatus"); bindFunc(cast(void**)&SDL_GetAudioDeviceStatus, "SDL_GetAudioDeviceStatus"); bindFunc(cast(void**)&SDL_PauseAudio, "SDL_PauseAudio"); bindFunc(cast(void**)&SDL_PauseAudioDevice, "SDL_PauseAudioDevice"); bindFunc(cast(void**)&SDL_LoadWAV_RW, "SDL_LoadWAV_RW"); bindFunc(cast(void**)&SDL_FreeWAV, "SDL_FreeWAV"); bindFunc(cast(void**)&SDL_BuildAudioCVT, "SDL_BuildAudioCVT"); bindFunc(cast(void**)&SDL_ConvertAudio, "SDL_ConvertAudio"); bindFunc(cast(void**)&SDL_MixAudio, "SDL_MixAudio"); bindFunc(cast(void**)&SDL_MixAudioFormat, "SDL_MixAudioFormat"); bindFunc(cast(void**)&SDL_LockAudio, "SDL_LockAudio"); bindFunc(cast(void**)&SDL_LockAudioDevice, "SDL_LockAudioDevice"); bindFunc(cast(void**)&SDL_UnlockAudio, "SDL_UnlockAudio"); bindFunc(cast(void**)&SDL_UnlockAudioDevice, "SDL_UnlockAudioDevice"); bindFunc(cast(void**)&SDL_CloseAudio, "SDL_CloseAudio"); bindFunc(cast(void**)&SDL_CloseAudioDevice, "SDL_CloseAudioDevice"); // bindFunc(cast(void**)&SDL_AudioDeviceConnected, "SDL_AudioDeviceConnected"); bindFunc(cast(void**)&SDL_SetClipboardText, "SDL_SetClipboardText"); bindFunc(cast(void**)&SDL_GetClipboardText, "SDL_GetClipboardText"); bindFunc(cast(void**)&SDL_HasClipboardText, "SDL_HasClipboardText"); bindFunc(cast(void**)&SDL_GetCPUCount, "SDL_GetCPUCount"); bindFunc(cast(void**)&SDL_GetCPUCacheLineSize, "SDL_GetCPUCacheLineSize"); bindFunc(cast(void**)&SDL_HasRDTSC, "SDL_HasRDTSC"); bindFunc(cast(void**)&SDL_HasAltiVec, "SDL_HasAltiVec"); bindFunc(cast(void**)&SDL_HasMMX, "SDL_HasMMX"); bindFunc(cast(void**)&SDL_Has3DNow, "SDL_Has3DNow"); bindFunc(cast(void**)&SDL_HasSSE, "SDL_HasSSE"); bindFunc(cast(void**)&SDL_HasSSE2, "SDL_HasSSE2"); bindFunc(cast(void**)&SDL_HasSSE3, "SDL_HasSSE3"); bindFunc(cast(void**)&SDL_HasSSE41, "SDL_HasSSE41"); bindFunc(cast(void**)&SDL_HasSSE42, "SDL_HasSSE42"); bindFunc(cast(void**)&SDL_SetError, "SDL_SetError"); bindFunc(cast(void**)&SDL_GetError, "SDL_GetError"); bindFunc(cast(void**)&SDL_ClearError, "SDL_ClearError"); bindFunc(cast(void**)&SDL_PumpEvents, "SDL_PumpEvents"); bindFunc(cast(void**)&SDL_PeepEvents, "SDL_PeepEvents"); bindFunc(cast(void**)&SDL_HasEvent, "SDL_HasEvent"); bindFunc(cast(void**)&SDL_HasEvents, "SDL_HasEvents"); bindFunc(cast(void**)&SDL_FlushEvent, "SDL_FlushEvent"); bindFunc(cast(void**)&SDL_FlushEvents, "SDL_FlushEvents"); bindFunc(cast(void**)&SDL_PollEvent, "SDL_PollEvent"); bindFunc(cast(void**)&SDL_WaitEvent, "SDL_WaitEvent"); bindFunc(cast(void**)&SDL_WaitEventTimeout, "SDL_WaitEventTimeout"); bindFunc(cast(void**)&SDL_PushEvent, "SDL_PushEvent"); bindFunc(cast(void**)&SDL_SetEventFilter, "SDL_SetEventFilter"); bindFunc(cast(void**)&SDL_GetEventFilter, "SDL_GetEventFilter"); bindFunc(cast(void**)&SDL_AddEventWatch, "SDL_AddEventWatch"); bindFunc(cast(void**)&SDL_DelEventWatch, "SDL_DelEventWatch"); bindFunc(cast(void**)&SDL_FilterEvents, "SDL_FilterEvents"); bindFunc(cast(void**)&SDL_EventState, "SDL_EventState"); bindFunc(cast(void**)&SDL_RegisterEvents, "SDL_RegisterEvents"); bindFunc(cast(void**)&SDL_GameControllerAddMapping, "SDL_GameControllerAddMapping"); bindFunc(cast(void**)&SDL_GameControllerMappingForGUID, "SDL_GameControllerMappingForGUID"); bindFunc(cast(void**)&SDL_GameControllerMapping, "SDL_GameControllerMapping"); bindFunc(cast(void**)&SDL_IsGameController, "SDL_IsGameController"); bindFunc(cast(void**)&SDL_GameControllerNameForIndex, "SDL_GameControllerNameForIndex"); bindFunc(cast(void**)&SDL_GameControllerOpen, "SDL_GameControllerOpen"); bindFunc(cast(void**)&SDL_GameControllerName, "SDL_GameControllerName"); bindFunc(cast(void**)&SDL_GameControllerGetAttached, "SDL_GameControllerGetAttached"); bindFunc(cast(void**)&SDL_GameControllerGetJoystick, "SDL_GameControllerGetJoystick"); bindFunc(cast(void**)&SDL_GameControllerEventState, "SDL_GameControllerEventState"); bindFunc(cast(void**)&SDL_GameControllerUpdate, "SDL_GameControllerUpdate"); bindFunc(cast(void**)&SDL_GameControllerGetAxisFromString, "SDL_GameControllerGetAxisFromString"); bindFunc(cast(void**)&SDL_GameControllerGetStringForAxis, "SDL_GameControllerGetStringForAxis"); bindFunc(cast(void**)&SDL_GameControllerGetBindForAxis, "SDL_GameControllerGetBindForAxis"); bindFunc(cast(void**)&SDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"); bindFunc(cast(void**)&SDL_GameControllerGetButtonFromString, "SDL_GameControllerGetButtonFromString"); bindFunc(cast(void**)&SDL_GameControllerGetStringForButton, "SDL_GameControllerGetStringForButton"); bindFunc(cast(void**)&SDL_GameControllerGetBindForButton, "SDL_GameControllerGetBindForButton"); bindFunc(cast(void**)&SDL_GameControllerGetButton, "SDL_GameControllerGetButton"); bindFunc(cast(void**)&SDL_GameControllerClose, "SDL_GameControllerClose"); bindFunc(cast(void**)&SDL_RecordGesture, "SDL_RecordGesture"); bindFunc(cast(void**)&SDL_SaveAllDollarTemplates, "SDL_SaveAllDollarTemplates"); bindFunc(cast(void**)&SDL_SaveDollarTemplate, "SDL_SaveDollarTemplate"); bindFunc(cast(void**)&SDL_LoadDollarTemplates, "SDL_LoadDollarTemplates"); bindFunc(cast(void**)&SDL_NumHaptics, "SDL_NumHaptics"); bindFunc(cast(void**)&SDL_HapticName, "SDL_HapticName"); bindFunc(cast(void**)&SDL_HapticOpen, "SDL_HapticOpen"); bindFunc(cast(void**)&SDL_HapticOpened, "SDL_HapticOpened"); bindFunc(cast(void**)&SDL_HapticIndex, "SDL_HapticIndex"); bindFunc(cast(void**)&SDL_MouseIsHaptic, "SDL_MouseIsHaptic"); bindFunc(cast(void**)&SDL_HapticOpenFromMouse, "SDL_HapticOpenFromMouse"); bindFunc(cast(void**)&SDL_JoystickIsHaptic, "SDL_JoystickIsHaptic"); bindFunc(cast(void**)&SDL_HapticOpenFromJoystick, "SDL_HapticOpenFromJoystick"); bindFunc(cast(void**)&SDL_HapticClose, "SDL_HapticClose"); bindFunc(cast(void**)&SDL_HapticNumEffects, "SDL_HapticNumEffects"); bindFunc(cast(void**)&SDL_HapticNumEffectsPlaying, "SDL_HapticNumEffectsPlaying"); bindFunc(cast(void**)&SDL_HapticQuery, "SDL_HapticQuery"); bindFunc(cast(void**)&SDL_HapticNumAxes, "SDL_HapticNumAxes"); bindFunc(cast(void**)&SDL_HapticEffectSupported, "SDL_HapticEffectSupported"); bindFunc(cast(void**)&SDL_HapticNewEffect, "SDL_HapticNewEffect"); bindFunc(cast(void**)&SDL_HapticUpdateEffect, "SDL_HapticUpdateEffect"); bindFunc(cast(void**)&SDL_HapticRunEffect, "SDL_HapticRunEffect"); bindFunc(cast(void**)&SDL_HapticStopEffect, "SDL_HapticStopEffect"); bindFunc(cast(void**)&SDL_HapticDestroyEffect, "SDL_HapticDestroyEffect"); bindFunc(cast(void**)&SDL_HapticGetEffectStatus, "SDL_HapticGetEffectStatus"); bindFunc(cast(void**)&SDL_HapticSetGain, "SDL_HapticSetGain"); bindFunc(cast(void**)&SDL_HapticSetAutocenter, "SDL_HapticSetAutocenter"); bindFunc(cast(void**)&SDL_HapticPause, "SDL_HapticPause"); bindFunc(cast(void**)&SDL_HapticUnpause, "SDL_HapticUnpause"); bindFunc(cast(void**)&SDL_HapticStopAll, "SDL_HapticStopAll"); bindFunc(cast(void**)&SDL_HapticRumbleSupported, "SDL_HapticRumbleSupported"); bindFunc(cast(void**)&SDL_HapticRumbleInit, "SDL_HapticRumbleInit"); bindFunc(cast(void**)&SDL_HapticRumblePlay, "SDL_HapticRumblePlay"); bindFunc(cast(void**)&SDL_HapticRumbleStop, "SDL_HapticRumbleStop"); bindFunc(cast(void**)&SDL_SetHintWithPriority, "SDL_SetHintWithPriority"); bindFunc(cast(void**)&SDL_SetHint, "SDL_SetHint"); bindFunc(cast(void**)&SDL_GetHint, "SDL_GetHint"); bindFunc(cast(void**)&SDL_ClearHints, "SDL_ClearHints"); // bindFunc(cast(void**)&SDL_RedetectInputDevices, "SDL_RedetectInputDevices"); // bindFunc(cast(void**)&SDL_GetNumInputDevices, "SDL_GetNumInputDevices"); // bindFunc(cast(void**)&SDL_GetInputDeviceName, "SDL_GetInputDeviceName"); // bindFunc(cast(void**)&SDL_IsDeviceDisconnected, "SDL_IsDeviceDisconnected"); bindFunc(cast(void**)&SDL_NumJoysticks, "SDL_NumJoysticks"); bindFunc(cast(void**)&SDL_JoystickNameForIndex, "SDL_JoystickNameForIndex"); bindFunc(cast(void**)&SDL_JoystickOpen, "SDL_JoystickOpen"); bindFunc(cast(void**)&SDL_JoystickName, "SDL_JoystickName"); bindFunc(cast(void**)&SDL_JoystickGetDeviceGUID, "SDL_JoystickGetDeviceGUID"); bindFunc(cast(void**)&SDL_JoystickGetGUID, "SDL_JoystickGetGUID"); bindFunc(cast(void**)&SDL_JoystickGetGUIDString, "SDL_JoystickGetGUIDString"); bindFunc(cast(void**)&SDL_JoystickGetGUIDFromString, "SDL_JoystickGetGUIDFromString"); bindFunc(cast(void**)&SDL_JoystickGetAttached, "SDL_JoystickGetAttached"); bindFunc(cast(void**)&SDL_JoystickInstanceID, "SDL_JoystickInstanceID"); bindFunc(cast(void**)&SDL_JoystickNumAxes, "SDL_JoystickNumAxes"); bindFunc(cast(void**)&SDL_JoystickNumBalls, "SDL_JoystickNumBalls"); bindFunc(cast(void**)&SDL_JoystickNumHats, "SDL_JoystickNumHats"); bindFunc(cast(void**)&SDL_JoystickNumButtons, "SDL_JoystickNumButtons"); bindFunc(cast(void**)&SDL_JoystickUpdate, "SDL_JoystickUpdate"); bindFunc(cast(void**)&SDL_JoystickEventState, "SDL_JoystickEventState"); bindFunc(cast(void**)&SDL_JoystickGetAxis, "SDL_JoystickGetAxis"); bindFunc(cast(void**)&SDL_JoystickGetHat, "SDL_JoystickGetHat"); bindFunc(cast(void**)&SDL_JoystickGetBall, "SDL_JoystickGetBall"); bindFunc(cast(void**)&SDL_JoystickGetButton, "SDL_JoystickGetButton"); bindFunc(cast(void**)&SDL_JoystickClose, "SDL_JoystickClose"); bindFunc(cast(void**)&SDL_GetKeyboardFocus, "SDL_GetKeyboardFocus"); bindFunc(cast(void**)&SDL_GetKeyboardState, "SDL_GetKeyboardState"); bindFunc(cast(void**)&SDL_GetModState, "SDL_GetModState"); bindFunc(cast(void**)&SDL_SetModState, "SDL_SetModState"); bindFunc(cast(void**)&SDL_GetKeyFromScancode, "SDL_GetKeyFromScancode"); bindFunc(cast(void**)&SDL_GetScancodeFromKey, "SDL_GetScancodeFromKey"); bindFunc(cast(void**)&SDL_GetScancodeName, "SDL_GetScancodeName"); bindFunc(cast(void**)&SDL_GetScancodeFromName, "SDL_GetScancodeFromName"); bindFunc(cast(void**)&SDL_GetKeyName, "SDL_GetKeyName"); bindFunc(cast(void**)&SDL_GetKeyFromName, "SDL_GetKeyFromName"); bindFunc(cast(void**)&SDL_StartTextInput, "SDL_StartTextInput"); bindFunc(cast(void**)&SDL_IsTextInputActive, "SDL_IsTextInputActive"); bindFunc(cast(void**)&SDL_StopTextInput, "SDL_StopTextInput"); bindFunc(cast(void**)&SDL_SetTextInputRect, "SDL_SetTextInputRect"); bindFunc(cast(void**)&SDL_HasScreenKeyboardSupport, "SDL_HasScreenKeyboardSupport"); bindFunc(cast(void**)&SDL_IsScreenKeyboardShown, "SDL_IsScreenKeyboardShown"); bindFunc(cast(void**)&SDL_LoadObject, "SDL_LoadObject"); bindFunc(cast(void**)&SDL_LoadFunction, "SDL_LoadFunction"); bindFunc(cast(void**)&SDL_UnloadObject, "SDL_UnloadObject"); bindFunc(cast(void**)&SDL_LogSetAllPriority, "SDL_LogSetAllPriority"); bindFunc(cast(void**)&SDL_LogSetPriority, "SDL_LogSetPriority"); bindFunc(cast(void**)&SDL_LogGetPriority, "SDL_LogGetPriority"); bindFunc(cast(void**)&SDL_LogResetPriorities, "SDL_LogResetPriorities"); bindFunc(cast(void**)&SDL_Log, "SDL_Log"); bindFunc(cast(void**)&SDL_LogVerbose, "SDL_LogVerbose"); bindFunc(cast(void**)&SDL_LogDebug, "SDL_LogDebug"); bindFunc(cast(void**)&SDL_LogInfo, "SDL_LogInfo"); bindFunc(cast(void**)&SDL_LogWarn, "SDL_LogWarn"); bindFunc(cast(void**)&SDL_LogError, "SDL_LogError"); bindFunc(cast(void**)&SDL_LogCritical, "SDL_LogCritical"); bindFunc(cast(void**)&SDL_LogMessage, "SDL_LogMessage"); bindFunc(cast(void**)&SDL_LogMessageV, "SDL_LogMessageV"); bindFunc(cast(void**)&SDL_LogGetOutputFunction, "SDL_LogGetOutputFunction"); bindFunc(cast(void**)&SDL_LogSetOutputFunction, "SDL_LogSetOutputFunction"); bindFunc(cast(void**)&SDL_ShowMessageBox, "SDL_ShowMessageBox"); bindFunc(cast(void**)&SDL_ShowSimpleMessageBox, "SDL_ShowSimpleMessageBox"); bindFunc(cast(void**)&SDL_GetMouseFocus, "SDL_GetMouseFocus"); bindFunc(cast(void**)&SDL_GetMouseState, "SDL_GetMouseState"); bindFunc(cast(void**)&SDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"); bindFunc(cast(void**)&SDL_WarpMouseInWindow, "SDL_WarpMouseInWindow"); bindFunc(cast(void**)&SDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"); bindFunc(cast(void**)&SDL_GetRelativeMouseMode, "SDL_GetRelativeMouseMode"); bindFunc(cast(void**)&SDL_CreateCursor, "SDL_CreateCursor"); bindFunc(cast(void**)&SDL_CreateColorCursor, "SDL_CreateColorCursor"); bindFunc(cast(void**)&SDL_CreateSystemCursor, "SDL_CreateSystemCursor"); bindFunc(cast(void**)&SDL_SetCursor, "SDL_SetCursor"); bindFunc(cast(void**)&SDL_GetCursor, "SDL_GetCursor"); bindFunc(cast(void**)&SDL_FreeCursor, "SDL_FreeCursor"); bindFunc(cast(void**)&SDL_ShowCursor, "SDL_ShowCursor"); bindFunc(cast(void**)&SDL_GetPixelFormatName, "SDL_GetPixelFormatName"); bindFunc(cast(void**)&SDL_PixelFormatEnumToMasks, "SDL_PixelFormatEnumToMasks"); bindFunc(cast(void**)&SDL_MasksToPixelFormatEnum, "SDL_MasksToPixelFormatEnum"); bindFunc(cast(void**)&SDL_AllocFormat, "SDL_AllocFormat"); bindFunc(cast(void**)&SDL_FreeFormat, "SDL_FreeFormat"); bindFunc(cast(void**)&SDL_AllocPalette, "SDL_AllocPalette"); bindFunc(cast(void**)&SDL_SetPixelFormatPalette, "SDL_SetPixelFormatPalette"); bindFunc(cast(void**)&SDL_SetPaletteColors, "SDL_SetPaletteColors"); bindFunc(cast(void**)&SDL_FreePalette, "SDL_FreePalette"); bindFunc(cast(void**)&SDL_MapRGB, "SDL_MapRGB"); bindFunc(cast(void**)&SDL_MapRGBA, "SDL_MapRGBA"); bindFunc(cast(void**)&SDL_GetRGB, "SDL_GetRGB"); bindFunc(cast(void**)&SDL_GetRGBA, "SDL_GetRGBA"); bindFunc(cast(void**)&SDL_CalculateGammaRamp, "SDL_CalculateGammaRamp"); bindFunc(cast(void**)&SDL_GetPlatform, "SDL_GetPlatform"); bindFunc(cast(void**)&SDL_GetPowerInfo, "SDL_GetPowerInfo"); bindFunc(cast(void**)&SDL_HasIntersection, "SDL_HasIntersection"); bindFunc(cast(void**)&SDL_IntersectRect, "SDL_IntersectRect"); bindFunc(cast(void**)&SDL_UnionRect, "SDL_UnionRect"); bindFunc(cast(void**)&SDL_EnclosePoints, "SDL_EnclosePoints"); bindFunc(cast(void**)&SDL_IntersectRectAndLine, "SDL_IntersectRectAndLine"); bindFunc(cast(void**)&SDL_GetNumRenderDrivers, "SDL_GetNumRenderDrivers"); bindFunc(cast(void**)&SDL_GetRenderDriverInfo, "SDL_GetRenderDriverInfo"); bindFunc(cast(void**)&SDL_CreateWindowAndRenderer, "SDL_CreateWindowAndRenderer"); bindFunc(cast(void**)&SDL_CreateRenderer, "SDL_CreateRenderer"); bindFunc(cast(void**)&SDL_CreateSoftwareRenderer, "SDL_CreateSoftwareRenderer"); bindFunc(cast(void**)&SDL_GetRendererInfo, "SDL_GetRendererInfo"); bindFunc(cast(void**)&SDL_CreateTexture, "SDL_CreateTexture"); bindFunc(cast(void**)&SDL_CreateTextureFromSurface, "SDL_CreateTextureFromSurface"); bindFunc(cast(void**)&SDL_QueryTexture, "SDL_QueryTexture"); bindFunc(cast(void**)&SDL_SetTextureColorMod, "SDL_SetTextureColorMod"); bindFunc(cast(void**)&SDL_GetTextureColorMod, "SDL_GetTextureColorMod"); bindFunc(cast(void**)&SDL_SetTextureAlphaMod, "SDL_SetTextureAlphaMod"); bindFunc(cast(void**)&SDL_GetTextureAlphaMod, "SDL_GetTextureAlphaMod"); bindFunc(cast(void**)&SDL_SetTextureBlendMode, "SDL_SetTextureBlendMode"); bindFunc(cast(void**)&SDL_GetTextureBlendMode, "SDL_GetTextureBlendMode"); bindFunc(cast(void**)&SDL_UpdateTexture, "SDL_UpdateTexture"); bindFunc(cast(void**)&SDL_LockTexture, "SDL_LockTexture"); bindFunc(cast(void**)&SDL_UnlockTexture, "SDL_UnlockTexture"); bindFunc(cast(void**)&SDL_RenderTargetSupported, "SDL_RenderTargetSupported"); bindFunc(cast(void**)&SDL_SetRenderTarget, "SDL_SetRenderTarget"); bindFunc(cast(void**)&SDL_GetRenderTarget, "SDL_GetRenderTarget"); bindFunc(cast(void**)&SDL_RenderSetLogicalSize, "SDL_RenderSetLogicalSize"); bindFunc(cast(void**)&SDL_RenderGetLogicalSize, "SDL_RenderGetLogicalSize"); bindFunc(cast(void**)&SDL_RenderSetViewport, "SDL_RenderSetViewport"); bindFunc(cast(void**)&SDL_RenderGetViewport, "SDL_RenderGetViewport"); bindFunc(cast(void**)&SDL_RenderSetScale, "SDL_RenderSetScale"); bindFunc(cast(void**)&SDL_RenderGetScale, "SDL_RenderGetScale"); bindFunc(cast(void**)&SDL_SetRenderDrawColor, "SDL_SetRenderDrawColor"); bindFunc(cast(void**)&SDL_GetRenderDrawColor, "SDL_GetRenderDrawColor"); bindFunc(cast(void**)&SDL_SetRenderDrawBlendMode, "SDL_SetRenderDrawBlendMode"); bindFunc(cast(void**)&SDL_GetRenderDrawBlendMode, "SDL_GetRenderDrawBlendMode"); bindFunc(cast(void**)&SDL_RenderClear, "SDL_RenderClear"); bindFunc(cast(void**)&SDL_RenderDrawPoint, "SDL_RenderDrawPoint"); bindFunc(cast(void**)&SDL_RenderDrawPoints, "SDL_RenderDrawPoints"); bindFunc(cast(void**)&SDL_RenderDrawLine, "SDL_RenderDrawLine"); bindFunc(cast(void**)&SDL_RenderDrawLines, "SDL_RenderDrawLines"); bindFunc(cast(void**)&SDL_RenderDrawRect, "SDL_RenderDrawRect"); bindFunc(cast(void**)&SDL_RenderDrawRects, "SDL_RenderDrawRects"); bindFunc(cast(void**)&SDL_RenderFillRect, "SDL_RenderFillRect"); bindFunc(cast(void**)&SDL_RenderFillRects, "SDL_RenderFillRects"); bindFunc(cast(void**)&SDL_RenderCopy, "SDL_RenderCopy"); bindFunc(cast(void**)&SDL_RenderCopyEx, "SDL_RenderCopyEx"); bindFunc(cast(void**)&SDL_RenderReadPixels, "SDL_RenderReadPixels"); bindFunc(cast(void**)&SDL_RenderPresent, "SDL_RenderPresent"); bindFunc(cast(void**)&SDL_DestroyTexture, "SDL_DestroyTexture"); bindFunc(cast(void**)&SDL_DestroyRenderer, "SDL_DestroyRenderer"); bindFunc(cast(void**)&SDL_GL_BindTexture, "SDL_GL_BindTexture"); bindFunc(cast(void**)&SDL_GL_UnbindTexture, "SDL_GL_UnbindTexture"); bindFunc(cast(void**)&SDL_RWFromFile, "SDL_RWFromFile"); bindFunc(cast(void**)&SDL_RWFromFP, "SDL_RWFromFP"); bindFunc(cast(void**)&SDL_RWFromMem, "SDL_RWFromMem"); bindFunc(cast(void**)&SDL_RWFromConstMem, "SDL_RWFromConstMem"); bindFunc(cast(void**)&SDL_AllocRW, "SDL_AllocRW"); bindFunc(cast(void**)&SDL_FreeRW, "SDL_FreeRW"); bindFunc(cast(void**)&SDL_ReadU8, "SDL_ReadU8"); bindFunc(cast(void**)&SDL_ReadLE16, "SDL_ReadLE16"); bindFunc(cast(void**)&SDL_ReadBE16, "SDL_ReadBE16"); bindFunc(cast(void**)&SDL_ReadLE32, "SDL_ReadLE32"); bindFunc(cast(void**)&SDL_ReadBE32, "SDL_ReadBE32"); bindFunc(cast(void**)&SDL_ReadLE64, "SDL_ReadLE64"); bindFunc(cast(void**)&SDL_ReadBE64, "SDL_ReadBE64"); bindFunc(cast(void**)&SDL_WriteU8, "SDL_WriteU8"); bindFunc(cast(void**)&SDL_WriteLE16, "SDL_WriteLE16"); bindFunc(cast(void**)&SDL_WriteBE16, "SDL_WriteBE16"); bindFunc(cast(void**)&SDL_WriteLE32, "SDL_WriteLE32"); bindFunc(cast(void**)&SDL_WriteBE32, "SDL_WriteBE32"); bindFunc(cast(void**)&SDL_WriteLE64, "SDL_WriteLE64"); bindFunc(cast(void**)&SDL_WriteBE64, "SDL_WriteBE64"); bindFunc(cast(void**)&SDL_CreateShapedWindow, "SDL_CreateShapedWindow"); bindFunc(cast(void**)&SDL_IsShapedWindow, "SDL_IsShapedWindow"); bindFunc(cast(void**)&SDL_SetWindowShape, "SDL_SetWindowShape"); bindFunc(cast(void**)&SDL_GetShapedWindowMode, "SDL_GetShapedWindowMode"); bindFunc(cast(void**)&SDL_CreateRGBSurface, "SDL_CreateRGBSurface"); bindFunc(cast(void**)&SDL_CreateRGBSurfaceFrom, "SDL_CreateRGBSurfaceFrom"); bindFunc(cast(void**)&SDL_FreeSurface, "SDL_FreeSurface"); bindFunc(cast(void**)&SDL_SetSurfacePalette, "SDL_SetSurfacePalette"); bindFunc(cast(void**)&SDL_LockSurface, "SDL_LockSurface"); bindFunc(cast(void**)&SDL_UnlockSurface, "SDL_UnlockSurface"); bindFunc(cast(void**)&SDL_LoadBMP_RW, "SDL_LoadBMP_RW"); bindFunc(cast(void**)&SDL_SaveBMP_RW, "SDL_SaveBMP_RW"); bindFunc(cast(void**)&SDL_SetSurfaceRLE, "SDL_SetSurfaceRLE"); bindFunc(cast(void**)&SDL_SetColorKey, "SDL_SetColorKey"); bindFunc(cast(void**)&SDL_GetColorKey, "SDL_GetColorKey"); bindFunc(cast(void**)&SDL_SetSurfaceColorMod, "SDL_SetSurfaceColorMod"); bindFunc(cast(void**)&SDL_GetSurfaceColorMod, "SDL_GetSurfaceColorMod"); bindFunc(cast(void**)&SDL_SetSurfaceAlphaMod, "SDL_SetSurfaceAlphaMod"); bindFunc(cast(void**)&SDL_GetSurfaceAlphaMod, "SDL_GetSurfaceAlphaMod"); bindFunc(cast(void**)&SDL_SetSurfaceBlendMode, "SDL_SetSurfaceBlendMode"); bindFunc(cast(void**)&SDL_GetSurfaceBlendMode, "SDL_GetSurfaceBlendMode"); bindFunc(cast(void**)&SDL_SetClipRect, "SDL_SetClipRect"); bindFunc(cast(void**)&SDL_GetClipRect, "SDL_GetClipRect"); bindFunc(cast(void**)&SDL_ConvertSurface, "SDL_ConvertSurface"); bindFunc(cast(void**)&SDL_ConvertSurfaceFormat, "SDL_ConvertSurfaceFormat"); bindFunc(cast(void**)&SDL_ConvertPixels, "SDL_ConvertPixels"); bindFunc(cast(void**)&SDL_FillRect, "SDL_FillRect"); bindFunc(cast(void**)&SDL_FillRects, "SDL_FillRects"); bindFunc(cast(void**)&SDL_UpperBlit, "SDL_UpperBlit"); bindFunc(cast(void**)&SDL_LowerBlit, "SDL_LowerBlit"); bindFunc(cast(void**)&SDL_SoftStretch, "SDL_SoftStretch"); bindFunc(cast(void**)&SDL_UpperBlitScaled, "SDL_UpperBlitScaled"); bindFunc(cast(void**)&SDL_LowerBlitScaled, "SDL_LowerBlitScaled"); bindFunc(cast(void**)&SDL_GetTicks, "SDL_GetTicks"); bindFunc(cast(void**)&SDL_GetPerformanceCounter, "SDL_GetPerformanceCounter"); bindFunc(cast(void**)&SDL_GetPerformanceFrequency, "SDL_GetPerformanceFrequency"); bindFunc(cast(void**)&SDL_Delay, "SDL_Delay"); bindFunc(cast(void**)&SDL_AddTimer, "SDL_AddTimer"); bindFunc(cast(void**)&SDL_GetNumTouchDevices, "SDL_GetNumTouchDevices"); bindFunc(cast(void**)&SDL_GetTouchDevice, "SDL_GetTouchDevice"); bindFunc(cast(void**)&SDL_GetNumTouchFingers, "SDL_GetNumTouchFingers"); bindFunc(cast(void**)&SDL_GetTouchFinger, "SDL_GetTouchFinger"); bindFunc(cast(void**)&SDL_GetVersion, "SDL_GetVersion"); bindFunc(cast(void**)&SDL_GetRevision, "SDL_GetRevision"); bindFunc(cast(void**)&SDL_GetRevisionNumber, "SDL_GetRevisionNumber"); bindFunc(cast(void**)&SDL_GetNumVideoDrivers, "SDL_GetNumVideoDrivers"); bindFunc(cast(void**)&SDL_GetVideoDriver, "SDL_GetVideoDriver"); bindFunc(cast(void**)&SDL_VideoInit, "SDL_VideoInit"); bindFunc(cast(void**)&SDL_VideoQuit, "SDL_VideoQuit"); bindFunc(cast(void**)&SDL_GetCurrentVideoDriver, "SDL_GetCurrentVideoDriver"); bindFunc(cast(void**)&SDL_GetNumVideoDisplays, "SDL_GetNumVideoDisplays"); bindFunc(cast(void**)&SDL_GetDisplayName, "SDL_GetDisplayName"); bindFunc(cast(void**)&SDL_GetDisplayBounds, "SDL_GetDisplayBounds"); bindFunc(cast(void**)&SDL_GetNumDisplayModes, "SDL_GetNumDisplayModes"); bindFunc(cast(void**)&SDL_GetDisplayMode, "SDL_GetDisplayMode"); bindFunc(cast(void**)&SDL_GetDesktopDisplayMode, "SDL_GetDesktopDisplayMode"); bindFunc(cast(void**)&SDL_GetCurrentDisplayMode, "SDL_GetCurrentDisplayMode"); bindFunc(cast(void**)&SDL_GetClosestDisplayMode, "SDL_GetClosestDisplayMode"); bindFunc(cast(void**)&SDL_GetWindowDisplayIndex, "SDL_GetWindowDisplayIndex"); bindFunc(cast(void**)&SDL_SetWindowDisplayMode, "SDL_SetWindowDisplayMode"); bindFunc(cast(void**)&SDL_GetWindowDisplayMode, "SDL_GetWindowDisplayMode"); bindFunc(cast(void**)&SDL_GetWindowPixelFormat, "SDL_GetWindowPixelFormat"); bindFunc(cast(void**)&SDL_CreateWindow, "SDL_CreateWindow"); bindFunc(cast(void**)&SDL_CreateWindowFrom, "SDL_CreateWindowFrom"); bindFunc(cast(void**)&SDL_GetWindowID, "SDL_GetWindowID"); bindFunc(cast(void**)&SDL_GetWindowFromID, "SDL_GetWindowFromID"); bindFunc(cast(void**)&SDL_GetWindowFlags, "SDL_GetWindowFlags"); bindFunc(cast(void**)&SDL_SetWindowTitle, "SDL_SetWindowTitle"); bindFunc(cast(void**)&SDL_GetWindowTitle, "SDL_GetWindowTitle"); bindFunc(cast(void**)&SDL_SetWindowIcon, "SDL_SetWindowIcon"); bindFunc(cast(void**)&SDL_SetWindowData, "SDL_SetWindowData"); bindFunc(cast(void**)&SDL_GetWindowData, "SDL_GetWindowData"); bindFunc(cast(void**)&SDL_SetWindowPosition, "SDL_SetWindowPosition"); bindFunc(cast(void**)&SDL_GetWindowPosition, "SDL_GetWindowPosition"); bindFunc(cast(void**)&SDL_SetWindowSize, "SDL_SetWindowSize"); bindFunc(cast(void**)&SDL_GetWindowSize, "SDL_GetWindowSize"); bindFunc(cast(void**)&SDL_SetWindowMinimumSize, "SDL_SetWindowMinimumSize"); bindFunc(cast(void**)&SDL_GetWindowMinimumSize, "SDL_GetWindowMinimumSize"); bindFunc(cast(void**)&SDL_SetWindowMaximumSize, "SDL_SetWindowMaximumSize"); bindFunc(cast(void**)&SDL_GetWindowMaximumSize, "SDL_GetWindowMaximumSize"); bindFunc(cast(void**)&SDL_SetWindowBordered, "SDL_SetWindowBordered"); bindFunc(cast(void**)&SDL_ShowWindow, "SDL_ShowWindow"); bindFunc(cast(void**)&SDL_HideWindow, "SDL_HideWindow"); bindFunc(cast(void**)&SDL_RaiseWindow, "SDL_RaiseWindow"); bindFunc(cast(void**)&SDL_MaximizeWindow, "SDL_MaximizeWindow"); bindFunc(cast(void**)&SDL_MinimizeWindow, "SDL_MinimizeWindow"); bindFunc(cast(void**)&SDL_RestoreWindow, "SDL_RestoreWindow"); bindFunc(cast(void**)&SDL_SetWindowFullscreen, "SDL_SetWindowFullscreen"); bindFunc(cast(void**)&SDL_GetWindowSurface, "SDL_GetWindowSurface"); bindFunc(cast(void**)&SDL_UpdateWindowSurface, "SDL_UpdateWindowSurface"); bindFunc(cast(void**)&SDL_UpdateWindowSurfaceRects, "SDL_UpdateWindowSurfaceRects"); bindFunc(cast(void**)&SDL_SetWindowGrab, "SDL_SetWindowGrab"); bindFunc(cast(void**)&SDL_GetWindowGrab, "SDL_GetWindowGrab"); bindFunc(cast(void**)&SDL_SetWindowBrightness, "SDL_SetWindowBrightness"); bindFunc(cast(void**)&SDL_GetWindowBrightness, "SDL_GetWindowBrightness"); bindFunc(cast(void**)&SDL_SetWindowGammaRamp, "SDL_SetWindowGammaRamp"); bindFunc(cast(void**)&SDL_GetWindowGammaRamp, "SDL_GetWindowGammaRamp"); bindFunc(cast(void**)&SDL_DestroyWindow, "SDL_DestroyWindow"); bindFunc(cast(void**)&SDL_IsScreenSaverEnabled, "SDL_IsScreenSaverEnabled"); bindFunc(cast(void**)&SDL_EnableScreenSaver, "SDL_EnableScreenSaver"); bindFunc(cast(void**)&SDL_DisableScreenSaver, "SDL_DisableScreenSaver"); bindFunc(cast(void**)&SDL_GL_LoadLibrary, "SDL_GL_LoadLibrary"); bindFunc(cast(void**)&SDL_GL_GetProcAddress, "SDL_GL_GetProcAddress"); bindFunc(cast(void**)&SDL_GL_UnloadLibrary, "SDL_GL_UnloadLibrary"); bindFunc(cast(void**)&SDL_GL_ExtensionSupported, "SDL_GL_ExtensionSupported"); bindFunc(cast(void**)&SDL_GL_SetAttribute, "SDL_GL_SetAttribute"); bindFunc(cast(void**)&SDL_GL_GetAttribute, "SDL_GL_GetAttribute"); bindFunc(cast(void**)&SDL_GL_CreateContext, "SDL_GL_CreateContext"); bindFunc(cast(void**)&SDL_GL_MakeCurrent, "SDL_GL_MakeCurrent"); bindFunc(cast(void**)&SDL_GL_SetSwapInterval, "SDL_GL_SetSwapInterval"); bindFunc(cast(void**)&SDL_GL_GetSwapInterval, "SDL_GL_GetSwapInterval"); bindFunc(cast(void**)&SDL_GL_SwapWindow, "SDL_GL_SwapWindow"); bindFunc(cast(void**)&SDL_GL_DeleteContext, "SDL_GL_DeleteContext"); // SDL_init will fail if SDL_SetMainReady has not been called. // Since there's no SDL_main on the D side, it needs to be handled // manually. My understanding that this is fine on the platforms // that D is currently available on. If we ever get on to Android // or iPhone, though, this will need to be versioned. // I've wrapped it in a try/catch because it seem the function is // not always exported on Linux. See issue #153 // https://github.com/aldacron/Derelict3/issues/153 import derelict.util.exception; try { da_SDL_SetMainReady setReady; bindFunc(cast(void**)&setReady, "SDL_SetMainReady"); setReady(); } catch( DerelictException de ) {} } } } DerelictSDL2Loader DerelictSDL2; static this() { DerelictSDL2 = new DerelictSDL2Loader(); } static ~this() { if(SharedLibLoader.isAutoUnloadEnabled()) DerelictSDL2.unload(); }
D
module wx.ScrolledWindow; public import wx.common; public import wx.Panel; //--------------------------------------------------------------------- extern(D) class ОкноСПрокруткой : Панель { enum { СтильОкнаСПрокруткой = (ГПРОКРУТ | ВПРОКРУТ), } public this(ЦелУкз вхобъ); public this(Окно родитель, цел ид /*= ЛЮБОЙ*/, Точка поз = ДЕФПОЗ, Размер размер = ДЕФРАЗМ, цел стиль = СтильОкнаСПрокруткой, ткст имя = СтрИмениПанели); public this(Окно родитель, Точка поз = ДЕФПОЗ, Размер размер = ДЕФРАЗМ, цел стиль = СтильОкнаСПрокруткой, ткст имя = СтрИмениПанели); public проц приПеретяге(КонтекстУстройства ку); public override проц подготовьКУ(КонтекстУстройства ку); public проц устСкроллбары(цел пикселейНаЕдцуХ, цел пикселейНаЕдцуУ, цел безЕдцХ, цел безЕдцУ); public проц устСкроллбары(цел пикселейНаЕдцуХ, цел пикселейНаЕдцуУ, цел безЕдцХ, цел безЕдцУ, цел x, цел y); public проц устСкроллбары(цел пикселейНаЕдцуХ, цел пикселейНаЕдцуУ, цел безЕдцХ, цел безЕдцУ, цел x, цел y, бул неОсвежать); //private проц приОтрисовке(Объект отправитель, Событие e); public Точка стартОбзора(); public проц дайСтартОбзора(inout цел x, inout цел y); public проц дайПикселиПрокруткиНаЕдиницу(inout цел хЕдц, inout цел уЕдц); public проц вычислиПрокрПозицию(цел x, цел y, inout цел xx, inout цел yy); public проц вычислиНепрокрПозицию(цел x, цел y, inout цел xx, inout цел yy); public проц дайВиртРазм(inout цел x, inout цел y); public проц промотай(цел x, цел y); public проц устрРейтПрокрутки(цел xstep, цел ystep); public проц целевоеОкно(Окно значение); }
D
module android.java.java.time.chrono.HijrahChronology; public import android.java.java.time.chrono.HijrahChronology_d_interface; import arsd.jni : ImportExportImpl; mixin ImportExportImpl!HijrahChronology; import import5 = android.java.java.time.chrono.ChronoLocalDateTime; import import14 = android.java.java.time.chrono.ChronoLocalDate; import import16 = android.java.java.lang.Class; import import18 = android.java.java.util.Set; import import0 = android.java.java.time.chrono.HijrahDate; import import6 = android.java.java.time.chrono.ChronoZonedDateTime; import import8 = android.java.java.time.chrono.HijrahEra; import import9 = android.java.java.util.List; import import20 = android.java.java.time.chrono.ChronoPeriod; import import10 = android.java.java.time.temporal.ValueRange;
D
/Users/jonb/Documents/dvlp/rust-oauthcli/target/debug/deps/oauthcli-872990c271b5cb03.rmeta: src/lib.rs /Users/jonb/Documents/dvlp/rust-oauthcli/target/debug/deps/liboauthcli-872990c271b5cb03.rlib: src/lib.rs /Users/jonb/Documents/dvlp/rust-oauthcli/target/debug/deps/oauthcli-872990c271b5cb03.d: src/lib.rs src/lib.rs:
D
/Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Fluent.build/Objects-normal/x86_64/PreparationError.o : /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Database.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Driver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Entity/Entity.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Filters.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/MemoryDriver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Database+Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Migration.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/PreparationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Action.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Comparison.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Filter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Join.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Limit.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Scope.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Children.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Parent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/RelationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Siblings.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Database+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Creator.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Field.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Modifier.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Fluent.build/Objects-normal/x86_64/PreparationError~partial.swiftmodule : /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Database.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Driver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Entity/Entity.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Filters.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/MemoryDriver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Database+Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Migration.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/PreparationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Action.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Comparison.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Filter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Join.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Limit.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Scope.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Children.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Parent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/RelationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Siblings.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Database+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Creator.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Field.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Modifier.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Intermediates/Pokedex.build/Debug/Fluent.build/Objects-normal/x86_64/PreparationError~partial.swiftdoc : /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Database.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Database/Driver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Entity/Entity.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Filters.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/Memory+Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Memory/MemoryDriver.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Database+Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Migration.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/Preparation.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Preparation/PreparationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Action.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Comparison.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Filter.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Group.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Join.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Limit.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Scope.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Query/Sort.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Children.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Parent.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/RelationError.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Relations/Siblings.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Database+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Creator.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Field.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema+Modifier.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Schema/Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/GeneralSQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Query.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL+Schema.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQL.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/SQL/SQLSerializer.swift /Users/Yowa/WorkSpace/Pokedex/Packages/Fluent-1.0.0/Sources/Fluent/Utilities/Fluent+Node.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 /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/Darwin.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/ObjectiveC.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/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Node.framework/Modules/Node.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/PathIndexable.framework/Modules/PathIndexable.swiftmodule/x86_64.swiftmodule /Users/Yowa/WorkSpace/Pokedex/Build/Products/Debug/Polymorphic.framework/Modules/Polymorphic.swiftmodule/x86_64.swiftmodule
D
module android.java.java.io.ObjectInput_d_interface; import arsd.jni : IJavaObjectImplementation, JavaPackageId, JavaName, IJavaObject, ImportExportImpl, JavaInterfaceMembers; static import arsd.jni; import import0 = android.java.java.lang.Class_d_interface; final class ObjectInput : IJavaObject { static immutable string[] _d_canCastTo = [ "java/io/DataInput", "java/lang/AutoCloseable", ]; @Import IJavaObject readObject(); @Import int read(); @Import int read(byte[]); @Import int read(byte, int, int[]); @Import long skip(long); @Import int available(); @Import void close(); @Import import0.Class getClass(); @Import int hashCode(); @Import bool equals(IJavaObject); @Import @JavaName("toString") string toString_(); override string toString() { return arsd.jni.javaObjectToString(this); } @Import void notify(); @Import void notifyAll(); @Import void wait(long); @Import void wait(long, int); @Import void wait(); @Import void readFully(byte[]); @Import void readFully(byte, int, int[]); @Import int skipBytes(int); @Import bool readBoolean(); @Import byte readByte(); @Import int readUnsignedByte(); @Import short readShort(); @Import int readUnsignedShort(); @Import wchar readChar(); @Import int readInt(); @Import long readLong(); @Import float readFloat(); @Import double readDouble(); @Import string readLine(); @Import string readUTF(); mixin IJavaObjectImplementation!(false); public static immutable string _javaParameterString = "Ljava/io/ObjectInput;"; }
D
/Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Response.o : /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/AFError.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/MultipartFormData.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Notifications.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Request.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Response.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Result.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/TaskDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Timeline.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Validation.swift /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/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Users/nathaneidelson/Developer/CS51-Demo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule /Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Response~partial.swiftmodule : /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/AFError.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/MultipartFormData.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Notifications.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Request.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Response.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Result.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/TaskDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Timeline.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Validation.swift /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/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Users/nathaneidelson/Developer/CS51-Demo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule /Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.build/Objects-normal/x86_64/Response~partial.swiftdoc : /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/AFError.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/DispatchQueue+Alamofire.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/MultipartFormData.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/NetworkReachabilityManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Notifications.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ParameterEncoding.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Request.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Response.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ResponseSerialization.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Result.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/ServerTrustPolicy.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/SessionManager.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/TaskDelegate.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Timeline.swift /Users/nathaneidelson/Developer/CS51-Demo/Pods/Alamofire/Source/Validation.swift /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/ObjectiveC.apinotesc /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/Foundation.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreGraphics.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/CoreText.apinotesc /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/x86_64/UIKit.apinotesc /Users/nathaneidelson/Developer/CS51-Demo/Pods/Target\ Support\ Files/Alamofire/Alamofire-umbrella.h /Users/nathaneidelson/Developer/CS51-Demo/Build/Intermediates/Pods.build/Debug-iphonesimulator/Alamofire.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/QuartzCore.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/SwiftOnoneSupport.swiftmodule
D
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric; void main() { auto T = readln.chomp; bool nc; int l, max_l; for (int i = 2; i <= T.length; i += 2) { if (T[i-2..i] == "??" || T[i-2..i] == "2?" || T[i-2..i] == "?5" || T[i-2..i] == "25") { l += 2; max_l = max(max_l, l); } else { l = 0; } } l = 0; for (int i = 3; i <= T.length; i += 2) { if (T[i-2..i] == "??" || T[i-2..i] == "2?" || T[i-2..i] == "?5" || T[i-2..i] == "25") { l += 2; max_l = max(max_l, l); } else { l = 0; } } writeln(max_l); }
D