Author: jsdelfino
Date: Mon Sep 11 21:01:51 2006
New Revision: 442442

URL: http://svn.apache.org/viewvc?view=rev&rev=442442
Log:
Added support for references in Ruby components. Added a Ruby module providing 
an SCA::locateService function to allow a Ruby client to locate an SCA service 
component

Added:
    
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
   (with props)
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorClient.rb
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb
Removed:
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Calculator.h
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/CalculatorClient.cpp
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Calculator.h
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.cpp
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.h
    incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Divide.h
Modified:
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/Makefile.am
    
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
    
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
    
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Makefile.am
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.bat
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.sh
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Makefile.am
    
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/sample.calculator.composite

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/Makefile.am?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/Makefile.am Mon Sep 
11 21:01:51 2006
@@ -12,7 +12,8 @@
 tuscany/sca/ruby/RubyServiceWrapper.cpp \
 tuscany/sca/ruby/model/RubyImplementation.cpp \
 tuscany/sca/ruby/model/RubyReferenceBinding.cpp \
-tuscany/sca/ruby/model/RubyServiceBinding.cpp
+tuscany/sca/ruby/model/RubyServiceBinding.cpp \
+tuscany/sca/ruby/RubyCompositeContext.cpp
 
 libtuscany_sca_ruby_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
        -L$(top_builddir)/runtime/core/src -ltuscany_sca \

Added: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp?view=auto&rev=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
 (added)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
 Mon Sep 11 21:01:51 2006
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/ruby/RubyServiceProxy.h"
+
+using namespace tuscany::sca::ruby;
+
+extern "C"
+{
+
+    // Implement the Sca::locateService module function    
+    SCA_API VALUE tuscany_sca_ruby_locateService(VALUE module, VALUE value)
+    {
+        
+        // Get the default component
+        Component* defaultComponent = 
tuscany::sca::SCARuntime::getInstance()->getDefaultComponent();
+        Composite* composite = (Composite*)defaultComponent->getType();
+                
+        // Locate the service
+        const char* serviceName = rb_string_value_cstr(&value);
+        Service* service = composite->findComponentService(serviceName);
+        string msg;
+        if (!service)
+        {
+            string msg = "Service not found: ";
+            msg = msg + serviceName;
+            rb_raise(rb_eRuntimeError, msg.c_str());
+        }
+
+        // Get a Proxy for this service
+        RubyServiceProxy* serviceProxy = new RubyServiceProxy(service);
+
+        // Return the Ruby proxy value object        
+        return serviceProxy->getProxyValue();
+    }
+    
+    // Initialize the Ruby extension
+    SCA_API void Init_tuscany_sca_ruby()
+    {
+        
+        // Define the Sca::locateService() function 
+        VALUE module = rb_define_module("SCA");
+        rb_define_module_function(module, "locateService", 
(VALUE(*)(ANYARGS))tuscany_sca_ruby_locateService, 1);
+        
+    }
+
+    SCA_API void Init_libtuscany_sca_ruby()
+    {
+        Init_tuscany_sca_ruby();
+    }
+}

Propchange: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
 Mon Sep 11 21:01:51 2006
@@ -20,6 +20,7 @@
 #include "tuscany/sca/ruby/RubyServiceProxy.h"
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Exceptions.h"
 #include "tuscany/sca/model/Reference.h"
 #include "tuscany/sca/model/ReferenceType.h"
 #include "tuscany/sca/model/Service.h"
@@ -32,6 +33,33 @@
 #include "tuscany/sca/ruby/model/RubyImplementation.h"
 #include "tuscany/sca/ruby/model/RubyReferenceBinding.h"
 
