@@ -6,28 +6,18 @@ local vobject = require "vips.vobject"
66
77local vips_lib = ffi .load (ffi .os == " Windows" and " libvips-42.dll" or " vips" )
88
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 = {}
2010
2111Connection .new = function (vconnection )
2212 local connection = {}
2313 connection .vconnection = vobject .new (vconnection )
2414 return setmetatable (connection , Connection .mt )
2515end
26- function Connection_method :vobject ()
16+ function Connection :vobject ()
2717 return ffi .cast (vobject .typeof , self .vconnection )
2818end
2919
30- function Connection_method :filename ()
20+ function Connection :filename ()
3121 -- Get the filename asscoiated with a connection. Return nil if there is no associated file.
3222 local so = ffi .cast (' VipsConnection *' , self .vconnection )
3323 local filename = vips_lib .vips_connection_filename (so )
@@ -38,7 +28,7 @@ function Connection_method:filename()
3828 end
3929end
4030
41- function Connection_method :nick ()
31+ function Connection :nick ()
4232 -- Make a human-readable name for a connection suitable for error messages.
4333
4434 local so = ffi .cast (' VipsConnection *' , self .vconnection )
@@ -51,5 +41,8 @@ function Connection_method:nick()
5141end
5242
5343return ffi .metatype (" VipsConnection" , {
54- __index = Connection
44+ __index = Connection ,
45+ __tostring = function (self )
46+ return self :filename () or self :nick () or " (nil)"
47+ end
5548})
0 commit comments