Esempio n. 1
0
        private void AddCefConfig(string token, string config, string className, string funcName)
        {
            if (config.Length > 0)
            {
                var items     = config.Split(',');
                var data      = new CefConfigData();
                var optParams = new List <string>();
                foreach (var item in items)
                {
                    var    pair  = item.Split('=');
                    string value = null;
                    if (pair.Length == 2)
                    {
                        value = pair[1].Trim();
                    }

                    switch (pair[0].Trim())
                    {
                    case "capi_name":
                        data.CppApiName = funcName;
                        token           = ReduceToken(className + value);
                        break;

                    case "index_param":
                        data.IndexParameter = value;
                        break;

                    case "optional_param":
                        optParams.Add(value);
                        break;

                    case "count_func":
                        data.CountFunction = value;
                        break;

                    case "default_retval":
                        data.DefaultRetval = value;
                        break;

                    case "api_hash_check":
                        data.ApiHashCheck = true;
                        break;

                    case "source":
                        data.Source = value;
                        break;

                    case "no_debugct_check":
                        data.NoDebugctCheck = true;
                        break;

                    default:
                        System.Diagnostics.Debugger.Break();
                        break;
                    }
                }
                data.OptionalParameters = optParams.ToArray();
                cefConfigs.Add(token, data);
            }
        }
Esempio n. 2
0
    public CefCallbackFunction(CefStructType parent, StructCategory category, string name, CefConfigData cefConfig, Parser.SignatureData sd, ApiTypeBuilder api, CommentData comments)
    {
        Name          = name;
        this.Parent   = parent;
        this.Comments = comments;
        if (cefConfig == null)
        {
            CefConfig = new CefConfigData();
        }
        else
        {
            CefConfig = cefConfig;
        }

        if (category == StructCategory.ApiCallbacks)
        {
            m_callMode     = CfxCallMode.Callback;
            this.Signature = Signature.Create(SignatureType.ClientCallback, CefName, CefConfig, CallMode, sd, api);
        }
        else
        {
            m_callMode     = CfxCallMode.FunctionCall;
            this.Signature = Signature.Create(SignatureType.LibraryCall, CefName, CefConfig, CallMode, sd, api);
        }
    }
Esempio n. 3
0
    public static Signature Create(SignatureType type, string cefName, CefConfigData cefConfig, CfxCallMode callMode, Parser.SignatureData sd, ApiTypeBuilder api)
    {
        var s  = new Signature(type, sd, api);
        var cs = CustomSignatures.ForFunction(s, cefName, cefConfig);

        if (cs == null)
        {
            s.DebugPrintUnhandledArrayArguments(cefName, cefConfig, callMode);
            AllSignatures.Add(s);
            return(s);
        }
        else
        {
            cs.DebugPrintUnhandledArrayArguments(cefName, cefConfig, callMode);
            AllSignatures.Add(cs);
            return(cs);
        }
    }
Esempio n. 4
0
    public StructMember(CefStructType parent, StructCategory structCategory, Parser.StructMemberData smd, ApiTypeBuilder api)
    {
        Debug.Assert(structCategory == StructCategory.Values);
        Debug.Assert(smd.MemberType != null);

        Name      = smd.Name;
        Comments  = smd.Comments;
        cefConfig = smd.CefConfig;

        MemberType = api.GetApiType(smd.MemberType, false);
        if (MemberType.Name == "int" && Comments != null)
        {
            foreach (var c in Comments.Lines)
            {
                if (c.Contains("true") || c.Contains("false"))
                {
                    MemberType = BooleanInteger.Convert(MemberType);
                }
            }
        }
    }
