├── .gitignore ├── Makefile ├── README ├── README.textile ├── analyzing └── debugger.d ├── binding ├── c.d ├── cairo │ ├── cairo.d │ ├── features.d │ ├── xlib.d │ └── xlibrender.d ├── lua.d ├── ncurses │ └── ncurses.d ├── opengl │ ├── gl.d │ └── glu.d ├── pango │ ├── attributes.d │ ├── cairo.d │ ├── context.d │ ├── coverage.d │ ├── engine.d │ ├── font.d │ ├── fontmap.d │ ├── fontset.d │ ├── glyph.d │ ├── glyphitem.d │ ├── gravity.d │ ├── item.d │ ├── layout.d │ ├── matrix.d │ ├── pango.d │ ├── pbreak.d │ ├── script.d │ ├── tabs.d │ └── types.d ├── perl.d ├── win32 │ ├── gdiplus.d │ ├── gdiplusbase.d │ ├── gdiplusbitmap.d │ ├── gdiplusbrush.d │ ├── gdipluscachedbitmap.d │ ├── gdipluscolor.d │ ├── gdipluscolormatrix.d │ ├── gdipluseffects.d │ ├── gdiplusenums.d │ ├── gdiplusflat.d │ ├── gdiplusfont.d │ ├── gdiplusfontcollection.d │ ├── gdiplusfontfamily.d │ ├── gdiplusgpstubs.d │ ├── gdiplusgraphics.d │ ├── gdiplusheaders.d │ ├── gdiplusimageattributes.d │ ├── gdiplusimagecodec.d │ ├── gdiplusimaging.d │ ├── gdiplusinit.d │ ├── gdipluslinecaps.d │ ├── gdiplusmatrix.d │ ├── gdiplusmem.d │ ├── gdiplusmetafile.d │ ├── gdiplusmetaheader.d │ ├── gdipluspath.d │ ├── gdipluspen.d │ ├── gdipluspixelformats.d │ ├── gdiplusregion.d │ ├── gdiplusstringformat.d │ ├── gdiplustypes.d │ ├── guiddef.d │ ├── inaddr.d │ ├── mmsystem.d │ ├── ntstatus.d │ ├── qos.d │ ├── uxtheme.d │ ├── winbase.d │ ├── wincon.d │ ├── windef.d │ ├── windows.d │ ├── winerror.d │ ├── wingdi.d │ ├── winnt.d │ ├── winsock.d │ ├── winsock2.d │ ├── winuser.d │ ├── ws2def.d │ └── ws2tcpip.d └── x │ ├── X.d │ ├── Xlib.d │ ├── Xrender.d │ ├── render.d │ └── xinerama.d ├── console └── prompt.d ├── core ├── application.d ├── arguments.d ├── color.d ├── date.d ├── definitions.d ├── endian.d ├── error.d ├── event.d ├── exception.d ├── library.d ├── locale.d ├── main.d ├── parameters.d ├── regex.d ├── stream.d ├── string.d ├── system.d ├── time.d ├── timezone.d ├── unicode.d ├── util.d └── variant.d ├── cui ├── application.d ├── buffer.d ├── codebox.d ├── container.d ├── dialog.d ├── filebox.d ├── label.d ├── listbox.d ├── tabbox.d ├── telnet.d ├── textbox.d ├── textfield.d ├── vt100.d ├── widget.d └── window.d ├── data ├── fibonacci.d ├── heap.d ├── iterable.d ├── list.d ├── queue.d ├── queue2.d └── stack.d ├── decoders ├── audio │ ├── all.d │ ├── aud.d │ ├── decoder.d │ ├── mp1.d │ ├── mp2.d │ ├── mp3.d │ ├── mp3Huffman.d │ ├── mp3Huffman.scm │ ├── mp4.d │ ├── mpegCommon.d │ ├── ra.d │ ├── snd.d │ ├── wav.d │ ├── wma.d │ └── xm.d ├── binary │ ├── base64.d │ ├── decoder.d │ ├── deflate.d │ ├── par2.d │ ├── template.d │ ├── yEnc.d │ └── zlib.d ├── decoder.d └── image │ ├── all.d │ ├── bmp.d │ ├── decoder.d │ ├── gif.d │ ├── jpeg.d │ ├── jpeg2000.d │ ├── pcx.d │ ├── png.d │ ├── tga.d │ └── tiff.d ├── djehuty.d ├── examples ├── CuiTetris │ ├── app.d │ ├── gamecontrol.d │ ├── gamewindow.d │ └── tetris.d ├── MoreDucks │ ├── MoreDucks.d │ ├── baby_ducks.png │ ├── duckling.png │ └── ducks-cute.png └── Snake │ ├── app.d │ ├── constants.d │ ├── game.d │ ├── posn.d │ ├── snake.d │ └── win.d ├── graphics ├── bitmap.d ├── brush.d ├── convexhull.d ├── font.d ├── gradient.d ├── graphics.d ├── path.d ├── pen.d ├── region.d └── view.d ├── gui ├── application.d ├── button.d ├── container.d ├── hscrollbar.d ├── listbox.d ├── listfield.d ├── progressbar.d ├── radiogroup.d ├── textfield.d ├── togglefield.d ├── trackbar.d ├── vscrollbar.d ├── widget.d └── window.d ├── hashes ├── alder32.d ├── all.d ├── crc32.d ├── digest.d ├── md5.d ├── sha1.d ├── sha224.d └── sha256.d ├── hello.lua ├── interfaces └── container.d ├── io ├── audio.d ├── console.d ├── directory.d ├── file.d ├── socket.d └── wavelet.d ├── locales ├── all.d ├── en_us.d └── fr_fr.d ├── math ├── common.d ├── currency.d ├── fixed.d ├── integer.d ├── mathobject.d ├── matrix.d ├── random.d └── vector.d ├── moreducks.exe.manifest ├── networking ├── ftp.d ├── http.d ├── irc.d ├── nntp.d ├── smtp.d ├── ssh.d └── telnet.d ├── opengl ├── light.d ├── texture.d └── window.d ├── parsing ├── ast.d ├── bnf.d ├── cfg.d ├── css.d ├── d │ ├── addexprunit.d │ ├── aggregatebodyunit.d │ ├── aggregatedeclunit.d │ ├── andexprunit.d │ ├── assignexprunit.d │ ├── basictypeunit.d │ ├── blockstmtunit.d │ ├── breakstmtunit.d │ ├── casestmtunit.d │ ├── classbodyunit.d │ ├── classdeclunit.d │ ├── cmpexprunit.d │ ├── conditionalexprunit.d │ ├── constructorunit.d │ ├── continuestmtunit.d │ ├── debugunit.d │ ├── declarationunit.d │ ├── declaratorsuffixunit.d │ ├── declaratortypeunit.d │ ├── declaratorunit.d │ ├── defaultstmtunit.d │ ├── destructorunit.d │ ├── enumbodyunit.d │ ├── enumdeclunit.d │ ├── expressionunit.d │ ├── foreachstmtunit.d │ ├── forstmtunit.d │ ├── functionbodyunit.d │ ├── gotostmtunit.d │ ├── importdeclunit.d │ ├── interfacebodyunit.d │ ├── interfacedeclunit.d │ ├── isexprunit.d │ ├── lexer.d │ ├── logicalandexprunit.d │ ├── logicalorexprunit.d │ ├── moduledeclunit.d │ ├── moduleunit.d │ ├── mulexprunit.d │ ├── nodes.d │ ├── orexprunit.d │ ├── parameterlistunit.d │ ├── parameterunit.d │ ├── parser.d │ ├── postfixexprlistunit.d │ ├── postfixexprunit.d │ ├── pragmastmtunit.d │ ├── primaryexprunit.d │ ├── returnstmtunit.d │ ├── scopedstmtunit.d │ ├── shiftexprunit.d │ ├── statementunit.d │ ├── staticassertunit.d │ ├── staticifunit.d │ ├── staticunit.d │ ├── switchstmtunit.d │ ├── template.d │ ├── templatebodyunit.d │ ├── throwstmtunit.d │ ├── tokens.d │ ├── trees.d │ ├── typedeclarationunit.d │ ├── typeunit.d │ ├── unaryexprunit.d │ ├── unittestunit.d │ ├── versionunit.d │ ├── volatilestmtunit.d │ └── xorexprunit.d ├── ebnf.d ├── html.d ├── lexer.d ├── options.d ├── parser.d ├── parseunit.d ├── sgml.d ├── token.d ├── wiki.d └── xml.d ├── platform ├── osx │ ├── common.d │ ├── definitions.d │ ├── gui │ │ └── apploop.d │ ├── imports.d │ ├── main.d │ ├── objc │ │ ├── OSXView.h │ │ ├── OSXWindow.h │ │ ├── app.m │ │ ├── view.m │ │ └── window.m │ ├── oscontrol.d │ ├── oscontrolinterface.d │ ├── platform │ │ ├── application.d │ │ ├── definitions.d │ │ └── vars │ │ │ ├── brush.d │ │ │ ├── condition.d │ │ │ ├── cui.d │ │ │ ├── directory.d │ │ │ ├── file.d │ │ │ ├── font.d │ │ │ ├── library.d │ │ │ ├── menu.d │ │ │ ├── mutex.d │ │ │ ├── pen.d │ │ │ ├── region.d │ │ │ ├── semaphore.d │ │ │ ├── socket.d │ │ │ ├── thread.d │ │ │ ├── view.d │ │ │ ├── wave.d │ │ │ └── window.d │ ├── scaffold │ │ ├── color.d │ │ ├── console.d │ │ ├── cui.d │ │ ├── directory.d │ │ ├── file.d │ │ ├── graphics.d │ │ ├── menu.d │ │ ├── opengl.d │ │ ├── socket.d │ │ ├── system.d │ │ ├── thread.d │ │ ├── time.d │ │ ├── view.d │ │ ├── wave.d │ │ └── window.d │ └── thread.d ├── unix │ ├── common.d │ ├── gui │ │ ├── apploop.d │ │ └── osbutton.d │ ├── imports.d │ ├── main.d │ ├── oscontrol.d │ ├── platform │ │ ├── application.d │ │ ├── definitions.d │ │ └── vars │ │ │ ├── brush.d │ │ │ ├── condition.d │ │ │ ├── cui.d │ │ │ ├── directory.d │ │ │ ├── file.d │ │ │ ├── font.d │ │ │ ├── library.d │ │ │ ├── menu.d │ │ │ ├── mutex.d │ │ │ ├── pen.d │ │ │ ├── region.d │ │ │ ├── semaphore.d │ │ │ ├── socket.d │ │ │ ├── thread.d │ │ │ ├── view.d │ │ │ ├── wave.d │ │ │ └── window.d │ └── scaffold │ │ ├── color.d │ │ ├── console.d │ │ ├── cui.d │ │ ├── directory.d │ │ ├── file.d │ │ ├── graphics.d │ │ ├── menu.d │ │ ├── opengl.d │ │ ├── socket.d │ │ ├── system.d │ │ ├── thread.d │ │ ├── time.d │ │ ├── view.d │ │ ├── wave.d │ │ └── window.d └── win │ ├── common.d │ ├── controls │ ├── oshscrollbar.d │ ├── oslistbox.d │ ├── oslistfield.d │ ├── osprogressbar.d │ ├── ostextfield.d │ ├── ostogglefield.d │ ├── ostrackbar.d │ └── osvscrollbar.d │ ├── def │ └── gdiplus.def │ ├── gui │ ├── apploop.d │ └── osbutton.d │ ├── lib │ ├── COMCTL32.LIB │ ├── CTL3D32.LIB │ ├── ODBC32.LIB │ ├── OLEAUT32.LIB │ ├── WS2_32.LIB │ ├── advapi32.lib │ ├── comdlg32.lib │ ├── gc.lib │ ├── gdi32.lib │ ├── gdiplus.lib │ ├── glu32.lib │ ├── kernel32.lib │ ├── lua5.1.lib │ ├── mpr.lib │ ├── msimg32.lib │ ├── netapi32.lib │ ├── ole32.lib │ ├── opengl32.lib │ ├── rpcrt4.lib │ ├── shell32.lib │ ├── snn.lib │ ├── user32.lib │ ├── uuid.lib │ ├── winmm.lib │ ├── winspool.lib │ ├── ws2_dll.lib │ └── wsock32.lib │ ├── main.d │ ├── platform │ ├── application.d │ ├── definitions.d │ └── vars │ │ ├── brush.d │ │ ├── condition.d │ │ ├── cui.d │ │ ├── directory.d │ │ ├── file.d │ │ ├── font.d │ │ ├── library.d │ │ ├── menu.d │ │ ├── mutex.d │ │ ├── pen.d │ │ ├── region.d │ │ ├── semaphore.d │ │ ├── socket.d │ │ ├── thread.d │ │ ├── view.d │ │ ├── wave.d │ │ └── window.d │ ├── scaffold │ ├── color.d │ ├── console.d │ ├── cui.d │ ├── directory.d │ ├── file.d │ ├── graphics.d │ ├── menu.d │ ├── opengl.d │ ├── socket.d │ ├── system.d │ ├── thread.d │ ├── time.d │ ├── view.d │ ├── wave.d │ └── window.d │ └── widget.d ├── resource ├── image.d ├── menu.d ├── resource.d └── sound.d ├── runtests.d ├── runtime ├── apply.d ├── array.d ├── assocarray.d ├── classinfo.d ├── classinvariant.d ├── common.d ├── dstatic.d ├── entry.d ├── error.d ├── exception.d ├── gc.d ├── lifetime.d ├── main.d ├── moduleinfo.d ├── monitor.d ├── object.d ├── precision.d ├── switchstmt.d ├── typeinfo.d ├── typeinfo │ ├── ti_array.d │ ├── ti_array_bool.d │ ├── ti_array_byte.d │ ├── ti_array_cdouble.d │ ├── ti_array_cfloat.d │ ├── ti_array_char.d │ ├── ti_array_creal.d │ ├── ti_array_dchar.d │ ├── ti_array_double.d │ ├── ti_array_float.d │ ├── ti_array_idouble.d │ ├── ti_array_ifloat.d │ ├── ti_array_int.d │ ├── ti_array_ireal.d │ ├── ti_array_long.d │ ├── ti_array_object.d │ ├── ti_array_real.d │ ├── ti_array_short.d │ ├── ti_array_ubyte.d │ ├── ti_array_uint.d │ ├── ti_array_ulong.d │ ├── ti_array_ushort.d │ ├── ti_array_void.d │ ├── ti_array_wchar.d │ ├── ti_assocarray.d │ ├── ti_byte.d │ ├── ti_cdouble.d │ ├── ti_cfloat.d │ ├── ti_char.d │ ├── ti_creal.d │ ├── ti_dchar.d │ ├── ti_delegate.d │ ├── ti_double.d │ ├── ti_enum.d │ ├── ti_float.d │ ├── ti_function.d │ ├── ti_idouble.d │ ├── ti_ifloat.d │ ├── ti_int.d │ ├── ti_interface.d │ ├── ti_ireal.d │ ├── ti_long.d │ ├── ti_object.d │ ├── ti_ptr.d │ ├── ti_real.d │ ├── ti_short.d │ ├── ti_staticarray.d │ ├── ti_struct.d │ ├── ti_tuple.d │ ├── ti_typedef.d │ ├── ti_ubyte.d │ ├── ti_uint.d │ ├── ti_ulong.d │ ├── ti_ushort.d │ ├── ti_void.d │ └── ti_wchar.d ├── types.d ├── unwind.d └── vararg.d ├── scripting ├── lua.d ├── minid.d ├── perl.d ├── php.d ├── python.d └── ruby.d ├── spec ├── itemspecification.d ├── logic.d ├── modulespecification.d ├── packagespecification.d ├── specification.d ├── support.d └── test.d ├── specs ├── core │ ├── application.ds │ ├── arguments.ds │ ├── date.ds │ ├── regex.ds │ ├── string.ds │ ├── time.ds │ ├── unicode.ds │ ├── util.ds │ └── variant.ds ├── data │ ├── fibonacci.ds │ ├── heap.ds │ ├── queue.ds │ └── stack.ds ├── hashes │ ├── digest.ds │ ├── md5.ds │ ├── sha1.ds │ ├── sha224.ds │ └── sha256.ds ├── math │ └── random.ds └── runtime │ ├── array.ds │ ├── foreach.ds │ └── switch.ds ├── synch ├── atomic.d ├── barrier.d ├── condition.d ├── mutex.d ├── semaphore.d ├── thread.d └── timer.d ├── tests ├── 01 Block Shaped Heart.mp3 ├── 58919__mattwasser__coin_up.aif ├── Dog_bounces_trampoline.gif ├── Pillow_pins_kitten.gif ├── begin.mp2 ├── fazed.dreamer.mp3 ├── outside.gif ├── sine_220.wav ├── sine_440.mp3 ├── sine_440.wav ├── test.d ├── test.png ├── testmd5a.bin ├── testmd5b.bin └── tiles.png ├── tools ├── dscribe │ ├── lexer.d │ ├── main.d │ └── tokens.d └── dspec │ ├── ast.d │ ├── feeder.d │ ├── filelist.d │ ├── main.d │ ├── output.d │ ├── parser.d │ └── parseunit.d ├── winsamp.d └── winsamp.exe.manifest /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.obj 3 | *.d~ 4 | .DS_Store 5 | winsamp 6 | cuitetris 7 | snake 8 | moreducks 9 | *.exe 10 | *.ppk 11 | key 12 | key.pub 13 | djehuty.lib 14 | *.map 15 | *.idb 16 | dspec 17 | runtests 18 | .specs 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Djehuty 2 | -------------- 3 | 4 | Abstract 5 | 6 | The Djehuty framework will provide a basis of multi-platform multi-purpose 7 | application development. It will focus, initially, on desktop application 8 | development providing means to quickly develop GUI, CUI, and CLI apps. The 9 | framework is also a master library of useful implementations of generic 10 | algorithms and provisions for utilizing common resources. 11 | -------------------------------------------------------------------------------- /binding/cairo/features.d: -------------------------------------------------------------------------------- 1 | /* 2 | * features.d 3 | * 4 | * This file holds bindings to cairo's cairo-features.h. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | /* Converted to D from cairo-features.h by htod */ 11 | 12 | module binding.cairo.features; 13 | 14 | const auto CAIRO_VERSION_MAJOR = 1; 15 | 16 | const auto CAIRO_VERSION_MINOR = 4; 17 | 18 | const auto CAIRO_VERSION_MICRO = 2; 19 | 20 | const auto CAIRO_HAS_SVG_SURFACE = 1; 21 | 22 | const auto CAIRO_HAS_PDF_SURFACE = 1; 23 | 24 | const auto CAIRO_HAS_PS_SURFACE = 1; 25 | 26 | const auto CAIRO_HAS_FT_FONT = 1; 27 | 28 | const auto CAIRO_HAS_PNG_FUNCTIONS = 1; 29 | 30 | const auto CAIRO_HAS_XLIB_XRENDER_SURFACE = 1; 31 | 32 | const auto CAIRO_HAS_XLIB_SURFACE = 1; 33 | -------------------------------------------------------------------------------- /binding/pango/pango.d: -------------------------------------------------------------------------------- 1 | /* 2 | * pango.d 3 | * 4 | * This file holds bindings to pango. It will import all of the pango 5 | * packages available. 6 | * 7 | * Author: Dave Wilkinson 8 | * 9 | */ 10 | 11 | module binding.pango.pango; 12 | 13 | public import binding.pango.font; 14 | public import binding.pango.types; 15 | public import binding.pango.context; 16 | public import binding.pango.pbreak; 17 | public import binding.pango.engine; 18 | public import binding.pango.fontmap; 19 | public import binding.pango.fontset; 20 | public import binding.pango.coverage; 21 | public import binding.pango.item; 22 | public import binding.pango.glyph; 23 | public import binding.pango.matrix; 24 | public import binding.pango.script; 25 | public import binding.pango.attributes; 26 | 27 | public import binding.pango.layout; 28 | 29 | public import binding.pango.cairo; 30 | -------------------------------------------------------------------------------- /binding/perl.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/binding/perl.d -------------------------------------------------------------------------------- /binding/win32/gdiplusbase.d: -------------------------------------------------------------------------------- 1 | /* 2 | * gdiplusbase.d 3 | * 4 | * This module implements GdiPlusBase.h for D. The original copyright 5 | * info is given below. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: November 24th, 2009 9 | * 10 | */ 11 | 12 | module binding.win32.gdiplusbase; 13 | 14 | import binding.win32.gdiplusmem; 15 | 16 | // The original copyright notice from GdiplusBase.h from which this module 17 | // is based: 18 | 19 | /**************************************************************************\ 20 | * 21 | * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. 22 | * 23 | * Module Name: 24 | * 25 | * GdiplusBase.h 26 | * 27 | * Abstract: 28 | * 29 | * GDI+ base memory allocation class 30 | * 31 | \**************************************************************************/ 32 | 33 | // These are C++ class bindings, and cannot be binded 34 | 35 | class GdiplusBase { 36 | /* 37 | 38 | delete(void* in_pVoid) { 39 | GdipFree(in_pVoid); 40 | } 41 | 42 | new(size_t in_size) { 43 | return GdipAlloc(in_size); 44 | } 45 | 46 | */ 47 | } -------------------------------------------------------------------------------- /binding/win32/gdiplusheaders.d: -------------------------------------------------------------------------------- 1 | /**************************************************************************\ 2 | * 3 | * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. 4 | * 5 | * Module Name: 6 | * 7 | * GdiplusHeaders.h 8 | * 9 | * Abstract: 10 | * 11 | * GDI+ Region, Font, Image, CustomLineCap class definitions. 12 | * 13 | * 14 | * Class definition and inline class implementation are separated into 15 | * different files to avoid circular dependencies. 16 | * 17 | \**************************************************************************/ 18 | 19 | 20 | //-------------------------------------------------------------------------- 21 | // Abstract base class for Image and Metafile 22 | //-------------------------------------------------------------------------- 23 | 24 | -------------------------------------------------------------------------------- /binding/win32/gdiplusmem.d: -------------------------------------------------------------------------------- 1 | /* 2 | * gdiplusmem.d 3 | * 4 | * This module binds GdiPlusMem.h to D. The original copyright 5 | * notice is preserved below. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: November 25th, 2009 9 | * 10 | */ 11 | 12 | module binding.win32.gdiplusmem; 13 | 14 | extern(System): 15 | 16 | /**************************************************************************\ 17 | * 18 | * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. 19 | * 20 | * Module Name: 21 | * 22 | * GdiplusMem.h 23 | * 24 | * Abstract: 25 | * 26 | * GDI+ Private Memory Management APIs 27 | * 28 | \**************************************************************************/ 29 | 30 | void* GdipAlloc(size_t size); 31 | 32 | void GdipFree(void* ptr); -------------------------------------------------------------------------------- /binding/x/xinerama.d: -------------------------------------------------------------------------------- 1 | /* 2 | * xinerama.d 3 | * 4 | * This file holds bindings to xinerama. This file was created from xinerama.h 5 | * which is provided with xinerama proper. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: May 20th, 2009 9 | * 10 | */ 11 | 12 | module binding.x.xinerama; 13 | 14 | import binding.x.Xlib; 15 | 16 | struct XineramaScreenInfo { 17 | int screen_number; 18 | short x_org; 19 | short y_org; 20 | short width; 21 | short height; 22 | } 23 | 24 | //_XFUNCPROTOBEGIN 25 | 26 | Bool XineramaQueryExtension ( 27 | Display *dpy, 28 | int *event_base, 29 | int *error_base 30 | ) 31 | 32 | Status XineramaQueryVersion( 33 | Display *dpy, 34 | int *major, 35 | int *minor 36 | ) 37 | 38 | Bool XineramaIsActive(Display *dpy); 39 | 40 | /* 41 | Returns the number of heads and a pointer to an array of 42 | structures describing the position and size of the individual 43 | heads. Returns NULL and number = 0 if Xinerama is not active. 44 | 45 | Returned array should be freed with XFree(). 46 | */ 47 | 48 | XineramaScreenInfo * 49 | XineramaQueryScreens( 50 | Display *dpy, 51 | int *number 52 | ); 53 | 54 | //_XFUNCPROTOEND 55 | -------------------------------------------------------------------------------- /core/arguments.d: -------------------------------------------------------------------------------- 1 | module core.arguments; 2 | 3 | import core.definitions; 4 | import core.util; 5 | import core.string; 6 | 7 | import data.list; 8 | 9 | // Description: This class holds the command line arguments that were passed into the app and will aid in parsing them. 10 | class Arguments : List!(string) { 11 | public: 12 | 13 | this() { 14 | } 15 | 16 | static Arguments instance() { 17 | if (appInstance is null) { 18 | appInstance = new Arguments(); 19 | } 20 | 21 | return appInstance; 22 | } 23 | 24 | protected: 25 | 26 | static Arguments appInstance; 27 | } 28 | -------------------------------------------------------------------------------- /core/error.d: -------------------------------------------------------------------------------- 1 | /* 2 | * error.d 3 | * 4 | * This module implements the Error objects useable by the system. 5 | * This objects are for irrecoverable failures. 6 | * 7 | * Originated: May 8th, 2010 8 | * 9 | */ 10 | 11 | module core.error; 12 | 13 | import core.definitions; 14 | 15 | // Description: This is for non irrecoverable failure. 16 | class Error : Exception { 17 | this(string msg, string file = "", ulong line = 0) { 18 | super(msg, file, line); 19 | } 20 | 21 | private: 22 | // Error _next; 23 | } 24 | 25 | abstract class RuntimeError : Error { 26 | this(string msg, string file, ulong line){ 27 | super(msg,file,line); 28 | } 29 | 30 | static: 31 | 32 | // Description: This Error is thrown when assertions fail. 33 | class Assert : RuntimeError { 34 | this(string msg, string file, ulong line) { 35 | super("Assertion `" ~ msg ~ "` failed", file, line); 36 | } 37 | 38 | this(string file, ulong line) { 39 | super("Assertion failed",file,line); 40 | } 41 | } 42 | 43 | // Description: This Error is thrown when a switch statement does not have a default and there is no case available. 44 | class NoDefaultCase : RuntimeError { 45 | this(string file, ulong line) { 46 | super("Switch has no default",file,line); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/library.d: -------------------------------------------------------------------------------- 1 | /* 2 | * library.d 3 | * 4 | * This file implements the Library class, which allows access to external 5 | * dynamic libraries at runtime. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: May 29, 2009 9 | * 10 | */ 11 | 12 | module core.library; 13 | 14 | import core.string; 15 | import core.definitions; 16 | 17 | import platform.vars.library; 18 | 19 | import scaffold.system; 20 | 21 | // Description: This class will allow runtime linking to dynamic libraries. 22 | class Library { 23 | 24 | // Description: This constructor will dynamically load the library found at the given framework path. 25 | // path: The path to the library in question. 26 | this(string path) { 27 | SystemLoadLibrary(_pfvars, path); 28 | } 29 | 30 | ~this() { 31 | SystemFreeLibrary(_pfvars); 32 | } 33 | 34 | protected: 35 | 36 | // Description: This function can only be called within an instance of the class. It will give the function pointer to the procedure specified by proc and null when the procedure cannot be found. 37 | // proc: The name of the procedure to call upon. 38 | // Returns: Will return null if the procedure cannot be found, otherwise it will return the address to this function. 39 | final void* getProc(string proc) { 40 | if (proc in _funcs) { 41 | return _funcs[proc]; 42 | } 43 | 44 | // acquire the signature (or null) 45 | void* signature = SystemLoadLibraryProc(_pfvars, proc); 46 | 47 | // set in hash 48 | _funcs[proc] = signature; 49 | return signature; 50 | } 51 | 52 | final void*[string] _funcs; 53 | 54 | LibraryPlatformVars _pfvars; 55 | } 56 | -------------------------------------------------------------------------------- /core/parameters.d: -------------------------------------------------------------------------------- 1 | module core.parameters; 2 | 3 | // For Parameters (Internal, Platform Use) 4 | 5 | enum Parameter_Colorbpp 6 | { 7 | Color8bpp, 8 | Color16bpp // Needs to be 1 for 16bpp static color definitions 9 | } 10 | 11 | enum Parameter_ColorType 12 | { 13 | ColorRGBA, 14 | ColorBGRA, 15 | ColorARGB, 16 | ColorABGR, 17 | } -------------------------------------------------------------------------------- /cui/telnet.d: -------------------------------------------------------------------------------- 1 | module cui.telnet; 2 | 3 | import cui.vt100; 4 | import cui.buffer; 5 | 6 | import core.string; 7 | 8 | import networking.telnet; 9 | 10 | // Section: Console 11 | 12 | // Description: This console control is a console buffer that will facilitate a connection to a telnet server within a section of your console view. 13 | class CuiTelnet : CuiVT100 { 14 | this( uint x, uint y, uint width, uint height) { 15 | super(x,y,width,height); 16 | 17 | _telnet = new TelnetClient; 18 | _telnet.setDelegate(&recvChar); 19 | _telnet.connect("ice9-tw.com", 2002); 20 | } 21 | 22 | override void onKeyChar(dchar chr) { 23 | if (chr == 10) 24 | { 25 | chr = 13; 26 | } 27 | _telnet.putChar(chr); 28 | } 29 | 30 | protected: 31 | 32 | void recvChar(dchar chr) { 33 | return; 34 | /*if (chr == 13 || chr == 10) { 35 | super.onKeyChar(chr); 36 | } 37 | else { 38 | writeChar(chr); 39 | }*/ 40 | } 41 | 42 | private: 43 | 44 | TelnetClient _telnet; 45 | } 46 | -------------------------------------------------------------------------------- /data/stack.d: -------------------------------------------------------------------------------- 1 | module data.stack; 2 | 3 | import data.list; 4 | 5 | import io.console; 6 | 7 | class Stack(T) : List!(T) { 8 | this() { 9 | super(); 10 | } 11 | 12 | this(uint size) { 13 | super(size); 14 | } 15 | 16 | this(T[] withList) { 17 | _data = withList.dup; 18 | _count = _data.length; 19 | } 20 | 21 | Stack!(T) dup() { 22 | return new Stack!(T)(_data[0.._count]); 23 | } 24 | 25 | T pop() { 26 | T ret; 27 | ret = remove(); 28 | 29 | return ret; 30 | } 31 | 32 | void push(T item) { 33 | add(item); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /decoders/audio/aud.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/aud.d -------------------------------------------------------------------------------- /decoders/audio/decoder.d: -------------------------------------------------------------------------------- 1 | /* 2 | * codec.d 3 | * 4 | * This file implements the abstraction for an audio codec. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module decoders.audio.decoder; 11 | 12 | import decoders.decoder; 13 | 14 | import core.string; 15 | import core.time; 16 | import core.stream; 17 | import core.definitions; 18 | 19 | import io.audio; 20 | import io.wavelet; 21 | import io.console; 22 | 23 | // Section: Interfaces 24 | 25 | // Description: The interface to an audio codec. 26 | abstract class AudioDecoder : Decoder { 27 | public: 28 | 29 | this() { 30 | curTime = new Time(); 31 | } 32 | 33 | StreamData decode(Stream stream, Wavelet toBuffer, ref AudioInfo wf) { 34 | return StreamData.Invalid; 35 | } 36 | 37 | StreamData seek(Stream stream, AudioFormat wf, AudioInfo wi, ref Time amount) { 38 | return StreamData.Invalid; 39 | } 40 | 41 | override string name() { 42 | return "Unknown Audio Codec"; 43 | } 44 | 45 | string extension() { 46 | return ""; 47 | } 48 | 49 | Time getCurrentTime() { 50 | return curTime; 51 | } 52 | 53 | protected: 54 | 55 | 56 | // For some decoders to aid in seeks 57 | // through the stream 58 | struct SeekPointer { 59 | Time time; 60 | ulong streamPosition; 61 | 62 | void* metaData; // maybe a place for metadata 63 | } 64 | SeekPointer seekLUT[]; 65 | 66 | // current time frame 67 | Time curTime; 68 | Time toSeek; 69 | bool isSeek; 70 | bool isSeekBack; // whether we are seeking backward 71 | } 72 | -------------------------------------------------------------------------------- /decoders/audio/mp1.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/mp1.d -------------------------------------------------------------------------------- /decoders/audio/mp4.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/mp4.d -------------------------------------------------------------------------------- /decoders/audio/ra.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/ra.d -------------------------------------------------------------------------------- /decoders/audio/snd.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/snd.d -------------------------------------------------------------------------------- /decoders/audio/wma.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/wma.d -------------------------------------------------------------------------------- /decoders/audio/xm.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/audio/xm.d -------------------------------------------------------------------------------- /decoders/binary/decoder.d: -------------------------------------------------------------------------------- 1 | /* 2 | * decoder.d 3 | * 4 | * This file implements the abstraction for an binary decoder. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module decoders.binary.decoder; 11 | 12 | import decoders.decoder; 13 | 14 | import core.string; 15 | import core.stream; 16 | import core.definitions; 17 | 18 | // Section: Interfaces 19 | 20 | // Description: The interface to a binary codec. 21 | class BinaryDecoder : Decoder { 22 | StreamData decode(Stream stream, Stream toStream) { 23 | return StreamData.Invalid; 24 | } 25 | 26 | override string name() { 27 | return "Unknown Binary Decoder"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /decoders/binary/template.d: -------------------------------------------------------------------------------- 1 | /* 2 | * template.d 3 | * 4 | * Author: 5 | * Originated: 6 | * References: 7 | * 8 | */ 9 | 10 | module decoders.binary.foo; 11 | 12 | import core.stream; 13 | 14 | import decoders.binary.codec; 15 | 16 | private { 17 | 18 | // States 19 | enum { 20 | FOO_STATE_INIT, 21 | } 22 | } 23 | 24 | // Section: Codecs/Binary 25 | 26 | // Description: This represents the Par2 Codec. 27 | class FooDecoder : BinaryDecoder { 28 | 29 | StreamData decode(Stream stream, Stream toStream) { 30 | 31 | for (;;) { 32 | switch (decoderState) { 33 | default: return StreamData.Invalid; 34 | } 35 | } 36 | 37 | return StreamData.Invalid; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /decoders/decoder.d: -------------------------------------------------------------------------------- 1 | /* 2 | * decoder.d 3 | * 4 | * This file implements the base class for all decoders. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module decoders.decoder; 11 | 12 | import core.time; 13 | import core.string; 14 | import core.definitions; 15 | 16 | // Description: Base class for all codecs 17 | class Decoder { 18 | string name() { 19 | return "Unknown Codec"; 20 | } 21 | 22 | protected: 23 | 24 | int decoderState = 0; 25 | int decoderNextState = 0; 26 | 27 | int decoderSubState = 0; 28 | int decoderNextSubState = 0; 29 | 30 | int decoderFrameState = 0; 31 | } 32 | -------------------------------------------------------------------------------- /decoders/image/all.d: -------------------------------------------------------------------------------- 1 | module decoders.image.all; 2 | 3 | import graphics.bitmap; 4 | 5 | import core.string; 6 | import core.stream; 7 | 8 | import decoders.decoder; 9 | import decoders.image.decoder; 10 | 11 | public import decoders.image.png; 12 | public import decoders.image.bmp; 13 | public import decoders.image.gif; 14 | public import decoders.image.jpeg; 15 | // TIFF 16 | // TGA 17 | // JPEG 2000 18 | // MNG 19 | // PCX 20 | // RAW 21 | 22 | StreamData runAllDecoders(ref ImageDecoder imageCodec, Stream stream, ref Bitmap view) { 23 | StreamData ret; 24 | 25 | ulong pos = stream.position; 26 | 27 | imageCodec = new PNGDecoder(); 28 | if ((ret = imageCodec.decode(stream, view)) != StreamData.Invalid) { 29 | return ret; 30 | } 31 | 32 | stream.position = pos; 33 | 34 | imageCodec = new BMPDecoder(); 35 | if ((ret = imageCodec.decode(stream, view)) != StreamData.Invalid) { 36 | return ret; 37 | } 38 | 39 | stream.position = pos; 40 | 41 | imageCodec = new GIFDecoder(); 42 | if ((ret = imageCodec.decode(stream, view)) != StreamData.Invalid) { 43 | return ret; 44 | } 45 | 46 | stream.position = pos; 47 | 48 | imageCodec = new JPEGDecoder(); 49 | if ((ret = imageCodec.decode(stream, view)) != StreamData.Invalid) { 50 | return ret; 51 | } 52 | 53 | imageCodec = null; 54 | return StreamData.Invalid; 55 | } 56 | 57 | // Codecs: 58 | //mixin(CreateCodecArray!()); 59 | // 60 | -------------------------------------------------------------------------------- /decoders/image/decoder.d: -------------------------------------------------------------------------------- 1 | module decoders.image.decoder; 2 | 3 | import graphics.bitmap; 4 | 5 | import core.string; 6 | import core.stream; 7 | import core.color; 8 | import core.definitions; 9 | 10 | import decoders.decoder; 11 | 12 | struct ImageFrameDescription { 13 | uint time; //time till the display of the next image 14 | uint xoffset; //the x offset of the image within the main image 15 | uint yoffset; //the y offset of the image within the main image 16 | uint clearFirst; //whether or not to clear the image prior to drawing next frame 17 | Color clearColor; //the color to use when clearing 18 | } 19 | 20 | abstract class ImageDecoder : Decoder { 21 | public: 22 | StreamData decode(Stream stream, ref Bitmap view) { 23 | return StreamData.Invalid; 24 | } 25 | 26 | StreamData decodeFrame(Stream stream, ref Bitmap view, ref ImageFrameDescription imageDesc) { 27 | return StreamData.Invalid; 28 | } 29 | 30 | override string name() { 31 | return "Unknown Image Decoder"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /decoders/image/jpeg2000.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/image/jpeg2000.d -------------------------------------------------------------------------------- /decoders/image/pcx.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/image/pcx.d -------------------------------------------------------------------------------- /decoders/image/tga.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/image/tga.d -------------------------------------------------------------------------------- /decoders/image/tiff.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/decoders/image/tiff.d -------------------------------------------------------------------------------- /djehuty.d: -------------------------------------------------------------------------------- 1 | module djehuty; 2 | 3 | public import core.definitions; 4 | public import core.string; 5 | public import core.unicode; 6 | public import core.event; 7 | public import core.application; 8 | public import core.regex; 9 | public import core.system; 10 | public import core.stream; 11 | public import core.unicode; 12 | public import core.time; 13 | public import core.timezone; 14 | public import core.util; 15 | public import core.main; 16 | public import core.arguments; 17 | public import core.color; 18 | public import core.endian; 19 | public import core.variant; 20 | public import core.date; 21 | public import core.locale; 22 | public import core.exception; 23 | -------------------------------------------------------------------------------- /examples/CuiTetris/app.d: -------------------------------------------------------------------------------- 1 | import cui.application; 2 | 3 | import djehuty; 4 | 5 | import io.console; 6 | 7 | import gamewindow; 8 | 9 | import binding.c; 10 | 11 | class TermTetris : CuiApplication { 12 | 13 | // Start an application instance 14 | static this() { printf("HELLO!\n"); new TermTetris(); } 15 | 16 | override void onApplicationStart() { 17 | Console.putln("foo"); 18 | Console.hideCaret(); 19 | 20 | gameWindow = new GameWindow(); 21 | 22 | push(gameWindow); 23 | } 24 | 25 | override void onApplicationEnd() { 26 | Console.clear(); 27 | Console.forecolor = Color.White; 28 | Console.put("Your Score was: "); 29 | Console.forecolor = Color.Yellow; 30 | Console.putln(gameWindow.getScore()); 31 | 32 | Console.putln(""); 33 | Console.forecolor = Color.Gray; 34 | Console.putln("Thank you for playing!"); 35 | } 36 | 37 | protected: 38 | GameWindow gameWindow; 39 | } 40 | -------------------------------------------------------------------------------- /examples/CuiTetris/gamewindow.d: -------------------------------------------------------------------------------- 1 | import cui.window; 2 | import cui.label; 3 | 4 | import io.console; 5 | 6 | import djehuty; 7 | 8 | import gamecontrol; 9 | 10 | class GameWindow : CuiWindow { 11 | this() { 12 | scoreLabel = new CuiLabel(4, 5, 10, "0"); 13 | game = new GameControl(); 14 | 15 | push(scoreLabel); 16 | push(new CuiLabel(2, 3, 10, "Score", Color.Yellow)); 17 | push(game); 18 | } 19 | 20 | override bool onSignal(Dispatcher source, uint signal) { 21 | if (source is game) { 22 | if(signal == GameControl.Event.ScoreUpdated) { 23 | scoreLabel.text = toStr(game.getScore()); 24 | return true; 25 | } 26 | } 27 | 28 | return false; 29 | } 30 | 31 | override void onKeyDown(Key key) { 32 | if (key.ctrl && key.code == Key.Q) { 33 | application.exit(0); 34 | return; 35 | } 36 | super.onKeyDown(key); 37 | } 38 | 39 | int getScore() { 40 | return game.getScore(); 41 | } 42 | 43 | protected: 44 | CuiLabel scoreLabel; 45 | GameControl game; 46 | } 47 | -------------------------------------------------------------------------------- /examples/MoreDucks/baby_ducks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/examples/MoreDucks/baby_ducks.png -------------------------------------------------------------------------------- /examples/MoreDucks/duckling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/examples/MoreDucks/duckling.png -------------------------------------------------------------------------------- /examples/MoreDucks/ducks-cute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/examples/MoreDucks/ducks-cute.png -------------------------------------------------------------------------------- /examples/Snake/app.d: -------------------------------------------------------------------------------- 1 | import cui.application; 2 | 3 | import win; 4 | 5 | class SnakeApp : CuiApplication { 6 | static this() { 7 | new SnakeApp(); 8 | } 9 | 10 | override void onApplicationStart() { 11 | push(new SnakeWindow()); 12 | } 13 | 14 | override void shutdown() { 15 | super.shutdown(); 16 | } 17 | 18 | override void end(uint exitCode) { 19 | super.end(exitCode); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /examples/Snake/constants.d: -------------------------------------------------------------------------------- 1 | import io.console; 2 | 3 | enum FrameWait : uint { 4 | Init = 1000, 5 | Min = 300, 6 | Multiplier = 100, 7 | Step = 1, 8 | } 9 | 10 | enum Growth : uint { 11 | Min = 10, 12 | Max = 50, 13 | } 14 | 15 | enum SpeedCoef : uint { 16 | H = 2, 17 | V = 3, 18 | } 19 | 20 | enum Tile : dchar { 21 | Head = '@', 22 | Block = '#', 23 | Food = '*', 24 | Portal = '^', 25 | Void = ' ', 26 | } 27 | 28 | enum TileColor : fgColor { 29 | Head = fgColor.BrightBlue, 30 | Block = fgColor.BrightCyan, 31 | Food = fgColor.BrightGreen, 32 | Portal = fgColor.BrightRed, 33 | } 34 | 35 | -------------------------------------------------------------------------------- /examples/Snake/posn.d: -------------------------------------------------------------------------------- 1 | enum Dir : int { 2 | Up = -1, 3 | Down = +1, 4 | Left = -2, 5 | Right = +2, 6 | } 7 | 8 | class Posn { 9 | this(int x_n, int y_n) { 10 | x = x_n; 11 | y = y_n; 12 | } 13 | 14 | Posn dup() { 15 | return new Posn(_x, _y); 16 | } 17 | 18 | static void SetBounds(uint max_x_n, uint max_y_n) { 19 | _max_x = max_x_n; 20 | _max_y = max_y_n; 21 | } 22 | 23 | void x(int x_n) { 24 | if (x_n < 0) { 25 | _x = _max_x; 26 | } else if (x_n > _max_x) { 27 | _x = 0; 28 | } else { 29 | _x = x_n; 30 | } 31 | } 32 | 33 | uint x() { 34 | return _x; 35 | } 36 | 37 | void y(int y_n) { 38 | if (y_n < 0) { 39 | _y = _max_y; 40 | } else if (y_n > _max_y) { 41 | _y = 0; 42 | } else { 43 | _y = y_n; 44 | } 45 | } 46 | 47 | uint y() { 48 | return _y; 49 | } 50 | 51 | void moveTo(Posn p) { 52 | x = p.x; 53 | y = p.y; 54 | } 55 | 56 | int opEquals(Posn p) { 57 | return cast(int)(x == p.x && y == p.y); 58 | } 59 | 60 | private: 61 | static uint _max_x, _max_y; 62 | 63 | uint _x, _y; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /graphics/bitmap.d: -------------------------------------------------------------------------------- 1 | /* 2 | * bitmap.d 3 | * 4 | * This module implements a bitmap view, or more specifically, a 5 | * device-independent-bitmap. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: July 20th 2009 9 | * 10 | */ 11 | 12 | module graphics.bitmap; 13 | 14 | import graphics.view; 15 | import graphics.graphics; 16 | 17 | import synch.semaphore; 18 | 19 | import scaffold.view; 20 | 21 | import io.console; 22 | 23 | class Bitmap : View { 24 | this() { 25 | super(); 26 | 27 | _buffer_mutex = new Semaphore; 28 | _buffer_mutex.init(1); 29 | } 30 | 31 | this(int width, int height) { 32 | create(width, height); 33 | } 34 | 35 | void create(int width, int height) { 36 | if (_inited) { destroy(); } 37 | 38 | _mutex.down(); 39 | 40 | _width = width; 41 | _height = height; 42 | 43 | _hasAlpha = false; 44 | 45 | ViewCreateDIB(this, &_pfvars); 46 | 47 | _inited = true; 48 | 49 | _mutex.up(); 50 | } 51 | 52 | void* getBufferUnsafe() { 53 | return ViewGetBytes(&_pfvars); 54 | } 55 | 56 | void lockBuffer(void** bufferPtr, ref ulong length) { 57 | _buffer_mutex.down(); 58 | bufferPtr[0] = ViewGetBytes(&_pfvars, length); 59 | } 60 | 61 | void unlockBuffer() { 62 | ViewUnlockBytes(&_pfvars); 63 | _buffer_mutex.up(); 64 | } 65 | 66 | private: 67 | 68 | Semaphore _buffer_mutex; 69 | } 70 | -------------------------------------------------------------------------------- /graphics/font.d: -------------------------------------------------------------------------------- 1 | module graphics.font; 2 | 3 | import platform.vars.font; 4 | 5 | import Scaffold = scaffold.graphics; 6 | 7 | import core.color; 8 | import core.string; 9 | import core.definitions; 10 | 11 | import graphics.view; 12 | 13 | class Font { 14 | this(string fontname, int fontsize, int weight, bool italic, bool underline, bool strikethru) { 15 | Scaffold.createFont(&_pfvars, fontname, fontsize, weight, italic, underline, strikethru); 16 | } 17 | 18 | ~this() { 19 | Scaffold.destroyFont(&_pfvars); 20 | } 21 | 22 | private: 23 | 24 | package FontPlatformVars _pfvars; 25 | 26 | // tied to a view? 27 | package View _view; // will be null if no view is tied with it 28 | } 29 | -------------------------------------------------------------------------------- /graphics/path.d: -------------------------------------------------------------------------------- 1 | /* 2 | * path.d 3 | * 4 | * This module implements a path object. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: December 19th, 2009 8 | * 9 | */ 10 | 11 | module graphics.path; 12 | 13 | class Path { 14 | } -------------------------------------------------------------------------------- /graphics/pen.d: -------------------------------------------------------------------------------- 1 | module graphics.pen; 2 | 3 | import platform.vars.pen; 4 | 5 | import Scaffold = scaffold.graphics; 6 | 7 | import core.color; 8 | 9 | import graphics.view; 10 | import graphics.brush; 11 | 12 | class Pen { 13 | 14 | public: 15 | 16 | // Constructor 17 | this(Color clr, double width = 1.0) { 18 | _width = width; 19 | Scaffold.createPen(&_pfvars, clr, width); 20 | } 21 | 22 | this(Brush brush, double width = 1.0) { 23 | _width = width; 24 | Scaffold.createPenWithBrush(&_pfvars, brush._pfvars, width); 25 | } 26 | 27 | // Destructor 28 | ~this() { 29 | Scaffold.destroyPen(&_pfvars); 30 | } 31 | 32 | // Sets color of a solid brush 33 | void setColor(Color clr) { 34 | Scaffold.destroyPen(&_pfvars); 35 | Scaffold.createPen(&_pfvars, clr, _width); 36 | 37 | // when tied to a locked view, update the brush being used 38 | if (_view !is null) { 39 | if (_view._locked) { 40 | _view._graphics.pen = _view._pen; 41 | } 42 | } 43 | } 44 | 45 | private: 46 | 47 | double _width; 48 | 49 | package PenPlatformVars _pfvars; 50 | 51 | // tied to a view? 52 | package View _view; // will be null if no view is tied with it 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gui/container.d: -------------------------------------------------------------------------------- 1 | 2 | 3 | // Section: Controls 4 | 5 | 6 | -------------------------------------------------------------------------------- /hashes/alder32.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/hashes/alder32.d -------------------------------------------------------------------------------- /hashes/all.d: -------------------------------------------------------------------------------- 1 | module hashes.all; 2 | 3 | import hashes.digest; 4 | import hashes.md5; 5 | import hashes.sha1; 6 | 7 | import core.string; 8 | import core.stream; 9 | 10 | enum HashType { 11 | MD5, 12 | SHA1, 13 | } 14 | 15 | template _HashCall(HashType type) { 16 | static if (type == HashType.MD5) { 17 | const char[] _HashCall = `return HashMD5(msg);`; 18 | } 19 | else static if (type == HashType.SHA1) { 20 | const char[] _HashCall = `return HashSHA1(msg);`; 21 | } 22 | else { 23 | static assert(false, "Hash type not supported."); 24 | } 25 | } 26 | 27 | struct Hash(HashType type) { 28 | static: 29 | Digest opCall(StringLiteral msg) { 30 | mixin(_HashCall!(type)); 31 | } 32 | 33 | Digest opCall(String msg) { 34 | mixin(_HashCall!(type)); 35 | } 36 | 37 | Digest opCall(ubyte[] msg) { 38 | mixin(_HashCall!(type)); 39 | } 40 | 41 | Digest opCall(Stream msg) { 42 | mixin(_HashCall!(type)); 43 | } 44 | } -------------------------------------------------------------------------------- /hashes/crc32.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/hashes/crc32.d -------------------------------------------------------------------------------- /hashes/digest.d: -------------------------------------------------------------------------------- 1 | /* 2 | * digest.d 3 | * 4 | * This module houses the Digest class used as a return value for all 5 | * hashing algorithms. 6 | * 7 | * Author: Dave Wilkinson 8 | * 9 | */ 10 | 11 | module hashes.digest; 12 | 13 | import djehuty; 14 | 15 | // Description: This class holds the computed digest from a hashing algorithm. 16 | class Digest { 17 | this (uint[] newData...) { 18 | data = newData.dup; 19 | } 20 | 21 | uint[] data; 22 | 23 | override string toString() { 24 | string ret = ""; 25 | for(int i=0; i 2 | 3 | 9 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /networking/nntp.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/networking/nntp.d -------------------------------------------------------------------------------- /networking/smtp.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/networking/smtp.d -------------------------------------------------------------------------------- /networking/ssh.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/networking/ssh.d -------------------------------------------------------------------------------- /opengl/light.d: -------------------------------------------------------------------------------- 1 | /* 2 | * light.d 3 | * 4 | * This module implements a light object. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: June 6th, 2009 8 | * 9 | */ 10 | 11 | module opengl.light; -------------------------------------------------------------------------------- /parsing/ast.d: -------------------------------------------------------------------------------- 1 | module parsing.ast; 2 | 3 | import core.string; 4 | import core.definitions; 5 | import core.variant; 6 | 7 | import data.list; 8 | 9 | import io.console; 10 | 11 | class AbstractSyntaxTree : List!(AbstractSyntaxTree) { 12 | this() { 13 | } 14 | 15 | this(uint type, AbstractSyntaxTree[] nodes ...) { 16 | addList(nodes); 17 | _type = type; 18 | } 19 | 20 | void type(uint value) { 21 | _type = type; 22 | } 23 | 24 | uint type() { 25 | return _type; 26 | } 27 | 28 | AbstractSyntaxTree next() { 29 | return _next; 30 | } 31 | 32 | AbstractSyntaxTree parent() { 33 | return _parent; 34 | } 35 | 36 | protected: 37 | AbstractSyntaxTree _next; 38 | AbstractSyntaxTree _parent; 39 | 40 | uint _type; 41 | Variant _value; 42 | } 43 | -------------------------------------------------------------------------------- /parsing/bnf.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/bnf.d -------------------------------------------------------------------------------- /parsing/cfg.d: -------------------------------------------------------------------------------- 1 | module parsing.cfg; 2 | 3 | import core.string; 4 | import core.definitions; 5 | 6 | import io.console; 7 | 8 | class GrammarPhrase { 9 | this(string rule) { 10 | Console.putln(rule); 11 | 12 | _rule = rule; 13 | } 14 | 15 | protected: 16 | 17 | string _rule; 18 | } 19 | 20 | 21 | 22 | 23 | class GrammarRule { 24 | this(string rule) { 25 | Console.putln(rule); 26 | 27 | // parse the rule string 28 | // get the left hand side and right hand side 29 | // the string "->" delimits 30 | 31 | int divider = rule.find("->"); 32 | 33 | _left = new GrammarPhrase(rule.substring(0, divider).trim()); 34 | _right = new GrammarPhrase(rule.substring(divider+2).trim()); 35 | } 36 | 37 | protected: 38 | 39 | GrammarPhrase _left; 40 | GrammarPhrase _right; 41 | } 42 | 43 | 44 | 45 | 46 | 47 | class Grammar { 48 | this() { 49 | } 50 | 51 | void addRule(string rule) { 52 | GrammarRule newRule = new GrammarRule(rule); 53 | 54 | _rules ~= newRule; 55 | } 56 | 57 | GrammarRule[] _rules; 58 | } 59 | -------------------------------------------------------------------------------- /parsing/css.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/css.d -------------------------------------------------------------------------------- /parsing/d/addexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * addexprunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.addexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.mulexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class AddExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Add: 26 | case DToken.Sub: 27 | case DToken.Cat: 28 | if (this.state == 1) { 29 | Console.putln("ADD"); 30 | this.state = 0; 31 | break; 32 | } 33 | 34 | // Fall through 35 | 36 | default: 37 | lexer.push(current); 38 | if (this.state == 1) { 39 | // Done. 40 | return false; 41 | } 42 | auto tree = expand!(MulExprUnit)(); 43 | this.state = 1; 44 | break; 45 | } 46 | return true; 47 | } 48 | 49 | protected: 50 | string cur_string = ""; 51 | 52 | static const string _common_error_msg = ""; 53 | static const string[] _common_error_usages = null; 54 | } 55 | -------------------------------------------------------------------------------- /parsing/d/aggregatebodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.aggregatebodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.declarationunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class AggregateBodyUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | // We are always looking for the end of the body. 26 | case DToken.RightCurly: 27 | // Done. 28 | return false; 29 | 30 | // A new keyword will set up an allocator. 31 | case DToken.New: 32 | // TODO: 33 | break; 34 | 35 | // Ditto for a delete token for deallocator. 36 | case DToken.Delete: 37 | // TODO: 38 | break; 39 | 40 | // Otherwise, it must be some Declarator 41 | default: 42 | lexer.push(current); 43 | auto tree = expand!(DeclarationUnit)(); 44 | break; 45 | } 46 | return true; 47 | } 48 | 49 | protected: 50 | string cur_string = ""; 51 | 52 | static const string _common_error_msg = ""; 53 | static const string[] _common_error_usages = null; 54 | } 55 | -------------------------------------------------------------------------------- /parsing/d/aggregatedeclunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.aggregatedeclunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.aggregatebodyunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class AggregateDeclUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | 26 | // We have found the name 27 | case DToken.Identifier: 28 | if (cur_string != "") { 29 | // Error: Two names? 30 | } 31 | Console.putln("Struct: ", current.value); 32 | cur_string = current.value.toString(); 33 | break; 34 | 35 | // We have found the left brace, so parse the body 36 | case DToken.LeftCurly: 37 | auto tree = expand!(AggregateBodyUnit)(); 38 | // Done. 39 | return false; 40 | 41 | case DToken.Semicolon: 42 | if (cur_string == "") { 43 | // Error: No name? 44 | } 45 | // Done. 46 | return false; 47 | 48 | default: 49 | break; 50 | } 51 | return true; 52 | } 53 | 54 | protected: 55 | string cur_string = ""; 56 | 57 | static const string _common_error_msg = ""; 58 | static const string[] _common_error_usages = null; 59 | } 60 | -------------------------------------------------------------------------------- /parsing/d/andexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.andexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.cmpexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class AndExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.And: 26 | if (this.state == 1) { 27 | Console.putln("AND"); 28 | this.state = 0; 29 | break; 30 | } 31 | 32 | // Fall through 33 | goto default; 34 | 35 | default: 36 | lexer.push(current); 37 | if (this.state == 1) { 38 | // Done. 39 | return false; 40 | } 41 | auto tree = expand!(CmpExprUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/d/assignexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.assignexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.conditionalexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class AssignExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | default: 26 | lexer.push(current); 27 | auto tree = expand!(ConditionalExprUnit)(); 28 | break; 29 | } 30 | return false; 31 | } 32 | 33 | protected: 34 | string cur_string = ""; 35 | 36 | static const string _common_error_msg = ""; 37 | static const string[] _common_error_usages = null; 38 | } 39 | -------------------------------------------------------------------------------- /parsing/d/basictypeunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * typedeclarationunit.d 3 | * 4 | */ 5 | 6 | module parsing.d.basictypeunit; 7 | 8 | import parsing.parseunit; 9 | import parsing.token; 10 | 11 | import parsing.d.tokens; 12 | import parsing.d.nodes; 13 | 14 | import parsing.d.staticunit; 15 | import parsing.d.declaratorunit; 16 | 17 | import djehuty; 18 | 19 | import io.console; 20 | 21 | class BasicTypeUnit : ParseUnit { 22 | override bool tokenFound(Token current) { 23 | 24 | switch (current.type) { 25 | case DToken.Bool: 26 | case DToken.Byte: 27 | case DToken.Ubyte: 28 | case DToken.Short: 29 | case DToken.Ushort: 30 | case DToken.Int: 31 | case DToken.Uint: 32 | case DToken.Long: 33 | case DToken.Ulong: 34 | case DToken.Char: 35 | case DToken.Wchar: 36 | case DToken.Dchar: 37 | case DToken.Float: 38 | case DToken.Double: 39 | case DToken.Real: 40 | case DToken.Ifloat: 41 | case DToken.Idouble: 42 | case DToken.Ireal: 43 | case DToken.Cfloat: 44 | case DToken.Cdouble: 45 | case DToken.Creal: 46 | case DToken.Void: 47 | // We have a basic type 48 | Console.putln("BasicType "); 49 | 50 | // Done. 51 | return false; 52 | 53 | case DToken.Identifier: 54 | // Named Type, could be a scoped list 55 | // TODO: 56 | break; 57 | 58 | // Scope Operator 59 | case DToken.Dot: 60 | // TODO: 61 | break; 62 | 63 | case DToken.Typeof: 64 | // TypeOfExpression 65 | // TODO: this 66 | break; 67 | 68 | default: 69 | 70 | // We will pass this off to a Declarator 71 | auto tree = expand!(DeclaratorUnit)(); 72 | this.state = 1; 73 | break; 74 | } 75 | return true; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /parsing/d/blockstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * blockunit.d 3 | * 4 | */ 5 | 6 | module parsing.d.blockstmtunit; 7 | 8 | import parsing.parseunit; 9 | import parsing.token; 10 | 11 | import parsing.d.tokens; 12 | import parsing.d.nodes; 13 | 14 | import parsing.d.statementunit; 15 | 16 | class BlockStmtUnit : ParseUnit { 17 | override bool tokenFound(Token current) { 18 | switch (current.type) { 19 | case DToken.RightCurly: 20 | // Done. 21 | return false; 22 | default: 23 | // We can look for a simple declaration 24 | lexer.push(current); 25 | auto tree = expand!(StatementUnit)(); 26 | break; 27 | } 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /parsing/d/breakstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.breakstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class BreakStmtUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.Semicolon: 24 | // Done. 25 | putln("Break: ", cur_string); 26 | return false; 27 | case DToken.Identifier: 28 | if (this.state == 1) { 29 | // Error: More than one identifier?!?! 30 | // TODO: 31 | } 32 | this.state = 1; 33 | cur_string = current.value.toString(); 34 | break; 35 | default: 36 | // Error: 37 | // TODO: 38 | break; 39 | } 40 | return true; 41 | } 42 | 43 | protected: 44 | string cur_string = ""; 45 | 46 | static const string _common_error_msg = ""; 47 | static const string[] _common_error_usages = null; 48 | } 49 | -------------------------------------------------------------------------------- /parsing/d/casestmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.casestmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.expressionunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class CaseStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Colon: 26 | if (this.state == 0) { 27 | // Error: 28 | // we have 'case: ' 29 | // TODO: 30 | } 31 | 32 | // Done. 33 | return false; 34 | default: 35 | lexer.push(current); 36 | if (this.state == 1) { 37 | // Error: Multiple expressions 38 | // TODO: 39 | } 40 | Console.putln("Case: "); 41 | auto tree = expand!(ExpressionUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/d/classbodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.classbodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.declarationunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ClassBodyUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | // We are always looking for the end of the body. 26 | case DToken.RightCurly: 27 | // Done. 28 | return false; 29 | 30 | // A new keyword will set up an allocator. 31 | case DToken.New: 32 | // TODO: 33 | break; 34 | 35 | // Ditto for a delete token for deallocator. 36 | case DToken.Delete: 37 | // TODO: 38 | break; 39 | 40 | // Otherwise, it must be some Declarator 41 | default: 42 | lexer.push(current); 43 | auto tree = expand!(DeclarationUnit)(); 44 | break; 45 | } 46 | return true; 47 | } 48 | 49 | protected: 50 | string cur_string = ""; 51 | 52 | static const string _common_error_msg = ""; 53 | static const string[] _common_error_usages = null; 54 | } 55 | -------------------------------------------------------------------------------- /parsing/d/conditionalexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.conditionalexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.logicalorexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ConditionalExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | default: 26 | lexer.push(current); 27 | auto tree = expand!(LogicalOrExprUnit)(); 28 | } 29 | return false; 30 | } 31 | 32 | protected: 33 | string cur_string = ""; 34 | 35 | static const string _common_error_msg = ""; 36 | static const string[] _common_error_usages = null; 37 | } 38 | -------------------------------------------------------------------------------- /parsing/d/continuestmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.continuestmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class ContinueStmtUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.Semicolon: 24 | // Done. 25 | putln("Continue: ", cur_string); 26 | return false; 27 | case DToken.Identifier: 28 | if (this.state == 1) { 29 | // Error: More than one identifier?!?! 30 | // TODO: 31 | } 32 | this.state = 1; 33 | cur_string = current.value.toString(); 34 | break; 35 | default: 36 | // Error: 37 | // TODO: 38 | break; 39 | } 40 | return true; 41 | } 42 | 43 | protected: 44 | string cur_string = ""; 45 | 46 | static const string _common_error_msg = ""; 47 | static const string[] _common_error_usages = null; 48 | } 49 | -------------------------------------------------------------------------------- /parsing/d/declaratortypeunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.declaratortypeunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class DeclaratorTypeUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | default: 24 | break; 25 | } 26 | return true; 27 | } 28 | 29 | protected: 30 | string cur_string = ""; 31 | 32 | static const string _common_error_msg = ""; 33 | static const string[] _common_error_usages = null; 34 | } 35 | -------------------------------------------------------------------------------- /parsing/d/defaultstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.defaultstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class DefaultStmtUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.Colon: 24 | Console.putln("Default:"); 25 | // Done. 26 | return false; 27 | default: 28 | // Error: Default does not allow expressions 29 | // TODO: 30 | break; 31 | } 32 | return true; 33 | } 34 | 35 | protected: 36 | string cur_string = ""; 37 | 38 | static const string _common_error_msg = ""; 39 | static const string[] _common_error_usages = null; 40 | } 41 | -------------------------------------------------------------------------------- /parsing/d/enumbodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.enumbodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.assignexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class EnumBodyUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | 26 | // Looking for a new member name 27 | case DToken.Identifier: 28 | if (this.state == 1) { 29 | // Error: A name next to a name?? 30 | } 31 | this.state = 1; 32 | Console.putln("Member: ", current.value); 33 | break; 34 | case DToken.RightCurly: 35 | // Done. 36 | return false; 37 | case DToken.Comma: 38 | if (this.state != 1) { 39 | // Error: A comma by itself? 40 | } 41 | this.state = 0; 42 | break; 43 | case DToken.Assign: 44 | if (this.state != 1) { 45 | // Error: An equals by itself? 46 | } 47 | 48 | // Look for an assignment expression. 49 | auto tree = expand!(AssignExprUnit)(); 50 | 51 | // Stay in the same state and wait for a comma. 52 | break; 53 | default: 54 | break; 55 | } 56 | return true; 57 | } 58 | 59 | protected: 60 | string cur_string = ""; 61 | 62 | static const string _common_error_msg = ""; 63 | static const string[] _common_error_usages = null; 64 | } 65 | -------------------------------------------------------------------------------- /parsing/d/expressionunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.expressionunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.assignexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ExpressionUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | default: 26 | lexer.push(current); 27 | auto tree = expand!(AssignExprUnit)(); 28 | } 29 | return false; 30 | } 31 | 32 | protected: 33 | string cur_string = ""; 34 | 35 | static const string _common_error_msg = ""; 36 | static const string[] _common_error_usages = null; 37 | } 38 | -------------------------------------------------------------------------------- /parsing/d/functionbodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.functionbodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.parameterlistunit; 17 | import parsing.d.functionbodyunit; 18 | import parsing.d.statementunit; 19 | 20 | import io.console; 21 | 22 | import djehuty; 23 | 24 | class FunctionBodyUnit : ParseUnit { 25 | override bool tokenFound(Token current) { 26 | switch (current.type) { 27 | 28 | // We always look FIRST for a left curly brace 29 | case DToken.LeftCurly: 30 | if (this.state % 2 == 1) { 31 | // Error: Left curly already found. 32 | // TODO: 33 | } 34 | this.state = this.state + 1; 35 | break; 36 | 37 | // We are always looking for the end of the block. 38 | case DToken.RightCurly: 39 | if (this.state % 2 == 0) { 40 | // Error: Left curly not found! 41 | // TODO: 42 | } 43 | this.state = this.state - 1; 44 | 45 | if (this.state == 0) { 46 | // Done. 47 | return false; 48 | } 49 | 50 | // TODO: in, out, body, blockstatement foo 51 | case DToken.In: 52 | break; 53 | case DToken.Out: 54 | break; 55 | case DToken.Body: 56 | break; 57 | 58 | default: 59 | lexer.push(current); 60 | if (this.state % 2 == 0) { 61 | } 62 | auto tree = expand!(StatementUnit)(); 63 | break; 64 | } 65 | return true; 66 | } 67 | 68 | protected: 69 | string cur_string = ""; 70 | 71 | static const string _common_error_msg = ""; 72 | static const string[] _common_error_usages = null; 73 | } 74 | -------------------------------------------------------------------------------- /parsing/d/gotostmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.gotostmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.expressionunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class GotoStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Semicolon: 26 | if (this.state == 0) { 27 | // Error. 28 | // TODO: 29 | } 30 | if (this.state == 2) { 31 | // Error. 32 | // TODO: 33 | } 34 | // Done. 35 | return false; 36 | case DToken.Identifier: 37 | if (this.state != 0) { 38 | // Error 39 | // TODO: 40 | } 41 | Console.putln("Goto: ", current.value); 42 | cur_string = current.value.toString(); 43 | this.state = 1; 44 | break; 45 | case DToken.Default: 46 | Console.putln("Goto: Default"); 47 | this.state = 2; 48 | break; 49 | case DToken.Case: 50 | Console.putln("Goto: Case"); 51 | this.state = 2; 52 | break; 53 | default: 54 | if (this.state != 2) { 55 | // Error 56 | // TODO: 57 | } 58 | 59 | lexer.push(current); 60 | if (this.state == 3) { 61 | // Error: Multiple expressions 62 | // TODO: 63 | } 64 | auto tree = expand!(ExpressionUnit)(); 65 | this.state = 3; 66 | break; 67 | } 68 | return true; 69 | } 70 | 71 | protected: 72 | string cur_string = ""; 73 | 74 | static const string _common_error_msg = ""; 75 | static const string[] _common_error_usages = null; 76 | } 77 | -------------------------------------------------------------------------------- /parsing/d/interfacebodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.interfacebodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.declarationunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class InterfaceBodyUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | // We are always looking for the end of the body. 26 | case DToken.RightCurly: 27 | // Done. 28 | return false; 29 | 30 | // We cannot have allocators in interfaces! 31 | case DToken.New: 32 | // Error: No allocators allowed. 33 | // TODO: 34 | break; 35 | 36 | // Ditto for a delete token for deallocator. 37 | case DToken.Delete: 38 | // Error: No deallocators allowed. 39 | // TODO: 40 | break; 41 | 42 | // Otherwise, it must be some Declarator 43 | default: 44 | lexer.push(current); 45 | auto tree = expand!(DeclarationUnit)(); 46 | break; 47 | } 48 | return true; 49 | } 50 | 51 | protected: 52 | string cur_string = ""; 53 | 54 | static const string _common_error_msg = ""; 55 | static const string[] _common_error_usages = null; 56 | } 57 | -------------------------------------------------------------------------------- /parsing/d/isexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.isexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class ExpressionUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.Dot: 24 | break; 25 | 26 | default: 27 | break; 28 | } 29 | return true; 30 | } 31 | 32 | protected: 33 | string cur_string = ""; 34 | 35 | static const string _common_error_msg = ""; 36 | static const string[] _common_error_usages = null; 37 | } 38 | -------------------------------------------------------------------------------- /parsing/d/logicalandexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.logicalandexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.orexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class LogicalAndExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.LogicalAnd: 26 | if (this.state == 1) { 27 | Console.putln("ANDAND"); 28 | this.state = 0; 29 | break; 30 | } 31 | 32 | // Fall through 33 | goto default; 34 | 35 | default: 36 | lexer.push(current); 37 | if (this.state == 1) { 38 | // Done. 39 | return false; 40 | } 41 | auto tree = expand!(OrExprUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/d/logicalorexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.logicalorexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.logicalandexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class LogicalOrExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.LogicalOr: 26 | if (this.state == 1) { 27 | Console.putln("OROR"); 28 | this.state = 0; 29 | break; 30 | } 31 | 32 | // Fall through 33 | goto default; 34 | 35 | default: 36 | lexer.push(current); 37 | if (this.state == 1) { 38 | // Done. 39 | return false; 40 | } 41 | auto tree = expand!(LogicalAndExprUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/d/moduleunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * moduleunit.d 3 | * 4 | * This module parses a D source file. It is the root parse unit. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: February 6th 2010 8 | * 9 | */ 10 | 11 | module parsing.d.moduleunit; 12 | 13 | import parsing.parseunit; 14 | import parsing.lexer; 15 | import parsing.token; 16 | 17 | import parsing.d.nodes; 18 | import parsing.d.tokens; 19 | 20 | import parsing.d.moduledeclunit; 21 | import parsing.d.declarationunit; 22 | 23 | import io.console; 24 | 25 | class ModuleUnit : ParseUnit { 26 | protected: 27 | 28 | override bool tokenFound(Token current) { 29 | 30 | // This parsing unit searches for declarations. 31 | 32 | switch (current.type) { 33 | 34 | // Module Declaration 35 | case DToken.Module: 36 | 37 | if (root !is null) { 38 | // Error: The module declaration is found, 39 | // but it is not at the root of the parse tree. 40 | error("Module declaration should be on one of the first lines of the file."); 41 | } 42 | else { 43 | auto tree = expand!(ModuleDeclUnit)(); 44 | } 45 | break; 46 | 47 | default: 48 | lexer.push(current); 49 | auto tree = expand!(DeclarationUnit)(); 50 | break; 51 | } 52 | return true; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /parsing/d/mulexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.mulexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.unaryexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class MulExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Mul: 26 | case DToken.Div: 27 | case DToken.Mod: 28 | if (this.state == 1) { 29 | Console.putln("MUL"); 30 | this.state = 0; 31 | break; 32 | } 33 | 34 | // Fall through 35 | 36 | default: 37 | lexer.push(current); 38 | if (this.state == 1) { 39 | // Done. 40 | return false; 41 | } 42 | auto tree = expand!(UnaryExprUnit)(); 43 | this.state = 1; 44 | break; 45 | } 46 | return true; 47 | } 48 | 49 | protected: 50 | string cur_string = ""; 51 | 52 | static const string _common_error_msg = ""; 53 | static const string[] _common_error_usages = null; 54 | } 55 | -------------------------------------------------------------------------------- /parsing/d/nodes.d: -------------------------------------------------------------------------------- 1 | /* 2 | * nodes.d 3 | * 4 | * This module lists the possible parse tree nodes for the D parser. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: February 6th 2010 8 | * 9 | */ 10 | 11 | module parsing.d.nodes; 12 | 13 | enum DNode : uint { 14 | Module, // module bleh.foo; => ModuleName 15 | Import, // import bleh.foo; => ModuleName 16 | ModuleName, // "foo.foo" 17 | Block, // { ... } 18 | } 19 | -------------------------------------------------------------------------------- /parsing/d/orexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.orexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.xorexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class OrExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Or: 26 | if (this.state == 1) { 27 | Console.putln("OR"); 28 | this.state = 0; 29 | break; 30 | } 31 | 32 | // Fall through 33 | goto default; 34 | 35 | default: 36 | lexer.push(current); 37 | if (this.state == 1) { 38 | // Done. 39 | return false; 40 | } 41 | auto tree = expand!(XorExprUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/d/parser.d: -------------------------------------------------------------------------------- 1 | /* 2 | * parser.d 3 | * 4 | * This module will provide a parser for the D programming language. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: February 1st, 2010 8 | * 9 | */ 10 | 11 | module parsing.d.parser; 12 | 13 | import parsing.d.lexer; 14 | import parsing.d.tokens; 15 | import parsing.d.nodes; 16 | 17 | import parsing.d.moduleunit; 18 | 19 | import parsing.token; 20 | import parsing.ast; 21 | import parsing.lexer; 22 | import parsing.parser; 23 | import parsing.parseunit; 24 | 25 | import djehuty; 26 | 27 | import io.console; 28 | 29 | class DParser : Parser { 30 | this(Stream stream) { 31 | super(stream); 32 | _lexer = new DLexer(stream); 33 | } 34 | 35 | override AbstractSyntaxTree parse() { 36 | ParseUnit parseUnit = new ModuleUnit(); 37 | parseUnit.lexer = _lexer; 38 | return parseUnit.parse(); 39 | } 40 | 41 | private: 42 | DLexer _lexer; 43 | } 44 | -------------------------------------------------------------------------------- /parsing/d/postfixexprlistunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.postfixexprlistunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.primaryexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class PostFixExprListUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | default: 26 | lexer.push(current); 27 | auto tree = expand!(PrimaryExprUnit)(); 28 | } 29 | return false; 30 | } 31 | 32 | protected: 33 | string cur_string = ""; 34 | 35 | static const string _common_error_msg = ""; 36 | static const string[] _common_error_usages = null; 37 | } 38 | -------------------------------------------------------------------------------- /parsing/d/postfixexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.postfixexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.postfixexprlistunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class PostFixExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Null: 26 | case DToken.True: 27 | case DToken.False: 28 | case DToken.IntegerLiteral: 29 | case DToken.Dollar: 30 | case DToken.FloatingPointLiteral: 31 | Console.putln("Expression: ", current.value); 32 | return false; 33 | case DToken.Mixin: 34 | // TODO: MixinExprUnit 35 | // auto tree = expand!(MixinExprUnit)(); 36 | break; 37 | case DToken.Assert: 38 | // TODO: AssertExprUnit 39 | // auto tree = expand!(AssertExprUnit)(); 40 | break; 41 | case DToken.Is: 42 | // TODO: IsExprUnit 43 | // auto tree = expand!(IsExprUnit)(); 44 | break; 45 | default: 46 | lexer.push(current); 47 | auto tree = expand!(PostFixExprListUnit)(); 48 | return false; 49 | } 50 | return true; 51 | } 52 | 53 | protected: 54 | string cur_string = ""; 55 | 56 | static const string _common_error_msg = ""; 57 | static const string[] _common_error_usages = null; 58 | } 59 | -------------------------------------------------------------------------------- /parsing/d/pragmastmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.pragmastmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | import parsing.d.statementunit; 16 | 17 | import io.console; 18 | 19 | import djehuty; 20 | 21 | class PragmaStmtUnit : ParseUnit { 22 | override bool tokenFound(Token current) { 23 | switch (current.type) { 24 | case DToken.LeftParen: 25 | if(this.state >= 1){ 26 | //XXX: Error 27 | } 28 | 29 | this.state = 1; 30 | break; 31 | case DToken.Identifier: 32 | if(this.state != 1){ 33 | //XXX: Error 34 | } 35 | 36 | cur_string = current.value.toString(); 37 | Console.putln("Pragma: ", current.value); 38 | this.state = 2; 39 | break; 40 | case DToken.RightParen: 41 | if(this.state != 2 && this.state != 3){ 42 | //XXX: Error 43 | } 44 | 45 | if (this.state == 2) { 46 | auto tree = expand!(StatementUnit)(); 47 | } 48 | 49 | // Done. 50 | return false; 51 | case DToken.Comma: 52 | if(this.state != 2){ 53 | //XXX: Error 54 | } 55 | 56 | this.state = 3; 57 | 58 | //TODO: Argument List 59 | 60 | break; 61 | default: 62 | break; 63 | } 64 | return true; 65 | } 66 | 67 | protected: 68 | string cur_string = ""; 69 | 70 | static const string _common_error_msg = ""; 71 | static const string[] _common_error_usages = null; 72 | } 73 | -------------------------------------------------------------------------------- /parsing/d/primaryexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.primaryexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class PrimaryExprUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.StringLiteral: 24 | Console.putln("Expression: \"", current.value, "\""); 25 | cur_string = current.value.toString(); 26 | return false; 27 | default: 28 | break; 29 | } 30 | return true; 31 | } 32 | 33 | protected: 34 | string cur_string = ""; 35 | 36 | static const string _common_error_msg = ""; 37 | static const string[] _common_error_usages = null; 38 | } 39 | -------------------------------------------------------------------------------- /parsing/d/returnstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.returnstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.expressionunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ReturnStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Semicolon: 26 | // Done. 27 | return false; 28 | 29 | default: 30 | if (this.state == 1) { 31 | // Error: Multiple expressions 32 | // TODO: 33 | } 34 | 35 | lexer.push(current); 36 | 37 | // Expression follows... and then a semicolon 38 | auto tree = expand!(ExpressionUnit)(); 39 | this.state = 1; 40 | 41 | break; 42 | } 43 | return true; 44 | } 45 | 46 | protected: 47 | string cur_string = ""; 48 | 49 | static const string _common_error_msg = ""; 50 | static const string[] _common_error_usages = null; 51 | } 52 | -------------------------------------------------------------------------------- /parsing/d/scopedstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.scopedstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.statementunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ScopedStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | 26 | // Statement Blocks 27 | case DToken.LeftCurly: 28 | this.state = 1; 29 | break; 30 | 31 | case DToken.RightCurly: 32 | if (this.state != 1) { 33 | } 34 | return false; 35 | 36 | case DToken.Semicolon: 37 | // Error. 38 | return false; 39 | 40 | default: 41 | // Just a statement 42 | auto tree = expand!(StatementUnit)(); 43 | if (this.state == 0) { 44 | return false; 45 | } 46 | break; 47 | } 48 | return true; 49 | } 50 | 51 | protected: 52 | string cur_string = ""; 53 | 54 | static const string _common_error_msg = ""; 55 | static const string[] _common_error_usages = null; 56 | } 57 | -------------------------------------------------------------------------------- /parsing/d/shiftexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.shiftexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.addexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ShiftExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.ShiftLeft: 26 | case DToken.ShiftRight: 27 | case DToken.ShiftRightSigned: 28 | if (this.state == 1) { 29 | Console.putln("SHIFT"); 30 | this.state = 0; 31 | break; 32 | } 33 | 34 | // Fall through 35 | goto default; 36 | 37 | default: 38 | lexer.push(current); 39 | if (this.state == 1) { 40 | // Done. 41 | return false; 42 | } 43 | auto tree = expand!(AddExprUnit)(); 44 | this.state = 1; 45 | break; 46 | } 47 | return true; 48 | } 49 | 50 | protected: 51 | string cur_string = ""; 52 | 53 | static const string _common_error_msg = ""; 54 | static const string[] _common_error_usages = null; 55 | } 56 | -------------------------------------------------------------------------------- /parsing/d/staticassertunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.staticassertunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class StaticAssertUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | default: 24 | break; 25 | } 26 | return true; 27 | } 28 | 29 | protected: 30 | string cur_string = ""; 31 | 32 | static const string _common_error_msg = ""; 33 | static const string[] _common_error_usages = null; 34 | } 35 | -------------------------------------------------------------------------------- /parsing/d/staticunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * staticunit.d 3 | * 4 | */ 5 | 6 | module parsing.d.staticunit; 7 | 8 | import parsing.parseunit; 9 | import parsing.token; 10 | 11 | import parsing.d.tokens; 12 | import parsing.d.nodes; 13 | 14 | import parsing.d.staticifunit; 15 | import parsing.d.staticassertunit; 16 | 17 | import djehuty; 18 | 19 | class StaticUnit : ParseUnit { 20 | override bool tokenFound(Token current) { 21 | switch (current.type) { 22 | case DToken.If: 23 | // Static If (Compile-time condition) 24 | // static if ... 25 | auto tree = expand!(StaticIfUnit)(); 26 | break; 27 | case DToken.Assert: 28 | // Static Assert (Compile-time assert) 29 | 30 | // static assert ... 31 | auto tree = expand!(StaticAssertUnit)(); 32 | break; 33 | case DToken.This: 34 | // Static Constructor 35 | 36 | // static this ... 37 | break; 38 | case DToken.Cat: 39 | // Static Destructor 40 | 41 | // static ~ this ... 42 | break; 43 | default: 44 | // Attribute Specifier 45 | // static Type 46 | break; 47 | } 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /parsing/d/switchstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.switchstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.expressionunit; 17 | import parsing.d.blockstmtunit; 18 | 19 | import io.console; 20 | 21 | import djehuty; 22 | 23 | class SwitchStmtUnit : ParseUnit { 24 | override bool tokenFound(Token current) { 25 | switch (current.type) { 26 | case DToken.LeftParen: 27 | if (this.state != 0) { 28 | } 29 | 30 | Console.putln("Switch:"); 31 | auto tree = expand!(ExpressionUnit)(); 32 | this.state = 1; 33 | break; 34 | case DToken.RightParen: 35 | if (this.state != 1) { 36 | } 37 | this.state = 2; 38 | break; 39 | case DToken.LeftCurly: 40 | if (this.state == 0) { 41 | } 42 | if (this.state == 1) { 43 | } 44 | 45 | auto tree = expand!(BlockStmtUnit)(); 46 | // Done. 47 | return false; 48 | default: 49 | // Error 50 | // TODO: 51 | break; 52 | } 53 | return true; 54 | } 55 | 56 | protected: 57 | string cur_string = ""; 58 | 59 | static const string _common_error_msg = ""; 60 | static const string[] _common_error_usages = null; 61 | } 62 | -------------------------------------------------------------------------------- /parsing/d/template.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.expressionunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class ExpressionUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | case DToken.Dot: 24 | break; 25 | 26 | default: 27 | break; 28 | } 29 | return true; 30 | } 31 | 32 | protected: 33 | string cur_string = ""; 34 | 35 | static const string _common_error_msg = ""; 36 | static const string[] _common_error_usages = null; 37 | } 38 | -------------------------------------------------------------------------------- /parsing/d/templatebodyunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.templatebodyunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.declarationunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class TemplateBodyUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | // We are always looking for the end of the body. 26 | case DToken.RightCurly: 27 | // Done. 28 | return false; 29 | 30 | // We cannot have allocators in templates! 31 | case DToken.New: 32 | // Error: No allocators allowed. 33 | // TODO: 34 | break; 35 | 36 | // Ditto for a delete token for deallocator. 37 | case DToken.Delete: 38 | // Error: No deallocators allowed. 39 | // TODO: 40 | break; 41 | 42 | // Otherwise, it must be some Declarator 43 | default: 44 | lexer.push(current); 45 | auto tree = expand!(DeclarationUnit)(); 46 | break; 47 | } 48 | return true; 49 | } 50 | 51 | protected: 52 | string cur_string = ""; 53 | 54 | static const string _common_error_msg = ""; 55 | static const string[] _common_error_usages = null; 56 | } 57 | -------------------------------------------------------------------------------- /parsing/d/throwstmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.throwstmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.expressionunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class ThrowStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Semicolon: 26 | if (this.state == 0) { 27 | // Error: No expression 28 | // TODO: 29 | } 30 | 31 | // Done. 32 | return false; 33 | default: 34 | if (this.state == 1) { 35 | // Error: Multiple expressions 36 | // TODO: 37 | } 38 | lexer.push(current); 39 | auto tree = expand!(ExpressionUnit)(); 40 | this.state = 1; 41 | break; 42 | } 43 | return true; 44 | } 45 | 46 | protected: 47 | string cur_string = ""; 48 | 49 | static const string _common_error_msg = ""; 50 | static const string[] _common_error_usages = null; 51 | } 52 | -------------------------------------------------------------------------------- /parsing/d/trees.d: -------------------------------------------------------------------------------- 1 | module parsing.d.trees; 2 | 3 | import parsing.ast; 4 | 5 | import djehuty; 6 | 7 | import io.console; 8 | 9 | class Import : AbstractSyntaxTree { 10 | this(string packageName) { 11 | Console.putln("Import: ", packageName); 12 | _packageName = packageName; 13 | } 14 | 15 | string packageName() { 16 | return _packageName; 17 | } 18 | 19 | protected: 20 | string _packageName; 21 | } 22 | -------------------------------------------------------------------------------- /parsing/d/typeunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.typeunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import io.console; 17 | 18 | import djehuty; 19 | 20 | class TypeUnit : ParseUnit { 21 | override bool tokenFound(Token current) { 22 | switch (current.type) { 23 | default: 24 | break; 25 | } 26 | return true; 27 | } 28 | 29 | protected: 30 | string cur_string = ""; 31 | 32 | static const string _common_error_msg = ""; 33 | static const string[] _common_error_usages = null; 34 | } 35 | -------------------------------------------------------------------------------- /parsing/d/unaryexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.unaryexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.postfixexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class UnaryExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | default: 26 | lexer.push(current); 27 | auto tree = expand!(PostFixExprUnit)(); 28 | break; 29 | } 30 | return false; 31 | } 32 | 33 | protected: 34 | string cur_string = ""; 35 | 36 | static const string _common_error_msg = ""; 37 | static const string[] _common_error_usages = null; 38 | } 39 | -------------------------------------------------------------------------------- /parsing/d/unittestunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.unittestunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.functionbodyunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class UnittestUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | // Look for the beginning of a functionbody 26 | case DToken.In: 27 | case DToken.Out: 28 | case DToken.Body: 29 | case DToken.LeftCurly: 30 | Console.putln("Unittest"); 31 | lexer.push(current); 32 | auto tree = expand!(FunctionBodyUnit)(); 33 | 34 | // Done. 35 | return false; 36 | 37 | // Errors otherwise. 38 | default: 39 | break; 40 | } 41 | return true; 42 | } 43 | 44 | protected: 45 | string cur_string = ""; 46 | 47 | static const string _common_error_msg = ""; 48 | static const string[] _common_error_usages = null; 49 | } 50 | -------------------------------------------------------------------------------- /parsing/d/volatilestmtunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.volatilestmtunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.statementunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class VolatileStmtUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Semicolon: 26 | // Done. 27 | return false; 28 | 29 | default: 30 | if (this.state == 1) { 31 | // Error: Multiple statements!? 32 | // TODO: 33 | } 34 | 35 | lexer.push(current); 36 | 37 | // Statement Follows. 38 | auto tree = expand!(StatementUnit)(); 39 | this.state = 1; 40 | 41 | break; 42 | } 43 | return true; 44 | } 45 | 46 | protected: 47 | string cur_string = ""; 48 | 49 | static const string _common_error_msg = ""; 50 | static const string[] _common_error_usages = null; 51 | } 52 | -------------------------------------------------------------------------------- /parsing/d/xorexprunit.d: -------------------------------------------------------------------------------- 1 | /* 2 | * expressionunit.d 3 | * 4 | * This module parses expressions. 5 | * 6 | */ 7 | 8 | module parsing.d.xorexprunit; 9 | 10 | import parsing.parseunit; 11 | import parsing.token; 12 | 13 | import parsing.d.tokens; 14 | import parsing.d.nodes; 15 | 16 | import parsing.d.andexprunit; 17 | 18 | import io.console; 19 | 20 | import djehuty; 21 | 22 | class XorExprUnit : ParseUnit { 23 | override bool tokenFound(Token current) { 24 | switch (current.type) { 25 | case DToken.Xor: 26 | if (this.state == 1) { 27 | Console.putln("XOR"); 28 | this.state = 0; 29 | break; 30 | } 31 | 32 | // Fall through 33 | goto default; 34 | 35 | default: 36 | lexer.push(current); 37 | if (this.state == 1) { 38 | // Done. 39 | return false; 40 | } 41 | auto tree = expand!(AndExprUnit)(); 42 | this.state = 1; 43 | break; 44 | } 45 | return true; 46 | } 47 | 48 | protected: 49 | string cur_string = ""; 50 | 51 | static const string _common_error_msg = ""; 52 | static const string[] _common_error_usages = null; 53 | } 54 | -------------------------------------------------------------------------------- /parsing/ebnf.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/ebnf.d -------------------------------------------------------------------------------- /parsing/html.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/html.d -------------------------------------------------------------------------------- /parsing/lexer.d: -------------------------------------------------------------------------------- 1 | module parsing.lexer; 2 | 3 | import parsing.token; 4 | 5 | import core.stream; 6 | import core.definitions; 7 | 8 | abstract class Lexer { 9 | this(Stream stream) { 10 | } 11 | 12 | void push(Token token) { 13 | } 14 | 15 | Token pop() { 16 | return Token.init; 17 | } 18 | 19 | string line() { 20 | return ""; 21 | } 22 | 23 | string line(uint idx) { 24 | return ""; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /parsing/parser.d: -------------------------------------------------------------------------------- 1 | module parsing.parser; 2 | 3 | import parsing.ast; 4 | 5 | import core.stream; 6 | 7 | abstract class Parser { 8 | this(Stream stream) { 9 | } 10 | 11 | AbstractSyntaxTree parse() { 12 | return null; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /parsing/sgml.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/sgml.d -------------------------------------------------------------------------------- /parsing/token.d: -------------------------------------------------------------------------------- 1 | module parsing.token; 2 | 3 | import core.variant; 4 | 5 | struct Token { 6 | uint type; 7 | Variant value; 8 | 9 | uint column; 10 | uint line; 11 | 12 | uint columnEnd; 13 | uint lineEnd; 14 | } 15 | -------------------------------------------------------------------------------- /parsing/wiki.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/wiki.d -------------------------------------------------------------------------------- /parsing/xml.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/parsing/xml.d -------------------------------------------------------------------------------- /platform/osx/common.d: -------------------------------------------------------------------------------- 1 | 2 | module platform.osx.common; 3 | 4 | public import platform.unix.common; 5 | 6 | -------------------------------------------------------------------------------- /platform/osx/imports.d: -------------------------------------------------------------------------------- 1 | module platform.osx.imports; 2 | 3 | // contains the templates and mixins to import the platform specific modules 4 | 5 | // should give the name of the directory 6 | const char[] PlatformTitle = "osx"; 7 | -------------------------------------------------------------------------------- /platform/osx/main.d: -------------------------------------------------------------------------------- 1 | 2 | module platform.osx.main; 3 | 4 | import platform.application; 5 | 6 | import core.arguments; 7 | import core.main; 8 | import core.definitions; 9 | import gui.window; 10 | import graphics.view; 11 | import resource.menu; 12 | 13 | import analyzing.debugger; 14 | 15 | import scaffold.console; 16 | 17 | import binding.c; 18 | 19 | import cui.window; 20 | 21 | import core.string; 22 | 23 | extern (C) void hi(); 24 | 25 | extern (C) void call(void* stuff) { 26 | } 27 | 28 | // These functions are within the objective-c code 29 | // These start the OS X event loop. 30 | extern (C) void _OSXStart(); 31 | extern (C) void _OSXEnd(); 32 | 33 | int main(char[][] args) { 34 | try { 35 | _OSXStart(); 36 | 37 | ConsoleInit(); 38 | Arguments argList = Arguments.instance(); 39 | foreach(arg; args) { 40 | argList.add(arg); 41 | } 42 | 43 | Djehuty.application.run(); 44 | ConsoleUninit(); 45 | } 46 | catch(Object o) { 47 | Debugger.raiseException(cast(Exception)o); 48 | } 49 | 50 | _OSXEnd(); 51 | return ApplicationController.instance.exitCode; 52 | } 53 | -------------------------------------------------------------------------------- /platform/osx/objc/OSXView.h: -------------------------------------------------------------------------------- 1 | #ifndef _OSXVIEW_INC 2 | #define _OSXVIEW_INC 3 | 4 | #include 5 | #include 6 | 7 | #include "OSXWindow.h" 8 | 9 | @class _OSXView; 10 | 11 | struct _OSXViewPlatformVars 12 | { 13 | //contains the stuff for drawing text 14 | //font colors and attributes and font description 15 | NSMutableDictionary* cur_font; 16 | 17 | NSLayoutManager* layout; 18 | 19 | NSTextContainer* container; 20 | 21 | NSTextStorage* txtstore; 22 | 23 | _OSXView* viewRef; 24 | 25 | NSRect nsRect; 26 | CGContextRef cgContext; 27 | 28 | // Buffers: 29 | 30 | NSBitmapImageRep* dib_image_rep; 31 | 32 | NSImage* dib_image; 33 | }; 34 | 35 | #endif // _OSXVIEW_INC 36 | -------------------------------------------------------------------------------- /platform/osx/objc/OSXWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _OSXWINDOW_INC 2 | #define _OSXWINDOW_INC 3 | 4 | #include 5 | #include 6 | 7 | struct _OSXWindowPlatformVars 8 | { 9 | void* windowClassRef; 10 | NSWindow* windowRef; 11 | NSEvent* curEvent; 12 | unsigned int curEventType; // 0 - mouseMoved, 1 - mouseDragged 13 | 14 | struct _OSXViewPlatformVars* viewVars; 15 | }; 16 | 17 | #endif // _OSXWINDOW_INC 18 | -------------------------------------------------------------------------------- /platform/osx/objc/app.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | @interface _OSXApp : NSApplication { 5 | } 6 | @end 7 | 8 | @implementation _OSXApp { 9 | } 10 | /* 11 | -(void)sendEvent:(NSEvent*)event 12 | { 13 | printf("event %d\n", [ event type ]); 14 | [ super sendEvent:event ]; 15 | } //*/ 16 | /* 17 | -(BOOL)tryToPerform:(SEL)sel with:(id)obj 18 | { 19 | printf("perform\n"); 20 | return [ super tryToPerform:sel with:obj ]; 21 | }//*/ 22 | @end 23 | 24 | NSAutoreleasePool* pool; 25 | 26 | NSArray* fntKeys; 27 | 28 | void _OSXStart() { 29 | fntKeys = [ [NSArray alloc ] initWithObjects: 30 | NSFontAttributeName, 31 | NSUnderlineStyleAttributeName, 32 | nil ] ; 33 | 34 | pool = [ [ NSAutoreleasePool alloc ] init ]; 35 | 36 | NSApp = [_OSXApp sharedApplication]; 37 | } 38 | 39 | void _OSXLoop() { 40 | // run the main event loop 41 | [ NSApp run ]; 42 | } 43 | 44 | void _OSXEnd() { 45 | [ NSApp release ]; 46 | 47 | [ pool release ]; 48 | } 49 | -------------------------------------------------------------------------------- /platform/osx/oscontrol.d: -------------------------------------------------------------------------------- 1 | module platform.osx.oscontrol; 2 | 3 | import core.literals; 4 | 5 | template PlatformTestControlStatus(StringLiteral8 ControlName) 6 | { 7 | static if (ControlName == "OSBlehField") 8 | { 9 | const char[] PlatformTestControlStatus = `true`; 10 | } 11 | else 12 | { 13 | const char[] PlatformTestControlStatus = `false`; 14 | } 15 | } -------------------------------------------------------------------------------- /platform/osx/oscontrolinterface.d: -------------------------------------------------------------------------------- 1 | 2 | module platform.osx.oscontrolinterface; 3 | 4 | // os control interface 5 | 6 | interface OSControl 7 | { 8 | protected: 9 | } 10 | -------------------------------------------------------------------------------- /platform/osx/platform/application.d: -------------------------------------------------------------------------------- 1 | module platform.application; 2 | 3 | import binding.c; 4 | 5 | class ApplicationController { 6 | this() { 7 | } 8 | 9 | void exitCode(uint value) { 10 | _exitCode = value; 11 | } 12 | 13 | uint exitCode() { 14 | return _exitCode; 15 | } 16 | 17 | void start() { 18 | } 19 | 20 | void end() { 21 | exit(_exitCode); 22 | } 23 | 24 | static ApplicationController instance() { 25 | if (_app is null) { 26 | _app = new ApplicationController(); 27 | } 28 | return _app; 29 | } 30 | 31 | bool usingCurses() { 32 | return _usingCurses; 33 | } 34 | 35 | void usingCurses(bool value) { 36 | _usingCurses = value; 37 | } 38 | 39 | private: 40 | 41 | bool _usingCurses; 42 | uint _exitCode; 43 | static ApplicationController _app; 44 | } 45 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/brush.d: -------------------------------------------------------------------------------- 1 | module platform.vars.brush; 2 | 3 | struct BrushPlatformVars { 4 | void* brush; 5 | } 6 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/condition.d: -------------------------------------------------------------------------------- 1 | /* 2 | * condition.d 3 | * 4 | * This struct contains implementation variables necessary for 5 | * using condition variables in Unix (pthread) 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: December 5th, 2009 9 | * 10 | */ 11 | 12 | module platform.vars.condition; 13 | 14 | import platform.unix.common; 15 | 16 | struct ConditionPlatformVars { 17 | pthread_cond_t cond_id; 18 | } 19 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/cui.d: -------------------------------------------------------------------------------- 1 | /* 2 | * cui.d 3 | * 4 | * This module contains platform specific variables that are stored with 5 | * a CuiApplication for Unix. 6 | * 7 | */ 8 | 9 | module platform.vars.cui; 10 | 11 | struct CuiPlatformVars { 12 | } 13 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/directory.d: -------------------------------------------------------------------------------- 1 | /* 2 | * directory.d 3 | * 4 | * This module implements the platform specifics for the Directory class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.directory; 12 | 13 | import platform.unix.common; 14 | 15 | struct DirectoryPlatformVars { 16 | DIR* dir; 17 | } 18 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/file.d: -------------------------------------------------------------------------------- 1 | /* 2 | * file.d 3 | * 4 | * This module implements the platform specifics for the File class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.file; 12 | 13 | import platform.unix.common; 14 | 15 | struct FilePlatformVars { 16 | FILE* file; 17 | } 18 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/font.d: -------------------------------------------------------------------------------- 1 | module platform.vars.font; 2 | 3 | struct FontPlatformVars { 4 | } 5 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/library.d: -------------------------------------------------------------------------------- 1 | /* 2 | * library.d 3 | * 4 | * This module implements the platform specifics for the Library class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.library; 12 | 13 | struct LibraryPlatformVars { 14 | void* handle; 15 | } 16 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/menu.d: -------------------------------------------------------------------------------- 1 | /* 2 | * menu.d 3 | * 4 | * This module implements the platform specifics for the Menu class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.menu; 12 | 13 | struct MenuPlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/mutex.d: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex.d 3 | * 4 | * This module implements the platform specifics for the Mutex class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.mutex; 12 | 13 | struct MutexPlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/pen.d: -------------------------------------------------------------------------------- 1 | module platform.vars.pen; 2 | 3 | struct PenPlatformVars { 4 | void* pen; 5 | } 6 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/region.d: -------------------------------------------------------------------------------- 1 | module platform.vars.region; 2 | 3 | struct RegionPlatformVars { 4 | } 5 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/semaphore.d: -------------------------------------------------------------------------------- 1 | /* 2 | * semaphore.d 3 | * 4 | * This module implements the platform specifics for the Semaphore class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.semaphore; 12 | 13 | import platform.osx.common; 14 | 15 | struct SemaphorePlatformVars { 16 | sem_t sem_id; 17 | } 18 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/socket.d: -------------------------------------------------------------------------------- 1 | /* 2 | * socket.d 3 | * 4 | * This module implements the platform specifics for the Socket class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.socket; 12 | 13 | struct SocketPlatformVars { 14 | int m_skt; 15 | } 16 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/thread.d: -------------------------------------------------------------------------------- 1 | /* 2 | * thread.d 3 | * 4 | * This module implements the platform specifics for the Thread class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.thread; 12 | 13 | import platform.osx.common; 14 | 15 | struct ThreadPlatformVars { 16 | } 17 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/view.d: -------------------------------------------------------------------------------- 1 | module platform.vars.view; 2 | 3 | import platform.osx.common; 4 | 5 | extern (C) struct _OSXViewPlatformVars; 6 | extern (C) struct _OSXMenuPlatformVars; 7 | extern (C) struct _OSXWavePlatformVars; 8 | 9 | struct ViewPlatformVars 10 | { 11 | _OSXViewPlatformVars* vars; 12 | ulong dibBytes; 13 | int fromWindow; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/wave.d: -------------------------------------------------------------------------------- 1 | /* 2 | * wave.d 3 | * 4 | * This module implements the platform specifics for the Wave class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.wave; 12 | 13 | struct WavePlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/osx/platform/vars/window.d: -------------------------------------------------------------------------------- 1 | module platform.vars.window; 2 | 3 | import platform.vars.view; 4 | 5 | import platform.osx.common; 6 | 7 | extern (C) struct _OSXWindowPlatformVars; 8 | 9 | struct WindowPlatformVars { 10 | _OSXWindowPlatformVars* vars; 11 | _OSXViewPlatformVars* viewVars; 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /platform/osx/scaffold/color.d: -------------------------------------------------------------------------------- 1 | module scaffold.color; 2 | 3 | import platform.osx.common; 4 | 5 | import graphics.view; 6 | import graphics.graphics; 7 | 8 | import gui.window; 9 | import core.string; 10 | import io.file; 11 | import core.color; 12 | 13 | import core.main; 14 | 15 | import core.definitions; 16 | 17 | 18 | void ColorGetSystemColor(ref Color clr, SystemColor sysColorIndex) { 19 | switch (sysColorIndex) { 20 | case SystemColor.Window: 21 | //ColorSetValue(clr, 0x0); 22 | break; 23 | default: break; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /platform/osx/scaffold/menu.d: -------------------------------------------------------------------------------- 1 | /* 2 | * menu.d 3 | * 4 | * This Scaffold holds the Menu implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.menu; 11 | 12 | import platform.vars.window; 13 | import platform.vars.menu; 14 | import platform.unix.common; 15 | 16 | import core.string; 17 | import core.main; 18 | import core.definitions; 19 | 20 | import resource.menu; 21 | 22 | import gui.window; 23 | 24 | void MenuCreate(MenuPlatformVars* menuVars) 25 | { 26 | } 27 | 28 | void MenuDestroy(MenuPlatformVars* menuVars) 29 | { 30 | } 31 | 32 | void MenuAppend(void* identifier, MenuPlatformVars* mnuVars, MenuPlatformVars* toAppendVars, string text, bool hasSubitems) 33 | { 34 | if (hasSubitems) 35 | { 36 | } 37 | else 38 | { 39 | } 40 | } 41 | 42 | void MenuUpdate(void* identifier, MenuPlatformVars* mnuVars, MenuPlatformVars* toUpdateVars, string text, uint position, bool hasSubitems) 43 | { 44 | if (hasSubitems) 45 | { 46 | } 47 | else 48 | { 49 | } 50 | } 51 | 52 | void WindowSetMenu(MenuPlatformVars* mnuVars, ref Window wnd, WindowPlatformVars* windowVars) 53 | { 54 | } 55 | 56 | -------------------------------------------------------------------------------- /platform/osx/scaffold/opengl.d: -------------------------------------------------------------------------------- 1 | /* 2 | * opengl.d 3 | * 4 | * This Scaffold holds the OpenGL implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.opengl; 11 | 12 | import binding.opengl.gl; 13 | 14 | import opengl.window; 15 | 16 | import platform.unix.common; 17 | 18 | import platform.vars.window; 19 | 20 | void OpenGLWindowInitialize(ref GLWindow glWindow, WindowPlatformVars* windowVars) 21 | { 22 | } 23 | -------------------------------------------------------------------------------- /platform/osx/scaffold/wave.d: -------------------------------------------------------------------------------- 1 | /* 2 | * wave.d 3 | * 4 | * This Scaffold holds the Wave implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.wave; 11 | 12 | import platform.vars.wave; 13 | 14 | import core.string; 15 | import core.stream; 16 | import core.time; 17 | import core.main; 18 | import core.definitions; 19 | 20 | import io.audio; 21 | 22 | import synch.thread; 23 | import synch.semaphore; 24 | 25 | void WaveOpenDevice(ref Audio wave, ref WavePlatformVars waveVars, ref AudioFormat wf) 26 | { 27 | } 28 | 29 | void WaveCloseDevice(ref Audio wave, ref WavePlatformVars waveVars) 30 | { 31 | } 32 | 33 | void WaveSendBuffer(ref Audio wave, ref WavePlatformVars waveVars, Stream waveBuffer, bool isLast) 34 | { 35 | } 36 | 37 | void WaveResume(ref Audio wave, ref WavePlatformVars waveVars) 38 | { 39 | } 40 | 41 | void WavePause(ref Audio wave, ref WavePlatformVars waveVars) 42 | { 43 | } 44 | 45 | 46 | 47 | Time WaveGetPosition(ref Audio wave, ref WavePlatformVars waveVars) 48 | { 49 | Time tm; 50 | 51 | tm = tm.init; 52 | return tm; 53 | } 54 | 55 | bool WaveIsOpen(ref Audio wave, ref WavePlatformVars waveVars) 56 | { 57 | return false; 58 | } 59 | -------------------------------------------------------------------------------- /platform/osx/thread.d: -------------------------------------------------------------------------------- 1 | module platform.osx.thread; 2 | 3 | class Thread 4 | { 5 | 6 | public: 7 | 8 | ~this() 9 | { 10 | Stop(); 11 | } 12 | 13 | // the common function for the thread 14 | void Call() 15 | { 16 | if (_thread_callback !is null) 17 | { 18 | _thread_callback(); 19 | } 20 | else if (_thread_f_callback !is null) 21 | { 22 | _thread_f_callback(); 23 | } 24 | } 25 | 26 | void SetDelegate(void delegate() callback) 27 | { 28 | _thread_callback = callback; 29 | _thread_f_callback = null; 30 | } 31 | 32 | void SetDelegate(void function() callback) 33 | { 34 | _thread_f_callback = callback; 35 | _thread_callback = null; 36 | } 37 | 38 | bool IsCurrentThread() 39 | { 40 | } 41 | 42 | void Sleep(long milliseconds) 43 | { 44 | } 45 | 46 | void Start() 47 | { 48 | } 49 | 50 | void Stop() 51 | { 52 | } 53 | 54 | protected: 55 | 56 | void delegate () _thread_callback = null; 57 | void function () _thread_f_callback = null; 58 | 59 | } 60 | 61 | 62 | class Semaphore 63 | { 64 | public: 65 | 66 | ~this() 67 | { 68 | if (_inited) 69 | { 70 | CloseHandle(_semaphore); 71 | } 72 | } 73 | 74 | void Init(uint initialValue) 75 | { 76 | } 77 | 78 | void Up() 79 | { 80 | } 81 | 82 | void Down() 83 | { 84 | } 85 | 86 | protected: 87 | 88 | } 89 | -------------------------------------------------------------------------------- /platform/unix/gui/osbutton.d: -------------------------------------------------------------------------------- 1 | module gui.osbutton; 2 | 3 | import gui.button; 4 | 5 | import core.string; 6 | import core.definitions; 7 | 8 | class OSButton : Button { 9 | 10 | mixin(ControlPrintCSTRList!()); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /platform/unix/imports.d: -------------------------------------------------------------------------------- 1 | /* 2 | * imports.d 3 | * 4 | * This file gives the platform hint. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module platform.unix.imports; 11 | 12 | // contains the templates and mixins to import the platform specific modules 13 | 14 | // should give the name of the directory 15 | const char[] PlatformTitle = "unix"; 16 | -------------------------------------------------------------------------------- /platform/unix/oscontrol.d: -------------------------------------------------------------------------------- 1 | module platform.unix.oscontrol; 2 | 3 | import core.literals; 4 | 5 | template PlatformTestControlStatus(StringLiteral8 ControlName) 6 | { 7 | static if (ControlName == "OSButton") 8 | { 9 | const char[] PlatformTestControlStatus = `false`; 10 | } 11 | else static if (ControlName == "OSSomeControl") 12 | { 13 | const char[] PlatformTestControlStatus = `false`; 14 | } 15 | else 16 | { 17 | const char[] PlatformTestControlStatus = `false`; 18 | } 19 | } -------------------------------------------------------------------------------- /platform/unix/platform/application.d: -------------------------------------------------------------------------------- 1 | module platform.application; 2 | 3 | import binding.c; 4 | 5 | class ApplicationController { 6 | this() { 7 | } 8 | 9 | void exitCode(uint value) { 10 | _exitCode = value; 11 | } 12 | 13 | uint exitCode() { 14 | return _exitCode; 15 | } 16 | 17 | void start() { 18 | } 19 | 20 | void end() { 21 | // exit(_exitCode); 22 | } 23 | 24 | static ApplicationController instance() { 25 | if (_app is null) { 26 | _app = new ApplicationController(); 27 | } 28 | return _app; 29 | } 30 | 31 | bool usingCurses() { 32 | return _usingCurses; 33 | } 34 | 35 | void usingCurses(bool value) { 36 | _usingCurses = value; 37 | } 38 | 39 | private: 40 | 41 | bool _usingCurses; 42 | uint _exitCode; 43 | static ApplicationController _app; 44 | } 45 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/brush.d: -------------------------------------------------------------------------------- 1 | /* 2 | * brush.d 3 | * 4 | * 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.brush; 12 | 13 | import Cairo = binding.cairo.cairo; 14 | 15 | struct BrushPlatformVars { 16 | Cairo.cairo_pattern_t* handle; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/condition.d: -------------------------------------------------------------------------------- 1 | /* 2 | * condition.d 3 | * 4 | * This struct contains implementation variables necessary for 5 | * using condition variables in Unix (pthread) 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: December 5th, 2009 9 | * 10 | */ 11 | 12 | module platform.vars.condition; 13 | 14 | import platform.unix.common; 15 | 16 | struct ConditionPlatformVars { 17 | pthread_cond_t cond_id; 18 | } 19 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/cui.d: -------------------------------------------------------------------------------- 1 | /* 2 | * cui.d 3 | * 4 | * This module contains platform specific variables that are stored with 5 | * a CuiApplication for Unix. 6 | * 7 | */ 8 | 9 | module platform.vars.cui; 10 | 11 | struct CuiPlatformVars { 12 | } 13 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/directory.d: -------------------------------------------------------------------------------- 1 | /* 2 | * directory.d 3 | * 4 | * This module implements the platform specifics for the Directory class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.directory; 12 | 13 | import platform.unix.common; 14 | 15 | struct DirectoryPlatformVars { 16 | DIR* dir; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/file.d: -------------------------------------------------------------------------------- 1 | /* 2 | * file.d 3 | * 4 | * This module implements the platform specifics for the File class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.file; 12 | 13 | import platform.unix.common; 14 | 15 | struct FilePlatformVars { 16 | FILE* file; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/font.d: -------------------------------------------------------------------------------- 1 | /* 2 | * font.d 3 | * 4 | * This module implements the platform specifics for the Font class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.font; 12 | 13 | import Pango = binding.pango.pango; 14 | 15 | struct FontPlatformVars { 16 | Pango.PangoFontDescription* pangoFont; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/library.d: -------------------------------------------------------------------------------- 1 | /* 2 | * library.d 3 | * 4 | * This module implements the platform specifics for the Library class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.library; 12 | 13 | struct LibraryPlatformVars { 14 | void* handle; 15 | } 16 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/menu.d: -------------------------------------------------------------------------------- 1 | /* 2 | * menu.d 3 | * 4 | * This module implements the platform specifics for the Menu class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.menu; 12 | 13 | struct MenuPlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/mutex.d: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex.d 3 | * 4 | * This module implements the platform specifics for the Mutex class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.mutex; 12 | 13 | import platform.unix.common; 14 | 15 | struct MutexPlatformVars { 16 | pthread_mutex_t mut_id; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/pen.d: -------------------------------------------------------------------------------- 1 | /* 2 | * pen.d 3 | * 4 | * This module implements the platform specifics for the Pen class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.pen; 12 | 13 | import Cairo = binding.cairo.cairo; 14 | 15 | struct PenPlatformVars { 16 | Cairo.cairo_pattern_t* handle; 17 | double width; 18 | } 19 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/region.d: -------------------------------------------------------------------------------- 1 | /* 2 | * region.d 3 | * 4 | * This module implements the platform specifics for the Region class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.region; 12 | 13 | struct RegionPlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/semaphore.d: -------------------------------------------------------------------------------- 1 | /* 2 | * semaphore.d 3 | * 4 | * This module implements the platform specifics for the Semaphore class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.semaphore; 12 | 13 | import platform.unix.common; 14 | 15 | struct SemaphorePlatformVars { 16 | sem_t sem_id; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/socket.d: -------------------------------------------------------------------------------- 1 | /* 2 | * socket.d 3 | * 4 | * This module implements the platform specifics for the Socket class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.socket; 12 | 13 | struct SocketPlatformVars { 14 | int m_skt; 15 | } 16 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/thread.d: -------------------------------------------------------------------------------- 1 | /* 2 | * thread.d 3 | * 4 | * This module implements the platform specifics for the Thread class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.thread; 12 | 13 | import platform.unix.common; 14 | 15 | struct ThreadPlatformVars { 16 | pthread_t id; 17 | } 18 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/view.d: -------------------------------------------------------------------------------- 1 | /* 2 | * view.d 3 | * 4 | * This module implements the platform specifics for the View class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.view; 12 | 13 | import platform.vars.brush; 14 | import platform.vars.pen; 15 | 16 | import Cairo = binding.cairo.cairo; 17 | import Pango = binding.pango.pango; 18 | import X = binding.x.Xlib; 19 | 20 | struct ViewPlatformVars { 21 | // antialias 22 | bool aa; 23 | 24 | X.Window cur_window; 25 | 26 | X.Pixmap pixmap; 27 | bool pixmap_loaded; 28 | 29 | X.GC gc; 30 | 31 | uint curpen; 32 | uint curbrush; 33 | 34 | PenPlatformVars curPen; 35 | BrushPlatformVars curBrush; 36 | 37 | //text 38 | Cairo.cairo_t* cr; 39 | Cairo.cairo_surface_t* surface; 40 | 41 | Pango.PangoLayout* layout; 42 | 43 | Pango.PangoAttrList* attr_list_opaque; 44 | Pango.PangoAttrList* attr_list_transparent; 45 | 46 | Pango.PangoAttribute* attr_bg; 47 | 48 | char* data; 49 | 50 | double textclr_red; 51 | double textclr_green; 52 | double textclr_blue; 53 | double textclr_alpha; 54 | 55 | int isOpaqueRendering; 56 | 57 | ulong bits_length; 58 | } 59 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/wave.d: -------------------------------------------------------------------------------- 1 | /* 2 | * wave.d 3 | * 4 | * This module implements the platform specifics for the Wave class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.wave; 12 | 13 | struct WavePlatformVars { 14 | } 15 | -------------------------------------------------------------------------------- /platform/unix/platform/vars/window.d: -------------------------------------------------------------------------------- 1 | /* 2 | * window.d 3 | * 4 | * This module implements the platform specifics for the Window class. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 25th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.window; 12 | 13 | import X = binding.x.Xlib; 14 | 15 | struct WindowPlatformVars { 16 | // required parameters: 17 | 18 | bool _hasGL; // is a GLWindow 19 | bool _hasView; // is a Window 20 | 21 | // ----- 22 | 23 | X.Window window; 24 | X.Window wm_parent; 25 | int wm_x; 26 | int wm_y; 27 | 28 | //GLXContext ctx; 29 | 30 | //to handle sync issues 31 | bool destroy_called = false; //true, when window is to be destroyed 32 | } 33 | -------------------------------------------------------------------------------- /platform/unix/scaffold/color.d: -------------------------------------------------------------------------------- 1 | /* 2 | * color.d 3 | * 4 | * This Scaffold holds the Color implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.color; 11 | 12 | import platform.unix.common; 13 | 14 | import core.color; 15 | import core.main; 16 | import core.definitions; 17 | 18 | void ColorGetSystemColor(ref Color clr, SystemColor sysColorIndex) 19 | { 20 | // code to get a system color 21 | switch (sysColorIndex) 22 | { 23 | case SystemColor.Window: 24 | clr.alpha = 1.0; 25 | clr.red = 0.7; 26 | clr.green = 0.7; 27 | clr.blue = 0.7; 28 | break; 29 | } 30 | } 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /platform/unix/scaffold/menu.d: -------------------------------------------------------------------------------- 1 | /* 2 | * menu.d 3 | * 4 | * This Scaffold holds the Menu implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.menu; 11 | 12 | import platform.vars.window; 13 | import platform.vars.menu; 14 | import platform.unix.common; 15 | 16 | import core.string; 17 | import core.main; 18 | import core.definitions; 19 | 20 | import resource.menu; 21 | 22 | import gui.window; 23 | 24 | void MenuCreate(MenuPlatformVars* menuVars) 25 | { 26 | } 27 | 28 | void MenuDestroy(MenuPlatformVars* menuVars) 29 | { 30 | } 31 | 32 | void MenuAppend(void* identifier, MenuPlatformVars* mnuVars, MenuPlatformVars* toAppendVars, string text, bool hasSubitems) 33 | { 34 | if (hasSubitems) 35 | { 36 | } 37 | else 38 | { 39 | } 40 | } 41 | 42 | void MenuUpdate(void* identifier, MenuPlatformVars* mnuVars, MenuPlatformVars* toUpdateVars, string text, uint position, bool hasSubitems) 43 | { 44 | if (hasSubitems) 45 | { 46 | } 47 | else 48 | { 49 | } 50 | } 51 | 52 | void WindowSetMenu(MenuPlatformVars* mnuVars, ref Window wnd, WindowPlatformVars* windowVars) 53 | { 54 | } 55 | 56 | -------------------------------------------------------------------------------- /platform/unix/scaffold/opengl.d: -------------------------------------------------------------------------------- 1 | /* 2 | * opengl.d 3 | * 4 | * This Scaffold holds the OpenGL implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.opengl; 11 | 12 | import binding.opengl.gl; 13 | 14 | import opengl.window; 15 | 16 | import platform.unix.common; 17 | 18 | import platform.vars.window; 19 | 20 | void OpenGLWindowInitialize(ref GLWindow glWindow, WindowPlatformVars* windowVars) 21 | { 22 | } 23 | -------------------------------------------------------------------------------- /platform/unix/scaffold/wave.d: -------------------------------------------------------------------------------- 1 | /* 2 | * wave.d 3 | * 4 | * This Scaffold holds the Wave implementations for the Linux platform 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.wave; 11 | 12 | import platform.vars.wave; 13 | 14 | import core.string; 15 | import core.stream; 16 | import core.time; 17 | import core.main; 18 | import core.definitions; 19 | 20 | import io.audio; 21 | 22 | import synch.thread; 23 | import synch.semaphore; 24 | 25 | void WaveOpenDevice(ref Audio wave, ref WavePlatformVars waveVars, ref AudioFormat wf) 26 | { 27 | } 28 | 29 | void WaveCloseDevice(ref Audio wave, ref WavePlatformVars waveVars) 30 | { 31 | } 32 | 33 | void WaveSendBuffer(ref Audio wave, ref WavePlatformVars waveVars, Stream waveBuffer, bool isLast) 34 | { 35 | } 36 | 37 | void WaveResume(ref Audio wave, ref WavePlatformVars waveVars) 38 | { 39 | } 40 | 41 | void WavePause(ref Audio wave, ref WavePlatformVars waveVars) 42 | { 43 | } 44 | 45 | 46 | 47 | Time WaveGetPosition(ref Audio wave, ref WavePlatformVars waveVars) 48 | { 49 | Time tm; 50 | 51 | tm = tm.init; 52 | return tm; 53 | } 54 | 55 | bool WaveIsOpen(ref Audio wave, ref WavePlatformVars waveVars) 56 | { 57 | return false; 58 | } 59 | -------------------------------------------------------------------------------- /platform/win/common.d: -------------------------------------------------------------------------------- 1 | /* 2 | * common.d 3 | * 4 | * This file holds bindings to the Windows API. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module platform.win.common; 11 | 12 | pragma(lib, "user32.lib"); 13 | 14 | // Kernel 15 | public import binding.win32.windef; 16 | public import binding.win32.winnt; 17 | public import binding.win32.winbase; 18 | public import binding.win32.winerror; 19 | 20 | // User 21 | public import binding.win32.winuser; 22 | 23 | // Graphical 24 | public import binding.win32.wingdi; 25 | 26 | // Console 27 | public import binding.win32.wincon; 28 | 29 | // Multimedia 30 | public import binding.win32.mmsystem; 31 | 32 | // Socket 33 | public import binding.win32.ws2def; 34 | public import binding.win32.winsock2; -------------------------------------------------------------------------------- /platform/win/lib/COMCTL32.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/COMCTL32.LIB -------------------------------------------------------------------------------- /platform/win/lib/CTL3D32.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/CTL3D32.LIB -------------------------------------------------------------------------------- /platform/win/lib/ODBC32.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/ODBC32.LIB -------------------------------------------------------------------------------- /platform/win/lib/OLEAUT32.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/OLEAUT32.LIB -------------------------------------------------------------------------------- /platform/win/lib/WS2_32.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/WS2_32.LIB -------------------------------------------------------------------------------- /platform/win/lib/advapi32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/advapi32.lib -------------------------------------------------------------------------------- /platform/win/lib/comdlg32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/comdlg32.lib -------------------------------------------------------------------------------- /platform/win/lib/gc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/gc.lib -------------------------------------------------------------------------------- /platform/win/lib/gdi32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/gdi32.lib -------------------------------------------------------------------------------- /platform/win/lib/gdiplus.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/gdiplus.lib -------------------------------------------------------------------------------- /platform/win/lib/glu32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/glu32.lib -------------------------------------------------------------------------------- /platform/win/lib/kernel32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/kernel32.lib -------------------------------------------------------------------------------- /platform/win/lib/lua5.1.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/lua5.1.lib -------------------------------------------------------------------------------- /platform/win/lib/mpr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/mpr.lib -------------------------------------------------------------------------------- /platform/win/lib/msimg32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/msimg32.lib -------------------------------------------------------------------------------- /platform/win/lib/netapi32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/netapi32.lib -------------------------------------------------------------------------------- /platform/win/lib/ole32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/ole32.lib -------------------------------------------------------------------------------- /platform/win/lib/opengl32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/opengl32.lib -------------------------------------------------------------------------------- /platform/win/lib/rpcrt4.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/rpcrt4.lib -------------------------------------------------------------------------------- /platform/win/lib/shell32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/shell32.lib -------------------------------------------------------------------------------- /platform/win/lib/snn.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/snn.lib -------------------------------------------------------------------------------- /platform/win/lib/user32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/user32.lib -------------------------------------------------------------------------------- /platform/win/lib/uuid.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/uuid.lib -------------------------------------------------------------------------------- /platform/win/lib/winmm.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/winmm.lib -------------------------------------------------------------------------------- /platform/win/lib/winspool.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/winspool.lib -------------------------------------------------------------------------------- /platform/win/lib/ws2_dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/ws2_dll.lib -------------------------------------------------------------------------------- /platform/win/lib/wsock32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/platform/win/lib/wsock32.lib -------------------------------------------------------------------------------- /platform/win/platform/vars/brush.d: -------------------------------------------------------------------------------- 1 | /* 2 | * brush.d 3 | * 4 | * This module has the structure that is kept with a Brush class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.brush; 12 | 13 | import binding.win32.gdiplusgpstubs; 14 | 15 | struct BrushPlatformVars { 16 | GpBrush* handle; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/condition.d: -------------------------------------------------------------------------------- 1 | /* 2 | * condition.d 3 | * 4 | * This module contains platform specific data for Condition objects. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: December 4th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.condition; 12 | 13 | struct ConditionPlatformVars { 14 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/cui.d: -------------------------------------------------------------------------------- 1 | /* 2 | * cui.d 3 | * 4 | * This module contains state information for a cui app for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: August 17th 2009 8 | * 9 | */ 10 | 11 | module platform.vars.cui; 12 | 13 | import core.definitions; 14 | 15 | import synch.thread; 16 | 17 | import data.queue; 18 | 19 | import platform.win.common; 20 | 21 | struct CuiPlatformVars { 22 | // Window resize thread 23 | Thread t; 24 | 25 | // Standard in and out 26 | HANDLE stdin; 27 | HANDLE stdout; 28 | 29 | // Input state 30 | INPUT_RECORD irInBuf[128]; 31 | 32 | Queue!(CuiEvent) events; 33 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/directory.d: -------------------------------------------------------------------------------- 1 | /* 2 | * directory.d 3 | * 4 | * This module has the structure that is kept with a Directory class for 5 | * Windows. 6 | * 7 | * Author: Dave Wilkinson 8 | * Originated: July 22th, 2009 9 | * 10 | */ 11 | 12 | module platform.vars.directory; 13 | 14 | struct DirectoryPlatformVars { 15 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/file.d: -------------------------------------------------------------------------------- 1 | /* 2 | * file.d 3 | * 4 | * This module has the structure that is kept with a File class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.file; 12 | 13 | import platform.win.common; 14 | 15 | struct FilePlatformVars { 16 | HANDLE f; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/font.d: -------------------------------------------------------------------------------- 1 | /* 2 | * font.d 3 | * 4 | * This module has the structure that is kept with a Font class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.font; 12 | 13 | import binding.win32.gdiplusgpstubs; 14 | 15 | struct FontPlatformVars { 16 | GpFont* handle; 17 | GpFontFamily* family; 18 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/library.d: -------------------------------------------------------------------------------- 1 | /* 2 | * library.d 3 | * 4 | * This module has the structure that is kept with a Library class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.library; 12 | 13 | import platform.win.common; 14 | 15 | struct LibraryPlatformVars { 16 | HMODULE hmodule; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/menu.d: -------------------------------------------------------------------------------- 1 | /* 2 | * menu.d 3 | * 4 | * This module has the structure that is kept with a Menu class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.menu; 12 | 13 | import binding.win32.windef; 14 | 15 | struct MenuPlatformVars { 16 | HMENU hMenu; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/mutex.d: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex.d 3 | * 4 | * This module has the structure that is kept with a Mutex class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.mutex; 12 | 13 | import platform.win.common; 14 | 15 | struct MutexPlatformVars { 16 | CRITICAL_SECTION* _mutex; 17 | 18 | HANDLE _semaphore; 19 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/pen.d: -------------------------------------------------------------------------------- 1 | /* 2 | * pen.d 3 | * 4 | * This module has the structure that is kept with a Pen class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.pen; 12 | 13 | import binding.win32.gdiplusgpstubs; 14 | 15 | struct PenPlatformVars { 16 | int clr; 17 | 18 | GpPen* handle; 19 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/region.d: -------------------------------------------------------------------------------- 1 | /* 2 | * region.d 3 | * 4 | * This module has the structure that is kept with a Region class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.region; 12 | 13 | import platform.win.common; 14 | 15 | struct RegionPlatformVars { 16 | HRGN regionHandle; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/semaphore.d: -------------------------------------------------------------------------------- 1 | /* 2 | * semaphore.d 3 | * 4 | * This module has the structure that is kept with a Semaphore class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.semaphore; 12 | 13 | import platform.win.common; 14 | 15 | struct SemaphorePlatformVars { 16 | HANDLE _semaphore; 17 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/socket.d: -------------------------------------------------------------------------------- 1 | /* 2 | * socket.d 3 | * 4 | * This module has the structure that is kept with a Socket class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.socket; 12 | 13 | import platform.win.common; 14 | 15 | struct SocketPlatformVars { 16 | SOCKET m_skt; 17 | SOCKET m_bind_skt; 18 | DWORD m_thread_id; 19 | ubyte m_recvbuff[2048]; 20 | 21 | static bool inited = false; 22 | static int init_ref = 0; 23 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/thread.d: -------------------------------------------------------------------------------- 1 | /* 2 | * thread.d 3 | * 4 | * This module has the structure that is kept with a Thread class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.thread; 12 | 13 | struct ThreadPlatformVars { 14 | } -------------------------------------------------------------------------------- /platform/win/platform/vars/wave.d: -------------------------------------------------------------------------------- 1 | /* 2 | * wave.d 3 | * 4 | * This module has the structure that is kept with an Audio class for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: July 22th, 2009 8 | * 9 | */ 10 | 11 | module platform.vars.wave; 12 | 13 | import platform.win.common; 14 | 15 | import core.stream; 16 | 17 | import io.audio; 18 | 19 | struct WavePlatformVars { 20 | // Handle to the device 21 | HWAVEOUT waveOut; 22 | WAVEFORMATEX wfx; 23 | 24 | struct BufferNode { 25 | Stream waveBuffer; 26 | WAVEHDR waveHeader; 27 | 28 | bool inUse; 29 | bool isLast; 30 | } 31 | 32 | BufferNode buffers[3]; 33 | 34 | // Semaphore to keep the queue clean 35 | HANDLE queueLock; 36 | HANDLE closeLock; 37 | HANDLE opLock; 38 | 39 | bool isClosed; 40 | bool inited; 41 | 42 | DWORD threadID; 43 | HANDLE thread; 44 | 45 | BufferNode* curQueueNode; 46 | 47 | Audio wave; 48 | 49 | HANDLE event; 50 | HANDLE resumeEvent; 51 | //_WaveThread waveThread; 52 | } -------------------------------------------------------------------------------- /platform/win/scaffold/color.d: -------------------------------------------------------------------------------- 1 | /* 2 | * color.d 3 | * 4 | * This file implements the Scaffold for platform specific Color for Windows. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module scaffold.color; 11 | 12 | import platform.win.common; 13 | import platform.win.main; 14 | 15 | import core.color; 16 | import core.definitions; 17 | 18 | void ColorGetSystemColor(ref Color clr, SystemColor sysColorIndex) 19 | { 20 | switch (sysColorIndex) 21 | { 22 | case SystemColor.Window: 23 | uint clrInt = GetSysColor(15); 24 | double r, g, b; 25 | clr.red = r / 255.0; 26 | clr.blue = b / 255.0; 27 | clr.green = g / 255.0; 28 | clr.alpha = 1.0; 29 | break; 30 | default: break; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /platform/win/widget.d: -------------------------------------------------------------------------------- 1 | /* 2 | * widget.d 3 | * 4 | * This file holds the WinWidget interface that must be a part of an OSWidget. 5 | * 6 | * Author: Dave Wilkinson 7 | * 8 | */ 9 | 10 | module platform.win.widget; 11 | 12 | import platform.win.common; 13 | 14 | import graphics.view; 15 | 16 | // os control interface 17 | 18 | interface WinWidget { 19 | protected: 20 | LRESULT _AppLoopMessage(uint message, WPARAM wParam, LPARAM lParam); 21 | View _ReturnView(out int x, out int y, out int w, out int h); 22 | HDC _GetDC(); 23 | } 24 | 25 | HDC GetBaseDC(WinWidget ctrl) { 26 | return ctrl._GetDC; 27 | } 28 | 29 | LRESULT CallAppLoopMessage(WinWidget ctrl, uint message, WPARAM wParam, LPARAM lParam) { 30 | return ctrl._AppLoopMessage(message, wParam, lParam); 31 | } 32 | 33 | View CallReturnView(WinWidget ctrl, out int x, out int y, out int w, out int h) { 34 | return ctrl._ReturnView(x,y,w,h); 35 | } -------------------------------------------------------------------------------- /runtime/classinfo.d: -------------------------------------------------------------------------------- 1 | module runtime.classinfo; 2 | 3 | import core.string; 4 | import core.definitions; 5 | 6 | // Description: The information stored for a class. Retrieved via the .classinfo property. 7 | // It is stored as the first entry in the class' vtbl[]. 8 | class ClassInfo { 9 | byte[] init; 10 | 11 | string name; 12 | void*[] vtbl; 13 | 14 | Interface[] interfaces; 15 | 16 | ClassInfo base; 17 | void function() destructor; 18 | void function(Object) classInvariant; 19 | 20 | uint flags; 21 | void function() deallocator; 22 | OffsetTypeInfo[] offTi; 23 | 24 | Object function() defaultConstructor; 25 | 26 | TypeInfo typeinfo; 27 | 28 | static ClassInfo find(string classname) { 29 | // Loop through every module 30 | // Then loop through every class 31 | // Trying to find the class 32 | return null; 33 | } 34 | 35 | Object create() { 36 | // Class factory 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/classinvariant.d: -------------------------------------------------------------------------------- 1 | /* 2 | * classinvariant.d 3 | * 4 | * This module implements the runtime calls that will execute invariant blocks 5 | * (contracts) within class definitions. 6 | * 7 | */ 8 | 9 | module runtime.classinvariant; 10 | 11 | extern(C): 12 | 13 | void _d_invariant(Object o) { 14 | // Make sure o is defined. 15 | assert(o !is null); 16 | 17 | // Get the main ClassInfo for o 18 | ClassInfo c = o.classinfo; 19 | 20 | do { 21 | // If the class has an invariant defined, execute it 22 | if(c.classInvariant !is null) { 23 | (*c.classInvariant)(o); 24 | } 25 | 26 | // Go up class hierarchy, return the next ClassInfo 27 | c = c.base; 28 | } while(c !is null) 29 | } 30 | -------------------------------------------------------------------------------- /runtime/common.d: -------------------------------------------------------------------------------- 1 | /* 2 | * common.d 3 | * 4 | * This module contains any common definitions. 5 | * 6 | */ 7 | 8 | module runtime.common; 9 | 10 | extern(C): 11 | 12 | package { 13 | struct aaA { 14 | aaA* left; 15 | aaA* right; 16 | hash_t hash; 17 | /* key */ 18 | /* value */ 19 | } 20 | 21 | struct BB { 22 | aaA*[] b; 23 | size_t nodes; 24 | } 25 | 26 | struct AA { 27 | BB* a; 28 | } 29 | 30 | enum BlkAttr : uint { 31 | FINALIZE = 0b0000_0001, 32 | NO_SCAN = 0b0000_0010, 33 | NO_MOVE = 0b0000_0100, 34 | ALL_BITS = 0b1111_1111 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /runtime/entry.d: -------------------------------------------------------------------------------- 1 | /* 2 | * entry.d 3 | * 4 | * The entry point to an app. 5 | * 6 | */ 7 | 8 | import user.syscall; 9 | 10 | // Will be linked to the user's main function 11 | int main(char[][]); 12 | 13 | extern(C) ubyte _bss; 14 | extern(C) ubyte _ebss; 15 | extern(C) ubyte _edata; 16 | extern(C) ubyte _end; 17 | 18 | extern(C) void _start() { 19 | // Zero the bss 20 | 21 | asm { 22 | pushq 0; 23 | } 24 | 25 | ubyte* startBSS = &_edata; 26 | ubyte* endBSS = &_end; 27 | 28 | for( ; startBSS != endBSS; startBSS++) { 29 | *startBSS = 0x00; 30 | } 31 | 32 | main(null); 33 | 34 | exit(0); 35 | } 36 | -------------------------------------------------------------------------------- /runtime/error.d: -------------------------------------------------------------------------------- 1 | /* 2 | * error.d 3 | * 4 | * This module implements the base class for a non recoverable failure. 5 | * 6 | */ 7 | 8 | module runtime.error; 9 | 10 | import core.definitions; 11 | import core.exception; 12 | 13 | // Description: This is called when an assertion without a message fails. 14 | // file: The file that contains the error. 15 | // line: The line number of the error. 16 | void _d_assert(string file, uint line ) { 17 | throw new RuntimeError.Assert(file,line); 18 | } 19 | 20 | // Description: This is called when an assertion fails with a message. 21 | // msg: The message associated with the assert. 22 | // file: The file that contains the error. 23 | // line: The line number of the error. 24 | void _d_assert_msg(string msg, string file, uint line ) { 25 | throw new RuntimeError.Assert(msg, file, line); 26 | } 27 | 28 | // Description: This is called when an array bounds check fails. 29 | // file: The file that contains the error. 30 | // line: The line number of the error. 31 | void _d_array_bounds(string file, uint line ) { 32 | throw new DataException.OutOfBounds("Array"); 33 | } 34 | 35 | // Description: This is called when there is no valid case for the switch. 36 | // file: The file that contains the error. 37 | // line: The line number of the error. 38 | void _d_switch_error(string file, uint line ) { 39 | throw RuntimeError.NoDefaultCase(file, line); 40 | } 41 | -------------------------------------------------------------------------------- /runtime/exception.d: -------------------------------------------------------------------------------- 1 | /* 2 | * exception.d 3 | * 4 | * This module implements the Exception base class and the runtime functions. 5 | * 6 | */ 7 | 8 | module runtime.exception; 9 | 10 | import core.exception; 11 | 12 | extern(C): 13 | 14 | // Description: This function will carefully throw an out of memory exception. 15 | void onOutOfMemoryError() { 16 | // Throw this without allocation 17 | throw cast(MemoryException.OutOfMemory)cast(void*)MemoryException.OutOfMemory.classinfo.init; 18 | } 19 | 20 | void _d_throw_exception(Object e) { 21 | } 22 | -------------------------------------------------------------------------------- /runtime/main.d: -------------------------------------------------------------------------------- 1 | /* 2 | * main.d 3 | * 4 | * This module provides the C entry into the application. 5 | * 6 | */ 7 | 8 | import runtime.gc; 9 | 10 | // The user supplied D entry 11 | int main(char[][] args); 12 | 13 | // Description: This function is the main entry point of the application. 14 | // argc: The number of arguments 15 | // argv: An array of strings that specify the arguments. 16 | // Returns: The error code for the application. 17 | extern(C) int main(int argc, char** argv) { 18 | // Initialize the garbage collector 19 | gc_init(); 20 | 21 | // Gather arguments 22 | 23 | // Terminate the garbage collector 24 | gc_term(); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /runtime/moduleinfo.d: -------------------------------------------------------------------------------- 1 | module runtime.moduleinfo; 2 | 3 | import core.definitions; 4 | 5 | // Description: This class describes a D module. 6 | class ModuleInfo { 7 | string name; 8 | ModuleInfo[] importedModules; 9 | ClassInfo[] localClasses; 10 | 11 | uint flags; 12 | 13 | void function() ctor; 14 | void function() dtor; 15 | void function() unitTest; 16 | 17 | void* xgetMembers; 18 | void function() ictor; 19 | 20 | static int opApply(int delegate(ref ModuleInfo) loopBody) { 21 | int ret = 0; 22 | 23 | foreach(mod; _modules) { 24 | ret = loopBody(mod); 25 | if(ret) { 26 | break; 27 | } 28 | } 29 | 30 | return ret; 31 | } 32 | 33 | ModuleInfo[] modules { 34 | return _modules.dup; 35 | } 36 | 37 | private: 38 | static ModuleInfo[] _modules; 39 | } 40 | -------------------------------------------------------------------------------- /runtime/monitor.d: -------------------------------------------------------------------------------- 1 | /* 2 | * monitor.d 3 | * 4 | * This module implements the logic to lock objects using the synchronized 5 | * keyword. 6 | * 7 | * Originated: May 8th, 2010 8 | * 9 | */ 10 | 11 | module runtime.monitor; 12 | 13 | extern(C): 14 | 15 | void _d_monitorenter(Object h) { 16 | } 17 | 18 | void _d_monitorexit(Object h) { 19 | } 20 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_bool.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_bool.d 3 | * 4 | * This module implements the TypeInfo for a bool[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_bool; 9 | 10 | import runtime.typeinfo.ti_array_ubyte; 11 | 12 | class TypeInfo_Ab : TypeInfo_Ah { 13 | char[] toString() { 14 | return "bool[]"; 15 | } 16 | 17 | TypeInfo next() { 18 | return typeid(bool); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_byte.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_byte.d 3 | * 4 | * This module implements the TypeInfo for a byte[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_byte; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Ag : ArrayInfo!("byte") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_char.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_char.d 3 | * 4 | * This module implements the TypeInfo for a char[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_char; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Aa : ArrayInfo!("char") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_dchar.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_dchar.d 3 | * 4 | * This module implements the TypeInfo for dchar[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_dchar; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Aw : ArrayInfo!("dchar") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_idouble.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_idouble.d 3 | * 4 | * This module implements the TypeInfo for a idouble[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_idouble; 9 | 10 | import runtime.typeinfo.ti_array_double; 11 | 12 | class TypeInfo_Ap : TypeInfo_Ad { 13 | char[] toString() { 14 | return "idouble[]"; 15 | } 16 | 17 | TypeInfo next() { 18 | return typeid(idouble); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_ifloat.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_ifloat.d 3 | * 4 | * This module implements the TypeInfo for ifloat[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_ifloat; 9 | 10 | import runtime.typeinfo.ti_array_float; 11 | 12 | class TypeInfo_Ao : TypeInfo_Af { 13 | char[] toString() { 14 | return "ifloat[]"; 15 | } 16 | 17 | TypeInfo next() { 18 | return typeid(ifloat); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_int.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_int.d 3 | * 4 | * This module implements the TypeInfo for int[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_int; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Ai : ArrayInfo!("int") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_ireal.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_ireal.d 3 | * 4 | * This module implements the TypeInfo for ireal[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_ireal; 9 | 10 | import runtime.typeinfo.ti_array_real; 11 | 12 | class TypeInfo_Aj : TypeInfo_Ae { 13 | char[] toString() { 14 | return "ireal[]"; 15 | } 16 | 17 | TypeInfo next() { 18 | return typeid(ireal); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_long.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_long.d 3 | * 4 | * This module implements the TypeInfo for long[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_long; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Al : ArrayInfo!("long") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_short.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_short.d 3 | * 4 | * This module implements the TypeInfo for short[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_short; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_As : ArrayInfo!("short") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_ubyte.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_ubyte.d 3 | * 4 | * This module implements the TypeInfo for a ubyte[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_ubyte; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Ah : ArrayInfo!("ubyte") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_uint.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_uint.d 3 | * 4 | * This module implements the TypeInfo for uint[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_uint; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Ak : ArrayInfo!("uint") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_ulong.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_ulong.d 3 | * 4 | * This module implements the TypeInfo for ulong[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_ulong; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Am : ArrayInfo!("ulong") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_ushort.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_ushort.d 3 | * 4 | * This module implements the TypeInfo for ushort[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_ushort; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_At : ArrayInfo!("ushort") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_void.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_void.d 3 | * 4 | * This module implements the TypeInfo for a void[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_void; 9 | 10 | import runtime.typeinfo.ti_array_ubyte; 11 | 12 | class TypeInfo_Av : TypeInfo_Ah { 13 | char[] toString() { 14 | return "void[]"; 15 | } 16 | 17 | TypeInfo next() { 18 | return typeid(void); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_array_wchar.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_array_wchar.d 3 | * 4 | * This module implements the TypeInfo for wchar[] 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_array_wchar; 9 | 10 | import runtime.typeinfo.ti_array; 11 | 12 | class TypeInfo_Au : ArrayInfo!("wchar") { } 13 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_assocarray.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_associativearray.d 3 | * 4 | * This module implements the TypeInfo for associative arrays. 5 | * 6 | */ 7 | 8 | class TypeInfo_AssociativeArray : TypeInfo { 9 | char[] toString() { 10 | return value.toString() ~ "[" ~ key.toString() ~ "]"; 11 | } 12 | 13 | int opEquals(Object o) { 14 | TypeInfo_AssociativeArray c; 15 | 16 | return this is o || 17 | ((c = cast(TypeInfo_AssociativeArray)o) !is null && 18 | this.key == c.key && 19 | this.value == c.value); 20 | } 21 | 22 | // BUG: need to add the rest of the functions 23 | 24 | size_t tsize() { 25 | return (char[int]).sizeof; 26 | } 27 | 28 | TypeInfo next() { 29 | return value; 30 | } 31 | 32 | uint flags() { 33 | return 1; 34 | } 35 | 36 | TypeInfo value; 37 | TypeInfo key; 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_byte.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_byte.d 3 | * 4 | * This module implements the TypeInfo for the byte type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_byte; 9 | 10 | // byte 11 | 12 | class TypeInfo_g : TypeInfo { 13 | char[] toString() { 14 | return "byte"; 15 | } 16 | 17 | hash_t getHash(void *p) { 18 | return *cast(byte *)p; 19 | } 20 | 21 | int equals(void *p1, void *p2) { 22 | return *cast(byte *)p1 == *cast(byte *)p2; 23 | } 24 | 25 | int compare(void *p1, void *p2) { 26 | return *cast(byte *)p1 - *cast(byte *)p2; 27 | } 28 | 29 | size_t tsize() { 30 | return byte.sizeof; 31 | } 32 | 33 | void swap(void *p1, void *p2) { 34 | byte t; 35 | 36 | t = *cast(byte *)p1; 37 | *cast(byte *)p1 = *cast(byte *)p2; 38 | *cast(byte *)p2 = t; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_cdouble.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_cdouble.d 3 | * 4 | * This module implements the TypeInfo for the cdouble type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_cdouble; 9 | 10 | class TypeInfo_r : TypeInfo { 11 | char[] toString() { 12 | return "cdouble"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return (cast(uint *)p)[0] + (cast(uint *)p)[1] + 17 | (cast(uint *)p)[2] + (cast(uint *)p)[3]; 18 | } 19 | 20 | static int _equals(cdouble f1, cdouble f2) { 21 | return f1 == f2; 22 | } 23 | 24 | static int _compare(cdouble f1, cdouble f2) { 25 | int result; 26 | 27 | if (f1.re < f2.re) 28 | result = -1; 29 | else if (f1.re > f2.re) 30 | result = 1; 31 | else if (f1.im < f2.im) 32 | result = -1; 33 | else if (f1.im > f2.im) 34 | result = 1; 35 | else 36 | result = 0; 37 | return result; 38 | } 39 | 40 | int equals(void *p1, void *p2) { 41 | return _equals(*cast(cdouble *)p1, *cast(cdouble *)p2); 42 | } 43 | 44 | int compare(void *p1, void *p2) { 45 | return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 46 | } 47 | 48 | size_t tsize() { 49 | return cdouble.sizeof; 50 | } 51 | 52 | void swap(void *p1, void *p2) { 53 | cdouble t; 54 | 55 | t = *cast(cdouble *)p1; 56 | *cast(cdouble *)p1 = *cast(cdouble *)p2; 57 | *cast(cdouble *)p2 = t; 58 | } 59 | 60 | void[] init() { 61 | static cdouble r; 62 | 63 | return (cast(cdouble *)&r)[0 .. 1]; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_cfloat.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_cfloat.d 3 | * 4 | * This module implements the TypeInfo for the cfloat type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_cfloat; 9 | 10 | class TypeInfo_q : TypeInfo { 11 | char[] toString() { 12 | return "cfloat"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return (cast(uint *)p)[0] + (cast(uint *)p)[1]; 17 | } 18 | 19 | static int _equals(cfloat f1, cfloat f2) { 20 | return f1 == f2; 21 | } 22 | 23 | static int _compare(cfloat f1, cfloat f2) { 24 | int result; 25 | 26 | if (f1.re < f2.re) { 27 | result = -1; 28 | } 29 | else if (f1.re > f2.re) { 30 | result = 1; 31 | } 32 | else if (f1.im < f2.im) { 33 | result = -1; 34 | } 35 | else if (f1.im > f2.im) { 36 | result = 1; 37 | } 38 | else { 39 | result = 0; 40 | } 41 | 42 | return result; 43 | } 44 | 45 | int equals(void *p1, void *p2) { 46 | return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); 47 | } 48 | 49 | int compare(void *p1, void *p2) { 50 | return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 51 | } 52 | 53 | size_t tsize() { 54 | return cfloat.sizeof; 55 | } 56 | 57 | void swap(void *p1, void *p2) { 58 | cfloat t; 59 | 60 | t = *cast(cfloat *)p1; 61 | *cast(cfloat *)p1 = *cast(cfloat *)p2; 62 | *cast(cfloat *)p2 = t; 63 | } 64 | 65 | void[] init() { 66 | static cfloat r; 67 | 68 | return (cast(cfloat *)&r)[0 .. 1]; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_char.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_char.d 3 | * 4 | * This module implements the TypeInfo for the char type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_char; 9 | 10 | class TypeInfo_a : TypeInfo { 11 | char[] toString() { 12 | return "char"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(char *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(char *)p1 == *cast(char *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(char *)p1 - *cast(char *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return char.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | char t; 33 | 34 | t = *cast(char *)p1; 35 | *cast(char *)p1 = *cast(char *)p2; 36 | *cast(char *)p2 = t; 37 | } 38 | 39 | void[] init() { 40 | static char c; 41 | 42 | return (cast(char *)&c)[0 .. 1]; 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_creal.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_creal.d 3 | * 4 | * This module implements the TypeInfo for the creal type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_creal; 9 | 10 | class TypeInfo_c : TypeInfo { 11 | char[] toString() { 12 | return "creal"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return (cast(uint *)p)[0] + (cast(uint *)p)[1] + 17 | (cast(uint *)p)[2] + (cast(uint *)p)[3] + 18 | (cast(uint *)p)[4]; 19 | } 20 | 21 | static int _equals(creal f1, creal f2) { 22 | return f1 == f2; 23 | } 24 | 25 | static int _compare(creal f1, creal f2) { 26 | int result; 27 | 28 | if (f1.re < f2.re) { 29 | result = -1; 30 | } 31 | else if (f1.re > f2.re) { 32 | result = 1; 33 | } 34 | else if (f1.im < f2.im) { 35 | result = -1; 36 | } 37 | else if (f1.im > f2.im) { 38 | result = 1; 39 | } 40 | else { 41 | result = 0; 42 | } 43 | 44 | return result; 45 | } 46 | 47 | int equals(void *p1, void *p2) { 48 | return _equals(*cast(creal *)p1, *cast(creal *)p2); 49 | } 50 | 51 | int compare(void *p1, void *p2) { 52 | return _compare(*cast(creal *)p1, *cast(creal *)p2); 53 | } 54 | 55 | size_t tsize() { 56 | return creal.sizeof; 57 | } 58 | 59 | void swap(void *p1, void *p2) { 60 | creal t; 61 | 62 | t = *cast(creal *)p1; 63 | *cast(creal *)p1 = *cast(creal *)p2; 64 | *cast(creal *)p2 = t; 65 | } 66 | 67 | void[] init() { 68 | static creal r; 69 | 70 | return (cast(creal *)&r)[0 .. 1]; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_dchar.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_dchar.d 3 | * 4 | * This module implements the TypeInfo for the dchar type. 5 | * 6 | */ 7 | 8 | // dchar 9 | 10 | module runtime.d.typeinfo.ti_dchar; 11 | 12 | class TypeInfo_w : TypeInfo { 13 | char[] toString() { 14 | return "dchar"; 15 | } 16 | 17 | hash_t getHash(void *p) { 18 | return *cast(dchar *)p; 19 | } 20 | 21 | int equals(void *p1, void *p2) { 22 | return *cast(dchar *)p1 == *cast(dchar *)p2; 23 | } 24 | 25 | int compare(void *p1, void *p2) { 26 | return *cast(dchar *)p1 - *cast(dchar *)p2; 27 | } 28 | 29 | size_t tsize() { 30 | return dchar.sizeof; 31 | } 32 | 33 | void swap(void *p1, void *p2) { 34 | dchar t; 35 | 36 | t = *cast(dchar *)p1; 37 | *cast(dchar *)p1 = *cast(dchar *)p2; 38 | *cast(dchar *)p2 = t; 39 | } 40 | 41 | void[] init() { 42 | static dchar c; 43 | 44 | return (cast(dchar *)&c)[0 .. 1]; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_delegate.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_delegate.d 3 | * 4 | * This module implements the TypeInfo for the delegate type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_delegate; 9 | 10 | class TypeInfo_Delegate : TypeInfo { 11 | hash_t getHash(void *p) { 12 | long l = *cast(long *)p; 13 | 14 | return cast(uint)(l + (l >> 32)); 15 | } 16 | 17 | int equals(void *p1, void *p2) { 18 | return *cast(dg *)p1 == *cast(dg *)p2; 19 | } 20 | 21 | size_t tsize() { 22 | return dg.sizeof; 23 | } 24 | 25 | void swap(void *p1, void *p2) { 26 | dg t; 27 | 28 | t = *cast(dg *)p1; 29 | *cast(dg *)p1 = *cast(dg *)p2; 30 | *cast(dg *)p2 = t; 31 | } 32 | 33 | uint flags() { 34 | return 1; 35 | } 36 | 37 | private alias void delegate(int) dg; 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_double.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_double.d 3 | * 4 | * This module implements the TypeInfo for the double type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_double; 9 | 10 | import runtime.util; 11 | 12 | class TypeInfo_d : TypeInfo { 13 | char[] toString() { 14 | return "double"; 15 | } 16 | 17 | hash_t getHash(void *p) { 18 | return (cast(uint *)p)[0] + (cast(uint *)p)[1]; 19 | } 20 | 21 | int equals(void *p1, void *p2) { 22 | return _equals(*cast(double *)p1, *cast(double *)p2); 23 | } 24 | 25 | int compare(void *p1, void *p2) 26 | { 27 | return _compare(*cast(double *)p1, *cast(double *)p2); 28 | } 29 | 30 | size_t tsize() { 31 | return double.sizeof; 32 | } 33 | 34 | void swap(void *p1, void *p2) { 35 | double t; 36 | 37 | t = *cast(double *)p1; 38 | *cast(double *)p1 = *cast(double *)p2; 39 | *cast(double *)p2 = t; 40 | } 41 | 42 | void[] init() { 43 | static double r; 44 | 45 | return (cast(double *)&r)[0 .. 1]; 46 | } 47 | 48 | package: 49 | static int _equals(double f1, double f2) { 50 | return f1 == f2 || 51 | (isnan(f1) && isnan(f2)); 52 | } 53 | 54 | static int _compare(double d1, double d2) { 55 | // if either are NaN 56 | if (d1 !<>= d2) { 57 | if (isnan(d1)) { 58 | if (isnan(d2)) { 59 | return 0; 60 | } 61 | return -1; 62 | } 63 | 64 | return 1; 65 | } 66 | return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_enum.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_enum.d 3 | * 4 | * This module implements the TypeInfo of an enum. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_enum; 9 | 10 | import runtime.typeinfo.ti_typedef; 11 | 12 | class TypeInfo_Enum : TypeInfo_Typedef { 13 | } 14 | 15 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_float.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_float.d 3 | * 4 | * This module implements the TypeInfo for the float type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_float; 9 | 10 | import runtime.util; 11 | 12 | class TypeInfo_f : TypeInfo { 13 | char[] toString() { 14 | return "float"; 15 | } 16 | 17 | hash_t getHash(void *p) { 18 | return *cast(uint *)p; 19 | } 20 | int equals(void *p1, void *p2) { 21 | return _equals(*cast(float *)p1, *cast(float *)p2); 22 | } 23 | 24 | int compare(void *p1, void *p2) { 25 | return _compare(*cast(float *)p1, *cast(float *)p2); 26 | } 27 | 28 | size_t tsize() { 29 | return float.sizeof; 30 | } 31 | 32 | void swap(void *p1, void *p2) { 33 | float t; 34 | 35 | t = *cast(float *)p1; 36 | *cast(float *)p1 = *cast(float *)p2; 37 | *cast(float *)p2 = t; 38 | } 39 | 40 | void[] init() { 41 | static float r; 42 | 43 | return (cast(float *)&r)[0 .. 1]; 44 | } 45 | 46 | package: 47 | static int _equals(float f1, float f2) { 48 | return f1 == f2 || (isnan(f1) && isnan(f2)); 49 | } 50 | 51 | static int _compare(float d1, float d2) { 52 | // if either are NaN 53 | if (d1 !<>= d2) { 54 | if (isnan(d1)) { 55 | if (isnan(d2)) { 56 | return 0; 57 | } 58 | return -1; 59 | } 60 | return 1; 61 | } 62 | 63 | if (d1 == d2) { 64 | return 0; 65 | } 66 | else if (d1 < d2) { 67 | return -1; 68 | } 69 | return 1; 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_function.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_function.d 3 | * 4 | * This module implements the TypeInfo for function types. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_function; 9 | 10 | class TypeInfo_Function : TypeInfo { 11 | char[] toString() { 12 | return next.toString() ~ "()"; 13 | } 14 | 15 | int opEquals(Object o) { 16 | TypeInfo_Function c; 17 | 18 | return this is o || 19 | ((c = cast(TypeInfo_Function)o) !is null && 20 | this.next == c.next); 21 | } 22 | 23 | // BUG: need to add the rest of the functions 24 | 25 | size_t tsize() { 26 | return 0; // no size for functions 27 | } 28 | 29 | TypeInfo next; 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_idouble.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_idouble.d 3 | * 4 | * This module implements the TypeInfo for the idouble type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_idouble; 9 | 10 | import runtime.typeinfo.ti_double; 11 | 12 | class TypeInfo_p : TypeInfo_d { 13 | char[] toString() { 14 | return "idouble"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ifloat.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ifloat.d 3 | * 4 | * This module implements the TypeInfo for the ifloat type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ifloat; 9 | 10 | import runtime.typeinfo.ti_float; 11 | 12 | class TypeInfo_o : TypeInfo_f { 13 | char[] toString() { 14 | return "ifloat"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_int.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_int.d 3 | * 4 | * This module implements the TypeInfo for the int type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_int; 9 | 10 | class TypeInfo_i : TypeInfo { 11 | char[] toString() { 12 | return "int"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(uint *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(uint *)p1 == *cast(uint *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | if (*cast(int*) p1 < *cast(int*) p2) { 25 | return -1; 26 | } 27 | else if (*cast(int*) p1 > *cast(int*) p2) { 28 | return 1; 29 | } 30 | return 0; 31 | } 32 | 33 | size_t tsize() { 34 | return int.sizeof; 35 | } 36 | 37 | void swap(void *p1, void *p2) { 38 | int t; 39 | 40 | t = *cast(int *)p1; 41 | *cast(int *)p1 = *cast(int *)p2; 42 | *cast(int *)p2 = t; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_interface.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_interface.d 3 | * 4 | * This module implements the TypeInfo for interfaces. 5 | * 6 | */ 7 | 8 | class TypeInfo_Interface : TypeInfo { 9 | char[] toString() { 10 | return info.name; 11 | } 12 | 13 | int opEquals(Object o) { 14 | TypeInfo_Interface c; 15 | 16 | return this is o || 17 | ((c = cast(TypeInfo_Interface)o) !is null && 18 | this.info.name == c.classinfo.name); 19 | } 20 | 21 | hash_t getHash(void *p) { 22 | Interface* pi = **cast(Interface ***)*cast(void**)p; 23 | Object o = cast(Object)(*cast(void**)p - pi.offset); 24 | assert(o); 25 | return o.toHash(); 26 | } 27 | 28 | int equals(void *p1, void *p2) { 29 | Interface* pi = **cast(Interface ***)*cast(void**)p1; 30 | Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); 31 | pi = **cast(Interface ***)*cast(void**)p2; 32 | Object o2 = cast(Object)(*cast(void**)p2 - pi.offset); 33 | 34 | return o1 == o2 || (o1 && o1.opCmp(o2) == 0); 35 | } 36 | 37 | int compare(void *p1, void *p2) { 38 | Interface* pi = **cast(Interface ***)*cast(void**)p1; 39 | Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); 40 | pi = **cast(Interface ***)*cast(void**)p2; 41 | Object o2 = cast(Object)(*cast(void**)p2 - pi.offset); 42 | int c = 0; 43 | 44 | // Regard null references as always being "less than" 45 | if (o1 != o2) { 46 | if (o1) { 47 | if (!o2) 48 | c = 1; 49 | else 50 | c = o1.opCmp(o2); 51 | } 52 | else 53 | c = -1; 54 | } 55 | return c; 56 | } 57 | 58 | size_t tsize() { 59 | return Object.sizeof; 60 | } 61 | 62 | uint flags() { 63 | return 1; 64 | } 65 | 66 | ClassInfo info; 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ireal.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ireal.d 3 | * 4 | * This module implements the TypeInfo for the ireal type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ireal; 9 | 10 | import runtime.typeinfo.ti_real; 11 | 12 | class TypeInfo_j : TypeInfo_e { 13 | char[] toString() { 14 | return "ireal"; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_long.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_long.d 3 | * 4 | * This module implements the TypeInfo for the long type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_long; 9 | 10 | class TypeInfo_l : TypeInfo { 11 | char[] toString() { 12 | return "long"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(uint *)p + (cast(uint *)p)[1]; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(long *)p1 == *cast(long *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | if (*cast(long *)p1 < *cast(long *)p2) { 25 | return -1; 26 | } 27 | else if (*cast(long *)p1 > *cast(long *)p2) { 28 | return 1; 29 | } 30 | return 0; 31 | } 32 | 33 | size_t tsize() { 34 | return long.sizeof; 35 | } 36 | 37 | void swap(void *p1, void *p2) { 38 | long t; 39 | 40 | t = *cast(long *)p1; 41 | *cast(long *)p1 = *cast(long *)p2; 42 | *cast(long *)p2 = t; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_object.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_object.d 3 | * 4 | * This module implements the TypeInfo for a class reference. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_object; 9 | 10 | class TypeInfo_Class : TypeInfo { 11 | hash_t getHash(void *p) { 12 | Object o = *cast(Object*)p; 13 | assert(o); 14 | return o.toHash(); 15 | } 16 | 17 | int equals(void *p1, void *p2) { 18 | Object o1 = *cast(Object*)p1; 19 | Object o2 = *cast(Object*)p2; 20 | 21 | return o1 == o2; 22 | } 23 | 24 | int compare(void *p1, void *p2) { 25 | Object o1 = *cast(Object*)p1; 26 | Object o2 = *cast(Object*)p2; 27 | int c = 0; 28 | 29 | // Regard null references as always being "less than" 30 | if (!(o1 is o2)) { 31 | if (o1) { 32 | if (!o2) { 33 | c = 1; 34 | } 35 | else { 36 | c = o1.opCmp(o2); 37 | } 38 | } 39 | else { 40 | c = -1; 41 | } 42 | } 43 | 44 | return c; 45 | } 46 | 47 | size_t tsize() { 48 | return Object.sizeof; 49 | } 50 | 51 | uint flags() { 52 | return 1; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ptr.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ptr.d 3 | * 4 | * This module implements the TypeInfo for a pointer type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ptr; 9 | 10 | class TypeInfo_Pointer : TypeInfo { 11 | hash_t getHash(void *p) { 12 | return cast(uint)*cast(void* *)p; 13 | } 14 | 15 | int equals(void *p1, void *p2) { 16 | return *cast(void* *)p1 == *cast(void* *)p2; 17 | } 18 | 19 | int compare(void *p1, void *p2) { 20 | auto c = *cast(void* *)p1 - *cast(void* *)p2; 21 | if (c < 0) { 22 | return -1; 23 | } 24 | else if (c > 0) { 25 | return 1; 26 | } 27 | return 0; 28 | } 29 | 30 | size_t tsize() { 31 | return (void*).sizeof; 32 | } 33 | 34 | void swap(void *p1, void *p2) { 35 | void* t; 36 | 37 | t = *cast(void* *)p1; 38 | *cast(void* *)p1 = *cast(void* *)p2; 39 | *cast(void* *)p2 = t; 40 | } 41 | 42 | uint flags() { 43 | return 1; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_real.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_real.d 3 | * 4 | * This module implements the TypeInfo for the real type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_real; 9 | 10 | import runtime.util; 11 | 12 | class TypeInfo_e : TypeInfo { 13 | char[] toString() { return "real"; } 14 | 15 | hash_t getHash(void *p) { 16 | return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return _equals(*cast(real *)p1, *cast(real *)p2); 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return _compare(*cast(real *)p1, *cast(real *)p2); 25 | } 26 | 27 | size_t tsize() { 28 | return real.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | real t; 33 | 34 | t = *cast(real *)p1; 35 | *cast(real *)p1 = *cast(real *)p2; 36 | *cast(real *)p2 = t; 37 | } 38 | 39 | void[] init() { 40 | static real r; 41 | 42 | return (cast(real *)&r)[0 .. 1]; 43 | } 44 | 45 | package: 46 | static int _equals(real f1, real f2) { 47 | return f1 == f2 || (isnan(f1) && isnan(f2)); 48 | } 49 | 50 | static int _compare(real d1, real d2) { 51 | // if either are NaN 52 | if (d1 !<>= d2) { 53 | if (isnan(d1)) { 54 | if (isnan(d2)) { 55 | return 0; 56 | } 57 | return -1; 58 | } 59 | return 1; 60 | } 61 | return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_short.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_short.d 3 | * 4 | * This module implements the TypeInfo for the short type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_short; 9 | 10 | class TypeInfo_s : TypeInfo { 11 | char[] toString() { 12 | return "short"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(short *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(short *)p1 == *cast(short *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(short *)p1 - *cast(short *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return short.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | short t; 33 | 34 | t = *cast(short *)p1; 35 | *cast(short *)p1 = *cast(short *)p2; 36 | *cast(short *)p2 = t; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_tuple.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_tuple.d 3 | * 4 | * This module implements the TypeInfo for tuple types. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_tuple; 9 | 10 | class TypeInfo_Tuple : TypeInfo { 11 | TypeInfo[] elements; 12 | 13 | char[] toString() { 14 | char[] s; 15 | s = "("; 16 | foreach (i, element; elements) { 17 | if (i) 18 | s ~= ','; 19 | s ~= element.toString(); 20 | } 21 | s ~= ")"; 22 | return s; 23 | } 24 | 25 | int opEquals(Object o) { 26 | if (this is o) 27 | return 1; 28 | 29 | auto t = cast(TypeInfo_Tuple)o; 30 | if (t && elements.length == t.elements.length) { 31 | for (size_t i = 0; i < elements.length; i++) { 32 | if (elements[i] != t.elements[i]) 33 | return 0; 34 | } 35 | return 1; 36 | } 37 | return 0; 38 | } 39 | 40 | hash_t getHash(void *p) { 41 | assert(0); 42 | } 43 | 44 | int equals(void *p1, void *p2) { 45 | assert(0); 46 | } 47 | 48 | int compare(void *p1, void *p2) { 49 | assert(0); 50 | } 51 | 52 | size_t tsize() { 53 | assert(0); 54 | } 55 | 56 | void swap(void *p1, void *p2) { 57 | assert(0); 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_typedef.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_typedef.d 3 | * 4 | * This module implements the TypeInfo for a typedef. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_typedef; 9 | 10 | class TypeInfo_Typedef : TypeInfo { 11 | char[] toString() { return name; } 12 | 13 | int opEquals(Object o) { 14 | TypeInfo_Typedef c; 15 | 16 | return cast(int) 17 | (this is o || 18 | ((c = cast(TypeInfo_Typedef)o) !is null && 19 | this.name == c.name && 20 | this.base == c.base)); 21 | } 22 | 23 | hash_t getHash(void *p) { 24 | return base.getHash(p); 25 | } 26 | 27 | int equals(void *p1, void *p2) { 28 | return base.equals(p1, p2); 29 | } 30 | 31 | int compare(void *p1, void *p2) { 32 | return base.compare(p1, p2); 33 | } 34 | 35 | size_t tsize() { 36 | return base.tsize(); 37 | } 38 | 39 | void swap(void *p1, void *p2) { 40 | return base.swap(p1, p2); 41 | } 42 | 43 | TypeInfo next() { 44 | return base.next(); 45 | } 46 | 47 | uint flags() { 48 | return base.flags(); 49 | } 50 | 51 | void[] init() { 52 | if (m_init.length > 0) { 53 | return m_init; 54 | } 55 | return base.init(); 56 | } 57 | 58 | TypeInfo base; 59 | char[] name; 60 | void[] m_init; 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ubyte.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ubyte.d 3 | * 4 | * This module implements the TypeInfo for the ubyte type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ubyte; 9 | 10 | class TypeInfo_h : TypeInfo { 11 | char[] toString() { 12 | return "ubyte"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(ubyte *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(ubyte *)p1 == *cast(ubyte *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(ubyte *)p1 - *cast(ubyte *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return ubyte.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | ubyte t; 33 | 34 | t = *cast(ubyte *)p1; 35 | *cast(ubyte *)p1 = *cast(ubyte *)p2; 36 | *cast(ubyte *)p2 = t; 37 | } 38 | } 39 | 40 | class TypeInfo_b : TypeInfo_h { 41 | char[] toString() { 42 | return "bool"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_uint.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_uint.d 3 | * 4 | * This module implements the TypeInfo for the uint type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_uint; 9 | 10 | class TypeInfo_k : TypeInfo { 11 | char[] toString() { 12 | return "uint"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(uint *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(uint *)p1 == *cast(uint *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | if (*cast(uint*) p1 < *cast(uint*) p2) { 25 | return -1; 26 | } 27 | else if (*cast(uint*) p1 > *cast(uint*) p2) { 28 | return 1; 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | size_t tsize() { 35 | return uint.sizeof; 36 | } 37 | 38 | void swap(void *p1, void *p2) { 39 | int t; 40 | 41 | t = *cast(uint *)p1; 42 | *cast(uint *)p1 = *cast(uint *)p2; 43 | *cast(uint *)p2 = t; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ulong.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ulong.d 3 | * 4 | * This module implements the TypeInfo for the ulong type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ulong; 9 | 10 | class TypeInfo_m : TypeInfo { 11 | char[] toString() { 12 | return "ulong"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(uint *)p + (cast(uint *)p)[1]; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(ulong *)p1 == *cast(ulong *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | if (*cast(ulong *)p1 < *cast(ulong *)p2) { 25 | return -1; 26 | } 27 | else if (*cast(ulong *)p1 > *cast(ulong *)p2) { 28 | return 1; 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | size_t tsize() { 35 | return ulong.sizeof; 36 | } 37 | 38 | void swap(void *p1, void *p2) { 39 | ulong t; 40 | 41 | t = *cast(ulong *)p1; 42 | *cast(ulong *)p1 = *cast(ulong *)p2; 43 | *cast(ulong *)p2 = t; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_ushort.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_ushort.d 3 | * 4 | * This module implements the TypeInfo for the ushort type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_ushort; 9 | 10 | class TypeInfo_t : TypeInfo { 11 | char[] toString() { 12 | return "ushort"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(ushort *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(ushort *)p1 == *cast(ushort *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(ushort *)p1 - *cast(ushort *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return ushort.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | ushort t; 33 | 34 | t = *cast(ushort *)p1; 35 | *cast(ushort *)p1 = *cast(ushort *)p2; 36 | *cast(ushort *)p2 = t; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_void.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_void.d 3 | * 4 | * This module implements the TypeInfo for the void type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_void; 9 | 10 | class TypeInfo_v : TypeInfo { 11 | char[] toString() { 12 | return "void"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | assert(0); 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(byte *)p1 == *cast(byte *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(byte *)p1 - *cast(byte *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return void.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | byte t; 33 | 34 | t = *cast(byte *)p1; 35 | *cast(byte *)p1 = *cast(byte *)p2; 36 | *cast(byte *)p2 = t; 37 | } 38 | 39 | uint flags() { 40 | return 1; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /runtime/typeinfo/ti_wchar.d: -------------------------------------------------------------------------------- 1 | /* 2 | * ti_wchar.d 3 | * 4 | * This module implements the TypeInfo for the wchar type. 5 | * 6 | */ 7 | 8 | module runtime.typeinfo.ti_wchar; 9 | 10 | class TypeInfo_u : TypeInfo { 11 | char[] toString() { 12 | return "wchar"; 13 | } 14 | 15 | hash_t getHash(void *p) { 16 | return *cast(wchar *)p; 17 | } 18 | 19 | int equals(void *p1, void *p2) { 20 | return *cast(wchar *)p1 == *cast(wchar *)p2; 21 | } 22 | 23 | int compare(void *p1, void *p2) { 24 | return *cast(wchar *)p1 - *cast(wchar *)p2; 25 | } 26 | 27 | size_t tsize() { 28 | return wchar.sizeof; 29 | } 30 | 31 | void swap(void *p1, void *p2) { 32 | wchar t; 33 | 34 | t = *cast(wchar *)p1; 35 | *cast(wchar *)p1 = *cast(wchar *)p2; 36 | *cast(wchar *)p2 = t; 37 | } 38 | 39 | void[] init() { 40 | static wchar c; 41 | 42 | return (cast(wchar *)&c)[0 .. 1]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /runtime/types.d: -------------------------------------------------------------------------------- 1 | /* 2 | * types.d 3 | * 4 | * This module defines common language types. 5 | * 6 | */ 7 | 8 | module runtime.types; 9 | 10 | // Figure out the size of a pointer 11 | static if ((ubyte*).sizeof == 8) { 12 | version = Arch64; 13 | } 14 | else static if ((ubyte*).sizeof == 4) { 15 | version = Arch32; 16 | } 17 | 18 | // Pointer sizes 19 | version(Arch32) { 20 | alias uint size_t; 21 | alias int ptrdiff_t; 22 | alias uint hash_t; 23 | } 24 | else { 25 | alias ulong size_t; 26 | alias long ptrdiff_t; 27 | alias ulong hash_t; 28 | } 29 | 30 | // String types 31 | alias char[] string; 32 | alias wchar[] wstring; 33 | alias dchar[] dstring; 34 | -------------------------------------------------------------------------------- /runtime/unwind.d: -------------------------------------------------------------------------------- 1 | /* 2 | * unwind.d 3 | * 4 | * This module implements the D runtime unwind functions which serve to 5 | * process exceptions and backtraces. 6 | * 7 | */ 8 | 9 | module runtime.unwind; 10 | 11 | import runtime.common; 12 | 13 | extern(C): 14 | 15 | void _d_throw(Object obj) { 16 | } 17 | 18 | -------------------------------------------------------------------------------- /runtime/vararg.d: -------------------------------------------------------------------------------- 1 | /* 2 | * vararg.d 3 | * 4 | * This module is the interface to a variadic function. 5 | * 6 | */ 7 | 8 | module runtime.vararg; 9 | 10 | 11 | -------------------------------------------------------------------------------- /scripting/minid.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/scripting/minid.d -------------------------------------------------------------------------------- /scripting/perl.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/scripting/perl.d -------------------------------------------------------------------------------- /scripting/php.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/scripting/php.d -------------------------------------------------------------------------------- /scripting/python.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/scripting/python.d -------------------------------------------------------------------------------- /scripting/ruby.d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/scripting/ruby.d -------------------------------------------------------------------------------- /spec/itemspecification.d: -------------------------------------------------------------------------------- 1 | /* 2 | * specification.d 3 | * 4 | * This module implements a class that wraps the specification of a particular 5 | * subsection of a module. 6 | * 7 | * Originated: May 6th, 2010 8 | * 9 | */ 10 | 11 | module spec.itemspecification; 12 | 13 | import spec.logic; 14 | 15 | import djehuty; 16 | 17 | class ItemSpecification { 18 | 19 | this(string name) { 20 | _name = name.dup; 21 | } 22 | 23 | string name() { 24 | return _name; 25 | } 26 | 27 | void add(string specification, it function() testBody) { 28 | _tests[specification] = testBody; 29 | } 30 | 31 | // Description: This will test a particular item. 32 | // Returns: When the test is successful, it returns true. It returns false otherwise. 33 | bool test(string name) { 34 | if (!(name in _tests)) { 35 | throw new Exception("Unknown Test"); 36 | } 37 | it ret = _tests[name](); 38 | return ret == it.does; 39 | } 40 | 41 | size_t length() { 42 | return _tests.length; 43 | } 44 | 45 | int opApply(int delegate(ref string) loopBody) { 46 | foreach(test; _tests.keys) { 47 | if (loopBody(test)) { 48 | return 1; 49 | } 50 | } 51 | return 1; 52 | } 53 | 54 | // Description: Print out the specification of the package, which serves as 55 | // documentation for the application. 56 | string toString() { 57 | // Item should do this 58 | // Item should do that 59 | string ret = ""; 60 | 61 | foreach(spec; _tests.keys) { 62 | ret ~= _name ~ " " ~ spec ~ "\n"; 63 | } 64 | 65 | return ret; 66 | } 67 | 68 | private: 69 | 70 | string _name; 71 | 72 | it function()[string] _tests; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /spec/logic.d: -------------------------------------------------------------------------------- 1 | module spec.logic; 2 | 3 | enum it { 4 | does, 5 | doesnt 6 | } 7 | 8 | alias void describe; 9 | alias void done; 10 | -------------------------------------------------------------------------------- /spec/modulespecification.d: -------------------------------------------------------------------------------- 1 | /* 2 | * moduletester.d 3 | * 4 | * This module implements a class that will interface the testing of a module. 5 | * 6 | * Originated: May 6th, 2010 7 | * 8 | */ 9 | 10 | module spec.modulespecification; 11 | 12 | import spec.itemspecification; 13 | 14 | import djehuty; 15 | 16 | import io.console; 17 | 18 | class ModuleSpecification { 19 | this(string name) { 20 | _name = name.dup; 21 | } 22 | 23 | string name() { 24 | return _name; 25 | } 26 | 27 | void add(ItemSpecification item) { 28 | _tests[item.name] = item; 29 | } 30 | 31 | // Description: This function will return a class representing the test 32 | // given by the name. 33 | // name: The name of the test. 34 | // Returns: A class that can be used to run the test. 35 | ItemSpecification retrieve(string name) { 36 | if (!(name in _tests)) { 37 | return null; 38 | } 39 | return _tests[name]; 40 | } 41 | 42 | int opApply(int delegate(ref ItemSpecification) loopBody) { 43 | foreach(test; _tests.keys.sort) { 44 | if (loopBody(_tests[test])) { 45 | return 1; 46 | } 47 | } 48 | return 1; 49 | } 50 | 51 | private: 52 | string _name; 53 | ItemSpecification[string] _tests; 54 | } 55 | -------------------------------------------------------------------------------- /spec/specification.d: -------------------------------------------------------------------------------- 1 | /* 2 | * specification.d 3 | * 4 | * This module facilitates specifying the application. 5 | * 6 | * Originated: May 6th, 2010 7 | * 8 | */ 9 | 10 | module spec.specification; 11 | import spec.packagespecification; 12 | 13 | import djehuty; 14 | 15 | class Specification { 16 | static: 17 | 18 | string name() { 19 | return Djehuty.app.name; 20 | } 21 | 22 | void add(PackageSpecification spec) { 23 | _packages[spec.name] = spec; 24 | } 25 | 26 | PackageSpecification traverse(string name) { 27 | if (!(name in _packages)) { 28 | return null; 29 | } 30 | return _packages[name]; 31 | } 32 | 33 | int opApply(int delegate(ref PackageSpecification) loopBody) { 34 | foreach(pack; _packages.values.sort) { 35 | if (loopBody(pack)) { 36 | return 1; 37 | } 38 | } 39 | return 1; 40 | } 41 | 42 | // Description: Print out the specification, which is documentation of 43 | // the application. 44 | string toString() { 45 | // Package 46 | // Module 47 | // Item should do this 48 | // Item should do that 49 | string ret = ""; 50 | 51 | foreach(pack; _packages.values.sort) { 52 | ret ~= pack.toString(); 53 | } 54 | 55 | return ret; 56 | } 57 | 58 | private: 59 | 60 | PackageSpecification[string] _packages; 61 | } 62 | -------------------------------------------------------------------------------- /spec/support.d: -------------------------------------------------------------------------------- 1 | module testing.support; 2 | 3 | import io.console; 4 | 5 | void should(bool expr) { 6 | } 7 | 8 | void shouldNot(bool expr) { 9 | } 10 | 11 | void shouldThrow() { 12 | } 13 | 14 | void shouldThrow(char[] exceptionMessage) { 15 | } 16 | 17 | alias void describe; 18 | alias void done; 19 | alias void it; 20 | -------------------------------------------------------------------------------- /specs/core/application.ds: -------------------------------------------------------------------------------- 1 | module specs.core.application; 2 | 3 | import testing.support; 4 | import core.application; 5 | 6 | describe application() { 7 | describe creation() { 8 | it should_not_create_inside_another_application { 9 | class MyApplication : Application {} 10 | shouldThrow(); 11 | MyApplication app = new MyApplication(); 12 | } 13 | } 14 | 15 | describe name() { 16 | it should_get_the_name { 17 | should(Djehuty.application().name() == "DjehutyTester"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /specs/core/arguments.ds: -------------------------------------------------------------------------------- 1 | module specs.core.arguments; 2 | 3 | import testing.support; 4 | import core.arguments; 5 | 6 | describe arguments() { 7 | describe creation() { 8 | it should_work_as_expected { 9 | Arguments args = new Arguments(); 10 | shouldNot(args is null); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /specs/core/variant.ds: -------------------------------------------------------------------------------- 1 | module specs.core.variant; 2 | 3 | import testing.support; 4 | 5 | import core.variant; 6 | 7 | describe variant() { 8 | describe initial_state() { 9 | it should_be_null() { 10 | Variant var; 11 | should(var.type == Type.Reference); 12 | should(var.to!(Object) is null); 13 | } 14 | } 15 | 16 | describe assignment() { 17 | it should_handle_integer_literals() { 18 | Variant var = 2; 19 | should(var == 2); 20 | should(var.to!(int) == 2); 21 | } 22 | 23 | it should_handle_reassignment() { 24 | Variant var = 2; 25 | var = 3; 26 | should(var == 3); 27 | var = "foo"; 28 | should(var == "foo"); 29 | } 30 | 31 | it should_handle_object_references() { 32 | Object foo = new Object(); 33 | Variant var = foo; 34 | should(var == foo); 35 | } 36 | 37 | it should_handle_float_literals() { 38 | Variant var = 0.5; 39 | should(var == 0.5); 40 | should(var.to!(float) == 0.5); 41 | } 42 | } 43 | 44 | describe comparison() { 45 | it should_handle_int() { 46 | int a = 2; 47 | Variant var = a; 48 | should(var == a); 49 | should(var == 2); 50 | } 51 | 52 | it should_handle_float() { 53 | float a = 1.23; 54 | Variant var = a; 55 | should(var == a); 56 | } 57 | 58 | it should_handle_string() { 59 | string a = "hello"; 60 | Variant var = a; 61 | should(var == a); 62 | should(var == "hello"); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /specs/hashes/digest.ds: -------------------------------------------------------------------------------- 1 | module specs.hashes.digest; 2 | 3 | import testing.support; 4 | 5 | import hashes.digest; 6 | 7 | describe digest() { 8 | describe creation() { 9 | it should_allow_for_64_bits() { 10 | Digest d = new Digest(0xDEADBEEF, 0x01234567); 11 | string s = d.toString(); 12 | 13 | should(s == "deadbeef01234567"); 14 | } 15 | 16 | it should_allow_for_128_bits() { 17 | Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567); 18 | string s = d.toString(); 19 | 20 | should(s == "deadbeef01234567deadbeef01234567"); 21 | } 22 | 23 | it should_allow_for_160_bits() { 24 | Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF); 25 | string s = d.toString(); 26 | 27 | should(s == "deadbeef01234567deadbeef01234567deadbeef"); 28 | } 29 | 30 | it should_allow_for_192_bits() { 31 | Digest d = new Digest(0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567, 0xDEADBEEF, 0x01234567); 32 | string s = d.toString(); 33 | 34 | should(s == "deadbeef01234567deadbeef01234567deadbeef01234567"); 35 | } 36 | } 37 | 38 | describe comparison() { 39 | it should_work_for_equals_overload() { 40 | Digest d1 = new Digest(0xDEADBEEF); 41 | Digest d2 = new Digest(0x01234567); 42 | Digest d3 = new Digest(0xDEADBEEF); 43 | 44 | should(d1 == d3); 45 | shouldNot(d1 == d2); 46 | } 47 | 48 | it should_work_for_equals_function() { 49 | Digest d1 = new Digest(0xDEADBEEF); 50 | Digest d2 = new Digest(0x01234567); 51 | Digest d3 = new Digest(0xDEADBEEF); 52 | 53 | should(d1.equals(d3)); 54 | shouldNot(d1.equals(d2)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /specs/hashes/md5.ds: -------------------------------------------------------------------------------- 1 | module specs.hashes.md5; 2 | 3 | import testing.support; 4 | 5 | import hashes.md5; 6 | 7 | describe MD5() { 8 | describe hash() { 9 | it should_hash_as_expected_for_string_literals() { 10 | string s = HashMD5.hash("Hashing Hashing Hashing").toString(); 11 | should(s == "7ba85cd90a910d790172b15e895f8e56"); 12 | } 13 | 14 | it should_respect_leading_zeroes() { 15 | // Testing: leading 0s on parts, note that there is a 0 on the 9th value from the left 16 | string s = HashMD5.hash("d").toString(); 17 | should(s == "8277e0910d750195b448797616e091ad"); 18 | } 19 | 20 | it should_work_on_byte_arrays() { 21 | // Testing a classic MD5 Collision 22 | ubyte[] filea = cast(ubyte[])import("testmd5a.bin"); 23 | ubyte[] fileb = cast(ubyte[])import("testmd5b.bin"); 24 | 25 | string a = HashMD5.hash(filea).toString(); 26 | string b = HashMD5.hash(fileb).toString(); 27 | 28 | should(a == b); 29 | should(a == "da5c61e1edc0f18337e46418e48c1290"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /specs/hashes/sha1.ds: -------------------------------------------------------------------------------- 1 | module specs.hashes.sha1; 2 | 3 | import testing.support; 4 | 5 | import hashes.sha1; 6 | 7 | describe SHA1() { 8 | describe hash() { 9 | it should_hash_as_expected_for_string_literals() { 10 | string s = HashSHA1.hash("a").toString(); 11 | should(s == "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"); 12 | } 13 | 14 | it should_hash_the_empty_string() { 15 | string s = HashSHA1.hash("").toString(); 16 | should(s == "da39a3ee5e6b4b0d3255bfef95601890afd80709"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /specs/hashes/sha224.ds: -------------------------------------------------------------------------------- 1 | module specs.hashes.sha224; 2 | 3 | import testing.support; 4 | 5 | import hashes.sha224; 6 | 7 | describe SHA224() { 8 | describe hash() { 9 | it should_hash_as_expected_for_string_literals() { 10 | string s = HashSHA224.hash("a").toString(); 11 | should(s == "abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5"); 12 | } 13 | 14 | it should_hash_the_empty_string() { 15 | string s = HashSHA224.hash("").toString(); 16 | should(s == "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /specs/hashes/sha256.ds: -------------------------------------------------------------------------------- 1 | module specs.hashes.sha256; 2 | 3 | import testing.support; 4 | 5 | import hashes.sha256; 6 | 7 | describe SHA256() { 8 | describe hash() { 9 | it should_hash_as_expected_for_string_literals() { 10 | string s = HashSHA256.hash("a").toString(); 11 | should(s == "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb"); 12 | } 13 | 14 | it should_hash_the_empty_string() { 15 | string s = HashSHA256.hash("").toString(); 16 | should(s == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /specs/runtime/array.ds: -------------------------------------------------------------------------------- 1 | module specs.runtime.array; 2 | 3 | import io.console; 4 | 5 | import math.random; 6 | 7 | describe runtime() { 8 | describe _adCmp() { 9 | it should_handle_empty_arrays() { 10 | int[] empty = []; 11 | shouldNot(empty == [1,2,3]); 12 | } 13 | } 14 | 15 | describe _adSort { 16 | it should_sort_simple_int_arrays { 17 | int[] sorted = [2,1,3].sort; 18 | should(sorted == [1,2,3]); 19 | } 20 | 21 | it should_sort_random_arrays { 22 | int[500] foo; 23 | auto r = new Random(); 24 | 25 | foreach(ref element; foo) { 26 | element = cast(int)r.next(); 27 | } 28 | 29 | foo.sort; 30 | int cur = foo[0]; 31 | foreach(element; foo) { 32 | // Ensure it is ascending 33 | should(element >= cur); 34 | } 35 | } 36 | 37 | it should_sort_simple_double_arrays { 38 | double[] sorted = [0.0, 0.8, 0.4, 0.2, 0.9].sort; 39 | should(sorted == [0.0,0.2,0.4,0.8,0.9]); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /synch/barrier.d: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier.d 3 | * 4 | * This module implements a barrier synchronization object. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: December 4th, 2009 8 | * 9 | */ 10 | 11 | module synch.barrier; 12 | 13 | class Barrier { 14 | this(uint reportsRequired) { 15 | _reportsNeeded = reportsRequired; 16 | } 17 | 18 | // Description: This function will report one task, and if the barrier has received as many reports as the threshold it will return. 19 | void report() { 20 | synchronized(this) { 21 | _reportsIn++; 22 | if (_reportsIn >= _reportsNeeded) { 23 | return; 24 | } 25 | } 26 | 27 | // XXX: Reimplement with a conditional wait 28 | while(_reportsIn >= _reportsNeeded) { 29 | } 30 | } 31 | 32 | protected: 33 | 34 | uint _reportsIn; 35 | uint _reportsNeeded; 36 | } 37 | -------------------------------------------------------------------------------- /synch/condition.d: -------------------------------------------------------------------------------- 1 | /* 2 | * condition.d 3 | * 4 | * This module implements a conditional wait object. 5 | * 6 | * Author: Dave Wilkinson 7 | * Originated: December 4th, 2009 8 | * 9 | */ 10 | 11 | module synch.condition; 12 | 13 | import platform.vars.mutex; 14 | import platform.vars.condition; 15 | 16 | import scaffold.thread; 17 | 18 | import synch.mutex; 19 | 20 | class Condition { 21 | this() { 22 | ConditionInit(_pfvars); 23 | } 24 | 25 | void signal() { 26 | ConditionSignal(_pfvars); 27 | } 28 | 29 | void wait() { 30 | ConditionWait(_pfvars); 31 | } 32 | 33 | package: 34 | 35 | void wait(ref MutexPlatformVars mutexVars) { 36 | ConditionWait(_pfvars, mutexVars); 37 | } 38 | 39 | ConditionPlatformVars _pfvars; 40 | } 41 | 42 | interface Waitable { 43 | Condition waitCondition(); 44 | } -------------------------------------------------------------------------------- /synch/mutex.d: -------------------------------------------------------------------------------- 1 | module synch.mutex; 2 | 3 | import platform.vars.mutex; 4 | 5 | import synch.condition; 6 | 7 | import scaffold.thread; 8 | 9 | // Section: Core/Synchronization 10 | 11 | // Description: This class provides a simple mutex, also known as a binary semaphore. This is provided as a means to manually lock critical sections. It is initially unlocked. 12 | class Mutex { 13 | this() { 14 | MutexInit(_pfvars); 15 | } 16 | 17 | ~this() { 18 | MutexUninit(_pfvars); 19 | } 20 | 21 | // Description: This function will lock the mutex. This could be used to enter a critical section. 22 | void lock() { 23 | MutexLock(_pfvars); 24 | } 25 | 26 | // Description: This function will unlock a locked mutex. This could be used to leave a critical section. 27 | void unlock() { 28 | MutexUnlock(_pfvars); 29 | } 30 | 31 | void lock(uint milliseconds) { 32 | MutexLock(_pfvars, milliseconds); 33 | } 34 | 35 | void wait(Condition cond) { 36 | cond.wait(_pfvars); 37 | } 38 | 39 | void wait(Waitable forObject) { 40 | wait(forObject.waitCondition()); 41 | } 42 | 43 | protected: 44 | 45 | MutexPlatformVars _pfvars; 46 | } 47 | -------------------------------------------------------------------------------- /tests/01 Block Shaped Heart.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/01 Block Shaped Heart.mp3 -------------------------------------------------------------------------------- /tests/58919__mattwasser__coin_up.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/58919__mattwasser__coin_up.aif -------------------------------------------------------------------------------- /tests/Dog_bounces_trampoline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/Dog_bounces_trampoline.gif -------------------------------------------------------------------------------- /tests/Pillow_pins_kitten.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/Pillow_pins_kitten.gif -------------------------------------------------------------------------------- /tests/begin.mp2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/begin.mp2 -------------------------------------------------------------------------------- /tests/fazed.dreamer.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/fazed.dreamer.mp3 -------------------------------------------------------------------------------- /tests/outside.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/outside.gif -------------------------------------------------------------------------------- /tests/sine_220.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/sine_220.wav -------------------------------------------------------------------------------- /tests/sine_440.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/sine_440.mp3 -------------------------------------------------------------------------------- /tests/sine_440.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/sine_440.wav -------------------------------------------------------------------------------- /tests/test.d: -------------------------------------------------------------------------------- 1 | module test.foo; 2 | 3 | import foo; 4 | 5 | pragma(msg); 6 | 7 | int b[][][][][]; 8 | int ((((q))))[][]; 9 | int a; 10 | 11 | enum FooEnum; 12 | enum FooBar { 13 | Member1, 14 | Member2, 15 | } 16 | 17 | struct FooStruct { 18 | struct FooInnerStruct { 19 | } 20 | } 21 | 22 | version(FooBarDeluxe) { 23 | } 24 | 25 | version = ReleaseFoo; 26 | 27 | debug(FooFooBunny) { 28 | } 29 | 30 | debug(FooFooBunnyEars): 31 | 32 | debug { 33 | } 34 | 35 | debug: 36 | 37 | unittest { 38 | } 39 | 40 | class FooClass { 41 | this(...) { 42 | for ( ; 2+3*5 ; ) { 43 | } 44 | } 45 | 46 | ~this() { 47 | } 48 | 49 | this(int a, int b) { 50 | switch("fudge") { 51 | case 4: 52 | goto default; 53 | goto case 3; 54 | goto foo; 55 | case 6: 56 | break; 57 | case 7: 58 | break foo; 59 | default: 60 | continue; 61 | } 62 | return 4; 63 | return; 64 | volatile; 65 | volatile switch(3) { case 4: } 66 | throw null; 67 | pragma(msg); 68 | } 69 | 70 | interface FooBarInterface { 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tests/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/test.png -------------------------------------------------------------------------------- /tests/testmd5a.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/testmd5a.bin -------------------------------------------------------------------------------- /tests/testmd5b.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/testmd5b.bin -------------------------------------------------------------------------------- /tests/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wilkie/djehuty/afaa80514ca0ca07288051cb029f7d77b386aa27/tests/tiles.png -------------------------------------------------------------------------------- /tools/dscribe/main.d: -------------------------------------------------------------------------------- 1 | /* 2 | * dscribe.d 3 | * 4 | * This tool will use the parser to parse source and produce documentation 5 | * 6 | */ 7 | 8 | import console.main; 9 | 10 | import core.main; 11 | import core.string; 12 | import core.unicode; 13 | import core.arguments; 14 | import core.application; 15 | 16 | import tools.dscribe.lexer; 17 | 18 | char[] usage = ` 19 | dscribe rev0 20 | 21 | USAGE: dscribe [-I] -o 22 | EXAMPLE: dscribe -odocs/.`; 23 | 24 | class DScribe : Application { 25 | static this() { new DScribe(); } 26 | 27 | this() { 28 | super("djehuty-dscribe"); 29 | } 30 | 31 | void OnApplicationStart() { 32 | Console.putln(usage); 33 | 34 | lexer = new LexerD(); 35 | 36 | push(lexer); 37 | lexer.work(); 38 | } 39 | 40 | private: 41 | LexerD lexer; 42 | } -------------------------------------------------------------------------------- /winsamp.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 19 | 20 | 21 | --------------------------------------------------------------------------------