@@ -278,8 +278,199 @@ def self.source_root
end



class ExtensionGenerator < BaseGenerator

def self.source_root
File.join(File.dirname(__FILE__), 'templates', 'extension')
end

desc <<-DESC
Adds native extension to Rhodes based application.
DESC

#option :testing_framework, :desc => 'Specify which testing framework to use (spec, test_unit)'

first_argument :name, :required => true, :desc => "extension name"

template :ext do |template|
template.source = 'extensions/montana/ext.yml'
template.destination = "extensions/#{name.downcase}/ext.yml"
end

template :extension_ruby do |template|
template.source = 'extensions/montana/montana.rb'
template.destination = "extensions/#{name.downcase}/#{name.downcase}.rb"
end

$build_script_full_path = ''

def callback_after_make_build(template)
# change atribbutes in build script file to executable
File.chmod(0755, $build_script_full_path)
end

template :build do |template|
template.source = 'extensions/montana/ext/build'
template.destination = "extensions/#{name.downcase}/ext/build"
$build_script_full_path = template.destination
template.options = { :after => :callback_after_make_build}
end

template :build_bat do |template|
template.source = 'extensions/montana/ext/build.bat'
template.destination = "extensions/#{name.downcase}/ext/build.bat"
end

template :extension_i do |template|
template.source = 'extensions/montana/ext/montana/shared/ruby/montana.i'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/shared/ruby/#{name.downcase}.i"
end

template :extension_wrap do |template|
template.source = 'extensions/montana/ext/montana/shared/ruby/montana_wrap.c'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/shared/ruby/#{name.downcase}_wrap.c"
end

template :extension_c do |template|
template.source = 'extensions/montana/ext/montana/shared/src/montana.c'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/shared/src/#{name.downcase}.c"
end

template :extension_iphone_rakefile do |template|
template.source = 'extensions/montana/ext/montana/platform/iphone/Rakefile'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/iphone/Rakefile"
end

file :extension_iphone_pch do |file|
file.source = 'extensions/montana/ext/montana/platform/iphone/Montana_Prefix.pch'
file.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/iphone/#{name.camel_case}_Prefix.pch"
end

template :extension_iphone_project do |template|
template.source = 'extensions/montana/ext/montana/platform/iphone/Montana.xcodeproj/project.pbxproj'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/iphone/#{name.camel_case}.xcodeproj/project.pbxproj"
end

template :extension_iphone_src_h do |template|
template.source = 'extensions/montana/ext/montana/platform/iphone/Classes/Montana.h'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/iphone/Classes/#{name.camel_case}.h"
end

template :extension_iphone_src_m do |template|
template.source = 'extensions/montana/ext/montana/platform/iphone/Classes/Montana.m'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/iphone/Classes/#{name.camel_case}.m"
end

template :extension_android_ext_build do |template|
template.source = 'extensions/montana/ext/montana/platform/android/ext_build.files'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/android/ext_build.files"
end

template :extension_android_rakefile do |template|
template.source = 'extensions/montana/ext/montana/platform/android/Rakefile'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/android/Rakefile"
end

template :extension_android_cpp do |template|
template.source = 'extensions/montana/ext/montana/platform/android/jni/src/montana.cpp'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/android/jni/src/#{name.downcase}.cpp"
end

template :extension_android_java do |template|
template.source = 'extensions/montana/ext/montana/platform/android/src/com/montana/Montana.java'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/android/src/com/#{name.downcase}/#{name.camel_case}.java"
end


template :extension_wm_rakefile do |template|
template.source = 'extensions/montana/ext/montana/platform/wm/Rakefile'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/wm/Rakefile"
end

template :extension_wm_vcproject do |template|
template.source = 'extensions/montana/ext/montana/platform/wm/Montana.vcproj'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/wm/#{name.camel_case}.vcproj"
end

template :extension_wm_h do |template|
template.source = 'extensions/montana/ext/montana/platform/wm/src/montana_wm.h'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/wm/src/#{name.downcase}_wm.h"
end

template :extension_wm_cpp do |template|
template.source = 'extensions/montana/ext/montana/platform/wm/src/montana_wm.cpp'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/wm/src/#{name.downcase}_wm.cpp"
end


template :extension_bb_files do |template|
template.source = 'extensions/montana/ext/montana/platform/bb/Montana.files'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/bb/#{name.camel_case}.files"
end

template :extension_bb_jgp do |template|
template.source = 'extensions/montana/ext/montana/platform/bb/montana.jdp'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/bb/#{name.downcase}.jdp"
end

template :extension_bb_Rakefile do |template|
template.source = 'extensions/montana/ext/montana/platform/bb/Rakefile'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/bb/Rakefile"
end

