motion.h 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -4
- data/lib/motion.h.rb +18 -6
- data/motion.h.gemspec +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4b20cc5a9df900392e473d3bffcc51f5e3a52d
|
4
|
+
data.tar.gz: 409003301af6fdc598cad5d2120568ab8791aefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8a11705edb6e7749d15e559d836faf5134ca7c9a22815ea6337248aca3370f34ecc3bfe572bc915d6d61e346d4b81b72dcf16067c0dc7a15a453df6694b3188
|
7
|
+
data.tar.gz: dd945be80a47f5c4880725ad978c58817ccaf37dbb4a8a80b2f6a2b80b2c7d01d91b58e8a0c539f5d46d2c46d79dfeb76f1d3b1b7d60df98992b03b351b14b7e
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# motion.h
|
2
2
|
|
3
|
-
|
3
|
+
Expose iOS system C libraries in RubyMotion.
|
4
4
|
|
5
5
|
Outside of the usual Apple frameworks, iOS includes many system C libraries,
|
6
6
|
with the most well known examples being [SQLite](http://www.sqlite.org/), and
|
@@ -12,6 +12,13 @@ C API, and this is what `motion.h` takes care of. Simply declare the header
|
|
12
12
|
files needed, just like in C, and now RubyMotion code can call directly into
|
13
13
|
the specified system library, without having to write an Objective-C wrapper.
|
14
14
|
|
15
|
+
Note, BridgeSupport only supports C libraries, C++ support does not exist.
|
16
|
+
|
17
|
+
RubyMotion's Runtime Guide includes a section called [Interfacing with
|
18
|
+
C](http://www.rubymotion.com/developer-center/guides/runtime/#_interfacing_with_c),
|
19
|
+
which is a must read for learning how to interact with C libraries in
|
20
|
+
RubyMotion.
|
21
|
+
|
15
22
|
## Installation
|
16
23
|
|
17
24
|
Add this line to your application's Gemfile:
|
@@ -26,12 +33,12 @@ Or install it yourself as:
|
|
26
33
|
|
27
34
|
$ gem install motion.h
|
28
35
|
|
29
|
-
##
|
30
|
-
|
31
|
-
In your `Rakefile`:
|
36
|
+
## Getting Started
|
32
37
|
|
33
38
|
### SQLite
|
34
39
|
|
40
|
+
In the `Rakefile`:
|
41
|
+
|
35
42
|
```ruby
|
36
43
|
Motion::Project::App.setup do |config|
|
37
44
|
config.libs << '/usr/lib/libsqlite3.dylib'
|
@@ -39,8 +46,17 @@ Motion::Project::App.setup do |config|
|
|
39
46
|
end
|
40
47
|
```
|
41
48
|
|
49
|
+
Example: Creating an in-memory database:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
db = Pointer.new(Sqlite3.type)
|
53
|
+
sqlite3_open(':memory', db)
|
54
|
+
```
|
55
|
+
|
42
56
|
### Objective-C Runtime
|
43
57
|
|
58
|
+
In the `Rakefile`:
|
59
|
+
|
44
60
|
```ruby
|
45
61
|
Motion::Project::App.setup do |config|
|
46
62
|
config.include 'objc/runtime.h'
|
data/lib/motion.h.rb
CHANGED
@@ -3,8 +3,12 @@ unless defined? Motion::Project::Config
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class Motion::Project::Config
|
6
|
-
|
7
|
-
|
6
|
+
# @param [String] header_file Requested C header file.
|
7
|
+
# @param [Hash] options Options for customizing BridgeSupport file generation
|
8
|
+
# @option options [String] :prefix Subdirectory of /usr/include used for root of included header files.
|
9
|
+
# @option options [String] :bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build
|
10
|
+
def include(header_file, options={})
|
11
|
+
MotionHeader.new(header_file, self, options).integrate
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -14,11 +18,14 @@ class MotionHeader
|
|
14
18
|
|
15
19
|
# @param [String] header_file Requested C header file.
|
16
20
|
# @param [Motion::Project::Config] config RubyMotion config provided in App.setup.
|
17
|
-
# @param [
|
18
|
-
|
21
|
+
# @param [Hash] options Options for customizing BridgeSupport file generation
|
22
|
+
# @option options [String] :prefix Subdirectory of /usr/include used for root of included header files.
|
23
|
+
# @option options [String] :bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build
|
24
|
+
def initialize(header_file, config, options={})
|
19
25
|
@header_file = header_file
|
20
26
|
@config = config
|
21
|
-
@
|
27
|
+
@prefix = options[:prefix]
|
28
|
+
@bridgesupport_dir = options[:bridgesupport_dir] || BRIDGESUPPORT_DIR
|
22
29
|
end
|
23
30
|
|
24
31
|
def integrate
|
@@ -39,7 +46,12 @@ class MotionHeader
|
|
39
46
|
end
|
40
47
|
|
41
48
|
def include_path
|
42
|
-
|
49
|
+
path_components = [@config.xcode_dir, *sdk_dir(@config.sdk_version), 'usr', 'include', @prefix].compact
|
50
|
+
File.join(*path_components)
|
51
|
+
end
|
52
|
+
|
53
|
+
def sdk_dir(sdk_version)
|
54
|
+
['Platforms', 'iPhoneOS.platform', 'Developer', 'SDKs', "iPhoneOS#{sdk_version}.sdk"]
|
43
55
|
end
|
44
56
|
|
45
57
|
def bridgesupport_file
|
data/motion.h.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "motion.h"
|
4
|
-
spec.version = '0.0.
|
4
|
+
spec.version = '0.0.2'
|
5
5
|
spec.authors = ["Dave Lee"]
|
6
6
|
spec.email = ['dave@kastiglione.com']
|
7
|
-
spec.description = '
|
8
|
-
spec.summary = '
|
7
|
+
spec.description = 'Expose iOS system C libraries in RubyMotion'
|
8
|
+
spec.summary = 'Expose iOS system C libraries in RubyMotion'
|
9
9
|
spec.homepage = 'https://github.com/kastiglione/motion.h'
|
10
10
|
spec.license = "MIT"
|
11
11
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion.h
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Lee
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: Expose iOS system C libraries in RubyMotion
|
42
42
|
email:
|
43
43
|
- dave@kastiglione.com
|
44
44
|
executables: []
|
@@ -75,6 +75,6 @@ rubyforge_project:
|
|
75
75
|
rubygems_version: 2.0.3
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
|
-
summary:
|
78
|
+
summary: Expose iOS system C libraries in RubyMotion
|
79
79
|
test_files: []
|
80
80
|
has_rdoc:
|