Skip to content

Commit

Permalink
Added a lot of empty files but did a lot of work on completing events
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSpyce committed Jun 6, 2018
1 parent e8b4002 commit 22b5ce5
Show file tree
Hide file tree
Showing 43 changed files with 2,099 additions and 12,185 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ When Thiq is initialized, it first creates a compiler to be used. Our environmen

### The Entry File

Think of this file as the `int main()` of the environment. Once the environment is finished initializing, this is called. Once this file is finished executing, Thiq is considered finished loading.
Think of this file as the `int main()` of the environment. Once the environment is finished initializing, this is called. Once this file is finished executing, Thiq is considered finished loading.

### Dependencies

Expand Down
16 changes: 10 additions & 6 deletions startup.js → index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// load all the profiles
var pf = require('pf');
pf.initialize();

var quests = require('quests2');
var factory = new quests.QuestFactory();
// load all the profiles
var pf = require('pf');
pf.initialize();

var quests = require('quests2');
var factory = new quests.QuestFactory();

require('./src/code-import');
require('./src/golden-axe');
require('./src/mention');
3 changes: 1 addition & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ function assert(toCheck, error) {
}
}

module.exports = assert;
global.assert = assert; // because we kinda need this everywhere. Not good to have globally, but fuck it
module.exports = assert;
236 changes: 236 additions & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
// an attempt at using Java's buffers to replicate Node functionality
var ByteBuffer = require('@java.nio.ByteBuffer');
var Integer = require('@java.lang.Integer');
var os = require('os');
var errors = require('internal/errors').codes;

function convertByteToSigned(b) {
if (b < 128) return b;
return Math.pow(2, 8) + Math.abs(b);
}

function convertShortToUnsigned(s) {
if (s > 0) return s;
return Math.pow(2, 16) + Math.abs(s);
}

function convertIntToUnsigned(i) {
if (i > 0) return i;
return Math.pow(2, 32) + Math.abs(i);
}

function Buffer(jb) {
this.jBuffer = jb;
}

Buffer.prototype.readDoubleBE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return this.jBuffer.getDouble(offset);
};

Buffer.prototype.readDoubleLE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readDoubleBE(offset, noAssert));
};

Buffer.prototype.readFloatBE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return this.jBuffer.getFloat(offset);
};

Buffer.prototype.readFloatLE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readFloatBE(offset, noAssert));
};

Buffer.prototype.readInt8 = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return convertByteToSigned(this.readUInt8(offset, noAssert));
};

Buffer.prototype.readUInt8 = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return this.jBuffer.get(offset);
};

Buffer.prototype.readInt16BE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return this.jBuffer.getShort(offset);
};

Buffer.prototype.readInt16LE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readInt16BE(offset, noAssert));
};

Buffer.prototype.readUInt16BE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return convertShortToUnsigned(this.jBuffer.getShort(offset));
};

Buffer.prototype.readUInt16LE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readUInt16BE(offset, noAssert));
};

Buffer.prototype.readInt32BE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return this.jBuffer.getInt(offset);
};

Buffer.prototype.readInt32LE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readInt32BE(offset, noAssert));
};

Buffer.prototype.readUInt32BE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return convertIntToUnsigned(this.jBuffer.getInt(offset));
};

Buffer.prototype.readUInt32LE = function(offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
return Integer.reverseBytes(this.readUInt32BE(offset, noAssert));
};

Buffer.prototype.writeDoubleBE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putDouble(value, offset);
return 8;
};

Buffer.prototype.writeDoubleLE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putDouble(Integer.reverseBytes(value), offset);
return 8;
};

Buffer.prototype.writeFloatBE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putFloat(value, offset);
return 4;
};

Buffer.prototype.writeFloatLE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putFloat(Integer.reverseBytes(value), offset);
return 4;
};

Buffer.prototype.writeInt8 = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.put(Integer.reverseBytes(value), offset);
return 1;
};

