@@ -6,18 +6,26 @@ local vobject = require "vips.vobject"
66
77local  vips_lib  =  ffi .load (ffi .os  ==  " Windows"  and  " libvips-42.dll"  or  " vips"  )
88
9- local  Connection  =  {}
9+ local  Connection_method  =  {}
1010
11- Connection .vobject  =  function (self )
12-     return  ffi .cast (vobject .typeof , self )
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)" 
1319end 
1420
15- Connection .new  =  function (self )
16-     return  vobject .new (self )
21+ Connection .new  =  function (vconnection )
22+     local  connection  =  {}
23+     connection .vconnection  =  vobject .new (vconnection )
24+     return  setmetatable (connection , Connection .mt )
1725end 
18- Connection . filename   =   function ( self )
26+ function   Connection_method : filename ( )
1927    --  Get the filename asscoiated with a connection. Return nil if there is no associated file.
20-     local  so  =  ffi .cast (' VipsConnection *'  , self .pointer )
28+     local  so  =  ffi .cast (' VipsConnection *'  , self .vconnection )
2129    local  filename  =  vips_lib .vips_connection_filename (so )
2230    if  filename  ==  ffi .NULL  then 
2331        return  nil 
@@ -26,10 +34,10 @@ Connection.filename = function(self)
2634    end 
2735end 
2836
29- Connection . nick   =   function ( self )
37+ function   Connection_method : nick ( )
3038    --  Make a human-readable name for a connection suitable for error messages.
3139
32-     local  so  =  ffi .cast (' VipsConnection *'  , self .pointer )
40+     local  so  =  ffi .cast (' VipsConnection *'  , self .vconnection )
3341    local  nick  =  vips_lib .vips_connection_nick (so )
3442    if  nick  ==  ffi .NULL  then 
3543        return  nil 
0 commit comments