Permalink
Browse files

Removes PolyDataView from the flocking repository in favour of a subm…

…odule.
  • Loading branch information...
1 parent c0f2aa4 commit 80a4c2eb9ffce5726d5dd0f0188b461b0ea02e8f @colinbdclark committed Aug 6, 2012
View
278 third-party/polydataview/GPL-LICENSE.txt
@@ -1,278 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
View
20 third-party/polydataview/MIT-LICENSE.txt
@@ -1,20 +0,0 @@
-Copyright (c) 2012 Colin Clark
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
24 third-party/polydataview/benchmarks/html/polyDataView-benchmarks.html
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>polyDataView Benchmarks</title>
-
- <link rel="stylesheet" type="text/css" href="../../../../tests/performance/shared/css/sheep.css" />
-
- <script type="text/javascript" src="../../../../tests/performance/shared/third-party/js/spin.min.js"></script>
- <script type="text/javascript" src="../../../../tests/performance/shared/js/sheep.js"></script>
-
- <script type="text/javascript" src="../../js/polydataview.js"></script>
- <script type="text/javascript" src="../third-party/js/jdataview.js"></script>
-
- <script type="text/javascript" src="../js/polyDataView-benchmarks.js"></script>
- </head>
-
- <body id="body">
-
- <script type="text/javascript">
- flock.test.polyDataViewBenchmarks();
- </script>
- </body>
-</html>
View
131 third-party/polydataview/benchmarks/js/polyDataView-benchmarks.js
@@ -1,131 +0,0 @@
-/*
-* PolyDataView Benchmarks
-* http://github.com/colinbdclark/PolyDataView
-*
-* Copyright 2012, Colin Clark
-* Dual licensed under the MIT and GPL Version 2 licenses.
-*/
-
-/*jslint white: true, plusplus: true, undef: true, newcap: true, regexp: true, browser: true,
- forin: true, continue: true, nomen: true, bitwise: true, maxerr: 100, indent: 4 */
-
-var flock = flock || {};
-
-(function () {
- "use strict";
-
- flock.test = flock.test || {};
-
- flock.test.polyDataViewBenchmarks = function () {
-
- var makeRandomBuffer = function (len, w) {
- var buffer = [];
- for (var i = 0; i < len; i++) {
- for (var j = 0; j < w; j++) {
- var val = Math.round(Math.random() * (Math.pow(2, w) - 1));
- buffer.push(val);
- }
- }
- return buffer;
- };
-
- var makeSetupFn = function (constructorName) {
- return function () {
- var buffer = new Uint8Array(makeRandomBuffer(1024, 2));
- return new window[constructorName](buffer.buffer);
- };
- };
-
- var setupDataViewTest = function (len, w, dvCreatorFn) {
- var buffer = new Uint8Array(makeRandomBuffer(len, w));
- return dvCreatorFn(buffer);
- };
-
- var getInt16Test = function (dv, isLittle) {
- for (var i = 0; i < 1024; i++) {
- dv.getInt16(i, 0, isLittle);
- }
- };
-
- var getPolyInt16ArrayTest = function (dv, isLittle) {
- dv.getInts(1024, 2, 0, isLittle);
- };
-
- var getSpecInt16ArrayTest = function (dv, isLittle) {
- var result = [];
- for (var i = 0; i < 1024; i++) {
- result.push(dv.getInt16(i, 0, isLittle));
- }
- };
-
- var getterTestSpecs = [
- {
- name: "get 1024 Int16 values",
- type: "PolyDataView",
- oneAtATimeTest: getInt16Test,
- arrayTest: getPolyInt16ArrayTest
- },
- {
- name: "get 1024 Int16 values",
- type: "jDataView",
- oneAtATimeTest: getInt16Test,
- arrayTest: getSpecInt16ArrayTest
- }
- ];
-
- if (window["DataView"]) {
- getterTestSpecs.push({
- name: "get 1024 Int16 values",
- type: "DataView",
- oneAtATimeTest: getInt16Test,
- arrayTest: getSpecInt16ArrayTest
- });
- }
-
- // TODO: Remove duplication.
- var expandTestSpecs = function (testSpecs) {
- var expanded = [],
- i,
- spec;
- for (i = 0; i < testSpecs.length; i++) {
- spec = testSpecs[i];
- expanded.push({
- name: spec.type + ": " + spec.name + ", one at a time - big endian.",
- setup: makeSetupFn(spec.type),
- test: function (dv) {
- spec.oneAtATimeTest(dv, false);
- }
- });
-
- expanded.push({
- name: spec.type + ": " + spec.name + ", one at a time - little endian.",
- setup: makeSetupFn(spec.type),
- test: function (dv) {
- spec.oneAtATimeTest(dv, true);
- }
- });
-
- expanded.push({
- name: spec.type + ": " + spec.name + " as an array - big endian.",
- setup: makeSetupFn(spec.type),
- test: function (dv) {
- spec.arrayTest(dv, false);
- }
- });
-
- expanded.push({
- name: spec.type + ": " + spec.name + " as an array - little endian.",
- setup: makeSetupFn(spec.type),
- test: function (dv) {
- spec.arrayTest(dv, true);
- }
- });
- }
- return expanded;
- };
-
- var testSpecs = expandTestSpecs(getterTestSpecs);
- sheep.test(testSpecs, true);
- };
-
-}());
View
451 third-party/polydataview/benchmarks/third-party/js/jdataview.js
@@ -1,451 +0,0 @@
-//
-// jDataView by Vjeux - Jan 2010
-//
-// A unique way to read a binary file in the browser
-// http://github.com/vjeux/jDataView
-// http://blog.vjeux.com/ <vjeuxx@gmail.com>
-//
-
-(function (global) {
-
-var compatibility = {
- ArrayBuffer: typeof ArrayBuffer !== 'undefined',
- DataView: typeof DataView !== 'undefined' && 'getFloat64' in DataView.prototype,
- NodeBuffer: typeof Buffer !== 'undefined',
-// 0.6.0 -> readInt8LE(offset)
- NodeBufferFull: typeof Buffer !== 'undefined' && 'readInt8LE' in Buffer,
-// 0.5.0 -> readInt8(offset, endian)
- NodeBufferEndian: typeof Buffer !== 'undefined' && 'readInt8' in Buffer
-};
-
-var jDataView = function (buffer, byteOffset, byteLength, littleEndian) {
- if (!(this instanceof arguments.callee)) {
- throw new Error("Constructor may not be called as a function");
- }
-
- this.buffer = buffer;
-
- // Handle Type Errors
- if (!(compatibility.NodeBuffer && buffer instanceof Buffer) &&
- !(compatibility.ArrayBuffer && buffer instanceof ArrayBuffer) &&
- typeof buffer !== 'string') {
- throw new TypeError('Type error');
- }
-
- // Check parameters and existing functionnalities
- this._isArrayBuffer = compatibility.ArrayBuffer && buffer instanceof ArrayBuffer;
- this._isDataView = compatibility.DataView && this._isArrayBuffer;
- this._isNodeBuffer = compatibility.NodeBuffer && buffer instanceof Buffer;
-
- // Default Values
- this._littleEndian = littleEndian === undefined ? true : littleEndian;
-
- var bufferLength = this._isArrayBuffer ? buffer.byteLength : buffer.length;
- if (byteOffset === undefined) {
- byteOffset = 0;
- }
- this.byteOffset = byteOffset;
-
- if (byteLength === undefined) {
- byteLength = bufferLength - byteOffset;
- }
- this.byteLength = byteLength;
-
- if (!this._isDataView) {
- // Do additional checks to simulate DataView
- if (typeof byteOffset !== 'number') {
- throw new TypeError('Type error');
- }
- if (typeof byteLength !== 'number') {
- throw new TypeError('Type error');
- }
- if (typeof byteOffset < 0) {
- throw new Error('INDEX_SIZE_ERR: DOM Exception 1');
- }
- if (typeof byteLength < 0) {
- throw new Error('INDEX_SIZE_ERR: DOM Exception 1');
- }
- }
-
- // Instanciate
- if (this._isDataView) {
- this._view = new DataView(buffer, byteOffset, byteLength);
- this._start = 0;
- }
- this._start = byteOffset;
- if (byteOffset + byteLength > bufferLength) {
- throw new Error("INDEX_SIZE_ERR: DOM Exception 1");
- }
-
- this._offset = 0;
-};
-
-jDataView.createBuffer = function () {
- if (compatibility.NodeBuffer) {
- var buffer = new Buffer(arguments.length);
- for (var i = 0; i < arguments.length; ++i) {
- buffer[i] = arguments[i];
- }
- return buffer;
- }
- if (compatibility.ArrayBuffer) {
- var buffer = new ArrayBuffer(arguments.length);
- var view = new Int8Array(buffer);
- for (var i = 0; i < arguments.length; ++i) {
- view[i] = arguments[i];
- }
- return buffer;
- }
-
- return String.fromCharCode.apply(null, arguments);
-};
-
-jDataView.prototype = {
-
- // Helpers
-
- getString: function (length, byteOffset) {
- var value;
-
- // Handle the lack of byteOffset
- if (byteOffset === undefined) {
- byteOffset = this._offset;
- }
-
- // Error Checking
- if (typeof byteOffset !== 'number') {
- throw new TypeError('Type error');
- }
- if (length < 0 || byteOffset + length > this.byteLength) {
- throw new Error('INDEX_SIZE_ERR: DOM Exception 1');
- }
-
- if (this._isNodeBuffer) {
- value = this.buffer.toString('ascii', this._start + byteOffset, this._start + byteOffset + length);
- }
- else {
- value = '';
- for (var i = 0; i < length; ++i) {
- var chr = this.getUint8(byteOffset + i);
- value += String.fromCharCode(chr > 127 ? 65533 : chr);
- }
- }
-
- this._offset = byteOffset + length;
- return value;
- },
-
- getChar: function (byteOffset) {
- return this.getString(1, byteOffset);
- },
-
- tell: function () {
- return this._offset;
- },
-
- seek: function (byteOffset) {
- if (typeof byteOffset !== 'number') {
- throw new TypeError('Type error');
- }
- if (byteOffset < 0 || byteOffset > this.byteLength) {
- throw new Error('INDEX_SIZE_ERR: DOM Exception 1');
- }
-
- return this._offset = byteOffset;
- },
-
- // Compatibility functions on a String Buffer
-
- _endianness: function (byteOffset, pos, max, littleEndian) {
- return byteOffset + (littleEndian ? max - pos - 1 : pos);
- },
-
- _getFloat64: function (byteOffset, littleEndian) {
- var b0 = this._getUint8(this._endianness(byteOffset, 0, 8, littleEndian)),
- b1 = this._getUint8(this._endianness(byteOffset, 1, 8, littleEndian)),
- b2 = this._getUint8(this._endianness(byteOffset, 2, 8, littleEndian)),
- b3 = this._getUint8(this._endianness(byteOffset, 3, 8, littleEndian)),
- b4 = this._getUint8(this._endianness(byteOffset, 4, 8, littleEndian)),
- b5 = this._getUint8(this._endianness(byteOffset, 5, 8, littleEndian)),
- b6 = this._getUint8(this._endianness(byteOffset, 6, 8, littleEndian)),
- b7 = this._getUint8(this._endianness(byteOffset, 7, 8, littleEndian)),
-
- sign = 1 - (2 * (b0 >> 7)),
- exponent = ((((b0 << 1) & 0xff) << 3) | (b1 >> 4)) - (Math.pow(2, 10) - 1),
-
- // Binary operators such as | and << operate on 32 bit values, using + and Math.pow(2) instead
- mantissa = ((b1 & 0x0f) * Math.pow(2, 48)) + (b2 * Math.pow(2, 40)) + (b3 * Math.pow(2, 32)) +
- (b4 * Math.pow(2, 24)) + (b5 * Math.pow(2, 16)) + (b6 * Math.pow(2, 8)) + b7;
-
- if (exponent === 1024) {
- if (mantissa !== 0) {
- return NaN;
- } else {
- return sign * Infinity;
- }
- }
-
- if (exponent === -1023) { // Denormalized
- return sign * mantissa * Math.pow(2, -1022 - 52);
- }
-
- return sign * (1 + mantissa * Math.pow(2, -52)) * Math.pow(2, exponent);
- },
-
- _getFloat32: function (byteOffset, littleEndian) {
- var b0 = this._getUint8(this._endianness(byteOffset, 0, 4, littleEndian)),
- b1 = this._getUint8(this._endianness(byteOffset, 1, 4, littleEndian)),
- b2 = this._getUint8(this._endianness(byteOffset, 2, 4, littleEndian)),
- b3 = this._getUint8(this._endianness(byteOffset, 3, 4, littleEndian)),
-
- sign = 1 - (2 * (b0 >> 7)),
- exponent = (((b0 << 1) & 0xff) | (b1 >> 7)) - 127,
- mantissa = ((b1 & 0x7f) << 16) | (b2 << 8) | b3;
-
- if (exponent === 128) {
- if (mantissa !== 0) {
- return NaN;
- } else {
- return sign * Infinity;
- }
- }
-
- if (exponent === -127) { // Denormalized
- return sign * mantissa * Math.pow(2, -126 - 23);
- }
-
- return sign * (1 + mantissa * Math.pow(2, -23)) * Math.pow(2, exponent);
- },
-
- _getInt32: function (byteOffset, littleEndian) {
- var b = this._getUint32(byteOffset, littleEndian);
- return b > Math.pow(2, 31) - 1 ? b - Math.pow(2, 32) : b;
- },
-
- _getUint32: function (byteOffset, littleEndian) {
- var b3 = this._getUint8(this._endianness(byteOffset, 0, 4, littleEndian)),
- b2 = this._getUint8(this._endianness(byteOffset, 1, 4, littleEndian)),
- b1 = this._getUint8(this._endianness(byteOffset, 2, 4, littleEndian)),
- b0 = this._getUint8(this._endianness(byteOffset, 3, 4, littleEndian));
-
- return (b3 * Math.pow(2, 24)) + (b2 << 16) + (b1 << 8) + b0;
- },
-
- _getInt16: function (byteOffset, littleEndian) {
- var b = this._getUint16(byteOffset, littleEndian);
- return b > Math.pow(2, 15) - 1 ? b - Math.pow(2, 16) : b;
- },
-
- _getUint16: function (byteOffset, littleEndian) {
- var b1 = this._getUint8(this._endianness(byteOffset, 0, 2, littleEndian)),
- b0 = this._getUint8(this._endianness(byteOffset, 1, 2, littleEndian));
-
- return (b1 << 8) + b0;
- },
-
- _getInt8: function (byteOffset) {
- var b = this._getUint8(byteOffset);
- return b > Math.pow(2, 7) - 1 ? b - Math.pow(2, 8) : b;
- },
-
- _getUint8: function (byteOffset) {
- if (this._isArrayBuffer) {
- return new Uint8Array(this.buffer, byteOffset, 1)[0];
- }
- else if (this._isNodeBuffer) {
- return this.buffer[byteOffset];
- } else {
- return this.buffer.charCodeAt(byteOffset) & 0xff;
- }
- }
-};
-
-// Create wrappers
-
-var dataTypes = {
- 'Int8': 1,
- 'Int16': 2,
- 'Int32': 4,
- 'Uint8': 1,
- 'Uint16': 2,
- 'Uint32': 4,
- 'Float32': 4,
- 'Float64': 8
-};
-var nodeNaming = {
- 'Int8': 'Int8',
- 'Int16': 'Int16',
- 'Int32': 'Int32',
- 'Uint8': 'UInt8',
- 'Uint16': 'UInt16',
- 'Uint32': 'UInt32',
- 'Float32': 'Float',
- 'Float64': 'Double'
-};
-
-for (var type in dataTypes) {
- if (!dataTypes.hasOwnProperty(type)) {
- continue;
- }
-
- // Bind the variable type
- (function (type) {
- var size = dataTypes[type];
-
- // Create the function
- jDataView.prototype['get' + type] =
- function (byteOffset, littleEndian) {
- var value;
-
- // Handle the lack of endianness
- if (littleEndian === undefined) {
- littleEndian = this._littleEndian;
- }
-
- // Handle the lack of byteOffset
- if (byteOffset === undefined) {
- byteOffset = this._offset;
- }
-
- // Dispatch on the good method
- if (this._isDataView) {
- // DataView: we use the direct method
- value = this._view['get' + type](byteOffset, littleEndian);
- }
- // ArrayBuffer: we use a typed array of size 1 if the alignment is good
- // ArrayBuffer does not support endianess flag (for size > 1)
- else if (this._isArrayBuffer && (this._start + byteOffset) % size === 0 && (size === 1 || littleEndian)) {
- value = new global[type + 'Array'](this.buffer, this._start + byteOffset, 1)[0];
- }
- // NodeJS Buffer
- else if (this._isNodeBuffer && compatibility.NodeBufferFull) {
- if (littleEndian) {
- value = this.buffer['read' + nodeNaming[type] + 'LE'](this._start + byteOffset);
- } else {
- value = this.buffer['read' + nodeNaming[type] + 'BE'](this._start + byteOffset);
- }
- } else if (this._isNodeBuffer && compatibility.NodeBufferEndian) {
- value = this.buffer['read' + nodeNaming[type]](this._start + byteOffset, littleEndian);
- }
- else {
- // Error Checking
- if (typeof byteOffset !== 'number') {
- throw new TypeError('Type error');
- }
- if (byteOffset + size > this.byteLength) {
- throw new Error('INDEX_SIZE_ERR: DOM Exception 1');
- }
- value = this['_get' + type](this._start + byteOffset, littleEndian);
- }
-
- // Move the internal offset forward
- this._offset = byteOffset + size;
-
- return value;
- };
- })(type);
-}
-
-if (typeof jQuery !== 'undefined' && jQuery.fn.jquery >= "1.6.2") {
- var convertResponseBodyToText = function (byteArray) {
- // http://jsperf.com/vbscript-binary-download/6
- var scrambledStr;
- try {
- scrambledStr = IEBinaryToArray_ByteStr(byteArray);
- } catch (e) {
- // http://stackoverflow.com/questions/1919972/how-do-i-access-xhr-responsebody-for-binary-data-from-javascript-in-ie
- // http://miskun.com/javascript/internet-explorer-and-binary-files-data-access/
- var IEBinaryToArray_ByteStr_Script =
- "Function IEBinaryToArray_ByteStr(Binary)\r\n"+
- " IEBinaryToArray_ByteStr = CStr(Binary)\r\n"+
- "End Function\r\n"+
- "Function IEBinaryToArray_ByteStr_Last(Binary)\r\n"+
- " Dim lastIndex\r\n"+
- " lastIndex = LenB(Binary)\r\n"+
- " if lastIndex mod 2 Then\r\n"+
- " IEBinaryToArray_ByteStr_Last = AscB( MidB( Binary, lastIndex, 1 ) )\r\n"+
- " Else\r\n"+
- " IEBinaryToArray_ByteStr_Last = -1\r\n"+
- " End If\r\n"+
- "End Function\r\n";
-
- // http://msdn.microsoft.com/en-us/library/ms536420(v=vs.85).aspx
- // proprietary IE function
- window.execScript(IEBinaryToArray_ByteStr_Script, 'vbscript');
-
- scrambledStr = IEBinaryToArray_ByteStr(byteArray);
- }
-
- var lastChr = IEBinaryToArray_ByteStr_Last(byteArray),
- result = "",
- i = 0,
- l = scrambledStr.length % 8,
- thischar;
- while (i < l) {
- thischar = scrambledStr.charCodeAt(i++);
- result += String.fromCharCode(thischar & 0xff, thischar >> 8);
- }
- l = scrambledStr.length
- while (i < l) {
- result += String.fromCharCode(
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8,
- (thischar = scrambledStr.charCodeAt(i++), thischar & 0xff), thischar >> 8);
- }
- if (lastChr > -1) {
- result += String.fromCharCode(lastChr);
- }
- return result;
- };
-
- jQuery.ajaxSetup({
- converters: {
- '* dataview': function(data) {
- return new jDataView(data);
- }
- },
- accepts: {
- dataview: "text/plain; charset=x-user-defined"
- },
- responseHandler: {
- dataview: function (responses, options, xhr) {
- // Array Buffer Firefox
- if ('mozResponseArrayBuffer' in xhr) {
- responses.text = xhr.mozResponseArrayBuffer;
- }
- // Array Buffer Chrome
- else if ('responseType' in xhr && xhr.responseType === 'arraybuffer' && xhr.response) {
- responses.text = xhr.response;
- }
- // Internet Explorer (Byte array accessible through VBScript -- convert to text)
- else if ('responseBody' in xhr) {
- responses.text = convertResponseBodyToText(xhr.responseBody);
- }
- // Older Browsers
- else {
- responses.text = xhr.responseText;
- }
- }
- }
- });
-
- jQuery.ajaxPrefilter('dataview', function(options, originalOptions, jqXHR) {
- // trying to set the responseType on IE 6 causes an error
- if (jQuery.support.ajaxResponseType) {
- if (!options.hasOwnProperty('xhrFields')) {
- options.xhrFields = {};
- }
- options.xhrFields.responseType = 'arraybuffer';
- }
- options.mimeType = 'text/plain; charset=x-user-defined';
- });
-}
-
-global.jDataView = (global.module || {}).exports = jDataView;
-
-})(this);
View
561 third-party/polydataview/js/polydataview.js
@@ -1,561 +0,0 @@
-/*!
-* PolyDataView, a better polyfill for DataView.
-* http://github.com/colinbdclark/PolyDataView
-*
-* Copyright 2012, Colin Clark
-* Dual licensed under the MIT and GPL Version 2 licenses.
-*
-* Contributions:
-* - getFloat32 and getFloat64, Copyright 2011 Christopher Chedeau
-* - getFloat80, Copyright 2011 Joe Turner
-*/
-
-/*global window, ArrayBuffer, Uint8Array, Uint32Array*/
-/*jslint white: true, funcinvoke: true, undef: true, newcap: false, regexp: true, browser: true,
- forin: true, continue: true, forvar: true, nomen: true, maxerr: 100, indent: 4 */
-
-/*
- * To Do:
- * - Finish unit tests for getFloat80() and the various array getters.
- */
-
-(function () {
- "use strict";
-
- var nativeDataView = typeof (window.DataView) !== "undefined" ? window.DataView : undefined;
-
- var isHostLittleEndian = (function () {
- var endianTest = new ArrayBuffer(4),
- u8View = new Uint8Array(endianTest),
- u32View = new Uint32Array(endianTest);
-
- u8View[0] = 0x01;
- u8View[1] = 0x02;
- u8View[2] = 0x03;
- u8View[3] = 0x04;
-
- return u32View[0] === 0x04030201;
- }());
-
-
- var addSharedMethods = function (that) {
-
- /**
- * Non-standard
- */
- that.getString = function (len, w, o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var s = "",
- i,
- c;
-
- for (i = 0; i < len; i++) {
- c = that.getUint(w, o, isL);
- if (c > 0xFFFF) {
- c -= 0x10000;
- s += String.fromCharCode(0xD800 + (c >> 10), 0xDC00 + (c & 0x3FF));
- } else {
- s += String.fromCharCode(c);
- }
- o = o + w;
- }
-
- return s;
- };
-
- /**
- * Non-standard
- */
- that.getFloat80 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- // This method is a modified version of Joe Turner's implementation of an "extended" float decoder,
- // originally licensed under the WTF license.
- // https://github.com/oampo/audiofile.js/blob/master/audiofile.js
- var expon = that.getUint(2, o, isL),
- hi = that.getUint(4, o + 2),
- lo = that.getUint(4, o + 6),
- rng = 1 << (16 - 1),
- sign = 1,
- value;
-
- if (expon >= rng) {
- expon |= ~(rng - 1);
- }
-
- if (expon < 0) {
- sign = -1;
- expon += rng;
- }
-
- if (expon === hi === lo === 0) {
- value = 0;
- } else if (expon === 0x7FFF) {
- value = Number.MAX_VALUE;
- } else {
- expon -= 16383;
- value = (hi * 0x100000000 + lo) * Math.pow(2, expon - 63);
- }
-
- that.offsetState = o + 10;
-
- return sign * value;
- };
- };
-
- var PolyDataView = function (buffer, byteOffset, byteLength) {
- var cachedArray = [];
-
- var that = {
- buffer: buffer,
- byteOffset: typeof (byteOffset) === "number" ? byteOffset : 0
- };
- that.byteLength = typeof (byteLength) === "number" ? byteLength : buffer.byteLength - that.byteOffset;
-
- // Bail if we're trying to read off the end of the buffer.
- if (that.byteOffset > buffer.byteLength || that.byteOffset + that.byteLength > buffer.byteLength) {
- throw new Error("INDEX_SIZE_ERR: DOM Exception 1");
- }
-
- /**
- * Non-standard
- */
- that.u8Buf = new Uint8Array(buffer, that.byteOffset, that.byteLength);
-
- /**
- * Non-standard
- */
- that.offsetState = that.byteOffset;
-
- /**
- * Non-standard
- */
- that.getUints = function (len, w, o, isL, array) {
- // TODO: Complete cut and paste job from getInts()!
- o = typeof (o) === "number" ? o : that.offsetState;
- if (o + (len * w) > that.u8Buf.length) {
- throw new Error("INDEX_SIZE_ERR: DOM Exception 1");
- }
-
- that.offsetState = o + (len * w);
- var arrayType = window["Uint" + (w * 8) + "Array"];
-
- if (len > 1 && isHostLittleEndian === isL) {
- return new arrayType(that.buffer, o, len);
- }
-
- array = array || new arrayType(len);
- var startByte,
- idxInc,
- i,
- idx,
- n,
- j,
- scale,
- v;
-
- if (isL) {
- startByte = 0;
- idxInc = 1;
- } else {
- startByte = w - 1;
- idxInc = -1;
- }
-
- for (i = 0; i < len; i++) {
- idx = o + (i * w) + startByte;
- n = 0;
- for (j = 0, scale = 1; j < w; j++, scale *= 256) {
- v = that.u8Buf[idx];
- n += v * scale;
- idx += idxInc;
- }
- array[i] = n;
- }
-
- return array;
- };
-
- /**
- * Non-standard
- */
- that.getInts = function (len, w, o, isL, array) {
- o = typeof (o) === "number" ? o : that.offsetState;
- if (o + (len * w) > that.u8Buf.length) {
- throw new Error("INDEX_SIZE_ERR: DOM Exception 1");
- }
-
- that.offsetState = o + (len * w);
- var arrayType = window["Int" + (w * 8) + "Array"];
-
- // If the host's endianness matches the file's, just use a typed array view directly.
- if (len > 1 && isHostLittleEndian === isL) {
- return new arrayType(that.buffer, o, len);
- }
-
- array = array || new arrayType(len);
- var mask = Math.pow(256, w),
- halfMask = (mask / 2) - 1,
- startByte,
- idxInc,
- i,
- idx,
- n,
- j,
- scale,
- v;
-
- if (isL) {
- startByte = 0;
- idxInc = 1;
- } else {
- startByte = w - 1;
- idxInc = -1;
- }
-
- for (i = 0; i < len; i++) {
- idx = o + (i * w) + startByte;
- n = 0;
- for (j = 0, scale = 1; j < w; j++, scale *= 256) {
- v = that.u8Buf[idx];
- n += v * scale;
- idx += idxInc;
- }
- array[i] = n > halfMask ? n - mask : n;
- }
-
- return array;
- };
-
- /**
- * Non-standard
- */
- that.getFloats = function (len, w, o, isL, array) {
- var bits = w * 8,
- getterName = "getFloat" + bits,
- arrayType = window["Float" + bits + "Array"],
- i;
-
- // If the host's endianness matches the file's, just use a typed array view directly.
- if (len > 1 && isHostLittleEndian === isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
- if (o + (len * w) > that.u8Buf.length) {
- throw new Error("INDEX_SIZE_ERR: DOM Exception 1");
- }
- that.offsetState = o + (len * w);
- return new arrayType(that.buffer, o, len);
- }
-
- array = array || new arrayType(len);
-
- for (i = 0; i < len; i++) {
- array[i] = that[getterName](o, isL);
- }
-
- return array;
- };
-
- /**
- * Non-standard
- */
- that.getUint = function (w, o, isL) {
- return w === 1 ? that.getUint8(o, isL) : that.getUints(1, w, o, isL, cachedArray)[0];
- };
-
- /**
- * Non-standard
- */
- that.getInt = function (w, o, isL) {
- return that.getInts(1, w, o, isL, cachedArray)[0];
- };
-
- that.getUint8 = function (o) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.u8Buf[o];
- that.offsetState = o + 1;
-
- return n;
- };
-
- that.getInt8 = function (o, isL) {
- return that.getInts(1, 1, o, isL, cachedArray)[0];
- };
-
- that.getUint16 = function (o, isL) {
- return that.getUints(1, 2, o, isL, cachedArray)[0];
- };
-
- that.getInt16 = function (o, isL) {
- return that.getInts(1, 2, o, isL, cachedArray)[0];
- };
-
- that.getUint32 = function (o, isL) {
- return that.getUints(1, 4, o, isL, cachedArray)[0];
- };
-
- that.getInt32 = function (o, isL) {
- return that.getInts(1, 4, o, isL, cachedArray)[0];
- };
-
- that.getFloat32 = function (o, isL) {
- // This method is a modified version of Christopher Chedeau's Float32 decoding
- // implementation from jDataView, originally distributed under the WTF license.
- // https://github.com/vjeux/jDataView
- var bytes = that.getUints(4, 1, o, isL),
- b0,
- b1,
- b2,
- b3,
- sign,
- exp,
- mant;
-
- if (isL) {
- b0 = bytes[3];
- b1 = bytes[2];
- b2 = bytes[1];
- b3 = bytes[0];
- } else {
- b0 = bytes[0];
- b1 = bytes[1];
- b2 = bytes[2];
- b3 = bytes[3];
- }
-
- sign = 1 - (2 * (b0 >> 7));
- exp = (((b0 << 1) & 255) | (b1 >> 7)) - 127;
- mant = ((b1 & 127) * 65536) | (b2 * 256) | b3;
-
- if (exp === 128) {
- return mant !== 0 ? NaN : sign * Infinity;
- }
-
- if (exp === -127) {
- return sign * mant * 1.401298464324817e-45;
- }
-
- return sign * (1 + mant * 1.1920928955078125e-7) * Math.pow(2, exp);
- };
-
- that.getFloat64 = function (o, isL) {
- // This method is a modified version of Christopher Chedeau's Float64 decoding
- // implementation from jDataView, originally distributed under the WTF license.
- // https://github.com/vjeux/jDataView
- var bytes = that.getUints(8, 1, o, isL),
- b0,
- b1,
- b2,
- b3,
- b4,
- b5,
- b6,
- b7,
- sign,
- exp,
- mant;
-
- if (isL) {
- b0 = bytes[7];
- b1 = bytes[6];
- b2 = bytes[5];
- b3 = bytes[4];
- b4 = bytes[3];
- b5 = bytes[2];
- b6 = bytes[1];
- b7 = bytes[0];
- } else {
- b0 = bytes[0];
- b1 = bytes[1];
- b2 = bytes[2];
- b3 = bytes[3];
- b4 = bytes[4];
- b5 = bytes[5];
- b6 = bytes[6];
- b7 = bytes[7];
- }
-
- sign = 1 - (2 * (b0 >> 7));
- exp = ((((b0 << 1) & 255) << 3) | (b1 >> 4)) - 1023;
- mant = ((b1 & 15) * 281474976710656) + (b2 * 1099511627776) + (b3 * 4294967296) +
- (b4 * 16777216) + (b5 * 65536) + (b6 * 256) + b7;
-
- if (exp === 1024) {
- return mant !== 0 ? NaN : sign * Infinity;
- }
-
- if (exp === -1023) {
- return sign * mant * 5e-324;
- }
-
- return sign * (1 + mant * 2.220446049250313e-16) * Math.pow(2, exp);
- };
-
- addSharedMethods(that);
- return that;
- };
-
- var wrappedDataView = function (buffer, byteOffset, byteLength) {
- var that = {
- buffer: buffer,
- byteOffset: typeof (byteOffset) === "number" ? byteOffset : 0
- };
- that.byteLength = typeof (byteLength) === "number" ? byteLength : buffer.byteLength - that.byteOffset;
-
- /**
- * Non-standard
- */
- that.dv = new nativeDataView(buffer, that.byteOffset, that.byteLength);
-
- /**
- * Non-standard
- */
- that.offsetState = that.byteOffset;
-
- /**
- * Non-standard
- */
- that.getUint = function (w, o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv["getUint" + (w * 8)](o, isL);
- that.offsetState = o + w;
-
- return n;
- };
-
- /**
- * Non-standard
- */
- that.getInt = function (w, o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv["getInt" + (w * 8)](o, isL);
- that.offsetState = o + w;
-
- return n;
- };
-
- /**
- * Non-standard
- */
- var getBytes = function (type, len, w, o, isL, array) {
- var bits = w * 8,
- typeSize = type + bits,
- dv = that.dv,
- getterName = "get" + typeSize,
- i;
-
- array = array || new window[typeSize + "Array"](len);
- o = typeof (o) === "number" ? o : that.offsetState;
-
- for (i = 0; i < len; i++) {
- array[i] = dv[getterName](o, isL);
- o += w;
- }
-
- that.offsetState = o;
-
- return array;
- };
-
- /**
- * Non-standard
- */
- that.getUints = function (len, w, o, isL, array) {
- return getBytes("Uint", len, w, o, isL, array);
- };
-
- /**
- * Non-standard
- */
- that.getInts = function (len, w, o, isL, array) {
- return getBytes("Int", len, w, o, isL, array);
- };
-
- /**
- * Non-standard
- */
- that.getFloats = function (len, w, o, isL, array) {
- return getBytes("Float", len, w, o, isL, array);
- };
-
- that.getUint8 = function (o) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getUint8(o);
- that.offsetState = o + 1;
-
- return n;
- };
-
- that.getInt8 = function (o) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getInt8(o);
- that.offsetState = o + 1;
-
- return n;
- };
-
- that.getUint16 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getUint16(o, isL);
- that.offsetState = o + 2;
-
- return n;
- };
-
- that.getInt16 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getInt16(o, isL);
- that.offsetState = o + 2;
-
- return n;
- };
-
- that.getUint32 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getUint32(o, isL);
- that.offsetState = o + 4;
-
- return n;
- };
-
- that.getInt32 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getInt32(o, isL);
- that.offsetState = o + 4;
-
- return n;
- };
-
- that.getFloat32 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getFloat32(o, isL);
- that.offsetState = o + 4;
-
- return n;
- };
-
- that.getFloat64 = function (o, isL) {
- o = typeof (o) === "number" ? o : that.offsetState;
-
- var n = that.dv.getFloat64(o, isL);
- that.offsetState = o + 8;
-
- return n;
- };
-
- addSharedMethods(that);
- return that;
- };
-
- window.PolyDataView = nativeDataView ? wrappedDataView : PolyDataView;
-}());
View
27 third-party/polydataview/tests/html/polydataview-tests.html
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>PolyDataview Unit Tests</title>
-
- <link rel="stylesheet" media="screen" href="../../../../tests/third-party/qunit/css/qunit.css" />
- <script type="text/javascript" src="../../../../tests/third-party/qunit/js/qunit.js"></script>
-
- <script type="text/javascript" src="../../js/polydataview.js"></script>
-
- <script type="text/javascript" src="../js/polydataview-tests.js"></script>
- </head>
-
- <body id="body">
- <h1 id="qunit-header">PolyDataview Unit Tests</h1>
- <h2 id="qunit-banner"></h2>
- <div id="qunit-testrunner-toolbar"></div>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests"></ol>
-
- <!-- Test HTML -->
- <div id="main" style="display: none;">
-
- </div>
- </body>
-</html>
View
329 third-party/polydataview/tests/js/polydataview-tests.js
@@ -1,329 +0,0 @@
-(function () {
- "use strict";
-
- module("Construction");
-
- var arrayView = new Float32Array([0, 0.5, 1.0, -0.5 -1.0]),
- buffer = arrayView.buffer;
-
- test("New DataView with offset and length not specified.", function () {
- var dv = new PolyDataView(buffer);
-
- equals(dv.byteOffset, 0, "When no offset is specified, it should default to 0.");
- equals(dv.byteLength, arrayView.byteLength, "When no length is specified, it should be the same as the array's byte length.");
- });
-
- test("New DataView with only offset specified.", function () {
- var dv = new PolyDataView(buffer, 4);
-
- equals(dv.byteOffset, 4, "When an offset is specified, it should be reflected correctly.");
- equals(dv.byteLength, 12,
- "With an offset but no length specified, the DataView's length should be the array's byte length less the offset.");
- });
-
- test("New DataView with both offset and length specified.", function () {
- var dv = new PolyDataView(buffer, 4, 4);
-
- equals(dv.byteOffset, 4, "When an offset is specified, it should be reflected correctly.");
- equals(dv.byteLength, 4, "When a length is specified, it should be correct.");
- });
-
-
- module("Typed Getters");
-
- var getterTest = function (name, spec) {
- var tester = function (typedBuffer, offset, isLittle) {
- var dv = new PolyDataView(typedBuffer.buffer),
- i,
- expected, actual;
-
- for (i = 0; i < spec.expected.length; i++) {
- expected = spec.expected[i];
- actual = dv[name](offset, isLittle);
- if (isNaN(expected)) {
- ok(isNaN(actual));
- } else {
- equal(actual, expected);
- }
-
- offset = typeof (offset) === "number" ? offset + spec.byteSize : undefined;
- }
- };
-
- for (var endian in spec.byteOrders) {
- var byteOrder = spec.byteOrders[endian];
- var isLittle = endian === "little";
- var testDescription = name + " " + endian + " endian, ";
- test(testDescription + "unspecified offset.", function () {
- tester(byteOrder, undefined, isLittle);
- });
-
- test(testDescription + "offset specified.", function () {
- tester(byteOrder, 0, isLittle);
- });
- }
- };
-
- var testTypedGetters = function (specs) {
- for (var getter in specs) {
- var spec = specs[getter];
- getterTest(getter, spec);
- }
- };
-
- var getterTestSpecs = {
- "getUint8": {
- byteSize: 1,
- expected: [0, 1, 128, 255],
- byteOrders: {
- little: new Uint8Array([0, 1, 128, 255]),
- big: new Uint8Array([0, 1, 128, 255])
- }
- },
-
- "getUint16": {
- byteSize: 2,
- expected: [0, 32768, 65535, 1],
- byteOrders: {
- little: new Uint8Array([
- 0, 0,
- 0, 128,
- 255, 255,
- 1, 0
- ]),
- big: new Uint8Array([
- 0, 0,
- 128, 0,
- 255, 255,
- 0, 1
- ])
- }
- },
-
- "getUint32": {
- byteSize: 4,
- expected: [0, 32768, 65535, 4294967295, 1],
- byteOrders: {
- little: new Uint8Array([
- 0, 0, 0, 0,
- 0, 128, 0, 0,
- 255, 255, 0, 0,
- 255, 255, 255, 255,
- 1, 0, 0, 0
- ]),
- big: new Uint8Array([
- 0, 0, 0, 0,
- 0, 0, 128, 0,
- 0, 0, 255, 255,
- 255, 255, 255, 255,
- 0, 0, 0, 1
- ])
- }
- },
-
- "getInt8": {
- byteSize: 1,
- expected: [0, 1, 127, -1, -128],
- byteOrders: {
- little: new Uint8Array([
- 0, 1, 127, 255, 128
- ]),
- big: new Uint8Array([
- 0, 1, 127, 255, 128
- ])
- }
- },
-
- "getInt16": {
- byteSize: 2,
- expected: [0, 1, 128, 256, 32767, -1, -32768],
- byteOrders: {
- little: new Uint8Array([
- 0, 0,
- 1, 0,
- 128, 0,
- 0, 1,
- 255, 127,
- 255, 255,
- 0, 128
- ]),
- big: new Uint8Array([
- 0, 0,
- 0, 1,
- 0, 128,
- 1, 0,
- 127, 255,
- 255, 255,
- 128, 0
- ])
- }
- },
-
- "getInt32": {
- byteSize: 4,
- expected: [0, 1, 128, 256, 65535, 2147483647, -1, -2147483648],
- byteOrders: {
- little: new Uint8Array([
- 0, 0, 0, 0,
- 1, 0, 0, 0,
- 128, 0, 0, 0,
- 0, 1, 0, 0,
- 255, 255, 0, 0,
- 255, 255, 255, 127,
- 255, 255, 255, 255,
- 0, 0, 0, 128
- ]),
- big: new Uint8Array([
- 0, 0, 0, 0,
- 0, 0, 0, 1,
- 0, 0, 0, 128,
- 0, 0, 1, 0,
- 0, 0, 255, 255,
- 127, 255, 255, 255,
- 255, 255, 255, 255,
- 128, 0, 0, 0
- ])
- }
- },
-
- "getFloat32": {
- byteSize: 4,
- expected: new Float32Array([0, -0, 0.5, 1.0, 3.4028234e+38, Infinity, -0.5, -1.0, -3.4028234e+38, -Infinity, 0.3333333432674408, NaN]),
- byteOrders: {
- little: new Uint8Array([
- 0, 0, 0, 0,
- 0, 0, 0, 128,
- 0, 0, 0, 63,
- 0, 0, 128, 63,
- 255, 255, 127, 127,
- 0, 0, 0, 128, 127,
- 0, 0, 0, 191,
- 0, 0, 128, 191,
- 255, 255, 127, 255,
- 0, 0, 128, 255,
- 171, 170, 170, 62,
- 0, 0, 192, 127
- ]),
- big: new Uint8Array([
- 0, 0, 0, 0,
- 128, 0, 0, 0,
- 63, 0, 0, 0,
- 63, 128, 0, 0,
- 127, 127, 255, 255,
- 127, 128, 0, 0,
- 191, 0, 0, 0,
- 191, 128, 0, 0,
- 255, 127, 255, 255,
- 255, 128, 0, 0,
- 62, 170, 170, 171,
- 127, 192, 0, 0
- ])
- }
- },
-
- "getFloat64": {
- byteSize: 8,
- expected: new Float64Array([1, 1.0000000000000002, 2, -2, 0, -0, Infinity, -Infinity, Number.MAX_VALUE, Number.MIN_VALUE, 1/3, NaN]),
- byteOrders: {
- little: new Uint8Array([
- 0, 0, 0, 0, 0, 0, 24, 63,
- 1, 240, 0, 0, 0, 0, 240, 63,
- 0, 0, 0, 0, 0, 0, 0, 64,
- 0, 0, 0, 0, 0, 0, 0, 192,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 128,
- 0, 0, 0, 0, 0, 0, 240, 127,
- 0, 0, 0, 0, 0, 0, 240, 255,
- 255, 255, 255, 255, 255, 255, 127, 239,
- 1, 0, 0, 0, 0, 0, 0, 0,
- 85, 85, 85, 85, 85, 85, 213, 63,
- 0, 0, 0, 0, 0, 0, 248, 127
- ]),
- big: new Uint8Array([
- 63, 240, 0, 0, 0, 0, 0, 0,
- 63, 240, 0, 0, 0, 0, 0, 1,
- 64, 0, 0, 0, 0, 0, 0, 0,
- 192, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 128, 0, 0, 0, 0, 0, 0, 0,
- 127, 240, 0, 0, 0, 0, 0, 0,
- 255, 240, 0, 0, 0, 0, 0, 0,
- 127, 239, 255, 255, 255, 255, 255, 255,
- 0, 0, 0, 0, 0, 0, 0, 1,
- 63, 213, 85, 85, 85, 85, 85, 85,
- 127, 248, 0, 0, 0, 0, 0, 0
- ])
- }
- }
- };
-
- testTypedGetters(getterTestSpecs);
-
- module("String Getter");
-
- test("8-bit Strings", function () {
- var expected = "Stringy",
- raw = [],
- actual,
- i,
- buffer;
-
- for (i = 0; i < expected.length; i++) {
- raw.push(expected.charCodeAt(i));
- }
- buffer = new Uint8Array(raw).buffer;
-
- // Track offset ourselves.
- var dv = new PolyDataView(buffer);
- actual = dv.getString(7, 1, 0, true);
- equal(actual, expected);
-
- // Don't track offset.
- dv = new PolyDataView(buffer);
- actual = dv.getString(7, 1, undefined, true);
- equal(actual, expected);
- });
-
- test("Multibyte Strings", function () {
- var spec = {
- expected: String.fromCharCode(0xf900) + String.fromCharCode(0xf901) + String.fromCharCode(0xf902),
- byteOrders: {
- little: new Uint8Array([
- 0x00, 0xf9, // 豈
- 0x01, 0xf9, // 更
- 0x02, 0xf9 // 車
- ]),
-
- big: new Uint8Array([
- 0xf9, 0x00, // 豈
- 0xf9, 0x01, // 更
- 0xf9, 0x02 // 車
- ])
- }
- };
-
- var endian,
- isLittle,
- byteOrder,
- dv,
- actual;
-
- for (endian in spec.byteOrders) {
- isLittle = endian === "little";
- byteOrder = spec.byteOrders[endian];
- dv = new PolyDataView(byteOrder.buffer);
- actual = dv.getString(spec.expected.length, 2, undefined, isLittle);
- equal(actual, spec.expected);
- }
- });
-
- /*
- Not yet tested:
- getUints
- getInts
- getFloats
- getUint
- getInt
- getFloat80
- */
-})();

0 comments on commit 80a4c2e

Please sign in to comment.