Esempio n. 1
0
        public static int Deserialize(string buffer, out Kowhai.kowhai_node_t[] descriptor, out byte[] data)
        {
            int bufferSize = 0x100;

            int result;
            do
            {
                byte[] scratch = new byte[bufferSize];
                descriptor = new Kowhai.kowhai_node_t[bufferSize];
                data = new byte[bufferSize];
                int descriptorSize = bufferSize;
                int dataSize = bufferSize;

                GCHandle h = GCHandle.Alloc(descriptor, GCHandleType.Pinned);
                result = kowhai_deserialize(buffer, scratch, bufferSize, h.AddrOfPinnedObject(), ref descriptorSize, data, ref dataSize);
                h.Free();

                if (result == Kowhai.STATUS_OK)
                {
                    Array.Resize(ref descriptor, descriptorSize);
                    Array.Resize(ref data, dataSize);
                }

                bufferSize *= 2;
            }
            while (result == Kowhai.STATUS_SCRATCH_TOO_SMALL || result == Kowhai.STATUS_TARGET_BUFFER_TOO_SMALL);

            return result;
        }
Esempio n. 2
0
 public KowhaiNodeInfo(Kowhai.kowhai_node_t kowhaiNode, int nodeIndex, bool isArrayItem, ushort arrayIndex, ushort offset, KowhaiNodeInfo parent)
 {
     KowhaiNode = kowhaiNode;
     NodeIndex = nodeIndex;
     IsArrayItem = isArrayItem;
     ArrayIndex = arrayIndex;
     Offset = offset;
     Parent = parent;
 }