Phalanger icon indicating copy to clipboard operation
Phalanger copied to clipboard

bug in library wrappers generator?

Open proff opened this issue 10 years ago • 2 comments

        [ImplementsFunction("tieArrayValue")]
        public static object tieArrayValue([PhpRw] ref PhpArray arr, object key, object value)
        {
...
        }

        [ImplementsFunction("tieArrayValue")]
        public static object tieArrayValue([PhpRw] ref PhpArray arr, object key)
        {
...
        }
    public static object tieArrayValue([In] object obj0, [In] PhpStack obj1)
    {
      switch (obj1.ArgCount)
      {
        case 2:
          PhpReference phpReference1 = obj1.PeekReferenceUnchecked(0); //why 0? it's throws exception
          PhpArray phpArray1 = phpReference1.value as PhpArray;
          // ISSUE: explicit reference operation
          // ISSUE: variable of a reference type
          PhpArray& arr1 = @phpArray1;
          object key1 = obj1.PeekValueUnchecked(2);
          obj1.RemoveFrame();
          object obj2 = Common.tieArrayValue(arr1, key1);
          phpReference1.value = (object) phpArray1;
          return obj2;
        case 3:
          PhpReference phpReference2 = obj1.PeekReferenceUnchecked(0); //why 0? it's throws exception
          PhpArray phpArray2 = phpReference2.value as PhpArray;
          // ISSUE: explicit reference operation
          // ISSUE: variable of a reference type
          PhpArray& arr2 = @phpArray2;
          object key2 = obj1.PeekValueUnchecked(2);
          object obj3 = obj1.PeekValueUnchecked(3);
          obj1.RemoveFrame();
          object obj4 = Common.tieArrayValue(arr2, key2, obj3);
          phpReference2.value = (object) phpArray2;
          return obj4;
        default:
          PhpException.InvalidArgumentCount((string) null, "tieArrayValue");
          return (object) null;
      }
    }

proff avatar Jul 09 '14 20:07 proff

PeekReferenceUnchecked(0); should never work, will be fixed - THANKS!

ref causes explicit referencing the variable, maybe can be discussed?

jakubmisek avatar Jul 09 '14 20:07 jakubmisek

I need to change bool to PhpArray if i got bool in first argument (original methods has object as first argument and also has this bug)

proff avatar Jul 10 '14 03:07 proff