Fix some *VERY* confusing nomenclature in CopyArray().
authorDavid Anderson <dvander@alliedmods.net>
Thu Sep 13 23:58:22 2012 -0700 (2012-09-13)
changeset 1795f3c91fa6058
parent 178 9efe9a1456fd
child 180 b98a56a533d0
Fix some *VERY* confusing nomenclature in CopyArray().
src/Interpreter.cpp
     1.1 --- a/src/Interpreter.cpp	Thu Sep 13 23:52:25 2012 -0700
     1.2 +++ b/src/Interpreter.cpp	Thu Sep 13 23:58:22 2012 -0700
     1.3 @@ -83,14 +83,20 @@
     1.4  
     1.5  static bool CopyStruct(Zone *zone, Handle<Struct> left, Handle<Struct> right);
     1.6  
     1.7 +static bool
     1.8 +ChangeArrayLength(Zone *zone, Handle<Array> source, Handle<Array> dest)
     1.9 +{
    1.10 +    return true;
    1.11 +}
    1.12 +
    1.13  // Even though this function can fail, we immediately bail out, so it doesn't
    1.14  // matter if we've leaving things unrooted.
    1.15  static bool
    1.16 -CopyArray(Zone *zone, Handle<Array> source, Handle<Array> dest)
    1.17 +CopyArray(Zone *zone, Handle<Array> dest, Handle<Array> source)
    1.18  {
    1.19      if (source->length() != dest->length()) {
    1.20 -//        if (!ChangeArrayLength(zone, source, dest))
    1.21 -//            return false;
    1.22 +        if (!ChangeArrayLength(zone, source, dest))
    1.23 +            return false;
    1.24      }
    1.25  
    1.26      if (source->type()->contained()->isArray()) {
    1.27 @@ -100,8 +106,8 @@
    1.28          Local<Array> left(zone);
    1.29          Local<Array> right(zone);
    1.30          for (unsigned i = 0; i < source->length(); i++) {
    1.31 -            left = Array::cast(source->readObject(i));
    1.32 -            right = Array::cast(dest->readObject(i));
    1.33 +            left = Array::cast(dest->readObject(i));
    1.34 +            right = Array::cast(source->readObject(i));
    1.35              if (!CopyArray(zone, left, right))
    1.36                  return false;
    1.37          }
    1.38 @@ -112,18 +118,18 @@
    1.39          Local<Struct> left(zone);
    1.40          Local<Struct> right(zone);
    1.41          for (unsigned i = 0; i < source->length(); i++) {
    1.42 -            left = Struct::cast(source->readObject(i));
    1.43 -            right = Struct::cast(dest->readObject(i));
    1.44 +            left = Struct::cast(dest->readObject(i));
    1.45 +            right = Struct::cast(source->readObject(i));
    1.46              if (!CopyStruct(zone, left, right))
    1.47                  return false;
    1.48          }
    1.49      } else {
    1.50          assert(source->type()->contained()->pod() == dest->type()->contained()->pod());
    1.51          assert(source->type()->contained()->pod() == PrimitiveType_Char
    1.52 -               ? source->length() >= dest->length()
    1.53 +               ? source->length() <= dest->length()
    1.54                 : source->length() == dest->length());
    1.55  
    1.56 -        memcpy(source->vec(), dest->vec(), dest->length() * dest->elementSize());
    1.57 +        memcpy(dest->vec(), source->vec(), source->length() * source->elementSize());
    1.58      }
    1.59      return true;
    1.60  }