diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2021-02-19 17:10:51 -0500 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2021-02-24 16:46:47 -0500 |
commit | 02ca32ae0a5bc290918d2b2a3288e385b9cc6b11 (patch) | |
tree | 06379785e8a0165a7deb981c2eba362894820634 /src/ext_depends/tinyendian | |
parent | build from static source-tree pre fetch depends (diff) |
external & build dependences in src tree
- external & build dependences boost licensed
- ext_depends (external depends)
- D-YAML
- tinyendian
- d2sqlite3
- imageformats
- build_depends
- dub2nix
Diffstat (limited to 'src/ext_depends/tinyendian')
-rw-r--r-- | src/ext_depends/tinyendian/.gitignore | 4 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/.travis.yml | 32 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/LICENSE_1_0.txt | 23 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/README.html | 444 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/README.md | 72 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/appveyor.yml | 121 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/highlight.pack.js | 1 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/index.html | 39 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/search.js | 59 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/show_hide.js | 17 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/style.css | 726 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/tinyendian.html | 117 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/doc/tinyendian/UTFEncoding.html | 46 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/dub.json | 16 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/hmod.cfg | 130 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/meson.build | 41 | ||||
-rw-r--r-- | src/ext_depends/tinyendian/source/tinyendian.d | 213 |
17 files changed, 2101 insertions, 0 deletions
diff --git a/src/ext_depends/tinyendian/.gitignore b/src/ext_depends/tinyendian/.gitignore new file mode 100644 index 0000000..0ed3f58 --- /dev/null +++ b/src/ext_depends/tinyendian/.gitignore @@ -0,0 +1,4 @@ +.dub +*.o +*.a +*.lib diff --git a/src/ext_depends/tinyendian/.travis.yml b/src/ext_depends/tinyendian/.travis.yml new file mode 100644 index 0000000..dd6a172 --- /dev/null +++ b/src/ext_depends/tinyendian/.travis.yml @@ -0,0 +1,32 @@ +dist: xenial +sudo: false + +language: d +os: + - linux + - osx +d: + - dmd + - ldc + +before_install: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install python3-pip python3-setuptools; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pip3 install 'meson==0.48.2'; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ninja; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip3 install 'meson==0.48.2'; fi + +install: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir .ntmp && curl -L https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip -o .ntmp/ninja-linux.zip; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then unzip .ntmp/ninja-linux.zip -d .ntmp; fi + +before_script: + - export PATH=$PATH:$PWD/.ntmp + +script: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then meson build && ninja -C build; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ninja -C build test -v; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) meson build && ninja -C build test; fi + - dub build + - dub test diff --git a/src/ext_depends/tinyendian/LICENSE_1_0.txt b/src/ext_depends/tinyendian/LICENSE_1_0.txt new file mode 100644 index 0000000..36b7cd9 --- /dev/null +++ b/src/ext_depends/tinyendian/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/ext_depends/tinyendian/README.html b/src/ext_depends/tinyendian/README.html new file mode 100644 index 0000000..f267aaf --- /dev/null +++ b/src/ext_depends/tinyendian/README.html @@ -0,0 +1,444 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /> +<title>TinyEndian</title> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; +} + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title, .code .error { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left, .figure.align-left, object.align-left { + clear: left ; + float: left ; + margin-right: 1em } + +img.align-right, .figure.align-right, object.align-right { + clear: right ; + float: right ; + margin-left: 1em } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left } + +.align-center { + clear: both ; + text-align: center } + +.align-right { + text-align: right } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit } + +/* div.align-center * { */ +/* text-align: left } */ + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font: inherit } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em ; + margin-right: 2em } + +pre.code .ln { color: grey; } /* line numbers */ +pre.code, code { background-color: #eeeeee } +pre.code .comment, code .comment { color: #5C6576 } +pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } +pre.code .literal.string, code .literal.string { color: #0C5404 } +pre.code .name.builtin, code .name.builtin { color: #352B84 } +pre.code .deleted, code .deleted { background-color: #DEB0A1} +pre.code .inserted, code .inserted { background-color: #A3D289} + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +/* "booktabs" style (no vertical lines) */ +table.docutils.booktabs { + border: 0px; + border-top: 2px solid; + border-bottom: 2px solid; + border-collapse: collapse; +} +table.docutils.booktabs * { + border: 0px; +} +table.docutils.booktabs th { + border-bottom: thin solid; + text-align: left; +} + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="tinyendian"> +<h1 class="title">TinyEndian</h1> + +<img alt="https://travis-ci.org/kiith-sa/tinyendian.svg?branch=master" src="https://travis-ci.org/kiith-sa/tinyendian.svg?branch=master" /> +<a class="reference external image-reference" href="http://code.dlang.org"><img alt="https://raw.githubusercontent.com/kiith-sa/tinyendian/master/code.dlang.org-shield.png" src="https://raw.githubusercontent.com/kiith-sa/tinyendian/master/code.dlang.org-shield.png" /></a> +<div class="section" id="introduction"> +<h1>Introduction</h1> +<p>TinyEndian is a minimal endianness library for the D programming language. It has no +external dependencies, it only needs a D compiler and Phobos (standard library). +TinyEndian doesn't allocate memory and is fully <strong>@nogc</strong> to allow use in +high-performance code.</p> +<p>The API is not stable and may change in the future.</p> +</div> +<div class="section" id="features"> +<h1>Features</h1> +<ul class="simple"> +<li>Swap byte order of 2- or 4-byte elements in an array in place.</li> +<li>Read a UTF-8, UTF-16 or UTF-32 buffer, determine its endianness using a UTF +byte-order-mark and convert it to system endianness in place.</li> +<li>No external dependencies.</li> +<li>pure, nothrow and @nogc.</li> +</ul> +</div> +<div class="section" id="directory-structure"> +<h1>Directory structure</h1> +<table border="1" class="docutils"> +<colgroup> +<col width="17%" /> +<col width="83%" /> +</colgroup> +<thead valign="bottom"> +<tr><th class="head">Directory</th> +<th class="head">Contents</th> +</tr> +</thead> +<tbody valign="top"> +<tr><td><tt class="docutils literal">./</tt></td> +<td>This README file, license, DUB package file.</td> +</tr> +<tr><td><tt class="docutils literal">./source</tt></td> +<td>Source code.</td> +</tr> +</tbody> +</table> +</div> +<div class="section" id="usage"> +<h1>Usage</h1> +<p>Assuming you use <a class="reference external" href="http://code.dlang.org/about">dub</a>, add this line:</p> +<pre class="literal-block"> +"tinyendian": { "version" : "~>0.1.0" } +</pre> +<p>to the <tt class="docutils literal">"dependencies"</tt> in your project's <tt class="docutils literal">dub.json</tt>.</p> +<p>If you don't use dub, you can directly copy the <tt class="docutils literal">source/tinyendian.d</tt> file into your +project.</p> +<p>TinyEndian requires DMD 2.066 or equivalent GDC/LDC.</p> +<p><a class="reference external" href="http://ddocs.org/tinyendian/latest/index.html">API documentation</a> can be found at +<a class="reference external" href="http://ddocs.org">DDocs.org</a>.</p> +</div> +<div class="section" id="license"> +<h1>License</h1> +<p>TinyEndian is released under the terms of the +<a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License 1.0</a>. +This license allows you to use the source code in your own projects, open source +or proprietary, and to modify it to suit your needs. However, in source +distributions, you have to preserve the license headers in the source code and +the accompanying license file.</p> +<p>Full text of the license can be found in file <tt class="docutils literal">LICENSE_1_0.txt</tt> and is also +displayed here:</p> +<pre class="literal-block"> +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +</pre> +</div> +<div class="section" id="credits"> +<h1>Credits</h1> +<p>TinyEndian was created by Ferdinand Majerech aka Kiith-Sa kiithsacmp[AT]gmail.com .</p> +<p>Parts of code based on the <tt class="docutils literal">std.stream</tt> Phobos module.</p> +<p>D:YAML was created using Vim and DMD Linux Mint as a YAML parsing library for the <a class="reference external" href="http://www.dlang.org">D +programming language</a>.</p> +</div> +</div> +</body> +</html> diff --git a/src/ext_depends/tinyendian/README.md b/src/ext_depends/tinyendian/README.md new file mode 100644 index 0000000..53d48e2 --- /dev/null +++ b/src/ext_depends/tinyendian/README.md @@ -0,0 +1,72 @@ +TinyEndian +========== + +![](https://travis-ci.org/dlang-community/tinyendian.svg?branch=master) ![](https://img.shields.io/dub/v/tinyendian.svg) + +Introduction +------------ + +TinyEndian is a minimal endianness library for the D programming +language. It has no external dependencies, it only needs a D compiler +and Phobos (standard library). TinyEndian doesn't allocate memory and is +fully `@nogc` to allow use in high-performance code. + +The API is not stable and may change in the future. + +Features +-------- + +- Swap byte order of 2- or 4-byte elements in an array in place. +- Read a UTF-8, UTF-16 or UTF-32 buffer, determine its endianness + using a UTF byte-order-mark and convert it to system endianness in + place. +- No external dependencies. +- pure, nothrow and @nogc. + +Directory structure +------------------- + +| Directory | Contents | +|------------|----------------------------------------------| +| `./` | This README file, license, DUB package file. | +| `./source` | Source code. | + +Usage +----- + +Assuming you use [dub](http://code.dlang.org/about), add this line: + + "tinyendian": { "version" : "~>0.2.0" } + +to the `"dependencies"` in your project's `dub.json`. + +If you don't use dub, you can directly copy the `source/tinyendian.d` +file into your project. + +TinyEndian requires DMD 2.067 or better. + +License +------- + +TinyEndian is released under the terms of the Boost Software License +1.0. This license allows you to use the source code in your own +projects, open source or proprietary, and to modify it to suit your +needs. However, in source distributions, you have to preserve the +license headers in the source code and the accompanying license file. + +Full text of the license can be found in file `LICENSE_1_0.txt` and is +also displayed here: + + Boost Software License - Version 1.0 - August 17th, 2003 + + Permission is hereby granted, free of charge, to any person or organization + obtaining a copy of the software and accompanying documentation covered by + this license (the "Software") to use, reproduce, display, distribute, + execute, and transmit the Software, and to prepare derivative works of the + Software, and to permit third-parties to whom the Software is furnished to + do so, all subject to the following: + + The copyright notices in the Software and this entire statement, including + the above license grant, this restriction and the following disclaimer, + + diff --git a/src/ext_depends/tinyendian/appveyor.yml b/src/ext_depends/tinyendian/appveyor.yml new file mode 100644 index 0000000..de7c310 --- /dev/null +++ b/src/ext_depends/tinyendian/appveyor.yml @@ -0,0 +1,121 @@ +platform: x64 +environment: + matrix: + #- DC: dmd + # DVersion: nightly + # arch: x64 + #- DC: dmd + # DVersion: nightly + # arch: x86 + #- DC: dmd + # DVersion: beta + # arch: x64 + #- DC: dmd + # DVersion: beta + # arch: x86 + - DC: dmd + DVersion: stable + arch: x64 + - DC: dmd + DVersion: stable + arch: x86 + #- DC: ldc + # DVersion: beta + # arch: x86 + #- DC: ldc + # DVersion: beta + # arch: x64 + - DC: ldc + DVersion: stable + arch: x86 + - DC: ldc + DVersion: stable + arch: x64 + +skip_tags: false +branches: + only: + - master + +install: + - ps: function ResolveLatestDMD + { + $version = $env:DVersion; + if($version -eq "stable") { + $latest = (Invoke-WebRequest "http://downloads.dlang.org/releases/LATEST").toString(); + $url = "http://downloads.dlang.org/releases/2.x/$($latest)/dmd.$($latest).windows.7z"; + }elseif($version -eq "beta") { + $latest = (Invoke-WebRequest "http://downloads.dlang.org/pre-releases/LATEST").toString(); + $latestVersion = $latest.split("-")[0].split("~")[0]; + $url = "http://downloads.dlang.org/pre-releases/2.x/$($latestVersion)/dmd.$($latest).windows.7z"; + }elseif($version -eq "nightly") { + $url = "http://nightlies.dlang.org/dmd-master-2017-05-20/dmd.master.windows.7z" + }else { + $url = "http://downloads.dlang.org/releases/2.x/$($version)/dmd.$($version).windows.7z"; + } + $env:PATH += ";C:\dmd2\windows\bin;"; + return $url; + } + - ps: function ResolveLatestLDC + { + $version = $env:DVersion; + if($version -eq "stable") { + $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST").toString().replace("`n","").replace("`r",""); + $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip"; + }elseif($version -eq "beta") { + $latest = (Invoke-WebRequest "https://ldc-developers.github.io/LATEST_BETA").toString().replace("`n","").replace("`r",""); + $url = "https://github.com/ldc-developers/ldc/releases/download/v$($latest)/ldc2-$($latest)-win64-msvc.zip"; + } else { + $latest = $version; + $url = "https://github.com/ldc-developers/ldc/releases/download/v$($version)/ldc2-$($version)-win64-msvc.zip"; + } + $env:PATH += ";C:\ldc2-$($latest)-win64-msvc\bin"; + $env:DC = "ldc2"; + return $url; + } + - ps: function SetUpDCompiler + { + $env:toolchain = "msvc"; + if($env:DC -eq "dmd"){ + echo "downloading ..."; + $url = ResolveLatestDMD; + echo $url; + Invoke-WebRequest $url -OutFile "c:\dmd.7z"; + echo "finished."; + pushd c:\\; + 7z x dmd.7z > $null; + popd; + } + elseif($env:DC -eq "ldc"){ + echo "downloading ..."; + $url = ResolveLatestLDC; + echo $url; + Invoke-WebRequest $url -OutFile "c:\ldc.zip"; + echo "finished."; + pushd c:\\; + 7z x ldc.zip > $null; + popd; + } + } + - ps: SetUpDCompiler + +build_script: + - ps: if($env:arch -eq "x86"){ + $env:compilersetupargs = "x86"; + $env:Darch = "x86"; + $env:DConf = "m32"; + }elseif($env:arch -eq "x64"){ + $env:compilersetupargs = "amd64"; + $env:Darch = "x86_64"; + $env:DConf = "m64"; + } + - ps: $env:compilersetup = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall"; + - '"%compilersetup%" %compilersetupargs%' + +test_script: + - echo %PLATFORM% + - echo %Darch% + - echo %DC% + - echo %PATH% + - '%DC% --version' + - dub test --arch=%Darch% --compiler=%DC% diff --git a/src/ext_depends/tinyendian/doc/highlight.pack.js b/src/ext_depends/tinyendian/doc/highlight.pack.js new file mode 100644 index 0000000..d45d419 --- /dev/null +++ b/src/ext_depends/tinyendian/doc/highlight.pack.js @@ -0,0 +1 @@ +var hljs=new function(){function k(v){return v.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function t(v){return v.nodeName.toLowerCase()}function i(w,x){var v=w&&w.exec(x);return v&&v.index==0}function d(v){return Array.prototype.map.call(v.childNodes,function(w){if(w.nodeType==3){return b.useBR?w.nodeValue.replace(/\n/g,""):w.nodeValue}if(t(w)=="br"){return"\n"}return d(w)}).join("")}function r(w){var v=(w.className+" "+(w.parentNode?w.parentNode.className:"")).split(/\s+/);v=v.map(function(x){return x.replace(/^language-/,"")});return v.filter(function(x){return j(x)||x=="no-highlight"})[0]}function o(x,y){var v={};for(var w in x){v[w]=x[w]}if(y){for(var w in y){v[w]=y[w]}}return v}function u(x){var v=[];(function w(y,z){for(var A=y.firstChild;A;A=A.nextSibling){if(A.nodeType==3){z+=A.nodeValue.length}else{if(t(A)=="br"){z+=1}else{if(A.nodeType==1){v.push({event:"start",offset:z,node:A});z=w(A,z);v.push({event:"stop",offset:z,node:A})}}}}return z})(x,0);return v}function q(w,y,C){var x=0;var F="";var z=[];function B(){if(!w.length||!y.length){return w.length?w:y}if(w[0].offset!=y[0].offset){return(w[0].offset<y[0].offset)?w:y}return y[0].event=="start"?w:y}function A(H){function G(I){return" "+I.nodeName+'="'+k(I.value)+'"'}F+="<"+t(H)+Array.prototype.map.call(H.attributes,G).join("")+">"}function E(G){F+="</"+t(G)+">"}function v(G){(G.event=="start"?A:E)(G.node)}while(w.length||y.length){var D=B();F+=k(C.substr(x,D[0].offset-x));x=D[0].offset;if(D==w){z.reverse().forEach(E);do{v(D.splice(0,1)[0]);D=B()}while(D==w&&D.length&&D[0].offset==x);z.reverse().forEach(A)}else{if(D[0].event=="start"){z.push(D[0].node)}else{z.pop()}v(D.splice(0,1)[0])}}return F+k(C.substr(x))}function m(y){function v(z){return(z&&z.source)||z}function w(A,z){return RegExp(v(A),"m"+(y.cI?"i":"")+(z?"g":""))}function x(D,C){if(D.compiled){return}D.compiled=true;D.k=D.k||D.bK;if(D.k){var z={};function E(G,F){if(y.cI){F=F.toLowerCase()}F.split(" ").forEach(function(H){var I=H.split("|");z[I[0]]=[G,I[1]?Number(I[1]):1]})}if(typeof D.k=="string"){E("keyword",D.k)}else{Object.keys(D.k).forEach(function(F){E(F,D.k[F])})}D.k=z}D.lR=w(D.l||/\b[A-Za-z0-9_]+\b/,true);if(C){if(D.bK){D.b=D.bK.split(" ").join("|")}if(!D.b){D.b=/\B|\b/}D.bR=w(D.b);if(!D.e&&!D.eW){D.e=/\B|\b/}if(D.e){D.eR=w(D.e)}D.tE=v(D.e)||"";if(D.eW&&C.tE){D.tE+=(D.e?"|":"")+C.tE}}if(D.i){D.iR=w(D.i)}if(D.r===undefined){D.r=1}if(!D.c){D.c=[]}var B=[];D.c.forEach(function(F){if(F.v){F.v.forEach(function(G){B.push(o(F,G))})}else{B.push(F=="self"?D:F)}});D.c=B;D.c.forEach(function(F){x(F,D)});if(D.starts){x(D.starts,C)}var A=D.c.map(function(F){return F.bK?"\\.?\\b("+F.b+")\\b\\.?":F.b}).concat([D.tE]).concat([D.i]).map(v).filter(Boolean);D.t=A.length?w(A.join("|"),true):{exec:function(F){return null}};D.continuation={}}x(y)}function c(S,L,J,R){function v(U,V){for(var T=0;T<V.c.length;T++){if(i(V.c[T].bR,U)){return V.c[T]}}}function z(U,T){if(i(U.eR,T)){return U}if(U.eW){return z(U.parent,T)}}function A(T,U){return !J&&i(U.iR,T)}function E(V,T){var U=M.cI?T[0].toLowerCase():T[0];return V.k.hasOwnProperty(U)&&V.k[U]}function w(Z,X,W,V){var T=V?"":b.classPrefix,U='<span class="'+T,Y=W?"":"</span>";U+=Z+'">';return U+X+Y}function N(){var U=k(C);if(!I.k){return U}var T="";var X=0;I.lR.lastIndex=0;var V=I.lR.exec(U);while(V){T+=U.substr(X,V.index-X);var W=E(I,V);if(W){H+=W[1];T+=w(W[0],V[0])}else{T+=V[0]}X=I.lR.lastIndex;V=I.lR.exec(U)}return T+U.substr(X)}function F(){if(I.sL&&!f[I.sL]){return k(C)}var T=I.sL?c(I.sL,C,true,I.continuation.top):g(C);if(I.r>0){H+=T.r}if(I.subLanguageMode=="continuous"){I.continuation.top=T.top}return w(T.language,T.value,false,true)}function Q(){return I.sL!==undefined?F():N()}function P(V,U){var T=V.cN?w(V.cN,"",true):"";if(V.rB){D+=T;C=""}else{if(V.eB){D+=k(U)+T;C=""}else{D+=T;C=U}}I=Object.create(V,{parent:{value:I}})}function G(T,X){C+=T;if(X===undefined){D+=Q();return 0}var V=v(X,I);if(V){D+=Q();P(V,X);return V.rB?0:X.length}var W=z(I,X);if(W){var U=I;if(!(U.rE||U.eE)){C+=X}D+=Q();do{if(I.cN){D+="</span>"}H+=I.r;I=I.parent}while(I!=W.parent);if(U.eE){D+=k(X)}C="";if(W.starts){P(W.starts,"")}return U.rE?0:X.length}if(A(X,I)){throw new Error('Illegal lexeme "'+X+'" for mode "'+(I.cN||"<unnamed>")+'"')}C+=X;return X.length||1}var M=j(S);if(!M){throw new Error('Unknown language: "'+S+'"')}m(M);var I=R||M;var D="";for(var K=I;K!=M;K=K.parent){if(K.cN){D=w(K.cN,D,true)}}var C="";var H=0;try{var B,y,x=0;while(true){I.t.lastIndex=x;B=I.t.exec(L);if(!B){break}y=G(L.substr(x,B.index-x),B[0]);x=B.index+y}G(L.substr(x));for(var K=I;K.parent;K=K.parent){if(K.cN){D+="</span>"}}return{r:H,value:D,language:S,top:I}}catch(O){if(O.message.indexOf("Illegal")!=-1){return{r:0,value:k(L)}}else{throw O}}}function g(y,x){x=x||b.languages||Object.keys(f);var v={r:0,value:k(y)};var w=v;x.forEach(function(z){if(!j(z)){return}var A=c(z,y,false);A.language=z;if(A.r>w.r){w=A}if(A.r>v.r){w=v;v=A}});if(w.language){v.second_best=w}return v}function h(v){if(b.tabReplace){v=v.replace(/^((<[^>]+>|\t)+)/gm,function(w,z,y,x){return z.replace(/\t/g,b.tabReplace)})}if(b.useBR){v=v.replace(/\n/g,"<br>")}return v}function p(z){var y=d(z);var A=r(z);if(A=="no-highlight"){return}var v=A?c(A,y,true):g(y);var w=u(z);if(w.length){var x=document.createElementNS("http://www.w3.org/1999/xhtml","pre");x.innerHTML=v.value;v.value=q(w,u(x),y)}v.value=h(v.value);z.innerHTML=v.value;z.className+=" hljs "+(!A&&v.language||"");z.result={language:v.language,re:v.r};if(v.second_best){z.second_best={language:v.second_best.language,re:v.second_best.r}}}var b={classPrefix:"hljs-",tabReplace:null,useBR:false,languages:undefined};function s(v){b=o(b,v)}function l(){if(l.called){return}l.called=true;var v=document.querySelectorAll("pre code");Array.prototype.forEach.call(v,p)}function a(){addEventListener("DOMContentLoaded",l,false);addEventListener("load",l,false)}var f={};var n={};function e(v,x){var w=f[v]=x(this);if(w.aliases){w.aliases.forEach(function(y){n[y]=v})}}function j(v){return f[v]||f[n[v]]}this.highlight=c;this.highlightAuto=g;this.fixMarkup=h;this.highlightBlock=p;this.configure=s;this.initHighlighting=l;this.initHighlightingOnLoad=a;this.registerLanguage=e;this.getLanguage=j;this.inherit=o;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE]};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE]};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.REGEXP_MODE={cN:"regexp",b:/\//,e:/\/[gim]*/,i:/\n/,c:[this.BE,{b:/\[/,e:/\]/,r:0,c:[this.BE]}]};this.TM={cN:"title",b:this.IR,r:0};this.UTM={cN:"title",b:this.UIR,r:0}}();hljs.registerLanguage("d",function(x){var b={keyword:"abstract alias align asm assert auto body break byte case cast catch class const continue debug default delete deprecated do else enum export extern final finally for foreach foreach_reverse|10 goto if immutable import in inout int interface invariant is lazy macro mixin module new nothrow out override package pragma private protected public pure ref return scope shared static struct super switch synchronized template this throw try typedef typeid typeof union unittest version void volatile while with __FILE__ __LINE__ __gshared|10 __thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__",built_in:"bool cdouble cent cfloat char creal dchar delegate double dstring float function idouble ifloat ireal long real short size_t string ubyte ucent uint ulong ushort wchar wstring",literal:"false null true"};var c="(0|[1-9][\\d_]*)",q="(0|[1-9][\\d_]*|\\d[\\d_]*|[\\d_]+?\\d)",h="0[bB][01_]+",v="([\\da-fA-F][\\da-fA-F_]*|_[\\da-fA-F][\\da-fA-F_]*)",y="0[xX]"+v,p="([eE][+-]?"+q+")",o="("+q+"(\\.\\d*|"+p+")|\\d+\\."+q+q+"|\\."+c+p+"?)",k="(0[xX]("+v+"\\."+v+"|\\.?"+v+")[pP][+-]?"+q+")",l="("+c+"|"+h+"|"+y+")",n="("+k+"|"+o+")";var z="\\\\(['\"\\?\\\\abfnrtv]|u[\\dA-Fa-f]{4}|[0-7]{1,3}|x[\\dA-Fa-f]{2}|U[\\dA-Fa-f]{8})|&[a-zA-Z\\d]{2,};";var m={cN:"number",b:"\\b"+l+"(L|u|U|Lu|LU|uL|UL)?",r:0};var j={cN:"number",b:"\\b("+n+"([fF]|L|i|[fF]i|Li)?|"+l+"(i|[fF]i|Li))",r:0};var s={cN:"string",b:"'("+z+"|.)",e:"'",i:"."};var r={b:z,r:0};var w={cN:"string",b:'"',c:[r],e:'"[cwd]?'};var f={cN:"string",b:'[rq]"',e:'"[cwd]?',r:5};var u={cN:"string",b:"`",e:"`[cwd]?"};var i={cN:"string",b:'x"[\\da-fA-F\\s\\n\\r]*"[cwd]?',r:10};var t={cN:"string",b:'q"\\{',e:'\\}"'};var e={cN:"shebang",b:"^#!",e:"$",r:5};var g={cN:"preprocessor",b:"#(line)",e:"$",r:5};var d={cN:"keyword",b:"@[a-zA-Z_][a-zA-Z_\\d]*"};var a={cN:"comment",b:"\\/\\+",c:["self"],e:"\\+\\/",r:10};return{l:x.UIR,k:b,c:[x.CLCM,x.CBLCLM,a,i,w,f,u,t,j,m,s,e,g,d]}}); diff --git a/src/ext_depends/tinyendian/doc/index.html b/src/ext_depends/tinyendian/doc/index.html new file mode 100644 index 0000000..cd513a4 --- /dev/null +++ b/src/ext_depends/tinyendian/doc/index.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"/> +<link rel="stylesheet" type="text/css" href="style.css"/> +<script src="highlight.pack.js"></script> +<title>Index</title> +<base href=""/> +<script src="search.js"></script> +<script src="show_hide.js"></script> +</head> +<body> +<div class="main"> +<div class="breadcrumbs"> +<table id="results"></table> +<a href="index.html" class="home">⌂</a><input type="search" id="search" placeholder="Search" onkeyup="searchSubmit(this.value, event)"/> +tinyendian : Main Page +</div> +<div class="sidebar"> +<a href=".html#hide-toc" class="hide" id="hide-toc">«</a> +<a href=".html#show-toc" class="show" id="show-toc">»</a> +<div id="toc-id" class="toc"> +<ul><li><a href="tinyendian.html">tinyendian</a></li> + +</ul> +</div></div> +<div class="content"> +<table class="module-list"> +<tr><td class="module-name"><a href="tinyendian.html">tinyendian</a></td><td><p>A minimal library providing functionality for changing the endianness of data. +</p> +</td></tr> + +</div> +<footer> +Generated with <a href="https://github.com/kiith-sa/harbored-mod">harbored-mod</a> +</footer> +</div> +</body> +</html> diff --git a/src/ext_depends/tinyendian/doc/search.js b/src/ext_depends/tinyendian/doc/search.js new file mode 100644 index 0000000..89a7b15 --- /dev/null +++ b/src/ext_depends/tinyendian/doc/search.js @@ -0,0 +1,59 @@ +"use strict"; +var items = [ +{"tinyendian" : "tinyendian.html"}, +{"tinyendian.UTFEncoding" : "tinyendian/UTFEncoding.html"}, +{"tinyendian.swapByteOrder" : "tinyendian.html#swapByteOrder"}, +{"tinyendian.fixUTFByteOrder" : "tinyendian.html#fixUTFByteOrder"}, +]; +function search(str) { + var re = new RegExp(str.toLowerCase()); + var ret = {}; + for (var i = 0; i < items.length; i++) { + var k = Object.keys(items[i])[0]; + if (re.test(k.toLowerCase())) + ret[k] = items[i][k]; + } + return ret; +} + +function searchSubmit(value, event) { + console.log("searchSubmit"); + var resultTable = document.getElementById("results"); + while (resultTable.firstChild) + resultTable.removeChild(resultTable.firstChild); + if (value === "" || event.keyCode == 27) { + resultTable.style.display = "none"; + return; + } + resultTable.style.display = "block"; + var results = search(value); + var keys = Object.keys(results); + if (keys.length === 0) { + var row = resultTable.insertRow(); + var td = document.createElement("td"); + var node = document.createTextNode("No results"); + td.appendChild(node); + row.appendChild(td); + return; + } + for (var i = 0; i < keys.length; i++) { + var k = keys[i]; + var v = results[keys[i]]; + var link = document.createElement("a"); + link.href = v; + link.textContent = k; + link.attributes.id = "link" + i; + var row = resultTable.insertRow(); + row.appendChild(link); + } +} + +function hideSearchResults(event) { + if (event.keyCode != 27) + return; + var resultTable = document.getElementById("results"); + while (resultTable.firstChild) + resultTable.removeChild(resultTable.firstChild); + resultTable.style.display = "none"; +} + diff --git a/src/ext_depends/tinyendian/doc/show_hide.js b/src/ext_depends/tinyendian/doc/show_hide.js new file mode 100644 index 0000000..ab7a50c --- /dev/null +++ b/src/ext_depends/tinyendian/doc/show_hide.js @@ -0,0 +1,17 @@ +window.onload = function(e) +{ + var elems = document.querySelectorAll( "div.toc ul ul" ); + for( i in elems ) + { + if( elems[i].style.display != "block" ) + elems[i].style.display = "none"; + } +} + +function show_hide(id) +{ + var elem = document.getElementById( id ); + if( elem.style.display == "block" ) + elem.style.display = "none"; + else elem.style.display = "block"; +} diff --git a/src/ext_depends/tinyendian/doc/style.css b/src/ext_depends/tinyendian/doc/style.css new file mode 100644 index 0000000..769e7d3 --- /dev/null +++ b/src/ext_depends/tinyendian/doc/style.css @@ -0,0 +1,726 @@ +html { + font-family: Verdana, "DejaVu Sans", sans; + margin: 0; + padding: 0; + background-color: #333; + border-left: .2em solid #333; + border-right: .2em solid #333; + min-height: 100%; +} + +body { + margin: 0; + padding: 0; +} + +div.main { + overflow: hidden; + background-color: #F8F8F8; +} + + + +/**** BREADCRUMBS ****/ + +div.breadcrumbs { + color: white; + background-color: #333; + padding: 1.0em 0.5em 0.0em 0.5em; + left: 0; + box-sizing: border-box; + text-align: right; + top: 0; + width: 100%; + height: 48px; + font-size: 95%; + + position: fixed; +} + +div.breadcrumbs a { + color: white; +} + +div.breadcrumbs span.highlight, div.breadcrumbs span a { + color: #DAAF07; +} + +div.breadcrumbs input { + width: 7em; + margin-top: -0.1em; +} + +div.breadcrumbs small { + font-size: 0.8em; +} + +/** narrow screen hacks **/ +@media only screen and (max-width: 1000px) +{ + div.breadcrumbs span, div.breadcrumbs small { + font-size: 80%; + } +} +@media only screen and (max-width: 800px) +{ + div.breadcrumbs small { + display: none; + position: fixed; + } + div.breadcrumbs span { + font-size: 75%; + } +} +@media only screen and (max-width: 600px) +{ + div.breadcrumbs span { + font-size: 65%; + } +} + +div.breadcrumbs a.home { + float: left; + font-weight: bold; + font-size: 200%; + margin: 0 2% 0 0%; + margin-top: -0.3em; + text-decoration: none; +} + +div.breadcrumbs input { + float: left; +} + + +/* anchors need to compensate for the fixed-pos breadcrumbs */ +a.anchor +{ + display: block; + position: relative; + top: -48px; + visibility: hidden; +} + +/** SEARCH RESULTS **/ +#results { + position: absolute; + max-height: 30em; + background-color: #eee; + box-shadow: 0 .25em .25em black; + display: none; + text-align: left; + color: black; + margin-top: 2em; + font-size: 70%; + z-index: 1000; + overflow-y: scroll; +} + +#results a { + color: blue; +} + + +/**** SIDEBAR, TABLE OF CONTENTS ****/ + +div.sidebar { + margin-top: 48px; + float: left; + margin-right: -1px; + border-right: 1px solid #D0D0D0; + background-color: #F8F8F0; +} + + +div.toc { + padding: 1.5em 0.75em 1em 0.5em; + font-size: 0.55em; + line-height: 1.95em; + display:block; +} + +@media only screen and (max-width: 800px) +{ + div.toc { + font-size: 0.5em; + padding: 1.5em 0.4em 1em 0.2em; + } +} + + +/* stuff for showing/hiding the sidebar */ +.hide, .show { + display: block; + float: right; + border-right: 1px solid #D0D0D0; + border-bottom: 1px solid #D0D0D0; + border-left: 1px solid #D0D0D0; + /* to avoid having double border */ + margin-right: -1px; + font-size: 1.1em; + padding: 0 0.6em; +} +a.hide, a.show { + color: #111; + text-decoration: none; +} +.hide { + background-color: #F8F8F8; + border-bottom-left-radius:3px; + border-right: 1px solid #F8F8F8; +} +.show { + background-color: #F8F8F0; + border-bottom-right-radius:3px; + display: none; +} +.hide:target + .show { + display: inline; + position: absolute; +} +.hide:target { + display: none; +} +.hide:target ~ .toc { + display:none; +} + + +div.toc .toc-additional { + border-bottom: 1px dashed #333; + line-height: 1.5em; +} + +div.toc .toc-additional p, div.toc .toc-additional ul { + margin: 0.4em 0; +} + +div.toc ul { + list-style-type: none; + padding-left: 0; + padding-bottom: 0.5em; +} + +div.toc ul ul { + list-style-type: none; + padding-left: 0.5em; +} + + +div.toc a { + color: #111; + font-size: 1.25em; +} + +@media only screen and (max-width: 800px) +{ + div.toc ul ul { + padding-left: 0.2em; + } +} + +div.toc span.package { + cursor: pointer; + line-height: 1.8em; + font-weight: bold; + border: 1px solid rgba(0, 0, 0, 0.12); + border-radius: 2px; + background-color: #F0F0F0; + font-size: 1.25em; + padding: 0 0.2em; + /* counteracts the text movement caused by the padding */ + margin: 0 -0.2em; +} + +div.toc span.package a { + font-size: 1em; +} + +/* Highlight the current module/package */ +div.toc .selected { + border-radius: 2px; + background-color: #DAAF07 !important; + padding: 0.325em 0.2em; + /* counteracts the text movement caused by the padding */ + margin: -0.325em -0.2em; +} + + + +/**** MAIN CONTENT ****/ + +div.content { + margin-top: 48px; + padding: 1.5em; + font-size: 90%; + line-height: 130%; + overflow: hidden; + border-left: 1px solid #D0D0D0; +} +@media only screen and (max-width: 800px) +{ + div.content { + font-size: 82%; + } +} +@media only screen and (max-width: 600px) +{ + div.content { + font-size: 70%; + padding: 1.5em 0.3em 1.5em 0.5em; + } +} + +div.content h2 { + margin: .35em 0 .45em 0; + padding-top: .35em; + font-size: 1.3em; +} + +div.content h3 { + font-size: 1.1em; +} + +div.content tr { + margin: 0; +} + +div.content table { + border-collapse: collapse; + border-bottom: 1px dashed #333; + font-size: 90%; + line-height: 130%; + margin: 1em 0; +} + +div.content td { + border-top: 1px dashed #333; + margin: 0; + padding: .32em; +} + +div.content td:first-child { + text-align: center; +} + +/* prevent function attribs from wrapping, make the cell wider instead */ +div.content td:first-child * { + white-space: nowrap +} + +/* The first markdown-generated paragraph in e.g. Params tables shouldn't add any vertical + * space + */ +div.content td p:first-child { + margin: 0; +} + +div.content p strong { + font-size: 92%; +} + +.paramName { + font-weight: bold; + width: 6em; +} + +div.section { + padding: 0; + margin: 0; +} + + + +/**** EXTRA INFO IN FUNCTION/CLASS/ETC LISTS ****/ + +div.content td .extrainfo{ + display: block; + line-height: 105%; + font-family: monospace; + font-size: 85%; + text-align: center; +} + +.extrainfo div { + display: block; + margin: 0; +} + +.extrainfo .attr-const { color: blueviolet; } +.extrainfo .attr-pure { color: darkslategray; } +.extrainfo .attr-nothrow { color: brown; } +.extrainfo .attr-nogc { color: darkgreen; } +.extrainfo .attr-safe { color: darkblue; } +.extrainfo .attr-trusted { color: firebrick; } +.extrainfo .attr-system { color: darkred; } +.extrainfo .attr-final { color: darkolivegreen; } +.extrainfo .attr-ref { color: fuchsia; } + + +/**** SYMBOLS (not used by the one-file-for-every-variable writer backend) ****/ + +div.aggregate-symbol { + display: flex; + flex-direction: column; + display: -webkit-flex; + -webkit-flex-direction: column; +} + +div.aggregate-symbol div.description { + order: -2; + -webkit-order: -2; +} + +div.aggregate-symbol div.members { + order: -1; + -webkit-order: -1; + padding-bottom: 0.3em; + border-bottom: 10px solid #333; + margin: 1em 0em 1.5em 0em; +} + +div.symbol { + border-radius: 3px; + border: 1px solid #d0d0d0; + padding: 1px 0.4em; + margin: 0.5em 0; +} + +a.anchor:target + div.symbol { + border: 2px solid #DAAF07; + border-radius: 0; + background-color: #F8F8F0; +} + + + +/**** SECTION-SPECIFIC STYLES ****/ + +.section.seealso, .section.note, .section.imports { + font-size: 75%; + line-height: 135%; + /* background-color: #F0F0C0; */ + /* background-color: #DA7F07; */ + /* background-color: #DA8F07; */ + /* background-color: #DA9F07; */ + background-color: #DAAF07; + /* background-color: #EABD08; */ + padding: 1em; + margin-bottom: 0.5em; +} + +.section.seealso h2, .section.note h2 { + display: block; + float: left; + margin: 0 0.7em -0.05em 0em; + padding: 0; + font-size: 1.1em; +} + +.section.imports h2 { + display: inline; + margin: 0.5em 0em; + padding: 0; + font-size: 1.1em; +} + +.section.seealso div.seealso-content, .section.note div.note-content { + display: block; + margin-left: 6.5em; +} + +.section.imports ul { + margin: 0; + list-style-type: none; + padding-left: 1.5em; + + -moz-column-count: 4; + -moz-column-gap: 20px; + -webkit-column-count: 4; + -webkit-column-gap: 20px; + column-count: 4; + column-gap: 20px; +} + +@media only screen and (max-width: 1400px) +{ + .section.imports ul { + -moz-column-count: 3; + -moz-column-gap: 20px; + -webkit-column-count: 3; + -webkit-column-gap: 20px; + column-count: 3; + column-gap: 20px; + } +} + +@media only screen and (max-width: 1100px) +{ + .section.imports ul { + -moz-column-count: 2; + -moz-column-gap: 13px; + -webkit-column-count: 2; + -webkit-column-gap: 13px; + column-count: 2; + column-gap: 13px; + } +} + +@media only screen and (max-width: 800px) +{ + .section.imports ul { + -moz-column-count: 1; + -moz-column-gap: 7px; + -webkit-column-count: 1; + -webkit-column-gap: 7px; + column-count: 1; + column-gap: 7px; + } +} + + +.section.imports ul a { + color: #111; +} + + +.section.seealso *:first-child, .section.note *:first-child { + margin-top: 0em; +} + +.section.seealso ul, .section.note ul { + padding-left: 1.5em; +} + +.section.seealso *:last-child, .section.note *:last-child { + margin-bottom: 0em; +} + +/**** FOOTER ****/ + +footer +{ + text-align: center; + font-size: 60%; + color: white; + background-color: #333; +} + +footer a +{ + color: white; +} + + + +/**** CODE ****/ + +pre { + margin-top: 0.4em; +} + +/* DDoc code examples */ +code { + background-color: #333; + color: #eee; + padding: 0.8em; + border-radius: .1em; + display: block; +} + +code a { + color: white; + text-decoration: none; + border-bottom: 1px dotted #888; +} + +/* hmod/libddoc errors */ +div.error { + color: darkred; +} + +/* Markdown inline code and $(D code) */ +code.prettyprint, .d_inlinecode { + font-family: monospace; + color: #333; + background-color:rgba(0,0,0,0.04); + border-radius: .15em; + border: 1px solid #C0C0C0; + padding: 0.22em; + display: inline; +} + +code.prettyprint a { + color: black; + border-color: #777; +} + +/*do not affect the first <pre>, which is not in a section*/ +div.section pre > code { + margin: .5em; + border-radius: .1em; + padding: 0.8em; +} + +div.section td pre { + margin: 0; + padding: 0; +} + + +div.section td code:not(.prettyprint) { + margin: 0; + padding: 0.6em; +} + +.hljs { + display: block; padding: 1em; + background: #282B2E; + overflow-x: auto; + display: block; +} + +.hljs-keyword, +.hljs-literal, +.hljs-change, +.hljs-winutils, +.hljs-flow, +.lisp .hljs-title, +.clojure .hljs-built_in, +.nginx .hljs-title, +.css .hljs-id, +.tex .hljs-special { + color: #93C763; +} + +.hljs-number { + color: #FFCD22; +} + +.hljs { + color: #E0E2E4; +} + +.css .hljs-tag, +.css .hljs-pseudo { + color: #D0D2B5; +} + +.hljs-attribute, +.hljs .hljs-constant { + color: #668BB0; +} + +.xml .hljs-attribute { + color: #B3B689; +} + +.xml .hljs-tag .hljs-value { + color: #E8E2B7; +} + +.hljs-code, +.hljs-class .hljs-title, +.hljs-header { + color: white; +} + +.hljs-class, +.hljs-hexcolor { + color: #93C763; +} + +.hljs-regexp { + color: #D39745; +} + +.hljs-at_rule, +.hljs-at_rule .hljs-keyword { + color: #A082BD; +} + +.hljs-doctype { + color: #557182; +} + +.hljs-link_url, +.hljs-tag, +.hljs-tag .hljs-title, +.hljs-bullet, +.hljs-subst, +.hljs-emphasis, +.haskell .hljs-type, +.hljs-preprocessor, +.hljs-pragma, +.ruby .hljs-class .hljs-parent, +.hljs-built_in, +.sql .hljs-aggregate, +.django .hljs-template_tag, +.django .hljs-variable, +.smalltalk .hljs-class, +.hljs-javadoc, +.django .hljs-filter .hljs-argument, +.smalltalk .hljs-localvars, +.smalltalk .hljs-array, +.hljs-attr_selector, +.hljs-pseudo, +.hljs-addition, +.hljs-stream, +.hljs-envvar, +.apache .hljs-tag, +.apache .hljs-cbracket, +.tex .hljs-command, +.hljs-prompt { + color: #8CBBAD; +} + +.hljs-string { + color: #EC7600; +} + +.hljs-comment, +.java .hljs-annotation, +.hljs-blockquote, +.hljs-horizontal_rule, +.python .hljs-decorator, +.hljs-template_comment, +.hljs-pi, +.hljs-deletion, +.hljs-shebang, +.apache .hljs-sqbracket, +.tex .hljs-formula { + color: #818E96; +} + +.hljs-keyword, +.hljs-literal, +.css .hljs-id, +.hljs-phpdoc, +.hljs-title, +.hljs-header, +.haskell .hljs-type, +.vbscript .hljs-built_in, +.sql .hljs-aggregate, +.rsl .hljs-built_in, +.smalltalk .hljs-class, +.diff .hljs-header, +.hljs-chunk, +.hljs-winutils, +.bash .hljs-variable, +.apache .hljs-tag, +.tex .hljs-special, +.hljs-request, +.hljs-at_rule .hljs-keyword, +.hljs-status { + font-weight: bold; +} + +.coffeescript .javascript, +.javascript .xml, +.tex .hljs-formula, +.xml .javascript, +.xml .vbscript, +.xml .css, +.xml .hljs-cdata { + opacity: 0.5; +} diff --git a/src/ext_depends/tinyendian/doc/tinyendian.html b/src/ext_depends/tinyendian/doc/tinyendian.html new file mode 100644 index 0000000..be69219 --- /dev/null +++ b/src/ext_depends/tinyendian/doc/tinyendian.html @@ -0,0 +1,117 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"/> +<link rel="stylesheet" type="text/css" href="style.css"/> +<script src="highlight.pack.js"></script> +<title>tinyendian</title> +<base href=""/> +<script src="search.js"></script> +<script src="show_hide.js"></script> +</head> +<body> +<div class="main"> +<div class="breadcrumbs"> +<table id="results"></table> +<a href="index.html" class="home">⌂</a><input type="search" id="search" placeholder="Search" onkeyup="searchSubmit(this.value, event)"/> +<small>tinyendian</small> +</div> +<div class="sidebar"> +<a href="tinyendian.html#hide-toc" class="hide" id="hide-toc">«</a> +<a href="tinyendian.html#show-toc" class="show" id="show-toc">»</a> +<div id="toc-id" class="toc"> +<ul><li><span class=" selected"><a href="tinyendian.html">tinyendian</a></span> +</li> + +</ul> +</div></div> +<div class="content"> +<div class="aggregate-symbol"><a class="anchor" id="swapByteOrder"></a><div class="symbol"><div class="description"><pre><code>public @system pure nothrow @nogc <a href="http://dlang.org/type.html#basic-data-types">void</a> <a href="tinyendian.html#swapByteOrder">swapByteOrder</a>(T)(T[] array) +if([2, 4].canFind(T.sizeof)) +</code></pre> +<div class="section "><p>Swap byte order of items in an array in place. +</p> + + +</div> +<div class="section"><h2>Parameters</h2> +<table class="params"> +<tr class="param"><td class="paramName">T</td><td class="paramDoc"><p>Item type. Must be either 2 or 4 bytes long. +</p> +</td></tr> +<tr class="param"><td class="paramName">array</td><td class="paramDoc"><p>Buffer with values to fix byte order of. +</p> +</td></tr> +</table> +</div> +</div></div><a class="anchor" id="fixUTFByteOrder"></a><div class="symbol"><div class="description"><pre><code>public @system pure nothrow @nogc auto <a href="tinyendian.html#fixUTFByteOrder">fixUTFByteOrder</a>(<a href="http://dlang.org/type.html#basic-data-types">ubyte</a>[] array) +</code></pre> +<div class="section "><p>Convert byte order of an array encoded in UTF(8/16/32) to system endianness in place. +</p> + + +</div> +<div class="section"><p>Uses the UTF byte-order-mark (BOM) to determine UTF encoding. If there is no BOM + at the beginning of array, UTF-8 is assumed (this is compatible with ASCII). The + BOM, if any, will be removed from the buffer. +</p> +<p> If the encoding is determined to be UTF-16 or UTF-32 and there aren't enough bytes + for the last code unit (i.e. if array.length is odd for UTF-16 or not divisible by + 4 for UTF-32), the extra bytes (1 for UTF-16, 1-3 for UTF-32) are stripped. +</p> +<p> Note that this function does <b>not</b> check if the array is a valid UTF string. It + only works with the BOM and 1,2 or 4-byte items. +</p> + + +</div> +<div class="section"><h2>Parameters</h2> +<table class="params"> +<tr class="param"><td class="paramName">array</td><td class="paramDoc"><p>The array with UTF-data. +</p> +</td></tr> +</table> +</div> +<div class="section"><h2>Returns</h2> +<p> A struct with the following members: +</p> +<p> <code class="d_inlinecode">ubyte[] array</code> A slice of the input array containing data in correct + byte order, without BOM and in case of UTF-16/UTF-32, + without stripped bytes, if any. + <code class="d_inlinecode">UTFEncoding encoding</code> Encoding of the result (UTF-8, UTF-16 or UTF-32) + <code class="d_inlinecode">std.system.Endian endian</code> Endianness of the original array. + <code class="d_inlinecode">uint bytesStripped</code> Number of bytes stripped from a UTF-16/UTF-32 array, if + any. This is non-zero only if array.length was not + divisible by 2 or 4 for UTF-16 and UTF-32, respectively. +</p> + + +</div> +<div class="section"><h2>Complexity</h2> +<p> (BIGOH array.length) +</p> + + +</div> +</div></div><div class="description"><div class="section "><p>A minimal library providing functionality for changing the endianness of data. +</p> + + +</div> +</div><div class="section members"><h2>Enums</h2><table><tr><td><a href="tinyendian/UTFEncoding.html">UTFEncoding</a></td><td></td><td><p>Unicode UTF encodings. +</p> +</td></tr></table><h2>Functions</h2><table><tr><td><a href="tinyendian.html#swapByteOrder">swapByteOrder</a><span class="extrainfo"></span></td><td></td><td><p>Swap byte order of items in an array in place. +</p> +</td></tr><tr><td><span class="extrainfo"><span class="attribs"><span class="attr-auto">auto</span></span></span><a href="tinyendian.html#fixUTFByteOrder">fixUTFByteOrder</a><span class="extrainfo"></span></td><td></td><td><p>Convert byte order of an array encoded in UTF(8/16/32) to system endianness in place. +</p> +</td></tr></table> +</div> +</div><script>hljs.initHighlightingOnLoad();</script> + +</div> +<footer> +Generated with <a href="https://github.com/kiith-sa/harbored-mod">harbored-mod</a> +</footer> +</div> +</body> +</html> diff --git a/src/ext_depends/tinyendian/doc/tinyendian/UTFEncoding.html b/src/ext_depends/tinyendian/doc/tinyendian/UTFEncoding.html new file mode 100644 index 0000000..0cde8fc --- /dev/null +++ b/src/ext_depends/tinyendian/doc/tinyendian/UTFEncoding.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"/> +<link rel="stylesheet" type="text/css" href="../style.css"/> +<script src="../highlight.pack.js"></script> +<title>UTFEncoding</title> +<base href="../"/> +<script src="search.js"></script> +<script src="show_hide.js"></script> +</head> +<body> +<div class="main"> +<div class="breadcrumbs"> +<table id="results"></table> +<a href="index.html" class="home">⌂</a><input type="search" id="search" placeholder="Search" onkeyup="searchSubmit(this.value, event)"/> +<small><a href=tinyendian.html>tinyendian</a>.</small><span class="highlight">UTFEncoding</span> +</div> +<div class="sidebar"> +<a href="tinyendian.html#hide-toc" class="hide" id="hide-toc">«</a> +<a href="tinyendian.html#show-toc" class="show" id="show-toc">»</a> +<div id="toc-id" class="toc"> +<ul><li><span class=" selected"><a href="tinyendian.html">tinyendian</a></span> +</li> + +</ul> +</div></div> +<div class="content"> +<div class="aggregate-symbol"><div class="description"><pre><code>public enum UTFEncoding : <a href="http://dlang.org/type.html#basic-data-types">ubyte</a> +</code></pre> +<div class="section "><p>Unicode UTF encodings. +</p> + + +</div> +</div><div class="section members"><h2>Values</h2><table><tr><td>UTF_8</td><td></td><td></td></tr><tr><td>UTF_16</td><td></td><td></td></tr><tr><td>UTF_32</td><td></td><td></td></tr></table> +</div> +</div><script>hljs.initHighlightingOnLoad();</script> + +</div> +<footer> +Generated with <a href="https://github.com/kiith-sa/harbored-mod">harbored-mod</a> +</footer> +</div> +</body> +</html> diff --git a/src/ext_depends/tinyendian/dub.json b/src/ext_depends/tinyendian/dub.json new file mode 100644 index 0000000..6313cdd --- /dev/null +++ b/src/ext_depends/tinyendian/dub.json @@ -0,0 +1,16 @@ +{ + "name": "tinyendian", + "description": "Lightweight endianness handling library", + "authors": [ "Ferdinand Majerech" ], + "importPaths": ["source"], + "license": "Boost 1.0", + "homepage": "https://github.com/kiith-sa/tinyendian", + "copyright": "Copyright © 2014, Ferdinand Majerech", + + "buildTypes": + { + "debug": { "buildOptions": ["debugMode", "debugInfoC"] }, + "release": { "buildOptions": ["releaseMode", "optimize", "inline", "noBoundsCheck"] }, + "profile": { "buildOptions": ["releaseMode", "optimize", "noBoundsCheck", "debugInfoC"] }, + }, +} diff --git a/src/ext_depends/tinyendian/hmod.cfg b/src/ext_depends/tinyendian/hmod.cfg new file mode 100644 index 0000000..b3255cc --- /dev/null +++ b/src/ext_depends/tinyendian/hmod.cfg @@ -0,0 +1,130 @@ +# This file contains configuration options for harbored-mod (hmod). +# +# By default, hmod loads configuration from file 'hmod.cfg' in the directory from where +# hmod is running, if such file exists. These configuration options can also be passed +# as command-line options for hmod, overriding contents of the config file, if any, +# with the exception of options that allow multiple values (such as 'exclude' or +# 'macros') where the values specified as command-line options are *added* to the values +# in config file. + + + +# Source code files or directories to document. Specify more than once to document more +# files/directories, e.g: +# +# source = ./source +# source = ./thirdparty +# +# This will document both the source code in the ./source/ and ./thirdparty/ directories. +# +# For DUB (http://code.dlang.org) projects, './source' is usually a good setting here. +source = ./source + + +# Name of the project. Used on the main page and possibly other places to help identify +# the project. +project-name = tinyendian + + +# Version of the project. Used on the main page and possibly other places to help +# identify the project. +project-version = + + +# Set to true to disable Markdown support, so that only DDoc is used. +no-markdown = false + + +# Directory where the generated documentation will be written. +output-directory = ./doc + +# Output format. Supported values: +# html-simple +# Every function, variable, etc. will be documented in a separate +# HTML file. A documentation page of an aggregate (e.g. class) will +# link to these files. Generates a large number of files; not +# recommended for large projects. +# html-aggregated +# Members of an aggregate will be documented in the same file as the +# aggregate, unless they are aggregates themselves. That is, member +# functions or variables will be documented in the same file as the +# class that contains them, but a subclass will be documented in a +# separate file. +format = html-aggregated + + +# Modules or packages to exclude from generated documentation. Specify more than once to +# exclude more modules/packages, e.g: +# +# exclude = tharsis.util +# exclude = tharsis.entity.gamestate +# +# This will exclude both the package (or module) tharsis.util and module (or package) +# tharsis.entity.gamestate . + +exclude = + + +# DDoc+markdown source of the main page of your documentation. Currently the main page is +# blank by default; this can be used to fill it with something useful. + +index = + + +# Filename of DDoc+markdown source of additional content to add to the table of contents +# sidebar. Useful e.g. to add links to tutorials. Can be used more than once to add +# content from more files. + +toc-additional = + + +# CSS file to use for styling. Can be used to replace the default style. +# To create a new style, you can start by generating the default style file with +# 'hmod --generate-css CSS_OUT_FILE' (CSS_OUT_FILE is name the generated file will have) +# and then modifying the CSS to get the desired style. + +css = + + +# File to load DDoc macros from. Can be used to override builtin macros or add new ones. +# Can be specified more than once to use multiple macro files, e.g.: +# +# macros = macros.ddoc +# macros = moremacros.ddoc + +macros = + + +# Maximum file size of D modules harbored-mod will process, in kiB. Any file +# bigger than specified size will be ignored. Useful in rare cases when modules +# are huge enough that the parser spends too much memory. +# By default, we ignore modules bigger than 16MiB. + +max-file-size = 16384 + + +# Additional config file to load, if needed. Configuration options in specified file will +# override or add to any options specified before this line, and will be overridden by +# any options after this line. Think of it as including the config file in this file. + +config = + + + +#--------------------------------------------------------------------------- +# Configuration options **only** useful for harbored-mod testing +#--------------------------------------------------------------------------- +# Uncommenting these will result in printing help information; only useful for testing. +# +# # Print help message. +# +# help = true +# +# +# # Generate default CSS file and write it to specified file. +# generate-css = hmod-style.css +# +# +# # Generate default config file and write it to 'hmod.cfg'. +# +# generate-cfg = true diff --git a/src/ext_depends/tinyendian/meson.build b/src/ext_depends/tinyendian/meson.build new file mode 100644 index 0000000..f666958 --- /dev/null +++ b/src/ext_depends/tinyendian/meson.build @@ -0,0 +1,41 @@ +# -*- mode: python; -*- + +project( + 'tinyendian', + 'd', + meson_version: '>=0.41', + version: '0.2.0', + default_options: ['buildtype=release'], +) + +src_dir = include_directories('source/') +pkgc = import('pkgconfig') + +tinyendian_src = [ + 'source/tinyendian.d' +] + +install_headers(tinyendian_src, subdir: 'd/') + +tinyendian_lib = library( + meson.project_name(), + [tinyendian_src], + include_directories: [src_dir], + version: meson.project_version(), + pic: true, + install: true, +) + +pkgc.generate( + name: meson.project_name(), + libraries: tinyendian_lib, + subdirs: 'd/', + version: meson.project_version(), + description: 'Lightweight endianness library for D.' +) + +# Make Tinyendian easy to use as subproject +tinyendian_dep = declare_dependency( + link_with: tinyendian_lib, + include_directories: [src_dir] +) diff --git a/src/ext_depends/tinyendian/source/tinyendian.d b/src/ext_depends/tinyendian/source/tinyendian.d new file mode 100644 index 0000000..731b048 --- /dev/null +++ b/src/ext_depends/tinyendian/source/tinyendian.d @@ -0,0 +1,213 @@ +// Copyright Ferdinand Majerech 2014. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +/// A minimal library providing functionality for changing the endianness of data. +module tinyendian; + +import std.system : Endian, endian; + +/// Unicode UTF encodings. +enum UTFEncoding : ubyte +{ + UTF_8, + UTF_16, + UTF_32 +} +/// +@safe unittest +{ + const ints = [314, -101]; + int[2] intsSwapBuffer = ints; + swapByteOrder(intsSwapBuffer[]); + swapByteOrder(intsSwapBuffer[]); + assert(ints == intsSwapBuffer, "Lost information when swapping byte order"); + + const floats = [3.14f, 10.1f]; + float[2] floatsSwapBuffer = floats; + swapByteOrder(floatsSwapBuffer[]); + swapByteOrder(floatsSwapBuffer[]); + assert(floats == floatsSwapBuffer, "Lost information when swapping byte order"); +} + +/** Swap byte order of items in an array in place. + * + * Params: + * + * T = Item type. Must be either 2 or 4 bytes long. + * array = Buffer with values to fix byte order of. + */ +void swapByteOrder(T)(T[] array) @trusted @nogc pure nothrow +if (T.sizeof == 2 || T.sizeof == 4) +{ + // Swap the byte order of all read characters. + foreach (ref item; array) + { + static if (T.sizeof == 2) + { + import std.algorithm.mutation : swap; + swap(*cast(ubyte*)&item, *(cast(ubyte*)&item + 1)); + } + else static if (T.sizeof == 4) + { + import core.bitop : bswap; + const swapped = bswap(*cast(uint*)&item); + item = *cast(const(T)*)&swapped; + } + else static assert(false, "Unsupported T: " ~ T.stringof); + } +} + +/// See fixUTFByteOrder. +struct FixUTFByteOrderResult +{ + ubyte[] array; + UTFEncoding encoding; + Endian endian; + uint bytesStripped = 0; +} + +/** Convert byte order of an array encoded in UTF(8/16/32) to system endianness in place. + * + * Uses the UTF byte-order-mark (BOM) to determine UTF encoding. If there is no BOM + * at the beginning of array, UTF-8 is assumed (this is compatible with ASCII). The + * BOM, if any, will be removed from the buffer. + * + * If the encoding is determined to be UTF-16 or UTF-32 and there aren't enough bytes + * for the last code unit (i.e. if array.length is odd for UTF-16 or not divisible by + * 4 for UTF-32), the extra bytes (1 for UTF-16, 1-3 for UTF-32) are stripped. + * + * Note that this function does $(B not) check if the array is a valid UTF string. It + * only works with the BOM and 1,2 or 4-byte items. + * + * Params: + * + * array = The array with UTF-data. + * + * Returns: + * + * A struct with the following members: + * + * $(D ubyte[] array) A slice of the input array containing data in correct + * byte order, without BOM and in case of UTF-16/UTF-32, + * without stripped bytes, if any. + * $(D UTFEncoding encoding) Encoding of the result (UTF-8, UTF-16 or UTF-32) + * $(D std.system.Endian endian) Endianness of the original array. + * $(D uint bytesStripped) Number of bytes stripped from a UTF-16/UTF-32 array, if + * any. This is non-zero only if array.length was not + * divisible by 2 or 4 for UTF-16 and UTF-32, respectively. + * + * Complexity: (BIGOH array.length) + */ +auto fixUTFByteOrder(ubyte[] array) @safe @nogc pure nothrow +{ + // Enumerates UTF BOMs, matching indices to byteOrderMarks/bomEndian. + enum BOM: ubyte + { + UTF_8 = 0, + UTF_16_LE = 1, + UTF_16_BE = 2, + UTF_32_LE = 3, + UTF_32_BE = 4, + None = ubyte.max + } + + // These 2 are from std.stream + static immutable ubyte[][5] byteOrderMarks = [ [0xEF, 0xBB, 0xBF], + [0xFF, 0xFE], + [0xFE, 0xFF], + [0xFF, 0xFE, 0x00, 0x00], + [0x00, 0x00, 0xFE, 0xFF] ]; + static immutable Endian[5] bomEndian = [ endian, + Endian.littleEndian, + Endian.bigEndian, + Endian.littleEndian, + Endian.bigEndian ]; + + // Documented in function ddoc. + + FixUTFByteOrderResult result; + + // Detect BOM, if any, in the bytes we've read. -1 means no BOM. + // Need the last match: First 2 bytes of UTF-32LE BOM match the UTF-16LE BOM. If we + // used the first match, UTF-16LE would be detected when we have a UTF-32LE BOM. + import std.algorithm.searching : startsWith; + BOM bomId = BOM.None; + foreach (i, bom; byteOrderMarks) + if (array.startsWith(bom)) + bomId = cast(BOM)i; + + result.endian = (bomId != BOM.None) ? bomEndian[bomId] : Endian.init; + + // Start of UTF data (after BOM, if any) + size_t start = 0; + // If we've read more than just the BOM, put the rest into the array. + with(BOM) final switch(bomId) + { + case None: result.encoding = UTFEncoding.UTF_8; break; + case UTF_8: + start = 3; + result.encoding = UTFEncoding.UTF_8; + break; + case UTF_16_LE, UTF_16_BE: + result.bytesStripped = array.length % 2; + start = 2; + result.encoding = UTFEncoding.UTF_16; + break; + case UTF_32_LE, UTF_32_BE: + result.bytesStripped = array.length % 4; + start = 4; + result.encoding = UTFEncoding.UTF_32; + break; + } + + // If there's a BOM, we need to move data back to ensure it starts at array[0] + if (start != 0) + { + array = array[start .. $ - result.bytesStripped]; + } + + // We enforce above that array.length is divisible by 2/4 for UTF-16/32 + if (endian != result.endian) + { + if (result.encoding == UTFEncoding.UTF_16) + swapByteOrder(cast(wchar[])array); + else if (result.encoding == UTFEncoding.UTF_32) + swapByteOrder(cast(dchar[])array); + } + + result.array = array; + return result; +} +/// +@safe unittest +{ + { + ubyte[] s = [0xEF, 0xBB, 0xBF, 'a']; + FixUTFByteOrderResult r = fixUTFByteOrder(s); + assert(r.encoding == UTFEncoding.UTF_8); + assert(r.array.length == 1); + assert(r.array == ['a']); + assert(r.endian == Endian.littleEndian); + } + + { + ubyte[] s = ['a']; + FixUTFByteOrderResult r = fixUTFByteOrder(s); + assert(r.encoding == UTFEncoding.UTF_8); + assert(r.array.length == 1); + assert(r.array == ['a']); + assert(r.endian == Endian.bigEndian); + } + + { + // strip 'a' b/c not complete unit + ubyte[] s = [0xFE, 0xFF, 'a']; + FixUTFByteOrderResult r = fixUTFByteOrder(s); + assert(r.encoding == UTFEncoding.UTF_16); + assert(r.array.length == 0); + assert(r.endian == Endian.bigEndian); + } + +} |