File: GLib-Timer.lua

package info (click to toggle)
lua-lgi 0.9.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,388 kB
  • sloc: ansic: 5,082; makefile: 169; sh: 31
file content (34 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-------------------------------------------------------------------------------
--
-- LGI GLib Timer support implementation.
--
-- Copyright (c) 2013 Pavel Holejsovsky
-- Licensed under the MIT license:
-- http://www.opensource.org/licenses/mit-license.php
--
-------------------------------------------------------------------------------

local pairs = pairs

local lgi = require 'lgi'
local core = require 'lgi.core'
local record = require 'lgi.record'
local ffi = require 'lgi.ffi'
local ti = ffi.types

local Timer = lgi.GLib.Timer:_resolve(true)

local module = core.gi.GLib.resolve
for name, def in pairs {
   new = { ret = { Timer, xfer = true } },
   elapsed = { ret = ti.double, { Timer }, { ti.ulong, dir = 'out' } },
} do
   local _ = Timer[name]
   def.addr = module['g_timer_' .. name]
   def.name = 'GLib.Timer.' .. name
   Timer[name] = core.callable.new(def)
end

Timer._free = core.gi.GLib.Timer.methods.destroy
Timer._method.destroy = nil
Timer._new = function(_, ...) return Timer.new(...) end