Esempio n. 5
0
    public virtual void DebugPrintUnhandledArrayArguments(string cefName, CefConfigData cefConfig, CfxCallMode callMode)
    {
        if (cefName == "cef_binary_value_create")
        {
            return;
        }
        if (cefName == "cef_binary_value::get_data")
        {
            return;
        }
        if (cefName == "cef_resource_handler::get_response_headers")
        {
            return;
        }
        if (cefName == "cef_resource_bundle_handler::get_data_resource")
        {
            return;
        }
        if (cefName == "cef_resource_bundle_handler::get_data_resource_for_scale")
        {
            return;
        }
        if (cefName == "cef_urlrequest_client::on_download_data")
        {
            return;
        }
        if (cefName == "cef_zip_reader::read_file")
        {
            return;
        }
        if (cefName == "cef_resource_bundle::get_data_resource")
        {
            return;
        }
        if (cefName == "cef_resource_bundle::get_data_resource_for_scale")
        {
            return;
        }
        if (cefName == "cef_response_filter::filter")
        {
            return;
        }
        if (cefName.StartsWith("cef_image::add_"))
        {
            return;
        }


        for (var i = 0; i <= Arguments.Length - 1; i++)
        {
            var suffixLength = CountArgumentSuffixLength(Arguments[i]);
            if (suffixLength > 0)
            {
                var arrName = Arguments[i].VarName.Substring(0, Arguments[i].VarName.Length - suffixLength);
                if (i > 0 && Arguments[i - 1].VarName.StartsWith(arrName))
                {
                    Debug.Print("UnhandledArrayArgument {0} {1} {2} {3}", callMode, cefName, Arguments[i - 1], Arguments[i]);
                }
                else if (i < Arguments.Length - 1 && Arguments[i + 1].VarName.StartsWith(arrName))
                {
                    Debug.Print("UnhandledArrayArgument {0} {1} {2} {3}", callMode, cefName, Arguments[i], Arguments[i + 1]);
                }
                else
                {
                }
            }
        }
    }
 public override void DebugPrintUnhandledArrayArguments(string cefName, CefConfigData cefConfig, CfxCallMode callMode)
 {
 }
Esempio n. 7
0
    public static Signature ForFunction(Signature s, string cefName, CefConfigData cefConfig)
    {
        if (cefName.Contains("::get_") && s.Arguments.Length == 2)
        {
            if (s.ReturnType.IsVoid)
            {
                if (s.Arguments[1].ArgumentType.Name.StartsWith("cef_string_list") || s.Arguments[1].ArgumentType.Name.StartsWith("cef_string_m"))
                {
                    return(new StringCollectionAsRetvalSignature(s));
                }
            }
        }

        if (cefConfig.CountFunction != null && s.Arguments.Length == 3 && s.ReturnType.IsVoid)
        {
            if (s.Arguments[2].ArgumentType.IsCefStructPtrPtrType)
            {
                return(new StructArrayGetterSignature(s, cefConfig.CountFunction));
            }
        }

        switch (cefName)
        {
        case "cef_browser::get_frame_identifiers":
            return(new GetFrameIdentifiersSignature(s));

        case "cef_v8handler::execute":
            return(new CefV8HandlerExecuteSignature(s));

        case "cef_print_settings::get_page_ranges":
            return(new GetPageRangesSignature(s, 2, 1));
        }

        for (var i = 0; i <= s.Arguments.Length - 1; i++)
        {
            var suffixLength = 0;
            if (s.Arguments[i].VarName.EndsWith("_count"))
            {
                suffixLength = 6;
            }
            if (s.Arguments[i].VarName.EndsWith("Count"))
            {
                suffixLength = 5;
            }

            if (suffixLength > 0)
            {
                var arrName       = s.Arguments[i].VarName.Substring(0, s.Arguments[i].VarName.Length - suffixLength);
                int arrayArgIndex = -1;
                if (i > 0 && s.Arguments[i - 1].VarName.StartsWith(arrName))
                {
                    arrayArgIndex = i - 1;
                }
                else if (i < s.Arguments.Length - 1 && s.Arguments[i + 1].VarName.StartsWith(arrName))
                {
                    arrayArgIndex = i + 1;
                }
                else
                {
                }
                if (arrayArgIndex > 0)
                {
                    var arrayType = s.Arguments[arrayArgIndex].ArgumentType;
                    if (arrayType.IsCefStructPtrType)
                    {
                        Debug.Assert(arrayType.AsCefStructPtrType.Struct.ClassBuilder.Category == StructCategory.Values);
                        return(new SignatureWithStructArray(s, arrayArgIndex, i));
                    }
                    else if (arrayType.IsCefStructPtrPtrType)
                    {
                        return(new SignatureWithStructPtrArray(s, arrayArgIndex, i));
                    }
                }
            }
        }

        return(null);
    }