Esempio n. 1
0
    /*
     * convenience overload
     */

    private void DefineEnum(Smoke.Type *type)
    {
        // we want the exact combination: t_enum | tf_stack
        if (type->flags != ((uint)Smoke.TypeId.t_enum | (uint)Smoke.TypeFlags.tf_stack))
        {
            // not an enum type
            return;
        }

        if (type->classId == 0 || data.Smoke->classes[type->classId].external)
        {
            // defined elsewhere
            return;
        }

        string enumName = ByteArrayManager.GetString(type->name);

        this.DefineEnum(enumName);
    }
Esempio n. 2
0
    public CodeTypeReference CppToCSharp(Smoke.Type *type, out bool isRef)
    {
        string typeString = ByteArrayManager.GetString(type->name);

        isRef = false;
        if ((IntPtr)type->name == IntPtr.Zero)
        {
            return(new CodeTypeReference(typeof(void)));
        }

        Smoke.TypeId typeId = (Smoke.TypeId)(type->flags & (ushort)Smoke.TypeFlags.tf_elem);
        if (typeId == Smoke.TypeId.t_bool)
        {
            return(new CodeTypeReference(typeof(bool)));
        }
        if (typeId == Smoke.TypeId.t_char)
        {
            return(new CodeTypeReference(typeof(sbyte)));
        }
        if (typeId == Smoke.TypeId.t_uchar)
        {
            return(new CodeTypeReference(typeof(byte)));
        }
        if (typeId == Smoke.TypeId.t_short)
        {
            return(new CodeTypeReference(typeof(short)));
        }
        if (typeId == Smoke.TypeId.t_ushort)
        {
            return(new CodeTypeReference(typeof(ushort)));
        }
        if (typeId == Smoke.TypeId.t_int)
        {
            return(new CodeTypeReference(typeof(int)));
        }
        if (typeId == Smoke.TypeId.t_uint)
        {
            // HACK: qdrawutil.h says, DrawingHint is for internal use; nonetheless, SMOKE generates an overload using it; ignoring
            if (typeString == "unsigned int" || typeString == "QFlags<QDrawBorderPixmap::DrawingHint>")
            {
                return(new CodeTypeReference(typeof(uint)));
            }
        }
        if (typeId == Smoke.TypeId.t_long)
        {
            return(new CodeTypeReference("NativeLong"));
        }
        if (typeId == Smoke.TypeId.t_ulong)
        {
            return(new CodeTypeReference("NativeULong"));
        }
        if (typeId == Smoke.TypeId.t_float)
        {
            return(new CodeTypeReference(typeof(float)));
        }
        if (typeId == Smoke.TypeId.t_double)
        {
            return(new CodeTypeReference(typeof(double)));
        }
        return(this.CppToCSharp(typeString, out isRef));
    }