Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

bug in library wrappers generator? #36

Open
proff opened this issue Jul 9, 2014 · 2 comments
Open

bug in library wrappers generator? #36

proff opened this issue Jul 9, 2014 · 2 comments

Comments

@proff
Copy link
Contributor

proff commented Jul 9, 2014

        [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;
      }
    }
@jakubmisek
Copy link
Member

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

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

@proff
Copy link
Contributor Author

proff commented Jul 10, 2014

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants