@@ -6,28 +6,18 @@ local vobject = require "vips.vobject"
6
6
7
7
local vips_lib = ffi .load (ffi .os == " Windows" and " libvips-42.dll" or " vips" )
8
8
9
- local Connection_method = {}
10
-
11
- local Connection = {
12
- mt = {
13
- __index = Connection_method ,
14
- }
15
- }
16
-
17
- function Connection .mt :__tostring ()
18
- return self :filename () or self :nick () or " (nil)"
19
- end
9
+ local Connection = {}
20
10
21
11
Connection .new = function (vconnection )
22
12
local connection = {}
23
13
connection .vconnection = vobject .new (vconnection )
24
14
return setmetatable (connection , Connection .mt )
25
15
end
26
- function Connection_method :vobject ()
16
+ function Connection :vobject ()
27
17
return ffi .cast (vobject .typeof , self .vconnection )
28
18
end
29
19
30
- function Connection_method :filename ()
20
+ function Connection :filename ()
31
21
-- Get the filename asscoiated with a connection. Return nil if there is no associated file.
32
22
local so = ffi .cast (' VipsConnection *' , self .vconnection )
33
23
local filename = vips_lib .vips_connection_filename (so )
@@ -38,7 +28,7 @@ function Connection_method:filename()
38
28
end
39
29
end
40
30
41
- function Connection_method :nick ()
31
+ function Connection :nick ()
42
32
-- Make a human-readable name for a connection suitable for error messages.
43
33
44
34
local so = ffi .cast (' VipsConnection *' , self .vconnection )
@@ -51,5 +41,8 @@ function Connection_method:nick()
51
41
end
52
42
53
43
return ffi .metatype (" VipsConnection" , {
54
- __index = Connection
44
+ __index = Connection ,
45
+ __tostring = function (self )
46
+ return self :filename () or self :nick () or " (nil)"
47
+ end
55
48
})
0 commit comments