1
|
|
|
/* |
2
|
|
|
* Copyright (c) 2018 Rafael da Silva Rocha. |
3
|
|
|
* |
4
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining |
5
|
|
|
* a copy of this software and associated documentation files (the |
6
|
|
|
* "Software"), to deal in the Software without restriction, including |
7
|
|
|
* without limitation the rights to use, copy, modify, merge, publish, |
8
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to |
9
|
|
|
* permit persons to whom the Software is furnished to do so, subject to |
10
|
|
|
* the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be |
13
|
|
|
* included in all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
16
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
17
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
18
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
19
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
20
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @fileoverview Externs for minibuffer 0.1.0 |
27
|
|
|
* |
28
|
|
|
* @see https://github.com/rochars/minibuffer |
29
|
|
|
* @externs |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* A class to read and write to buffers. |
34
|
|
|
*/ |
35
|
|
|
var MiniBuffer = {}; |
36
|
|
|
|
37
|
|
|
// The types param |
38
|
|
|
var typeDefinition = { |
39
|
|
|
bits: 0, |
40
|
|
|
signed: false, |
41
|
|
|
float: false, |
42
|
|
|
be: false |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @type {number} |
47
|
|
|
*/ |
48
|
|
|
MiniBuffer.head = 0; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Read a number from a buffer. |
52
|
|
|
* @param {!Uint8Array} buffer The bufefr. |
53
|
|
|
* @param {!Object} typeDefinition The type definition. |
54
|
|
|
* @return {number} The number. |
55
|
|
|
*/ |
56
|
|
|
MiniBuffer.read = function(buffer, typeDefinition) {}; |
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Write a number to a buffer. |
60
|
|
|
* @param {!Uint8Array} buffer The buffer. |
61
|
|
|
* @param {!Object} typeDefinition The type definition. |
62
|
|
|
* @param {number} num The number to write. |
63
|
|
|
* @param {?number=} index The buffer index to write. |
64
|
|
|
*/ |
65
|
|
|
MiniBuffer.write = function(buffer, typeDefinition, num, index=null) {}; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Write a ASCII string to a buffer. If the string is smaller |
69
|
|
|
* than the max size the output buffer is filled with 0s. |
70
|
|
|
* @param {!Uint8Array} buffer The buffer. |
71
|
|
|
* @param {string} str The string to be written as bytes. |
72
|
|
|
* @param {number=} size The size of the string. |
73
|
|
|
* @param {?number=} index The buffer index to write. |
74
|
|
|
* @throws {Error} If size + index > buffer.length |
75
|
|
|
*/ |
76
|
|
|
MiniBuffer.writeStr = function(buffer, str, size=str.length, index=null) {}; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Read a ASCII string from a buffer. |
80
|
|
|
* @param {!Uint8Array} buffer The buffer. |
81
|
|
|
* @param {number} size the max size of the string. |
82
|
|
|
* @param {?number=} index The buffer index to read. |
83
|
|
|
* @return {string} The string. |
84
|
|
|
* @throws {Error} If size + index > buffer.length |
85
|
|
|
*/ |
86
|
|
|
MiniBuffer.readStr = function(buffer, size, index=null) {}; |
87
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.