-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinit.lua
114 lines (95 loc) · 2.59 KB
/
init.lua
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
jit.off()
local argc, argv = ...
package.path = PATH..'/?.lua;'..
PATH..'/?/init.lua;'..
package.path
pcall(require, 'autorun')
pcall(require, 'config.repos')
REPOS = REPOS or {}
require 'constants'
config = require 'config'
ffi = require 'ffi'
C = ffi.C
bit = require 'bit'
objc = require 'objc'
require 'util'
require 'cdef'
function Cmd(cmd, f)
C.pipeit(APP_PATH..'/setuid /usr/bin/env '..cmd, f)
end
function HOOK(t, k, hook)
local orig = t[k]
if not(type(orig) == 'function') then
error('invalid type')
end
t[k] = function(...)
return hook(orig, ...)
end
end
local count = 0
function objc.GenerateClass(super, ...)
super = super or 'NSObject'
count = count + 1
local name = 'DPKGAPP_'..count..super
if ... then
objc.class(name, super..'<'..table.concat({...}, ',')..'>')
else
objc.class(name, super)
end
return objc[name]
end
local objc_objz = {}
function objc.AssocLua(obj, set)
local hash = tonumber(ffi.cast('uintptr_t',obj))
local result = objc_objz[hash]
if set then
if result then error('wtf???') end
objc_objz[hash] = set
result = set
end
return result
end
function objc.Lua(...)
return objc.AssocLua(...)
end
function VIEWCONTROLLER(callback, title)
local m = objc.GenerateClass('UIViewController'):alloc():init()
m:setTitle(title or '')
if callback then
function m:viewDidLoad()
callback(m)
end
end
return m
end
Object = require 'object'
Deb = require 'deb'
Depiction = require 'depiction'
Repo = require 'repo'
ui = {}
require 'ui.table'
require 'ui.filtertable'
require 'ui.cell'
require 'ui.searchbar'
require 'ui.button'
require 'ui.gesture'
require 'ui.textbox'
require 'ui.scroll'
ns = {}
require 'ns.target'
require 'ns.http'
objc.class('AppDelegate', 'UIResponder')
objc.addmethod(objc.AppDelegate, 'application:didFinishLaunchingWithOptions:', function(self, app, options)
require 'main'
return true
end, ffi.arch == 'arm64' and 'B32@0:8@16@24' or 'B16@0:4@8@12')
objc.addmethod(objc.AppDelegate, 'application:openURL:sourceApplication:annotation:', function(self, app, url, sourceApp, annotation)
url = objc.tolua(url:absoluteString())
url = string.sub(url, #'dpkgapp://' + 1, #url)
OPENURL(url)
return true
end, ffi.arch == 'arm64' and 'B48@0:8@16@24@32@40' or 'B24@0:4@8@12@16@20')
DONT_RETAIN = true
objc.NSAutoreleasePool:alloc():init() --lol who cares about memory management
DONT_RETAIN = false
return C.UIApplicationMain(argc, argv, nil, objc.toobj('AppDelegate'))