template :extension_bb_java do |template|
template.source = 'extensions/montana/ext/montana/platform/bb/src/com/montana/Montana.java'
template.destination = "extensions/#{name.downcase}/ext/#{name.downcase}/platform/bb/src/com/#{name.downcase}/#{name.camel_case}.java"
end



template :extension_test_controller do |template|
template.source = 'app/MontanaTest/controller.rb'
template.destination = "app/#{name.camel_case}Test/controller.rb"
end

template :extension_test_index do |template|
template.source = 'app/MontanaTest/index.erb'
template.destination = "app/#{name.camel_case}Test/index.erb"
end




#<%= name.downcase %>
#<%= name.camel_case %>

#template :spec do |template|
# underscore_name = name.camel_case.split(/(?=[A-Z])/).map{|w| w.downcase}.join("_")
# template.source = 'spec.rb'
# template.destination = "app/test/#{underscore_name}_spec.rb"
#end

#file :loadingpng do |file|
# file.source = 'app/loading.png'
# file.destination = "#{name}/app/loading.png"
#end

#directory :helpers do |directory|
# directory.source = 'app/helpers'
# directory.destination = "#{name}/app/helpers"
#end


def attributes?
self.attributes && !self.attributes.empty?
end

end




add :app, AppGenerator
add :model, ModelGenerator
add :spec, SpecGenerator
add :extension, ExtensionGenerator

end
@@ -0,0 +1,20 @@
require 'rho/rhocontroller'
require 'helpers/application_helper'
require 'helpers/browser_helper'
require '<%= name.downcase %>'

class <%= name.camel_case %>TestController < Rho::RhoController
include BrowserHelper
include ApplicationHelper
def index
render :back => '/app'
end

def run_test
sum = <%= name.camel_case %>.calc_summ(3,7)
Alert.show_popup <%= name.camel_case %>::<%= name.camel_case %>StringHelper::process_string('test')+sum.to_s
render :action => :index, :back => '/app'
end

end
@@ -0,0 +1,17 @@
<div data-role="page">

<div data-role="header" data-position="inline">
<h1><%= name.camel_case %> Extension Test</h1>
<a href="<%%= Rho::RhoConfig.start_path %>" class="ui-btn-left" data-icon="home" data-direction="reverse"
<%%= "data-ajax='false'" if is_bb6 %>>Home</a>

</div>

<div data-role="content">
<ul data-role="listview">
<%%= link_to 'Run <%= name.camel_case %> test', { :action => :run_test }%>
</ul>
</div>

</div>

@@ -0,0 +1,4 @@
entry: Init_<%= name.camel_case %>_extension
javaentry: com.<%= name.downcase %>.<%= name.camel_case %>
android_additional_sources_list: ext/<%= name.downcase %>/platform/android/ext_build.files
libraries: ["<%= name.camel_case %>"]
@@ -0,0 +1,17 @@
#!/bin/sh


if [ "$RHO_PLATFORM" = "android" ]; then

cd <%= name.downcase %>/platform/android
rake --trace

elif [ "$RHO_PLATFORM" = "iphone" ]; then

cd <%= name.downcase %>/platform/iphone
rake --trace

fi



@@ -0,0 +1,36 @@

if "%RHO_PLATFORM%" == "android" (

cd <%= name.downcase %>\platform\android
rake --trace

)

if "%RHO_PLATFORM%" == "iphone" (

cd <%= name.downcase %>\platform\phone
rake --trace

)

if "%RHO_PLATFORM%" == "wm" (

cd <%= name.downcase %>\platform\wm
rake --trace

)

if "%RHO_PLATFORM%" == "win32" (

cd <%= name.downcase %>\platform\wm
rake --trace

)

if "%RHO_PLATFORM%" == "bb" (

cd <%= name.downcase %>\platform\bb
rake --trace

)

@@ -0,0 +1,77 @@
require 'fileutils'


def build_extension(name, arch, src_files)
objects = []
mkdir_p $tempdir unless File.exists? $tempdir

use_own_stlport = false
$std_includes = File.join ENV['ANDROID_NDK'], "sources", "cxx-stl", "stlport", "stlport"
unless File.directory? $std_includes
$stlport_includes = "#{$rootdir}/platform/shared/stlport/stlport"
use_own_stlport = true
end

#Dir.glob("*.c").each do |f|
src_files.each do |f|
objname = File.join( $tempdir, File.basename( f.gsub(/\.c$/, '.o') ) )
objects << objname

args = []
args << "-I."
args << "-I#{$rootdir}/platform/android/Rhodes/jni/include"
args << "-I#{$rootdir}/platform/shared/ruby/include"
args << "-I#{$rootdir}/platform/shared"
args << "-I#{$rootdir}/platform/shared/common"

args << "-I#{$std_includes}" unless $std_includes.nil?
args << "-D__NEW__" if use_own_stlport
args << "-I#{$stlport_includes}" if use_own_stlport

