Example #1
0
    public CefCallbackFunction(CefStructType parent, StructCategory category, string name, CefConfigNode cefConfig, Parser.SignatureNode sd, ApiTypeBuilder api, CommentNode comments)
    {
        Name          = name;
        this.Parent   = parent;
        this.Comments = comments;
        if (cefConfig == null)
        {
            CefConfig = new CefConfigNode();
        }
        else
        {
            CefConfig = cefConfig;
        }

        if (category == StructCategory.Client)
        {
            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);
        }
    }
Example #2
0
 private bool ParseCefConfigItem(CefConfigNode config)
 {
     return
         (Scan("api_hash_check", () => config.ApiHashCheck = true) ||
          Scan("no_debugct_check", () => config.NoDebugctCheck = true) ||
          Scan(@"optional_param=(\w+)", () => config.OptionalParameters.Add(Group01)) ||
          Scan(@"capi_name=(\w+)", () => config.CApiName = Group01) ||
          Scan(@"index_param=(\w+)", () => config.IndexParameter = Group01) ||
          Scan(@"count_func=(\w+:\w+)", () => config.CountFunction = Group01) ||
          Scan(@"default_retval=(\w+)", () => config.DefaultRetval = Group01) ||
          Scan(@"source=(\w+)", () => config.Source = Group01));
 }
Example #3
0
        private bool ParseCefConfig(CefConfigNode config)
        {
            if (!Skip(@"/\*--cef\("))
            {
                return(false);
            }

            while (ParseCefConfigItem(config))
            {
                Skip(",");
            }
            Ensure(Skip(@"\)--\*/"));
            return(true);
        }
    public virtual void DebugPrintUnhandledArrayParameters(string cefName, CefConfigNode cefConfig, CfxCallMode callMode)
    {
        if (cefName == "cef_resource_handler::get_response_headers")
        {
            return;
        }

        if (cefName == "cef_server::send_http_response") // false positive
        {
            return;
        }

        for (var i = 0; i <= Parameters.Length - 1; i++)
        {
            var suffixLength = CountParameterSuffixLength(Parameters[i]);
            if (suffixLength > 0)
            {
                var arrName = Parameters[i].VarName.Substring(0, Parameters[i].VarName.Length - suffixLength);
                int iArray  = -1;
                if (i > 0 && Parameters[i - 1].VarName.StartsWith(arrName))
                {
                    iArray = i - 1;
                }
                else if (i < Parameters.Length - 1 && Parameters[i + 1].VarName.StartsWith(arrName))
                {
                    iArray = i + 1;
                }
                else
                {
                }
                if (iArray >= 0)
                {
                    switch (Parameters[iArray].ParameterType.Name)
                    {
                    case "void*":
                    case "void**":
                        //binary data
                        break;

                    default:
                        Debug.Print("UnhandledArrayArgument {0} {1} {2} {3}", callMode, cefName, Parameters[i], Parameters[iArray]);
                        break;
                    }
                }
            }
        }
    }
Example #5
0
    public static Signature Create(SignatureType type, string cefName, CefConfigNode cefConfig, CfxCallMode callMode, Parser.SignatureNode sd, ApiTypeBuilder api)
    {
        var s  = new Signature(type, sd, api);
        var cs = CustomSignatures.ForFunction(s, cefName, cefConfig);

        if (cs == null)
        {
            s.DebugPrintUnhandledArrayParameters(cefName, cefConfig, callMode);
            AllSignatures.Add(s);
            return(s);
        }
        else
        {
            cs.DebugPrintUnhandledArrayParameters(cefName, cefConfig, callMode);
            AllSignatures.Add(cs);
            return(cs);
        }
    }
Example #6
0
    public StructMember(CefStructType parent, StructCategory structCategory, Parser.StructMemberNode 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);
                }
            }
        }
    }
    public static Signature ForFunction(Signature s, string cefName, CefConfigNode cefConfig)
    {
        if (cefName.Contains("::get_") && s.Parameters.Length == 2)
        {
            if (s.ReturnType.IsVoid)
            {
                if (s.Parameters[1].ParameterType.Name.StartsWith("cef_string_list") || s.Parameters[1].ParameterType.Name.StartsWith("cef_string_m"))
                {
                    return(new StringCollectionAsRetvalSignature(s));
                }
            }
        }

        if (cefConfig.CountFunction != null && s.Parameters.Length == 3 && s.ReturnType.IsVoid)
        {
            if (s.Parameters[2].ParameterType.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.Parameters.Length - 1; i++)
        {
            var suffixLength = 0;
            if (s.Parameters[i].VarName.EndsWith("_count"))
            {
                suffixLength = 6;
            }
            if (s.Parameters[i].VarName.EndsWith("Count"))
            {
                suffixLength = 5;
            }

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

        return(null);
    }
 public override void DebugPrintUnhandledArrayParameters(string cefName, CefConfigNode cefConfig, CfxCallMode callMode)
 {
 }