<commit_before>﻿using CppSharp.AST;
using CppSharp.Generators;

namespace MonoEmbeddinator4000.Generators
{
    public class ObjCSources : CSources
    {
        public ObjCSources(BindingContext context, Options options,
            TranslationUnit unit)
            : base(context, options, unit)
        {
        }

        public override string FileExtension => "mm";

        public override void Process()
        {
            base.Process();
        }
        
        public override void GenerateMethodSignature(Method method,
            bool isSource)
        {
            this.GenerateObjCMethodSignature(method);
        }

        public override string GenerateClassObjectAlloc(string type)
        {
            return $"[[{type} alloc]init]";
        }

        public override bool VisitClassDecl(Class @class)
        {
            PushBlock();

            WriteLine($"@implementation {@class.QualifiedName}");
            NewLine();

            VisitDeclContext(@class);

            NewLine();
            WriteLine("@end");

            PopBlock(NewLineKind.BeforeNextBlock);

            return true;
        }

        public override bool VisitFieldDecl(Field field)
        {
            return this.GenerateObjCField(field);
        }
    }
}<commit_msg>Generate class lookup methods in Objective-C.<commit_after>﻿using CppSharp.AST;
using CppSharp.Generators;

namespace MonoEmbeddinator4000.Generators
{
    public class ObjCSources : CSources
    {
        public ObjCSources(BindingContext context, Options options,
            TranslationUnit unit)
            : base(context, options, unit)
        {
        }

        public override string FileExtension => "mm";

        public override void Process()
        {
            base.Process();
        }
        
        public override void GenerateMethodSignature(Method method,
            bool isSource)
        {
            this.GenerateObjCMethodSignature(method);
        }

        public override string GenerateClassObjectAlloc(string type)
        {
            return $"[[{type} alloc]init]";
        }

        public override bool VisitClassDecl(Class @class)
        {
            PushBlock();

            GenerateClassLookup(@class);

            WriteLine($"@implementation {@class.QualifiedName}");
            NewLine();

            VisitDeclContext(@class);

            NewLine();
            WriteLine("@end");

            PopBlock(NewLineKind.BeforeNextBlock);

            return true;
        }

        public override bool VisitFieldDecl(Field field)
        {
            return this.GenerateObjCField(field);
        }
    }
}
{'fraction_non_alphanumeric': 0.08459214501510574, 'fraction_numerical': 0.0030211480362537764, 'mean_word_length': 1.82409381663113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2348829', 'n_tokens_mistral': 676, 'n_tokens_neox': 630, 'n_words': 142}