示例#1
0
    /*
     * Loops through all wrapped methods. Any class that is found is converted to a .NET class (see DefineClass()).
     * A MethodGenerator is then created to generate the methods for that class.
     */

    public void Run()
    {
        for (short i = 1; i <= data.Smoke->numClasses; i++)
        {
            Smoke.Class *klass = data.Smoke->classes + i;
            if (klass->external)
            {
                continue;
            }

            DefineClass(i);
        }

        eg.DefineEnums();

        // create interfaces if necessary
        ClassInterfacesGenerator cig = new ClassInterfacesGenerator(data, translator);

        cig.Run();

        for (short i = 1; i <= data.Smoke->numClasses; i++)
        {
            Smoke.Class *klass = data.Smoke->classes + i;
            if (klass->external)
            {
                continue;
            }

            string className         = ByteArrayManager.GetString(klass->className);
            CodeTypeDeclaration type = data.SmokeTypeMap[(IntPtr)klass];
            CodeTypeDeclaration iface;
            if (data.InterfaceTypeMap.TryGetValue(className, out iface))
            {
                type.BaseTypes.Add(new CodeTypeReference('I' + type.Name));
            }

            short *parent      = data.Smoke->inheritanceList + klass->parents;
            bool   firstParent = true;
            while (*parent > 0)
            {
                if (firstParent)
                {
                    firstParent = false;
                    parent++;
                    continue;
                }
                // Translator.CppToCSharp() will take care of 'interfacifying' the class name
                type.BaseTypes.Add(translator.CppToCSharp(data.Smoke->classes + *parent));
                parent++;
            }
        }

        if (PreClassesHook != null)
        {
            PreClassesHook();
        }

        GenerateMethods();
        GenerateInternalImplementationMethods();

        if (PostClassesHook != null)
        {
            PostClassesHook();
        }
        MethodsGenerator.Provider.Dispose();
    }
示例#2
0
    /*
     * Loops through all wrapped methods. Any class that is found is converted to a .NET class (see DefineClass()).
     * A MethodGenerator is then created to generate the methods for that class.
     */
    public void Run()
    {
        for (short i = 1; i <= data.Smoke->numClasses; i++)
        {
            Smoke.Class* klass = data.Smoke->classes + i;
            if (klass->external)
                continue;

            DefineClass(i);
        }

        eg.DefineEnums();

        // create interfaces if necessary
        ClassInterfacesGenerator cig = new ClassInterfacesGenerator(data, translator);
        cig.Run();

        for (short i = 1; i <= data.Smoke->numClasses; i++)
        {
            Smoke.Class* klass = data.Smoke->classes + i;
            if (klass->external)
                continue;

            string className = ByteArrayManager.GetString(klass->className);
            CodeTypeDeclaration type = data.SmokeTypeMap[(IntPtr) klass];
            CodeTypeDeclaration iface;
            if (data.InterfaceTypeMap.TryGetValue(className, out iface))
            {
                type.BaseTypes.Add(new CodeTypeReference('I' + type.Name));
            }

            short* parent = data.Smoke->inheritanceList + klass->parents;
            bool firstParent = true;
            while (*parent > 0)
            {
                if (firstParent)
                {
                    firstParent = false;
                    parent++;
                    continue;
                }
                // Translator.CppToCSharp() will take care of 'interfacifying' the class name
                type.BaseTypes.Add(translator.CppToCSharp(data.Smoke->classes + *parent));
                parent++;
            }
        }

        if (PreClassesHook != null)
        {
            PreClassesHook();
        }

        GenerateMethods();
        GenerateInternalImplementationMethods();

        if (PostClassesHook != null)
        {
            PostClassesHook();
        }
        MethodsGenerator.Provider.Dispose();
    }