+extern "C"
+{
+    
+    // Initialize a Ruby proxy
+    SCA_API VALUE tuscany_sca_ruby_proxy_initialize(VALUE self, VALUE 
serviceProxy)
+    {
+        rb_iv_set(self, "@cppProxy", serviceProxy);
+        return self;
+    }
+
+    // Handle a method_missing message and dispatch to
+    // our C++ proxy
+    SCA_API VALUE tuscany_sca_ruby_proxy_method_missing(int argc, VALUE* argv, 
VALUE self)
+    {
+        VALUE proxy = rb_iv_get(self, "@cppProxy");
+        
+        // Get the target service wrapper
+        tuscany::sca::ruby::RubyServiceProxy *serviceProxy;
+        Data_Get_Struct(proxy, tuscany::sca::ruby::RubyServiceProxy, 
serviceProxy);
+
+        // Handle the invocation
+        return serviceProxy->invoke(argc, argv); 
+        
+    }
+    
+}
+
 namespace tuscany
 {
     namespace sca
@@ -39,6 +67,8 @@
         namespace ruby
         {
             
+            VALUE RubyServiceProxy::proxyClass = Qnil; 
+            
             // ============================
             // Constructor: Create a proxy
             // ============================
@@ -58,6 +88,9 @@
                 
                 serviceWrapper = 
referenceBinding->getTargetServiceBinding()->getServiceWrapper();
     
+                // Create the Ruby proxy
+                createProxy();
+                
                 LOGEXIT(1,"RubyServiceProxy::constructor");
             }
             
@@ -77,7 +110,10 @@
                 
                 // Get the service wrapper
                 serviceWrapper = service->getBinding()->getServiceWrapper();
-    
+                
+                // Create the Ruby proxy
+                createProxy();
+                
                 LOGEXIT(1,"RubyServiceProxy::constructor");
             }
             
