Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Android module documentation stub #173

Merged
merged 2 commits into from
Aug 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions assets/android.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
--[[--
Java Native Interface (JNI) wrapper.

@module android
]]

local ffi = require("ffi")

ffi.cdef[[
Expand Down Expand Up @@ -1231,8 +1237,11 @@ function android.LOGE(message)
android.LOG(ffi.C.ANDROID_LOG_ERROR, message)
end

--[[
a loader function for Lua which will look for assets when loading modules
--[[--
A loader function for Lua which will look for assets when loading modules.

@string modulename
@return module or error message
--]]
function android.asset_loader(modulename)
local errmsg = ""
Expand Down Expand Up @@ -1262,8 +1271,11 @@ function android.asset_loader(modulename)
return errmsg
end

--[[
this loader function just loads dependency libraries for C module
--[[--
This loader function just loads dependency libraries for the C module.

@string modulename
@treturn bool success or failure
--]]
function android.deplib_loader(modulename)
local function readable(filename)
Expand Down Expand Up @@ -1291,8 +1303,8 @@ end
function android.get_application_directory()
end

--[[
the C code will call this function:
--[[--
The C code will call this function.
--]]
local function run(android_app_state)
android.app = ffi.cast("struct android_app*", android_app_state)
Expand Down Expand Up @@ -1354,7 +1366,8 @@ local function run(android_app_state)
end)
end

-- device identification
--- Device identification.
-- @treturn string product
android.getProduct = function()
return JNI:context(android.app.activity.vm, function(JNI)
local product = JNI:callObjectMethod(
Expand All @@ -1377,7 +1390,8 @@ local function run(android_app_state)
end)
end

-- build identification
--- Build identification.
-- @treturn string flavor
android.getFlavor = function()
return JNI:context(android.app.activity.vm, function(JNI)
local flavor = JNI:callObjectMethod(
Expand Down Expand Up @@ -1455,6 +1469,8 @@ local function run(android_app_state)
end
end

--- Gets screen width.
-- @treturn int screen width
android.getScreenWidth = function()
return JNI:context(android.app.activity.vm, function(JNI)
return JNI:callIntMethod(
Expand All @@ -1465,6 +1481,8 @@ local function run(android_app_state)
end)
end

--- Gets screen height.
-- @treturn int screen height
android.getScreenHeight = function()
return JNI:context(android.app.activity.vm, function(JNI)
return JNI:callIntMethod(
Expand Down Expand Up @@ -1710,7 +1728,8 @@ local function run(android_app_state)
end
end

-- android permission check
--- Android permission check.
-- @treturn bool hasWriteSettingsPermission
android.canWriteSettings = function()
android.DEBUG("checking write settings permission")
return JNI:context(android.app.activity.vm, function(JNI)
Expand Down