Skip to content

Commit

Permalink
add all prebuilt libraries and lua files
Browse files Browse the repository at this point in the history
  • Loading branch information
naman14 committed May 9, 2016
1 parent da98b08 commit b512da3
Show file tree
Hide file tree
Showing 340 changed files with 48,166 additions and 12 deletions.
20 changes: 18 additions & 2 deletions app/src/main/java/com/naman14/arcade/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.naman14.arcade.library.Torch;

public class MainActivity extends AppCompatActivity {

Torch torch;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Torch torch = new Torch(this);
torch.call("main.lua");
torch = new Torch(this);

}


@Override
public void onStart() {
super.onStart();
Log.d("torchdemo","onStart\n");
Runnable r = new Runnable() {
public void run() {
torch.call("neural_style.lua");
}
};
r.run();
}

@Override
Expand Down
18 changes: 17 additions & 1 deletion arcade/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: 'com.android.model.library'

model {

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

ndk {
moduleName "arcade"
ldLibs.add("log")
ldLibs.addAll(["android", "log"])
CFlags.add("-DSTDC_HEADERS")
}

Expand All @@ -24,11 +25,26 @@ model {
}
}


}

android.sources {

main {
jniLibs {
source {
srcDirs 'src/main/libs'
}
}
}
}

}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
}


24 changes: 24 additions & 0 deletions arcade/src/main/assets/lua/5.1/argcheck/doc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local doc = {}

function doc.record()
doc.__record = {}
end

function doc.stop()
local md = table.concat(doc.__record)
doc.__record = nil
return md
end

function doc.doc(str)
if doc.__record then
table.insert(doc.__record, str)
end
end

setmetatable(doc, {__call=
function(self, ...)
return self.doc(...)
end})

return doc
11 changes: 11 additions & 0 deletions arcade/src/main/assets/lua/5.1/argcheck/dump.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local doc = require 'argcheck.doc'

local ffi = require 'ffi'

doc.__noop = ffi.new('int*')
ffi.gc(doc.__noop,
function()
print(doc.stop())
end)

doc.record()
55 changes: 55 additions & 0 deletions arcade/src/main/assets/lua/5.1/argcheck/env.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
local env = {}

-- user configurable function
function env.istype(obj, typename)
local mt = getmetatable(obj)
if type(mt) == 'table' then
local objtype = rawget(mt, '__typename')
if objtype then
return objtype == typename
end
end
return type(obj) == typename
end

function env.type(obj)
local mt = getmetatable(obj)
if type(mt) == 'table' then
local objtype = rawget(mt, '__typename')
if objtype then
return objtype
end
end
return type(obj)
end

-- torch specific
if pcall(require, 'torch') then
function env.istype(obj, typename)
local thname = torch.typename(obj)
if thname then
-- __typename (see below) might be absent
local match = thname:match(typename)
if match and (match ~= typename or match == thname) then
return true
end
local mt = torch.getmetatable(thname)
while mt do
if mt.__typename then
match = mt.__typename:match(typename)
if match and (match ~= typename or match == mt.__typename) then
return true
end
end
mt = getmetatable(mt)
end
return false
end
return type(obj) == typename
end
function env.type(obj)
return torch.type(obj)
end
end

return env
Loading

0 comments on commit b512da3

Please sign in to comment.