@@ -88,6 +124,191 @@
             {
                 LOGENTRY(1,"RubyServiceProxy::destructor");
                 LOGEXIT(1,"RubyServiceProxy::destructor");
+            }
+            
+            void RubyServiceProxy::createProxy()
+            {
+                // Create the Ruby proxy class
+                if (RubyServiceProxy::proxyClass == Qnil)
+                {
+                    VALUE module = rb_define_module("Tuscany");
+                    proxyClass = rb_define_class_under(module, "ServiceProxy", 
rb_cObject);
+                    rb_define_method(proxyClass, "initialize", 
(VALUE(*)(ANYARGS))tuscany_sca_ruby_proxy_initialize, 1);
+                    rb_define_method(proxyClass, "method_missing", 
(VALUE(*)(ANYARGS))tuscany_sca_ruby_proxy_method_missing, -1);
+                }
+                
+                // Create the Ruby proxy instance, pass the service wrapper to 
it
+                VALUE* args = new VALUE[1];
+                args[0] = Data_Wrap_Struct(rb_cObject, NULL, NULL, this);
+                proxyValue = rb_class_new_instance(1, args, proxyClass);
+                
+                // Mark proxyValue busy so that it doesn't get GC'ed by Ruby 
+                rb_gc_register_address(&proxyValue);
+            }
+            
+            
+            VALUE RubyServiceProxy::invoke(int argc, VALUE* argv)
+            {
+                // Get the method name
+                char* methodName = rb_id2name(SYM2ID(argv[0]));
+        
+                // Get the block passed by the caller
+                VALUE block =rb_block_given_p() ? rb_block_proc() : Qnil;
+                
+                // Create new Operation object
+                Operation operation(methodName);
+        
+                // Convert the Ruby parameters to C++
+                for (int i = 1; i < argc; i++)
+                {
+                    VALUE value = argv[i];
+                    
+                    int valueType = TYPE(value);
+                    
+                    switch (valueType)
+                    {
+                    case T_FLOAT: 
+                        {
+                            float* data = new float; 
+                            *data = rb_num2dbl(value);
+                            operation.addParameter(data);
+                            break;
+                        }
+                    case T_STRING: 
+                        {
+                            string* data = new 
string(rb_string_value_cstr(&value));
+                            const char** cdata = new const char*; 
+                            *cdata = data->c_str();
+                            operation.addParameter(cdata);
+                            break;
+                        }
+                    case T_FIXNUM: 
+                        {
+                            long* data = new long;
+                            *data = rb_num2long(value);
+                            operation.addParameter(data);
+                            break;
+                        }
+                    case T_BIGNUM: 
+                        {
+                            long double* data = new long double; 
+                            *data = rb_num2dbl(value);
+                            operation.addParameter(data);
+                            break;
+                        }
+                    case T_TRUE: 
+                        {
+                            bool* data = new bool;
+                            *data = true; 
+                            operation.addParameter(data);
+                            break;
+                        }
+                    case T_FALSE: 
+                        {
+                            bool* data = new bool;
+                            *data = false; 
+                            operation.addParameter(data);
+                            break;
+                        }
+                    default:;
+                        string msg = "Ruby type not supported: " + valueType;
+                        rb_raise(rb_eTypeError, msg.c_str());
+                        return Qnil;
+                    }
+
+                }
+                
+                try
+                {
+                    // Call into the target service wrapper
+                    serviceWrapper->invoke(operation);
+            
+                    // Convert the result to a Ruby value
+                    VALUE value;
+                    Operation::ParameterType resultType = 
operation.getReturnType();
+                    switch(resultType)
+                    {
+                        case Operation::BOOL: 
+                        {
+                            if( *(bool*)operation.getReturnValue())
+                            {
+                                //boolean true
+                                value = rb_int2inum(1);
+                            }
+                            else
+                            {
+                                value = rb_int2inum(0);
+                            }
+                            break;
+                        }
+                        case Operation::SHORT: 
+                        {
+                            value = 
rb_int2inum(*(short*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::USHORT: 
+                        {
+                            value = rb_uint2inum(*(unsigned 
short*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::LONG: 
+                        {
+                            value = 
rb_int2inum(*(long*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::ULONG: 
+                        {
+                            value = rb_uint2inum(*(unsigned 
long*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::FLOAT: 
+                        {
+                            value = 
rb_dbl2big(*(float*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::DOUBLE: 
+                        {
+                            value = 
rb_dbl2big(*(double*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::LONGDOUBLE: 
+                        {
+                            value = rb_dbl2big(*(long 
double*)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::CHARS: 
+                        {
+                            value = 
rb_str_new2(*(char**)operation.getReturnValue());
+                            break;
+                        }
+                        case Operation::STRING: 
+                        {
+                            value = 
rb_str_new2((*(string*)operation.getReturnValue()).c_str());
+                            break;
+                        }
+                        default:
+                        {
+                            //throw new 
ComponentInvocationException("Operation parameter type not supported");
+                            string msg = "Operation parameter type not 
supported" + resultType;
+                            rb_raise(rb_eRuntimeError, msg.c_str());
+                            return Qnil;
+                        }
+                    }
+            
+                    return value;
+
+                }
+                catch(TuscanyRuntimeException &ex)
+                {   
+                    string msg = "Exception while invoking a service: ";
+                    msg += ex.getEClassName();
+                    msg += ": ";
+                    msg += ex.getMessageText();
+                    rb_raise(rb_eRuntimeError, msg.c_str());
+                    return Qnil;
+                }
+                  
+                return Qnil;
             }
             
         } // End namespace ruby        

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
 Mon Sep 11 21:01:51 2006
@@ -72,9 +72,19 @@
                 /**
                  * Returns the Ruby value of the proxy
                  */
-                 VALUE getValue() const { return value; };
+                 VALUE getProxyValue() const { return proxyValue; };
+                 
+                 /**
+                  * Handles the invocation of a Ruby method.
+                  */
+                  VALUE invoke(int argc, VALUE* argv);
             
             private:
+            
+                /**
+                 * Create the Ruby proxy object
+                 */
+                 void createProxy();
     
                 /**
                  * The target service wrapper
@@ -84,7 +94,12 @@
                 /**
                  * The Ruby value of the proxy
                  */
-                 VALUE value;
+                 VALUE proxyValue;
+
+                /**
+                 * The Ruby proxy class
+                 */
+                static VALUE proxyClass;                  
                  
             };
             

Modified: 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
 (original)
+++ 
incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
 Mon Sep 11 21:01:51 2006
@@ -82,22 +82,25 @@
                     // Create a new instance of the Ruby implementation class
                     VALUE instance = rb_class_new_instance(0, NULL, 
implementation->getImplementationClass());
 
-                    // Set all the references and properties
+                    // Set all the references
                     const Component::REFERENCE_MAP& references = 
component->getReferences();
                     Component::REFERENCE_MAP::const_iterator refiter = 
references.begin();
                     for (int ri=0; ri< references.size(); ri++)
                     {
                         Reference* reference = refiter->second;
                         RubyServiceProxy* proxy = 
(RubyServiceProxy*)reference->getBinding()->getServiceProxy();
-                        VALUE referenceValue = proxy->getValue();
-                        rb_iv_set(instance, refiter->first.c_str(), 
referenceValue);
+                        VALUE proxyValue = proxy->getProxyValue();
+                        string varName = "@" + refiter->first; 
+                        rb_iv_set(instance, varName.c_str(), proxyValue);
                         refiter++;
                     }
                     
+                    // TODO Set all the properties
+                    
                     // Get the ID of the specified method
                     ID method = rb_intern(operation.getName().c_str());
 
-                    // Convert C arguments to Ruby arguments
+                    // Convert C++ parameters to Ruby parameters
                     VALUE *args = NULL;
                     int n = operation.getNParms();
                     if (n != 0)
@@ -109,7 +112,8 @@
                             VALUE value;
                             
                             Operation::Parameter& parm = 
operation.getParameter(i);
-                            switch(parm.getType())
+                            Operation::ParameterType parmType = parm.getType();
+                            switch(parmType)
                             {
                                 case Operation::BOOL: 
                                 {
@@ -172,7 +176,8 @@
                                 default:
                                 {
                                     //throw new 
ComponentInvocationException("Operation parameter type not supported");
-                                    std::cout << "Operation parameter type not 
supported" << std::endl;
+                                    string msg = "Operation parameter type not 
supported" + parmType;
+                                    throw msg.c_str();
                                 }
                             }
                             
@@ -182,70 +187,68 @@
 
                     
                     // Invoke the specified method
-                    VALUE value;
+                    VALUE result;
                     if (n == 0)
                     {
-                        value = rb_funcall(instance, method, 0);
+                        result = rb_funcall(instance, method, 0);
                     }
                     else
                     {
-                        value = rb_funcall2(instance, method, n, args);
+                        result = rb_funcall2(instance, method, n, args);
                     }
                     
-                    // Convert the result to a C result
-                    switch(operation.getReturnType())
+                    // Convert the Ruby result value to a C++ result
+                    int resultType = TYPE(result);
+                    switch(resultType)
                     {
-                    case Operation::BOOL: 
-                        {
-                            *(bool*)operation.getReturnValue() = 
(rb_num2long(value)!=0);
-                            break;
-                        }
-                    case Operation::SHORT: 
-                        {
-                            *(short*)operation.getReturnValue() = (short) 
rb_num2long(value);
-                            break;
-                        }
-                    case Operation::LONG: 
-                        {
-                            *(long*)operation.getReturnValue() =  (long) 
rb_num2long(value);
-                            break;
-                        }
-                    case Operation::USHORT: 
+                    case T_FLOAT: 
                         {
-                            *(unsigned short*)operation.getReturnValue() = 
(unsigned short) rb_num2ulong(value);
+                            float* data = new float; 
+                            *data = rb_num2dbl(result);
+                            operation.setReturnValue(data);
                             break;
                         }
-                    case Operation::ULONG: 
+                    case T_STRING: 
                         {
-                            *(unsigned long*)operation.getReturnValue() = 
(unsigned long) rb_num2ulong(value);
+                            string* data = new 
string(rb_string_value_cstr(&result));
+                            const char** cdata = new const char*; 
+                            *cdata = data->c_str();
+                            operation.setReturnValue(cdata);
                             break;
                         }
-                    case Operation::FLOAT: 
+                    case T_FIXNUM: 
                         {
-                            *(float*)operation.getReturnValue() = (float) 
rb_num2dbl(value);
+                            long* data = new long;
+                            *data = rb_num2long(result);
+                            operation.setReturnValue(data);
                             break;
                         }
-                    case Operation::DOUBLE: 
+                    case T_BIGNUM: 
                         {
-                            *(double*)operation.getReturnValue() = (double) 
rb_num2dbl(value);
+                            long double* data = new long double; 
+                            *data = rb_num2dbl(result);
+                            operation.setReturnValue(data);
                             break;
                         }
-                    case Operation::LONGDOUBLE: 
+                    case T_TRUE: 
                         {
-                            *(long double*)operation.getReturnValue() = (long 
double) rb_num2dbl(value);
+                            bool* data = new bool;
+                            *data = true; 
+                            operation.setReturnValue(data);
                             break;
                         }
-                    case Operation::CHARS: 
+                    case T_FALSE: 
                         {
-                            *(char**)operation.getReturnValue() = 
strdup(rb_string_value_cstr(&value));
+                            bool* data = new bool;
+                            *data = false; 
+                            operation.setReturnValue(data);
                             break;
                         }
-                    case Operation::STRING: 
+                    default:
                         {
-                            *(string*)operation.getReturnValue() = 
string(rb_string_value_cstr(&value));
-                            break;
-                        }
-                    default:;
+                            string msg = "Ruby type not supported: " + 
resultType;
+                            throw msg.c_str();
+                        } 
                     }
                     
                 }

Modified: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Makefile.am?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Makefile.am
 (original)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/Makefile.am
 Mon Sep 11 21:01:51 2006
@@ -1,34 +1,5 @@
 deploydir=$(prefix)/samples/RubyCalculator/deploy
 prgbindir=$(deploydir)/bin
 
-prgbin_PROGRAMS = calculator_client
 prgbin_SCRIPTS = runclient.sh
 EXTRA_DIST = runclient.sh
-
-AM_CPPFLAGS = $(CPPFLAGS)
-calculator_client_SOURCES = \
-CalculatorClient.cpp
-
-calculator_client_LDADD = \
--L${TUSCANY_SCACPP}/lib \
-  -ltuscany_sca \
--L${TUSCANY_SCACPP}/extensions/cpp/lib \
-  -ltuscany_sca_cpp \
--L${TUSCANY_SDOCPP}/lib \
-  -ltuscany_sdo \
-  -ltuscany_sdo_axiom \
--L$(AXIS2C_HOME)/lib \
-  -laxis2_util \
-  -laxis2_axiom \
-  -laxis2_wsdl \
-  -laxis2_engine \
-  -laxis2_parser \
-  -laxis2_minizip \
-  -lpthread \
-  -laxis2_http_sender \
-  -laxis2_http_receiver
-       
-INCLUDES = \
--I$(TUSCANY_SCACPP)/extensions/cpp/include \
--I${TUSCANY_SCACPP}/include \
--I${TUSCANY_SDOCPP}/include

Modified: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.bat
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.bat?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.bat
 (original)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.bat
 Mon Sep 11 21:01:51 2006
@@ -37,11 +37,9 @@
 set TUSCANY_SCACPP_SYSTEM_ROOT=%~d0%~p0\..\
 set TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent
 
-set 
PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\cpp\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH%
+set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH%
 
-.\calculator_client.exe add 4.7 9
-.\calculator_client.exe div 7.2 3.6
-.\calculator_client.exe mul 7 6
+ruby -C..\packages\sample.calculator -I%TUSCANY_SCACPP%\extensions\ruby\lib 
CalculatorClient.rb
 
 :end
 endlocal

Modified: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.sh
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.sh?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.sh
 (original)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator.client/runclient.sh
 Mon Sep 11 21:01:51 2006
@@ -36,12 +36,9 @@
 
 TEST_SYSTEM=$APFULLDIR/../
 
-export 
LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/cpp/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH
+export 
LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH
 
 export TUSCANY_SCACPP_SYSTEM_ROOT=$TEST_SYSTEM
 export TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent
 
-./calculator_client add 4.7 9
-./calculator_client div 7.2 3.6
-./calculator_client mul 7 6
-
+ruby -C../packages/sample.calculator -I$TUSCANY_SCACPP/extensions/ruby/lib 
CalculatorClient.rb

Added: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorClient.rb
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorClient.rb?view=auto&rev=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorClient.rb
 (added)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorClient.rb
 Mon Sep 11 21:01:51 2006
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+require("libtuscany_sca_ruby")
+
+calculator = SCA::locateService("CalculatorComponent/CalculatorService")
+
+x = calculator.add(1, 2)
+print x
+print "\n"
+
+x = calculator.div(4, 2)
+print x
+print "\n"

Added: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb?view=auto&rev=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb
 (added)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb
 Mon Sep 11 21:01:51 2006
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+
+class CalculatorImpl
+
+  def initialize()
+    print "Ruby - CalculatorImpl.initialize\n"
+  end
+       
+  def div(arg1, arg2)
+    print "Ruby - CalculatorImpl.div\n"
+    @divideService.divide(arg1, arg2)
+  end
+
+  def add(arg1, arg2)
+    print "Ruby - CalculatorImpl.add\n"
+    arg1 + arg2
+  end
+
+  def sub(arg1, arg2)
+    print "Ruby - CalculatorImpl.sub\n"
+    arg1 - arg2
+  end
+
+  def mul(arg1, arg2)
+    print "Ruby - CalculatorImpl.mul\n"
+    arg1 * arg2
+  end
+
+end
\ No newline at end of file

Modified: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Makefile.am?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Makefile.am 
(original)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/Makefile.am 
Mon Sep 11 21:01:51 2006
@@ -1,32 +1,5 @@
 deploydir=$(prefix)/samples/RubyCalculator/deploy
 compositedir=$(deploydir)/packages/sample.calculator
 
-BUILT_SOURCES = CalculatorImpl_CalculatorService_Proxy.cpp \
-CalculatorImpl_CalculatorService_Wrapper.cpp \
-CalculatorImpl_divideService_Proxy.cpp
-
-noinst_HEADERS = *.h
-
-${BUILT_SOURCES}: sample.calculator.composite
-       java -jar $(TUSCANY_SCACPP)/bin/scagen.jar -dir . -output .
-
-composite_LTLIBRARIES = libCalculator.la
 composite_DATA = *.composite *.componentType *.wsdl *.rb
 EXTRA_DIST = *.composite *.componentType *.wsdl *.rb
-
-libCalculator_la_SOURCES = \
-CalculatorImpl.cpp \
-CalculatorImpl_CalculatorService_Proxy.cpp \
-CalculatorImpl_CalculatorService_Wrapper.cpp \
-CalculatorImpl_divideService_Proxy.cpp
-
-libCalculator_la_LIBADD = \
--L${TUSCANY_SCACPP}/lib \
-  -ltuscany_sca \
--L${TUSCANY_SCACPP}/extensions/cpp/lib \
-  -ltuscany_sca_cpp
-
-INCLUDES = \
--I$(TUSCANY_SCACPP)/extensions/cpp/include \
--I$(TUSCANY_SCACPP)/include \
--I${TUSCANY_SDOCPP}/include

Modified: 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/sample.calculator.composite
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/sample.calculator.composite?view=diff&rev=442442&r1=442441&r2=442442
==============================================================================
--- 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/sample.calculator.composite
 (original)
+++ 
incubator/tuscany/cpp/sca/samples/RubyCalculator/sample.calculator/sample.calculator.composite
 Mon Sep 11 21:01:51 2006
@@ -25,7 +25,7 @@
        </service>
 
        <component name="CalculatorComponent">
-               <implementation.cpp library="Calculator" 
header="CalculatorImpl.h"/>
+               <implementation.ruby script="CalculatorImpl.rb" 
class="CalculatorImpl"/>
            <reference 
name="divideService">DivideComponent/DivideService</reference>
        </component>
         



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to