python

Dependencies:   TSI mbed

Fork of pymite by Norimasa Okamoto

Files at this revision

API Documentation at this revision

Comitter:
kausdev
Date:
Thu Aug 28 19:35:16 2014 +0000
Parent:
11:0522cf53ac30
Commit message:
pymte

Changed in this revision

vm/bytearray.c Show annotated file Show diff for this revision Revisions of this file
diff -r 0522cf53ac30 -r d27ad05214e3 vm/bytearray.c
--- a/vm/bytearray.c	Wed Jul 23 03:22:42 2014 +0000
+++ b/vm/bytearray.c	Thu Aug 28 19:35:16 2014 +0000
@@ -52,10 +52,8 @@
 {
     PmReturn_t retval = PM_RET_OK;
 
-    if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_INT)
-    {
-        if ((((pPmInt_t)pobj)->val > 255) || (((pPmInt_t)pobj)->val < 0))
-        {
+    if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_INT) {
+        if ((((pPmInt_t)pobj)->val > 255) || (((pPmInt_t)pobj)->val < 0)) {
             PM_RAISE(retval, PM_RET_EX_VAL);
             return retval;
         }
@@ -63,18 +61,15 @@
         *b = (uint8_t)((pPmInt_t)pobj)->val;
     }
 
-    else if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_STR)
-    {
-        if (((pPmString_t)pobj)->length != 1)
-        {
+    else if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_STR) {
+        if (((pPmString_t)pobj)->length != 1) {
             PM_RAISE(retval, PM_RET_EX_VAL);
             return retval;
         }
         *b = ((pPmString_t)pobj)->val[0];
     }
 
-    else
-    {
+    else {
         PM_RAISE(retval, PM_RET_EX_TYPE);
     }
     return retval;
@@ -94,8 +89,7 @@
     uint8_t objid;
 
     /* If object is an instance, get the thing it is containing */
-    if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_CLI)
-    {
+    if (OBJ_GET_TYPE(pobj) == OBJ_TYPE_CLI) {
         retval = dict_getItem((pPmObj_t)((pPmInstance_t)pobj)->cli_attrs,
                               PM_NONE,
                               (pPmObj_t *)&pba);
@@ -104,12 +98,10 @@
     }
 
     /* Get the requested length of the new bytearray */
-    switch (OBJ_GET_TYPE(pobj))
-    {
+    switch (OBJ_GET_TYPE(pobj)) {
         case OBJ_TYPE_INT:
             i = ((pPmInt_t)pobj)->val;
-            if ((i < 0) || (i > 65535))
-            {
+            if ((i < 0) || (i > 65535)) {
                 PM_RAISE(retval, PM_RET_EX_VAL);
                 return retval;
             }
@@ -152,8 +144,7 @@
     pba->val = pb;
 
     /* Fill the bytes */
-    switch (OBJ_GET_TYPE(pobj))
-    {
+    switch (OBJ_GET_TYPE(pobj)) {
         case OBJ_TYPE_INT:
             sli_memset((unsigned char *)&(pb->val), '\0', n);
             break;
@@ -169,8 +160,7 @@
 
         case OBJ_TYPE_LST:
         case OBJ_TYPE_TUP:
-            for (i = 0; i < n; i++)
-            {
+            for (i = 0; i < n; i++) {
                 retval = seq_getSubscript(pobj, i, &pitem);
                 PM_RETURN_IF_ERROR(retval);
                 retval = bytes_getByteFromObj(pitem, &b);
@@ -196,14 +186,12 @@
     pba = (pPmBytearray_t)pobj;
 
     /* Adjust a negative index */
-    if (index < 0)
-    {
+    if (index < 0) {
         index += pba->length;
     }
 
     /* Check the bounds of the index */
-    if ((index < 0) || (index >= pba->length))
-    {
+    if ((index < 0) || (index >= pba->length)) {
         PM_RAISE(retval, PM_RET_EX_INDX);
         return retval;
     }
@@ -225,14 +213,12 @@
     uint8_t b = 0;
 
     /* Adjust a negative index */
-    if (index < 0)
-    {
+    if (index < 0) {
         index += ((pPmBytearray_t)pba)->length;
     }
 
     /* Check the bounds of the index */
-    if ((index < 0) || (index >= ((pPmBytearray_t)pba)->length))
-    {
+    if ((index < 0) || (index >= ((pPmBytearray_t)pba)->length)) {
         PM_RAISE(retval, PM_RET_EX_INDX);
         return retval;
     }