Buffer.prototype.writeUInt8 = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.put(value, offset);
return 1;
};

Buffer.prototype.writeInt16BE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putShort(value, offset);
return 2;
};

Buffer.prototype.writeInt16LE = function(value, offset, noAssert) {
return this.writeInt16BE(Integer.reverseBytes(value), offset, noAssert);
};

Buffer.prototype.writeUInt16BE = function(value, offset, noAssert) {
return this.writeInt16BE(convertShortToUnsigned(value), offset, noAssert);
};

Buffer.prototype.writeUInt16LE = function(value, offset, noAssert) {
return this.writeInt16LE(convertShortToUnsigned(value), offset, noAssert);
};

Buffer.prototype.writeInt32BE = function(value, offset, noAssert) {
if (noAssert !== true && this.jBuffer.limit() <= offset) throw new Error("The offset must be less than the buffer's length.");
this.jBuffer.putInt(value, offset);
return 4;
};

Buffer.prototype.writeInt32LE = function(value, offset, noAssert) {
return this.writeInt32BE(Integer.reverseBytes(value), offset, noAssert);
};

Buffer.prototype.writeUInt32BE = function(value, offset, noAssert) {
return this.writeInt32BE(convertIntToUnsigned(value), offset, noAssert);
};

Buffer.prototype.writeUInt32LE = function(value, offset, noAssert) {
return this.writeInt32LE(convertIntToUnsigned(value), offset, noAssert);
};

Buffer.prototype.write = function(value, offset, length, encoding) {
if (offset === undefined) offset = 0;
if (length === undefined) length = this.jBuffer.limit() - offset;
if (encoding === undefined) encoding = 'UTF8';
var remaining = this.jBuffer.remaining();
var bytes = value.getBytes(encoding);
this.jBuffer.put(bytes, offset, length);
return Math.min([remaining, bytes.length]);
};

Buffer.prototype.slice = function(start, end) {
// this is really hackish, but I don't know a faster/native way.
var source = this.jb.array();
var result = java.util.Arrays.copyOfRange(source, start || 0, end || source.capacity());
return Buffer.from(result);
}

Buffer.prototype.swap16 = function() {
if (this.jb.capacity() % 2 > 0) throw new errors.ERR_INVALID_BUFFER_SIZE();
}

Buffer.prototype.swap32 = function() {
if (this.jb.capacity() % 4 > 0) throw new errors.ERR_INVALID_BUFFER_SIZE();
}

Buffer.prototype.swap64 = function() {
if (this.jb.capacity() % 8 > 0) throw new errors.ERR_INVALID_BUFFER_SIZE();

}

Buffer.prototype.toJSON = function() {

}

Buffer.prototype.toString = function(encoding, start, end) {

}

Buffer.prototype.values = function() {

}

Buffer.alloc = function(size, fill, encoding) {
var buffer = new Buffer(ByteBuffer.alloc(size));
if (fill != undefined) {
for (var i = 0; i < size; i++) {
buffer.write(fill[i]);
}
}

return buffer;
};

Buffer.INSPECT_MAX_BYTES = 50;
Buffer.constants = {
MAX_LENGTH: os.is64Bit ? (2^31) - 1 : (2^30) - 1,
MAX_STRING_LENGTH: os.is64Bit ? (2^31) - 1 : (2^30) - 1,
}

Buffer.transcode = function(source, fromEnc, toEnc) {

}

Buffer.from = function(contents) {
return new Buffer(ByteBuffer.wrap(contents));
};

module.exports = Buffer;
module.exports.kMaxLength = Buffer.constants.MAX_LENGTH;
Empty file added lib/cluster.js
Empty file.
Empty file added lib/console.js
Empty file.
Empty file added lib/crypto.js
Empty file.
Empty file added lib/dgram.js
Empty file.
Empty file added lib/dns.js
Empty file.
Empty file added lib/domain.js
Empty file.

0 comments on commit 22b5ce5

Please sign in to comment.