OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | August 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[fractal-commits] [8403] trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src:Fix bug in AttributeLoader that makes uninitialized string attributes being initilized to (char*) "0" rather than (char*) 0


Title: [8403] trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src: Fix bug in AttributeLoader that makes uninitialized string attributes being initilized to (char*) "0" rather than (char*) 0
Revision
8403
Author
leclercq
Date
2008-08-28 14:32:33 +0200 (Thu, 28 Aug 2008)

Log Message

Fix bug in AttributeLoader that makes uninitialized string attributes being initilized to (char*) "0" rather than (char*) 0
Add corresponding test.

Modified Paths

Added Paths

Diff

Modified: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/main/java/org/objectweb/fractal/cecilia/adl/attributes/AttributeLoader.java (8402 => 8403)


--- trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/main/java/org/objectweb/fractal/cecilia/adl/attributes/AttributeLoader.java	2008-08-28 07:47:59 UTC (rev 8402)
+++ trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/main/java/org/objectweb/fractal/cecilia/adl/attributes/AttributeLoader.java	2008-08-28 12:32:33 UTC (rev 8403)
@@ -191,27 +191,26 @@
           attrNode.setValue(getDefaultValue(field));
         } else {
           attrNode = assignedAttribute;
-        }
-
-        final PrimitiveType pt = field.getPrimitiveType();
-        if (pt != null) {
-          final String typeName = pt.getName();
-          if (typeName.equals(PrimitiveType.PrimitiveTypeEnum.STRING.name())) {
-            // If the attribute is a string and it doesn't have
-            // surrounding quotes, add them.
-            final String attrValue = attrNode.getValue();
-            if (!(attrValue.startsWith("\"") && attrValue.endsWith("\""))) {
-              attrNode.setValue("\"" + attrValue + "\"");
+          final PrimitiveType pt = field.getPrimitiveType();
+          if (pt != null) {
+            final String typeName = pt.getName();
+            if (typeName.equals(PrimitiveType.PrimitiveTypeEnum.STRING.name())) {
+              // If the attribute is a string and it doesn't have
+              // surrounding quotes, add them.
+              final String attrValue = attrNode.getValue();
+              if (!(attrValue.startsWith("\"") && attrValue.endsWith("\""))) {
+                attrNode.setValue("\"" + attrValue + "\"");
+              }
+            } else if (typeName.equals(PrimitiveType.PrimitiveTypeEnum.BOOLEAN
+                .name())) {
+              // If the attribute is a boolean, turn it into '1' or '0'.
+              final String attrValue = attrNode.getValue();
+              if (Boolean.parseBoolean(attrValue)) {
+                attrNode.setValue("1");
+              } else {
+                attrNode.setValue("0");
+              }
             }
-          } else if (typeName.equals(PrimitiveType.PrimitiveTypeEnum.BOOLEAN
-              .name())) {
-            // If the attribute is a boolean, turn it into '1' or '0'.
-            final String attrValue = attrNode.getValue();
-            if (Boolean.parseBoolean(attrValue)) {
-              attrNode.setValue("1");
-            } else {
-              attrNode.setValue("0");
-            }
           }
         }
 

Modified: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/java/org/objectweb/fractal/cecilia/adl/test/AttributesTest.java (8402 => 8403)


--- trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/java/org/objectweb/fractal/cecilia/adl/test/AttributesTest.java	2008-08-28 07:47:59 UTC (rev 8402)
+++ trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/java/org/objectweb/fractal/cecilia/adl/test/AttributesTest.java	2008-08-28 12:32:33 UTC (rev 8403)
@@ -35,6 +35,10 @@
     compileAndRun("test.attributes.AttributeMC");
   }
 
+  public void testUninitializedAttributeMC() throws Exception {
+    compileAndRun("test.attributes.UninitializedAttributeMC");
+  }
+
   public void testZeroValueAttributeUsingAttributesMacro() throws Exception {
     compileAndRun("test.attributes.ZeroAttributeMC");
   }

Modified: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/api/Attributes.idl (8402 => 8403)


--- trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/api/Attributes.idl	2008-08-28 07:47:59 UTC (rev 8402)
+++ trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/api/Attributes.idl	2008-08-28 12:32:33 UTC (rev 8403)
@@ -26,4 +26,5 @@
 
 record Attributes {
    int a;
+   string b;
 }

Added: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.c (0 => 8403)


--- trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.c	                        (rev 0)
+++ trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.c	2008-08-28 12:32:33 UTC (rev 8403)
@@ -0,0 +1,36 @@
+/**
+ * Cecilia, an implementation of the Fractal component model in C.
+ * Copyright (C) 2006-2008 STMicroelectronics
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: fractal@xxxxxxxxxxxxx
+ *
+ * Author: Matthieu Leclercq
+ */
+
+DECLARE_DATA{};
+
+#include <cecilia.h>
+
+jint METHOD(r, run)(void* _this) {
+  if (ATTRIBUTES.a != 0)
+    return 1;
+  if (ATTRIBUTES.b != ((char *) 0))
+	return 2;
+
+  return 0;
+}
Property changes on: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.c
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.fractal (0 => 8403)


--- trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.fractal	                        (rev 0)
+++ trunk/cecilia-framework/cecilia/toolchain/cecilia-adl/src/test/resources/test/attributes/UninitializedAttributeMC.fractal	2008-08-28 12:32:33 UTC (rev 8403)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE definition PUBLIC "-//objectweb.org//DTD Fractal ADL 2.0//EN" 
+  "classpath://org/objectweb/fractal/cecilia/adl/parser/xml/cecilia.dtd">
+
+<definition name="test.attributes.UninitializedAttributeMC" extends="test.AbstractTest">
+  <component name="test">
+    <content class="test.attributes.UninitializedAttributeMC" language="thinkMC"/>
+    <attributes signature="test.api.Attributes">
+    </attributes>
+  </component>
+</definition>


<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.