Exemplo n.º 1
0
        public string ReadString(int len)
        {
            //--------
            if (len <= 0)
            {
                return(string.Empty);
            }
            //--------
            if (len < 256)
            {
                unsafe
                {
                    char *h         = stackalloc char[len];
                    int   actualLen = 0;
                    Cef3Binder.MyCefStringHolder_Read(this.nativePtr, h, len, out actualLen);
                    return(new string(h, 0, len));
                }
            }
            else
            {
                char[] buffer = new char[len];
                unsafe
                {
                    fixed(char *h = &buffer[0])
                    {
                        int actualLen = 0;

                        Cef3Binder.MyCefStringHolder_Read(this.nativePtr, h, len, out actualLen);
                    }
                }
                return(new string(buffer, 0, len));
            }
        }
Exemplo n.º 2
0
        public string GetRequest()
        {
            //get request from native string

            int acutalLen = 0;

            unsafe
            {
                int   BUFF_LEN = 256;
                char *buffHead = stackalloc char[BUFF_LEN];
                Cef3Binder.MyCefStringHolder_Read(_requestCefStringHolder, buffHead, BUFF_LEN, ref acutalLen);
                if (acutalLen > BUFF_LEN)
                {
                    //read more
                }
                return(new string(buffHead, 0, acutalLen));
            }
        }
Exemplo n.º 3
0
        unsafe static string MyCefJsReadString(JsValue *jsval)
        {
            int actualLen;
            int buffLen = jsval->I32 + 1; //string len

            //check if string is on method-call's frame stack or heap
            if (jsval->Type == JsValueType.NativeCefString)
            {
                char *rawCefString_char16_t;
                Cef3Binder.MyCefStringGetRawPtr(jsval->Ptr, out rawCefString_char16_t, out actualLen);
                return(new string(rawCefString_char16_t, 0, actualLen));
            }
            if (buffLen < 1024)
            {
                char *buffHead = stackalloc char[buffLen];
                Cef3Binder.MyCefStringHolder_Read(jsval->Ptr, buffHead, buffLen, out actualLen);
                if (actualLen > buffLen)
                {
                    //read more
                }
                return(new string(buffHead, 0, actualLen));
            }
            else
            {
                char[] buffHead = new char[buffLen];
                fixed(char *h = &buffHead[0])
                {
                    Cef3Binder.MyCefStringHolder_Read(jsval->Ptr, h, buffLen, out actualLen);
                    if (actualLen > buffLen)
                    {
                        //read more
                    }
                }

                return(new string(buffHead, 0, actualLen));
            }
        }