args << "-I#{$rootdir}/platform/shared/ruby/android"
args << "-I#{$rootdir}/platform/shared/ruby/generated"

cc_compile f, $tempdir, args or exit 1

end

mkdir_p $targetdir unless File.exist? $targetdir

cc_ar File.join( $targetdir, 'lib' + name + '.a' ), Dir.glob($tempdir + "/**/*.o") or exit 1

end

namespace "build" do
task :config do
curdir = pwd
$<%= name.downcase %>dir = curdir.gsub('/ext/<%= name.downcase %>/platform/android','');
$targetdir = ENV['TARGET_TEMP_DIR']
raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?
$tempdir = ENV['TEMP_FILES_DIR']
raise "TEMP_FILES_DIR is not set" if $tempdir.nil?
$rootdir = ENV['RHO_ROOT']
raise "RHO_ROOT is not set" if $rootdir.nil?
require File.join($rootdir, 'platform/android/build/androidcommon.rb')

setup_ndk(ENV['ANDROID_NDK'],ENV['ANDROID_API_LEVEL'])

end

task :all => :config do

src_files = []

src_files << $<%= name.downcase %>dir + '/ext/<%= name.downcase %>/platform/android/jni/src/<%= name.downcase %>.cpp'
src_files << $<%= name.downcase %>dir + '/ext/<%= name.downcase %>/shared/ruby/<%= name.downcase %>_wrap.c'
src_files << $<%= name.downcase %>dir + '/ext/<%= name.downcase %>/shared/src/<%= name.downcase %>.c'

# build native part
build_extension('<%= name.camel_case %>', $arch, src_files)

# java part will be builded automatically (java files should be listed in ext_build.files ans ext. yml should be configured)

end
end

task :default => "build:all"
@@ -0,0 +1 @@
ext/<%= name.downcase %>/platform/android/src/com/<%= name.downcase %>/<%= name.camel_case %>.java
@@ -0,0 +1,28 @@
#include <rhodes.h>
#include "rubyext/WebView.h"
#include <stdlib.h>
#include "ruby/ext/rho/rhoruby.h"



extern "C" VALUE <%= name.downcase %>_native_process_string(const char* str) {

JNIEnv *env = jnienv();
jclass cls = rho_find_class(env, "com/<%= name.downcase %>/<%= name.camel_case %>");
if (!cls) return rho_ruby_get_NIL();;
jmethodID mid = env->GetStaticMethodID( cls, "processString", "(Ljava/lang/String;)Ljava/lang/String;");
if (!mid) return rho_ruby_get_NIL();;
jstring objStr = env->NewStringUTF(str);
jstring jstr = (jstring)env->CallStaticObjectMethod(cls, mid, objStr);
env->DeleteLocalRef(objStr);
const char* buf = env->GetStringUTFChars(jstr,0);
VALUE result = rho_ruby_create_string(buf);
env->ReleaseStringUTFChars(jstr, buf);
return result;
}


extern "C" int <%= name.downcase %>_calc_summ(int x, int y) {
return (x+y);
}

@@ -0,0 +1,10 @@
package com.<%= name.downcase %>;

public class <%= name.camel_case %> {

public static String processString(String str) {
return "<Android>" + str + "<Android>";
}


}
@@ -0,0 +1 @@
src\com\<%= name.downcase %>\<%= name.camel_case %>.java
@@ -0,0 +1,97 @@
require 'fileutils'


USE_STLPORT = true


def build_extension

require File.join($rhoroot, 'lib/build/jake.rb')

vsrclist = "<%= name.camel_case %>.files"

args = []
args << "-g"
args << "-d"
args << $tempdir
args << "-classpath"
args << $rubyvmjar
args << "-bootclasspath"
args << $jde + "/lib/net_rim_api.jar"
args << "-source"
args << "1.3"
args << "-target"
args << "1.3"
args << "-nowarn"
args << "@#{vsrclist}"
puts "\texecuting javac"
puts Jake.run($javac,args)
unless $? == 0
puts "Error compiling java code"
exit 1
end
$stdout.flush



args2 = []
args2 << "cf"
args2 << $targetdir+"/<%= name.camel_case %>.jar"
#args2 << manifest
args2 << "-C"
args2 << $tempdir
args2 << "."


puts "\texecuting jar"
puts Jake.run($jar, args2)
unless $? == 0
puts "Error making JAR"
exit 1
end
$stdout.flush



end

namespace "build" do
task :config do
$targetdir = ENV['TARGET_TEMP_DIR']
raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?

$javac = ENV['JAVAC_EXE']
raise "JAVAC_EXE is not set" if $javac.nil?

