motion.h 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -4
  3. data/lib/motion.h.rb +18 -6
  4. data/motion.h.gemspec +3 -3
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3563f032b9abc0292b0a360b3c7314fc6eb8334
4
- data.tar.gz: dda1f773593647d5588514b5a625368c7595072a
3
+ metadata.gz: be4b20cc5a9df900392e473d3bffcc51f5e3a52d
4
+ data.tar.gz: 409003301af6fdc598cad5d2120568ab8791aefa
5
5
  SHA512:
6
- metadata.gz: 250a6333b2536b6bab308c0dbbe58cb970e78593f08de68ad4c5bc0b146cc762c1f8b79b57cbc75f23107fd249a51c13e5c8bd95362bd97e28d893aa3194328d
7
- data.tar.gz: 6059442158529d4a6b50e9313de1c83740a16d30aceeec7dd5f6c84fce5aea39f533f620656b23e6e0c98995d3241a50c119ccb106839cf81306476431e84dee
6
+ metadata.gz: a8a11705edb6e7749d15e559d836faf5134ca7c9a22815ea6337248aca3370f34ecc3bfe572bc915d6d61e346d4b81b72dcf16067c0dc7a15a453df6694b3188
7
+ data.tar.gz: dd945be80a47f5c4880725ad978c58817ccaf37dbb4a8a80b2f6a2b80b2c7d01d91b58e8a0c539f5d46d2c46d79dfeb76f1d3b1b7d60df98992b03b351b14b7e
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # motion.h
2
2
 
3
- Include iOS system libraries in RubyMotion.
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
- ## Examples
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
- def include(header_file, output_dir=nil)
7
- MotionHeader.new(header_file, self, output_dir).integrate
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 [String] bridgesupport_dir Path where the generated bridgesupport file is saved. Defaults to ./build.
18
- def initialize(header_file, config, bridgesupport_dir=BRIDGESUPPORT_DIR)
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
- @bridgesupport_dir = bridgesupport_dir || BRIDGESUPPORT_DIR
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
- "#{@config.xcode_dir}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS#{@config.sdk_version}.sdk/usr/include"
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.1'
4
+ spec.version = '0.0.2'
5
5
  spec.authors = ["Dave Lee"]
6
6
  spec.email = ['dave@kastiglione.com']
7
- spec.description = 'Include iOS system libraries in RubyMotion'
8
- spec.summary = 'Include iOS system libraries in RubyMotion'
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.1
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: Include iOS system libraries in RubyMotion
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: Include iOS system libraries in RubyMotion
78
+ summary: Expose iOS system C libraries in RubyMotion
79
79
  test_files: []
80
80
  has_rdoc: