No subject

Jacek Caban jacek at codeweavers.com
Tue Dec 10 11:57:21 CST 2019


Hi Gabriel,

On 12/10/19 6:17 PM, Gabriel Ivăncescu wrote:
> On 12/10/19 5:35 PM, Jacek Caban wrote:
>> On 12/9/19 4:29 PM, Gabriel Ivăncescu wrote:
>>> +enum memid_type {
>>> +    memid_invalid,
>>> +    memid_inherited,
>>> +    memid_func,
>>> +    memid_var
>>> +};
>>> +
>>> +static inline enum memid_type get_memid_type(const ScriptTypeInfo 
>>> *typeinfo, MEMBERID memid)
>>> +{
>>> +    if (memid <= 0) return memid_invalid;
>>> +    if (memid & DISPID_FUNCTION_MASK)
>>> +    {
>>> +        memid &= ~DISPID_FUNCTION_MASK;
>>> +        if (memid >= typeinfo->func_memid_map_cnt)
>>> +            return memid_inherited;
>>> +        if (typeinfo->func_memid_map[memid] == ~0)
>>> +            return memid_invalid;
>>> +        return memid_func;
>>> +    }
>>> +    if (memid > typeinfo->num_vars)
>>> +        return memid_inherited;
>>> +    return memid_var;
>>> +}
>>
>>
>> It seems that could let default ITypeInfo handle invalid IDs and you 
>> could just forward all calls to unknown IDs to it. You don't need a 
>> new map for that, you could just use a binary search on funcs.
>>
>>
>> Thanks,
>>
>> Jacek
>>
>
> Sure, that sounds like a good approach as well. I'll look into it 
> tomorrow.
>
> I have a question, though, about jscript (similar patch for jscript, 
> not sent yet to mailing list). In jscript, variables and functions can 
> be deleted, and so currently I have a map of memids for both vars and 
> functions (just one map for both).
>
> Should I also use a binary search there (needed for both variables and 
> functions), or rather keep the single map for both, which I think is 
> slightly simpler code?
>
> Currently I identify whether an element in the map is a variable or a 
> function by looking at where it points to: if it points within the 
> bounds of the function array, then it's a function. So no extra fields 
> needed, other than the map itself.
>
> This is all for jscript of course (not vbscript or this patch, but 
> related). 


I'm not sure without looking at the code, but two binary searches seem fine.


Thanks,

Jacek




More information about the wine-devel mailing list