Example #1
0
 public void AddDeclarations(IEnumerable <Declaration> aDeclarations)
 {
     foreach (var decl in aDeclarations)
     {
         if (DeclarationsToIgnore.Contains(decl.Name))
         {
             continue;
         }
         //== "sp_uint64" || decl.Name == "bool" || decl.Name == "byte") continue;
         if (decl.Kind == "typedef")
         {
             StructCType   structType   = decl.CType as StructCType;
             EnumCType     enumType     = decl.CType as EnumCType;
             FunctionCType functionType = decl.CType as FunctionCType;
             if (structType != null)
             {
                 if (structType.Fields == null)
                 {
                     HandleTable.Add(decl.Name);
                 }
                 else
                 {
                     StructTable.Add(decl.Name, structType);
                 }
             }
             else if (enumType != null)
             {
                 EnumTable.Add(decl.Name, enumType);
             }
             else if (functionType != null)
             {
                 FunctionTypedefTable.Add(decl.Name, functionType);
             }
         }
         else if (decl.Kind == "instance")
         {
             FunctionCType funcType = decl.CType as FunctionCType;
             if (funcType == null)
             {
                 continue;
             }
             FunctionTable.Add(decl.Name, funcType);
         }
     }
 }
Example #2
0
    private static bool _register(HandleTable handles,
                                  string eventname,
                                  object obj,
                                  string funcname)
    {
        _unregister(handles, eventname, obj, funcname);
        List <Pair> lst;

        var pair = new Pair();

        pair._obj      = obj;
        pair._funcname = funcname;
        pair._method   = obj.GetType().GetMethod(funcname);

        if (pair._method == null)
        {
            Debug.Log("funcname not exist: " + eventname + " " + funcname);
            return(false);
        }

        handles.Lock();

        if (!handles.TryGetValue(eventname, out lst))
        {
            lst = new List <Pair>();
            lst.Add(pair);
            handles.Add(eventname, lst);
            handles.UnLock();
            return(true);
        }

        lst.Add(pair);
        handles.UnLock();

        return(true);
    }