mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-25 14:05:39 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers into MC1.7
This commit is contained in:
commit
fed7f32ad7
@ -31,11 +31,18 @@ function internet.request(url, data)
|
||||
end
|
||||
|
||||
return function()
|
||||
local data, reason = result.read()
|
||||
if not data and reason then
|
||||
error(reason, 2)
|
||||
else
|
||||
return data
|
||||
while true do
|
||||
local data, reason = result.read()
|
||||
if not data then
|
||||
if reason then
|
||||
error(reason, 2)
|
||||
else
|
||||
return nil -- eof
|
||||
end
|
||||
elseif #data > 0 then
|
||||
return data
|
||||
end
|
||||
-- else: no data, block
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -244,17 +244,22 @@ sandbox._G = sandbox
|
||||
-- wrap and isolate it, to make sure it can't be touched by user code.
|
||||
-- These functions provide the logic for wrapping and unwrapping (when
|
||||
-- pushed to user code and when pushed back to the host, respectively).
|
||||
local wrapUserdata, wrapSingleUserdata, unwrapUserdata
|
||||
local wrappedUserdata = setmetatable({}, {
|
||||
local wrapUserdata, wrapSingleUserdata, unwrapUserdata, wrappedUserdataMeta
|
||||
wrappedUserdataMeta = {
|
||||
-- Weak keys, clean up once a proxy is no longer referenced anywhere.
|
||||
__mode="k",
|
||||
-- We need custom persist logic here to avoid ERIS trying to save the
|
||||
-- userdata referenced in this table directly. It will be repopulated
|
||||
-- in the load methods of the persisted userdata wrappers (see below).
|
||||
__persist = function()
|
||||
return function() return {} end
|
||||
return function()
|
||||
-- When using special persistence we have to manually reassign the
|
||||
-- metatable of the persisted value.
|
||||
return setmetatable({}, wrappedUserdataMeta)
|
||||
end
|
||||
end
|
||||
})
|
||||
}
|
||||
local wrappedUserdata = setmetatable({}, wrappedUserdataMeta)
|
||||
|
||||
local function processArguments(...)
|
||||
local args = table.pack(...)
|
||||
|
@ -269,14 +269,16 @@ object InternetCard {
|
||||
}
|
||||
}
|
||||
|
||||
class Request(val owner: Option[InternetCard] = None) extends AbstractValue {
|
||||
class Request extends AbstractValue {
|
||||
private var owner: Option[InternetCard] = None
|
||||
private var url: URL = null
|
||||
private var post: Option[String] = None
|
||||
private var data: Option[Array[Byte]] = None
|
||||
private var error: Option[String] = None
|
||||
|
||||
def this(owner: InternetCard, url: URL, post: Option[String]) {
|
||||
this(Option(owner))
|
||||
this()
|
||||
this.owner = Option(owner)
|
||||
this.url = url
|
||||
this.post = post
|
||||
scheduleRequest()
|
||||
|
Loading…
x
Reference in New Issue
Block a user