Skip to content

Commit 9f8b6db

Browse files
authored
Merge pull request #173 from cryi/master
Added type names for exposed metatables
2 parents 833e87c + 691dfb1 commit 9f8b6db

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/l52util.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ int lutil_newmetatablep (lua_State *L, const void *p) {
6868

6969
lua_newtable(L); /* create metatable */
7070
lua_pushvalue(L, -1); /* duplicate metatable to set*/
71+
72+
lua_pushliteral (L, "__type");
73+
lua_pushstring(L, p); // push meta name
74+
lua_settable (L, -3); // set meta name
75+
7176
lua_rawsetp(L, LUA_REGISTRYINDEX, p);
7277

7378
return 1;
@@ -122,7 +127,6 @@ int lutil_createmetap (lua_State *L, const void *p, const luaL_Reg *methods, int
122127
lua_pushliteral (L, "__index"); /* define metamethods */
123128
lua_pushvalue (L, -2);
124129
lua_settable (L, -3);
125-
126130
return 1;
127131
}
128132

src/lua/cURL/impl/cURL.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ local function form_add(form, data)
219219
return form
220220
end
221221

222-
local function class(ctor)
222+
local function class(ctor, type_name)
223223
local C = {}
224+
C.__type = type_name or "LcURL Unknown"
224225
C.__index = function(self, k)
225226
local fn = C[k]
226227

@@ -254,7 +255,7 @@ end
254255
local function Load_cURLv2(cURL, curl)
255256

256257
-------------------------------------------
257-
local Easy = class(curl.easy) do
258+
local Easy = class(curl.easy, "LcURL Easy") do
258259

259260
local perform = wrap_function("perform")
260261
local setopt_share = wrap_function("setopt_share")
@@ -400,7 +401,7 @@ end
400401
-------------------------------------------
401402

402403
-------------------------------------------
403-
local Multi = class(curl.multi) do
404+
local Multi = class(curl.multi, "LcURL Multi") do
404405

405406
local perform = wrap_function("perform")
406407
local add_handle = wrap_function("add_handle")
@@ -460,7 +461,7 @@ end
460461
-------------------------------------------
461462

462463
-------------------------------------------
463-
local Share = class(curl.share) do
464+
local Share = class(curl.share, "LcURL Share") do
464465

465466
Share.setopt_share = wrap_setopt_flags("share", {
466467
[ "COOKIE" ] = curl.LOCK_DATA_COOKIE;
@@ -485,7 +486,7 @@ end
485486
local function Load_cURLv3(cURL, curl)
486487

487488
-------------------------------------------
488-
local Form = class(curl.form) do
489+
local Form = class(curl.form, "LcURL Form") do
489490

490491
function Form:__init(opt)
491492
if opt then return self:add(opt) end
@@ -505,7 +506,7 @@ end
505506
-------------------------------------------
506507

507508
-------------------------------------------
508-
local Easy = class(curl.easy) do
509+
local Easy = class(curl.easy, "LcURL Easy") do
509510

510511
function Easy:__init(opt)
511512
if opt then return self:setopt(opt) end
@@ -595,7 +596,7 @@ end
595596
-------------------------------------------
596597

597598
-------------------------------------------
598-
local Multi = class(curl.multi) do
599+
local Multi = class(curl.multi, "LcURL Multi") do
599600

600601
local add_handle = wrap_function("add_handle")
601602
local remove_handle = wrap_function("remove_handle")

0 commit comments

Comments
 (0)