$jar = ENV['JAR_EXE']
raise "JAR_EXE is not set" if $jar.nil?

$jde = ENV['JDE_HOME']
raise "JDE_HOME is not set" if $jde.nil?

$tempdir = ENV['TEMP_FILES_DIR']
raise "TEMP_FILES_DIR is not set" if $tempdir.nil?

$jde = ENV['JDE_HOME']
raise "JDE_HOME is not set" if $jde.nil?

$rubyvmjar = ENV['RUBYVM_JAR']
raise "RUBYVM_JAR is not set" if $rubyvmjar.nil?

$rhoroot = ENV['RHO_ROOT']
raise "RHO_ROOT is not set" if $rhoroot.nil?

$bbver = ENV['BB_SDK_VERSION']
raise "BB_SDK_VERSION is not set" if $bbver.nil?

end

task :all => :config do


build_extension

end
end

task :default => "build:all"
@@ -0,0 +1,48 @@
## RIM Java Development Environment
# RIM Project file
#
# This file is generated and managed by BlackBerry developer tools.
# It SHOULD NOT BE modified manually.
#
AddOn=0
AlwaysBuild=0
[AlxImports
]
AutoRestart=0
[ClassProtection
]
[CustomBuildFiles
]
[CustomBuildRules
]
[DefFiles
]
[DependsOn
]
ExcludeFromBuildAll=0
[Files
src\com\<%= name.downcase %>\<%= name.camel_case %>.java
]
HaveAlxImports=0
HaveDefs=0
HaveImports=0
[Icons
]
[ImplicitRules
]
[Imports
]
Listing=0
Options=-quiet
OutputFileName=<%= name.downcase %>
[PackageProtection
]
RibbonPosition=0
[RolloverIcons
]
RunOnStartup=0
StartupTier=7
SystemModule=0
Type=0
UserData=|src
Version=1.51
@@ -0,0 +1,118 @@
package com.<%= name.downcase %>;

import com.rho.RhodesApp;
import com.rho.file.SimpleFile;
import com.rho.net.IHttpConnection;
import com.rho.net.RhoConnection;
import com.rho.net.URI;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Image;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;

import com.rho.RhoClassFactory;
import com.rho.RhoEmptyLogger;
import com.rho.RhoLogger;
import com.rho.RhoRuby;

import com.xruby.runtime.builtin.ObjectFactory;
import com.xruby.runtime.builtin.RubyString;
import com.xruby.runtime.builtin.RubyFixnum;
import com.xruby.runtime.builtin.RubyInteger;
import com.xruby.runtime.lang.*;

public class <%= name.camel_case %> implements Runnable {

private static final RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
new RhoLogger("<%= name.camel_case %>");

public static RubyModule <%= name.camel_case %>Module;


public String doProcessString( String str ) {
return "<BB>" + str + "<BB>";
}

public int doCalcSumm( int x, int y ) {
return (x+y);
}




public void run() {
LOG.INFO("$$$ Register <%= name.camel_case %> Ruby class");
// register Ruby Module
<%= name.camel_case %>Module = RubyAPI.defineModule("<%= name.camel_case %>");
// register Ruby method
<%= name.camel_case %>Module.getSingletonClass().defineMethod("native_process_string", new RubyOneArgMethod() {
protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyBlock block) {
if ( arg0 instanceof RubyString )
{
String str = arg0.toString();
String result = doProcessString(str);
return ObjectFactory.createString(result);
}
else {
throw new RubyException(RubyRuntime.ArgumentErrorClass, "in <%= name.camel_case %>.native_process_string: wrong argument type.Should be String");
}
}
});
<%= name.camel_case %>Module.getSingletonClass().defineMethod("calc_summ", new RubyTwoArgMethod() {
protected RubyValue run(RubyValue receiver, RubyValue arg1, RubyValue arg2, RubyBlock block) {
try {
int x = 0;
int y = 0;
if (arg1 instanceof RubyFixnum) {
RubyFixnum rv = (RubyFixnum)arg1;
x = rv.toInt();
}
else {
if (arg1 instanceof RubyInteger) {
RubyInteger rv = (RubyInteger)arg1;
x = rv.toInt();
}
else {
if (arg1 instanceof RubySymbol) {
RubySymbol rv = (RubySymbol)arg1;
x = rv.toInt();
}
else {
throw new RubyException(RubyRuntime.ArgumentErrorClass, "in <%= name.camel_case %>.calc_summ: wrong argument type.Should be Fixnum or Integer");
}
}
}
if (arg2 instanceof RubyFixnum) {
RubyFixnum rv = (RubyFixnum)arg2;
y = rv.toInt();
}
else {
if (arg2 instanceof RubyInteger) {
RubyInteger rv = (RubyInteger)arg2;
y = rv.toInt();
}
else {
if (arg2 instanceof RubySymbol) {
RubySymbol rv = (RubySymbol)arg2;
y = rv.toInt();
}
else {
throw new RubyException(RubyRuntime.ArgumentErrorClass, "in <%= name.camel_case %>.calc_summ: wrong argument type.Should be Fixnum or Integer");
}
}
}
int res = doCalcSumm(x,y);
return ObjectFactory.createInteger(res);
} catch(Exception e) {
e.printStackTrace();
LOG.ERROR("<%= name.camel_case %>.calc_summ failed with exception", e);
throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
}
}
});
}

}
@@ -0,0 +1,4 @@

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@@ -0,0 +1,24 @@

