You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/08/25 13:29:33 UTC

svn commit: r436761 - in /incubator/tuscany/cpp/sdo/runtime/core: src/commonj/sdo/TypeImpl.cpp test/jira490.txt test/main.cpp test/sdotest.cpp test/sdotest.h

Author: robbinspg
Date: Fri Aug 25 04:29:32 2006
New Revision: 436761

URL: http://svn.apache.org/viewvc?rev=436761&view=rev
Log:
TUSCANY-490 - Apply Geoff Winn's patch

Added:
    incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt   (with props)
Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
    incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h

Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp?rev=436761&r1=436760&r2=436761&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp Fri Aug 25 04:29:32 2006
@@ -2859,7 +2859,24 @@
         case UriType:
             {
              if (value == 0) return 0;
-             return (char)*(wchar_t*)value;
+              // Assume the string is a number eg "123" and attempt to convert it.
+
+#if defined(WIN32) || defined(_WINDOWS)
+              return (char) _wtoi((wchar_t*) value);
+#else
+              char* tmpstr = new char[len + 1];
+              short s = 0;
+              wchar_t* srcptr = (wchar_t*) value;
+
+              for (int j = 0; j < len; j++)
+              {
+                 tmpstr[j] = (char) srcptr[j];
+              }
+              tmpstr[len] = 0;
+              s = (char) atoi(tmpstr);
+              delete tmpstr;
+              return (char) s;
+#endif
             }
 
         case BytesType:

Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt?rev=436761&view=auto
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt Fri Aug 25 04:29:32 2006
@@ -0,0 +1,53 @@
+Test Program starting to create types ...
+
+Before Resolution
+
+Printing Types
+Type BigDecimal
+Type BigInteger
+Type Boolean
+Type Byte
+Type Bytes
+Type ChangeSummary
+Type Character
+Type DataObject
+Type Date
+Type Double
+Type Float
+Type Integer
+Type Long
+Type OpenDataObject
+Type Short
+Type String
+Type URI
+Type Employee
+Has Property name of type String
+Has Property officeNumber of type String
+
+After Resolution
+
+Printing Types
+Type BigDecimal
+Type BigInteger
+Type Boolean
+Type Byte
+Type Bytes
+Type ChangeSummary
+Type Character
+Type DataObject
+Type Date
+Type Double
+Type Float
+Type Integer
+Type Long
+Type OpenDataObject
+Type Short
+Type String
+Type URI
+Type Employee
+Has Property name of type String
+Has Property officeNumber of type String
+Mr A Trader
+123
+123
+{

Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira490.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?rev=436761&r1=436760&r2=436761&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Fri Aug 25 04:29:32 2006
@@ -167,6 +167,7 @@
     TEST (  sdotest::b46617() );
     TEST (  sdotest::b46613() );
     TEST (  sdotest::b45933() );
+    TEST (  sdotest::jira490() );
 
     cout << "Total tests:" << totaltests << " Tests passed:" << testspassed << endl;
 

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp?rev=436761&r1=436760&r2=436761&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp Fri Aug 25 04:29:32 2006
@@ -2876,6 +2876,58 @@
     }
 }
 
+int sdotest::jira490()
+{
+
+   FILE *f;
+
+   f = fopen("jira490.dat", "w+");
+   if (f == 0)
+   {
+      if (!silent) cout << "Failed to open jira490.dat" << endl;
+   }
+
+   fprintf(f,"Test Program starting to create types ...\n");
+
+   DataFactoryPtr mdg  = DataFactory::getDataFactory();
+
+   mdg->addType("myspace","Employee");
+  
+   const Type& ts = mdg->getType("commonj.sdo","String");
+   const Type& te = mdg->getType("myspace","Employee");
+
+   mdg->addPropertyToType(te,"name",ts);
+   mdg->addPropertyToType(te,"officeNumber",ts);
+
+   fprintf(f, "\nBefore Resolution\n\n");
+   printDataStructure(f, mdg);
+
+   /* Now create some objects in the dg */
+
+   DataObjectPtr dor = mdg->create((Type&) te);
+
+   fprintf(f, "\nAfter Resolution\n\n");
+   printDataStructure(f, mdg);
+
+   dor->setCString("name", "Mr A Trader");
+   dor->setCString("officeNumber", "123");
+
+   const char* chnam = dor->getCString("name");
+   fprintf(f, "%s\n", chnam);
+
+   const char* offnum = dor->getCString("officeNumber");
+   fprintf(f, "%s\n", offnum);
+
+   char c = dor->getByte("officeNumber");
+   fprintf(f, "%d\n", c);
+   fprintf(f, "%c\n", c);
+
+   fclose(f);
+
+   return comparefiles("jira490.dat", "jira490.txt");
+
+}
+
 int sdotest::getproptest()
 {
     // should be able to get a property by xpath...

Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?rev=436761&r1=436760&r2=436761&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Fri Aug 25 04:29:32 2006
@@ -169,6 +169,7 @@
         static int testGetters(DataObjectPtr dor);
         static int testGetter(DataObjectPtr dor, char* str);
         static int maintest();
+        static int jira490();
         
         static int b48602();
         static int b48736();



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org