From 808c1972a912d0d4570c9672fdd154e57e21463a Mon Sep 17 00:00:00 2001 From: apemanzilla Date: Sat, 24 Mar 2018 15:01:41 -0400 Subject: [PATCH] Add HTTP lib and globals --- extraParams.hxml | 0 haxelib.json | 4 ++-- src/cc/ComputerCraft.hx | 10 ++++++++++ src/cc/HTTP.hx | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) delete mode 100644 extraParams.hxml create mode 100644 src/cc/ComputerCraft.hx create mode 100644 src/cc/HTTP.hx diff --git a/extraParams.hxml b/extraParams.hxml deleted file mode 100644 index e69de29..0000000 diff --git a/haxelib.json b/haxelib.json index 0884b97..34322c7 100644 --- a/haxelib.json +++ b/haxelib.json @@ -4,9 +4,9 @@ "license": "MIT", "tags": ["computercraft", "cc", "minecraft", "lua"], "description": "Bindings for the Lua APIs of the ComputerCraft mod for Minecraft", - "version": "1.0.0", + "version": "1.0.1", "classPath": "src", - "releasenote": "Initial release", + "releasenote": "Adds missing HTTP api and globals (in ComputerCraft class)", "contributors": [ "apemanzilla" ] diff --git a/src/cc/ComputerCraft.hx b/src/cc/ComputerCraft.hx new file mode 100644 index 0000000..225d056 --- /dev/null +++ b/src/cc/ComputerCraft.hx @@ -0,0 +1,10 @@ +package src.cc; + +@:native("_G") +extern class ComputerCraft { + public static var _CC_DEFAULT_SETTINGS: String; + public static function printError(message: String): Void; + public static function sleep(seconds: Float): Void; + public static function read(?replacement: String): String; // todo: second and third args + public static var _HOST: String; +} \ No newline at end of file diff --git a/src/cc/HTTP.hx b/src/cc/HTTP.hx new file mode 100644 index 0000000..84fd5af --- /dev/null +++ b/src/cc/HTTP.hx @@ -0,0 +1,24 @@ +package src.cc; + +import lua.Table; + +@:multiReturn +extern class HTTPCheckReturn { + public var allowed: Bool; + public var error: Null; +} + +extern class HTTPResponse { + public function close(): Void; + public function readLine(): String; + public function readAll(): String; + public function getResponseCode(): Int; +} + +@:native("http") +extern class HTTP { + public static function checkURL(url: String): Bool; + public static function request(url: String, ?postData: String, ?headers: Table): Void; + public static function get(url: String, ?headers: Table): Null; + public static function post(url: String, postData: String, ?header: Table): Null; +} \ No newline at end of file