Skip to content

Commit 3d2d59d

Browse files
committed
wip
1 parent 004d2ed commit 3d2d59d

5 files changed

Lines changed: 25 additions & 6 deletions

File tree

Runtime/Bindings/FFI/curl/curl.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ struct static_curl_exports_table {
355355
CURLcode (*curl_easy_recv)(CURL* handle, void* buffer, size_t buflen, size_t* n);
356356
void (*curl_easy_reset)(CURL* handle);
357357
CURLcode (*curl_easy_send)(CURL* handle, const void* buffer, size_t buflen, size_t* n);
358-
CURLcode (*curl_easy_setopt)(CURL* handle, const struct curl_easyoption* option, ...);
358+
CURLcode (*curl_easy_setopt)(CURL* handle, const struct curl_easyoption* option, va_list);
359359
CURLcode (*curl_easy_ssls_import)(CURL* handle,
360360
const char* session_key,
361361
const unsigned char* shmac,
@@ -544,6 +544,17 @@ function curl.easy_init()
544544
return handle
545545
end
546546

547+
function curl.easy_setopt(handle, name, value)
548+
local option = curl.bindings.curl_easy_option_by_name(name)
549+
assert(option ~= ffi.NULL, "Invalid option name: " .. name) -- TBD
550+
551+
local status = curl.bindings.curl_easy_setopt(handle, option, value)
552+
if status ~= ffi.C.CURLUE_OK then
553+
-- return nil, curl.curl_easy_strerror(status) -- TBD
554+
end
555+
556+
return status
557+
end
547558
function curl.free(pointer)
548559
curl.bindings.curl_free(pointer)
549560
end

Runtime/Bindings/FFI/curl/curl_ffi.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
typedef CURLU* url_ptr_t;
77
typedef const CURLU* url_cptr_t;
88

9+
extern "C" {
10+
#include "curl_exports.h"
11+
}
12+
13+
914
// typedef enum {
1015
// /* This is the FILE * or void * the regular output should be written to. */
1116
// CURLOPT(CURLOPT_WRITEDATA, CURLOPTTYPE_CBPOINT, 1),
@@ -1124,8 +1129,6 @@ typedef const CURLU* url_cptr_t;
11241129
// CURLOPT_LASTENTRY /* the last unused */
11251130
// } CURLoption;
11261131

1127-
#include "curl_exports.h"
1128-
11291132
namespace curl_ffi {
11301133
void* getExportsTable();
11311134
}

Runtime/Libraries/bdd.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function bdd.startSubsection(label, testFunction)
230230
end
231231

232232
local success, errorDetails = xpcall(testFunction, errorHandler)
233-
233+
print(success, errorDetails)
234234
for _, teardownFunction in ipairs(bdd.registeredTeardownFunctions) do
235235
teardownFunction()
236236
end

Tests/BDD/curl-library.spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ describe("curl", function()
1717

1818
describe("easy_setopt", function()
1919
it("should be able to set the URL", function()
20-
local easy = curl.easy_init()
21-
assert(easy)
20+
local easy = assert(curl.easy_init())
21+
assert(curl.easy_setopt(easy, "url", "http://localhost:8080"))
2222
end)
2323
end)
2424

Tests/SmokeTests/bdd-library/test-start-runner.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ local function testSetupTeardownHookNestingCase()
389389
_G.CALLSTACK = nil -- Is it a crime if there aren't any witnesses?
390390
end
391391

392+
function testInvalidErrorDetailsAfterThrownException()
393+
394+
end
395+
392396
local function testStartTestRunner()
393397
testNoFilesCase()
394398
testInvalidFileCase()
@@ -407,6 +411,7 @@ local function testStartTestRunner()
407411
testDetailedPassingTestCase()
408412
testDetailedFailingTestCase()
409413
testSetupTeardownHookNestingCase()
414+
testInvalidErrorDetailsAfterThrownException()
410415
end
411416

412417
testStartTestRunner()

0 commit comments

Comments
 (0)