#import "<%= name.camel_case %>.h"

#include "ruby/ext/rho/rhoruby.h"



VALUE <%= name.downcase %>_native_process_string(const char* str) {

NSString* os_string = @"<iOS>";

NSString* result_string = [os_string stringByAppendingString:[NSString stringWithUTF8String:str]];
result_string = [result_string stringByAppendingString:os_string];

VALUE result = rho_ruby_create_string([result_string UTF8String]);

return result;
}


int <%= name.downcase %>_calc_summ(int x, int y) {
return (x+y);
}

@@ -0,0 +1,300 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objects = {

/* Begin PBXBuildFile section */
FAC155E7145855CF0016F3BD /* <%= name.camel_case %>_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = FAD45FD51225FED600141873 /* <%= name.camel_case %>_Prefix.pch */; };
FAC155E8145855CF0016F3BD /* <%= name.camel_case %>.h in Headers */ = {isa = PBXBuildFile; fileRef = FAC155E01458523C0016F3BD /* <%= name.camel_case %>.h */; };
FAC155EA145855CF0016F3BD /* <%= name.downcase %>_wrap.c in Sources */ = {isa = PBXBuildFile; fileRef = FAC155D614584FD80016F3BD /* <%= name.downcase %>_wrap.c */; };
FAC155EB145855CF0016F3BD /* <%= name.downcase %>.c in Sources */ = {isa = PBXBuildFile; fileRef = FAC155D814584FE20016F3BD /* <%= name.downcase %>.c */; };
FAC155EC145855CF0016F3BD /* <%= name.camel_case %>.m in Sources */ = {isa = PBXBuildFile; fileRef = FAC155DE145851440016F3BD /* <%= name.camel_case %>.m */; };
FAC155EE145855CF0016F3BD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
FAC155EF145855CF0016F3BD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD4602C12260A8500141873 /* UIKit.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
FAC155D614584FD80016F3BD /* <%= name.downcase %>_wrap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = <%= name.downcase %>_wrap.c; path = ../../shared/ruby/<%= name.downcase %>_wrap.c; sourceTree = "<group>"; };
FAC155D814584FE20016F3BD /* <%= name.downcase %>.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = <%= name.downcase %>.c; path = ../../shared/src/<%= name.downcase %>.c; sourceTree = "<group>"; };
FAC155DE145851440016F3BD /* <%= name.camel_case %>.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = <%= name.camel_case %>.m; path = Classes/<%= name.camel_case %>.m; sourceTree = "<group>"; };
FAC155E01458523C0016F3BD /* <%= name.camel_case %>.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = <%= name.camel_case %>.h; path = Classes/<%= name.camel_case %>.h; sourceTree = "<group>"; };
FAC155F3145855CF0016F3BD /* lib<%= name.camel_case %>.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = lib<%= name.camel_case %>.a; sourceTree = BUILT_PRODUCTS_DIR; };
FAD45FD51225FED600141873 /* <%= name.camel_case %>_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = <%= name.camel_case %>_Prefix.pch; sourceTree = "<group>"; };
FAD4602C12260A8500141873 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
FAC155ED145855CF0016F3BD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FAC155EE145855CF0016F3BD /* Foundation.framework in Frameworks */,
FAC155EF145855CF0016F3BD /* UIKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
034768DFFF38A50411DB9C8B /* Products */ = {
isa = PBXGroup;
children = (
FAC155F3145855CF0016F3BD /* lib<%= name.camel_case %>.a */,
);
name = Products;
sourceTree = "<group>";
};
0867D691FE84028FC02AAC07 /* Barcode */ = {
isa = PBXGroup;
children = (
08FB77AEFE84172EC02AAC07 /* Classes */,
32C88DFF0371C24200C91783 /* Other Sources */,
0867D69AFE84028FC02AAC07 /* Frameworks */,
034768DFFF38A50411DB9C8B /* Products */,
);
name = Barcode;
sourceTree = "<group>";
};
0867D69AFE84028FC02AAC07 /* Frameworks */ = {
isa = PBXGroup;
children = (
AACBBE490F95108600F1A2B1 /* Foundation.framework */,
FAD4602C12260A8500141873 /* UIKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
08FB77AEFE84172EC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
FAC155DD1458511E0016F3BD /* iOS_specific */,
FAC155DA145850EB0016F3BD /* Shared */,
);
name = Classes;
sourceTree = "<group>";
};
32C88DFF0371C24200C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
FAD45FD51225FED600141873 /* <%= name.camel_case %>_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
FAC155DA145850EB0016F3BD /* Shared */ = {
isa = PBXGroup;
children = (
FAC155DC145851020016F3BD /* src */,
FAC155DB145850F80016F3BD /* Ruby */,
);
name = Shared;
sourceTree = "<group>";
};
FAC155DB145850F80016F3BD /* Ruby */ = {
isa = PBXGroup;
children = (
FAC155D614584FD80016F3BD /* <%= name.downcase %>_wrap.c */,
);
name = Ruby;
sourceTree = "<group>";
};
FAC155DC145851020016F3BD /* src */ = {
isa = PBXGroup;
children = (
FAC155D814584FE20016F3BD /* <%= name.downcase %>.c */,
);
name = src;
sourceTree = "<group>";
};
FAC155DD1458511E0016F3BD /* iOS_specific */ = {
isa = PBXGroup;
children = (
FAC155E01458523C0016F3BD /* <%= name.camel_case %>.h */,
FAC155DE145851440016F3BD /* <%= name.camel_case %>.m */,
);
name = iOS_specific;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
FAC155E6145855CF0016F3BD /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
FAC155E7145855CF0016F3BD /* <%= name.camel_case %>_Prefix.pch in Headers */,
FAC155E8145855CF0016F3BD /* <%= name.camel_case %>.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
FAC155E5145855CF0016F3BD /* <%= name.camel_case %> */ = {
isa = PBXNativeTarget;
buildConfigurationList = FAC155F0145855CF0016F3BD /* Build configuration list for PBXNativeTarget "<%= name.camel_case %>" */;
buildPhases = (
FAC155E6145855CF0016F3BD /* Headers */,
FAC155E9145855CF0016F3BD /* Sources */,
FAC155ED145855CF0016F3BD /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = <%= name.camel_case %>;
productName = Barcode;
productReference = FAC155F3145855CF0016F3BD /* lib<%= name.camel_case %>.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "<%= name.camel_case %>" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
);
mainGroup = 0867D691FE84028FC02AAC07 /* Barcode */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
FAC155E5145855CF0016F3BD /* <%= name.camel_case %> */,
);
};
/* End PBXProject section */

/* Begin PBXSourcesBuildPhase section */
FAC155E9145855CF0016F3BD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FAC155EA145855CF0016F3BD /* <%= name.downcase %>_wrap.c in Sources */,
FAC155EB145855CF0016F3BD /* <%= name.downcase %>.c in Sources */,
FAC155EC145855CF0016F3BD /* <%= name.camel_case %>.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
1DEB922308733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(RHO_ROOT)/platform/shared/common",
"$(RHO_ROOT)/platform/shared/rubyext",
"$(RHO_ROOT)/platform/shared/ruby/include",
"$(RHO_ROOT)/platform/shared/ruby/iphone",
"$(RHO_ROOT)/platform/shared",
);
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
SDKROOT = iphonesimulator4.1;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
};
name = Debug;
};
1DEB922408733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(RHO_ROOT)/platform/shared/common",
"$(RHO_ROOT)/platform/shared/rubyext",
"$(RHO_ROOT)/platform/shared/ruby/include",
"$(RHO_ROOT)/platform/shared/ruby/iphone",
"$(RHO_ROOT)/platform/shared",
);
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
SDKROOT = iphonesimulator4.1;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = static;
};
name = Release;
};
FAC155F1145855CF0016F3BD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/<%= name.camel_case %>.dst;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = <%= name.camel_case %>_Prefix.pch;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
MACOSX_DEPLOYMENT_TARGET = 10.5;
PRODUCT_NAME = <%= name.camel_case %>;
SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7";
};
name = Debug;
};
FAC155F2145855CF0016F3BD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
DSTROOT = /tmp/<%= name.camel_case %>.dst;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = <%= name.camel_case %>_Prefix.pch;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
MACOSX_DEPLOYMENT_TARGET = 10.5;
PRODUCT_NAME = <%= name.camel_case %>;
SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "<%= name.camel_case %>" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DEB922308733DC00010E9CD /* Debug */,
1DEB922408733DC00010E9CD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FAC155F0145855CF0016F3BD /* Build configuration list for PBXNativeTarget "<%= name.camel_case %>" */ = {
isa = XCConfigurationList;
buildConfigurations = (
FAC155F1145855CF0016F3BD /* Debug */,
FAC155F2145855CF0016F3BD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
}
@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project.
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
@@ -0,0 +1,74 @@
require 'fileutils'

USE_STLPORT = true

puts "<%= name.camel_case %> extension !"

namespace "build" do

task :config do

$targetdir = ENV['TARGET_TEMP_DIR']
raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?

$tempdir = ENV['TEMP_FILES_DIR']
raise "TEMP_FILES_DIR is not set" if $tempdir.nil?

$rootdir = ENV['RHO_ROOT']
raise "RHO_ROOT is not set" if $rootdir.nil?

$xcodebuild = ENV['XCODEBUILD']
raise "XCODEBUILD is not set" if $xcodebuild.nil?

$configuration = ENV['CONFIGURATION']
raise "CONFIGURATION is not set" if $configuration.nil?

$sdk = ENV['SDK_NAME']
raise "SDK_NAME is not set" if $sdk.nil?

$bindir = ENV['PLATFORM_DEVELOPER_BIN_DIR']
raise "PLATFORM_DEVELOPER_BIN_DIR is not set" if $bindir.nil?

$sdkroot = ENV['SDKROOT']
raise "SDKROOT is not set" if $sdkroot.nil?

$arch = ENV['ARCHS']
raise "ARCHS is not set" if $arch.nil?

$gccbin = $bindir + '/gcc-4.2'
$arbin = $bindir + '/ar'

end

task :all => :config do

iphone_path = '.'

simulator = $sdk =~ /iphonesimulator/

if $configuration == 'Distribution'
$configuration = 'Release'
end

result_lib = iphone_path + '/build/' + $configuration + '-' + ( simulator ? "iphonesimulator" : "iphoneos") + '/lib<%= name.camel_case %>.a'
target_lib = $targetdir + '/lib<%= name.camel_case %>.a'

rm_rf 'build'
rm_rf target_lib

args = ['build', '-target', '<%= name.camel_case %>', '-configuration', $configuration, '-sdk', $sdk]

require $rootdir + '/lib/build/jake.rb'

puts Jake.run($xcodebuild,args)
ret = $?

# copy result to $targetdir
cp result_lib,target_lib

end


end

task :default => "build:all"
@@ -0,0 +1,331 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="<%= name.camel_case() %>"
ProjectGUID="{93453E28-E84A-40C4-BD6A-51A8373D7044}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Windows Mobile 6 Professional SDK (ARMV4I)"
/>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Windows Mobile 6 Professional SDK (ARMV4I)"
OutputDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
IntermediateDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="$(RHO_ROOT)\platform\shared\ruby\wince;$(RHO_ROOT)\platform\shared\ruby\include;$(RHO_ROOT)\platform\shared;$(RHO_ROOT)\platform\shared\common"
PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
MinimalRebuild="true"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES)"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalOptions=" /subsystem:windowsce,5.02"
OutputFile="$(OutDir)/<%= name.camel_case() %>.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
IntermediateDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="$(RHO_ROOT)\platform\shared\ruby\win32;$(RHO_ROOT)\platform\shared\ruby\include;$(RHO_ROOT)\platform\shared;$(RHO_ROOT)\platform\shared\common"
PreprocessorDefinitions="_DEBUG;WIN32;WINDOWS;DEBUG;_LIB;_UNICODE;UNICODE"
MinimalRebuild="true"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES)"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/<%= name.camel_case() %>.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Windows Mobile 6 Professional SDK (ARMV4I)"
OutputDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
IntermediateDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="2"
AdditionalIncludeDirectories="$(RHO_ROOT)\platform\shared\ruby\wince;$(RHO_ROOT)\platform\shared\ruby\include;$(RHO_ROOT)\platform\shared;$(RHO_ROOT)\platform\shared\common"
PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_LIB;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES)"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalOptions=" /subsystem:windowsce,5.02"
OutputFile="$(OutDir)/<%= name.camel_case() %>.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
IntermediateDirectory="$(TEMP_FILES_DIR)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="$(RHO_ROOT)\platform\shared\ruby\win32;$(RHO_ROOT)\platform\shared\ruby\include;$(RHO_ROOT)\platform\shared;$(RHO_ROOT)\platform\shared\common"
PreprocessorDefinitions="NDEBUG;WIN32;WINDOWS;_LIB;_UNICODE;UNICODE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES)"
Culture="1033"
AdditionalIncludeDirectories="$(IntDir)"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/<%= name.camel_case() %>.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{9FC737FA-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\shared\src\<%= name.camel_case() %>.c"
>
</File>
<File
RelativePath=".\src\<%= name.camel_case() %>_wm.cpp"
>
</File>
<File
RelativePath="..\..\shared\ruby\<%= name.camel_case() %>_wrap.c"
>
</File>
</Filter>
<Filter
Name="Headers"
>
<File
RelativePath=".\src\<%= name.camel_case() %>.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
@@ -0,0 +1,62 @@
require 'fileutils'

USE_STLPORT = true


def build_extension(name, arch)
objects = []
mkdir_p $tempdir unless File.exists? $tempdir

mkdir_p $targetdir unless File.exist? $targetdir

if ENV['RHO_PLATFORM'] == 'wm'
args = []
args << "/M4"
args << name + ".vcproj"
args << "\"Release|#{$sdk}\""
cmdline = "\"" + $vcbuild + "\"" + ' ' + args.join(' ')
puts cmdline
puts `#{cmdline}`
exit unless $? == 0

cp_r File.join($tempdir, "Release", name + ".lib"), $targetdir

elsif ENV['RHO_PLATFORM'] == 'win32'
args = []
args << "/M4"
args << name + ".vcproj"
args << "\"Debug|Win32\""
cmdline = "\"" + $vcbuild + "\"" + ' ' + args.join(' ')
puts cmdline
puts `#{cmdline}`
exit unless $? == 0

cp_r File.join($tempdir, "Debug", name + ".lib"), $targetdir
end

cp_r File.join($tempdir, "Release", name + ".lib"), $targetdir
end

namespace "build" do
task :config do
$targetdir = ENV['TARGET_TEMP_DIR']
raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?
$tempdir = ENV['TEMP_FILES_DIR']
raise "TEMP_FILES_DIR is not set" if $tempdir.nil?
$rootdir = ENV['RHO_ROOT']
raise "RHO_ROOT is not set" if $rootdir.nil?

$vcbuild = ENV['VCBUILD']
raise "VCBUILD is not set" if $vcbuild.nil?
$sdk = ENV['SDK']
raise "SDK is not set" if $sdk.nil?

end

task :all => :config do

build_extension('<%= name.camel_case %>', $arch)
end
end

task :default => "build:all"
@@ -0,0 +1,40 @@
#include <common/RhodesApp.h>
#include <logging/RhoLogConf.h>

#include <stdlib.h>
#include <windows.h>
#include <commctrl.h>

#include <RhoNativeViewManager.h>
#include "rubyext/WebView.h"

#include "ruby/ext/rho/rhoruby.h"

#include "<%= name.downcase %>_wm.h"


extern "C" VALUE <%= name.downcase %>_native_process_string(const char* str) {

const char block[] = "<WM>";
char* buf = NULL;
buf = (char*)malloc(strlen(str) + strlen(block)*2 + 1);

strcpy(buf, block);
strcat(buf, str);
strcat(buf, block);

VALUE result = rho_ruby_create_string(buf);

free(buf);

return result;
}


extern "C" int <%= name.downcase %>_calc_summ(int x, int y) {
return (x+y);
}




@@ -0,0 +1,2 @@


@@ -0,0 +1,15 @@
/* <%= name.downcase %>.i */
%module <%= name.camel_case %>
%{
#include "ruby/ext/rho/rhoruby.h"

extern VALUE <%= name.downcase %>_native_process_string(const char* str);
extern int <%= name.downcase %>_calc_summ(int x, int y);

#define native_process_string <%= name.downcase %>_native_process_string
#define calc_summ <%= name.downcase %>_calc_summ

%}

extern VALUE native_process_string(const char* str);
extern int calc_summ(int x, int y);

Large diffs are not rendered by default.

@@ -0,0 +1,20 @@
#ifdef __cplusplus
extern "C" {
#endif

// declare Ruby registration method generated by SWIG in <%= name.downcase %>_wrap.c
extern void Init_<%= name.camel_case %>(void);

// this method executed once on start of program
void Init_<%= name.camel_case %>_extension(void) {
// execute initialization of Ruby registration (generated by SWIG)
Init_<%= name.camel_case %>();

// You can add some code to this place:


}

#ifdef __cplusplus
} //extern "C"
#endif
@@ -0,0 +1,13 @@
module <%= name.camel_case %>
class <%= name.camel_case %>StringHelper

def self.process_string(str)
return <%= name.camel_case %>::native_process_string(str)
end

end


end

@@ -8,7 +8,7 @@ vendor: rhomobile
sdkversion: 1.4
#wmsdk: "Windows Mobile 6 Professional SDK (ARMV4I)"
iphone:
sdk: iphonesimulator4.3
sdk: iphonesimulator5.0
entitlements: ""
codesignidentity: ""
configuration: Release
@@ -8,7 +8,7 @@ vendor: rhomobile
sdkversion: 1.4
wmsdk: "Windows Mobile 6 Professional SDK (ARMV4I)"
iphone:
sdk: iphonesimulator4.3
sdk: iphonesimulator5.0
entitlements: ""
codesignidentity: ""
configuration: Release