text:
#nullable disable
using Wiz.Common;
using WizBot.Modules.Searches.Common;
using Newtonsoft.Json.Linq;

namespace WizBot.Modules.Nsfw;

public partial class NSFW : WizBotModule<ISearchImagesService>
{
    private static readonly ConcurrentHashSet<ulong> _hentaiBombBlacklist = new();
    private readonly IHttpClientFactory _httpFactory;
    private readonly WizBotRandom _rng;

    public NSFW(IHttpClientFactory factory)
    {
        _httpFactory = factory;
        _rng = new();
    }

    private async Task InternalBoobs()
    {
        try
        {
            JToken obj;
            using (var http = _httpFactory.CreateClient())
            {
                obj = JArray.Parse(
                    await http.GetStringAsync($"http://api.oboobs.ru/boobs/{new WizBotRandom().Next(0, 10330)}"))[0];
            }

            await ctx.Channel.SendMessageAsync($"http://media.oboobs.ru/{obj["preview"]}");
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message);
        }
    }

    private async Task InternalButts(IMessageChannel channel)
    {
        try
        {
            JToken obj;
            using (var http = _httpFactory.CreateClient())
            {
                obj = JArray.Parse(
                    await http.GetStringAsync($"http://api.obutts.ru/butts/{new WizBotRandom().Next(0, 4335)}"))[0];
            }

            await channel.SendMessageAsync($"http://media.obutts.ru/{obj["preview"]}");
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message);
        }
    }

    private async Task InternalNeko(IMessageChannel Channel, string format = "img", string category = "all_tags_lewd")
        {
            // List if category to pull an image from.
            string[] img_cat = { "pantyhose_lewd", "holo_lewd", "anus_lewd", "kemonomimi_lewd", "peeing_lewd", "cosplay_lewd", "futanari_lewd", "blowjob_lewd", "shinobu_ero", "shinobu_lewd", "kitsune_lewd", "all_tags_lewd", "kemonomimi_ero", "wallpaper_lewd", "feet_ero", "anal_lewd", "femdom_lewd", "kitsune_ero", "solo_lewd", "holo_ero", "yuri_lewd", "feet_lewd", "classic_lewd", "keta_lewd", "neko_lewd", "piersing_lewd", "trap_lewd", "pantyhose_ero", "yiff_lewd", "hplay_ero", "smallboobs_lewd", "neko_ero", "pussy_lewd", "cum_lewd", "keta_avatar", "ero_wallpaper_ero", "ahegao_avatar", "piersing_ero", "bdsm_lewd", "holo_avatar", "all_tags_ero", "tits_lewd", "yuri_ero" };

            string[] gif_cat = { "yiff", "pussy_wank", "neko", "kuni", "blow_job", "pussy", "girls_solo", "yuri", "anal", "tits", "classic", "feet", "spank", "cum", "all_tags" };

            // Check to see if the command is calling for a normal image or a gif.
            string[] img_format = { "img", "gif" };

            if (string.IsNullOrWhiteSpace(category))
                return;

            if (string.IsNullOrWhiteSpace(format))
                return;

            try
            {
                JToken nekotitle;
                JToken nekoimg;
                using (var http = _httpFactory.CreateClient())
                {
                    nekotitle = JObject.Parse(await http.GetStringAsync($"https://api.nekos.dev/api/v3/text/cat_emote/").ConfigureAwait(false));
                    nekoimg = JObject.Parse(await http.GetStringAsync($"https://api.nekos.dev/api/v3/images/nsfw/{format}/{category}/").ConfigureAwait(false));
                }
                if (img_format.Contains("img") && img_cat.Contains(category))
                    await Channel.EmbedAsync(_eb.Create().WithOkColor()
                        .WithAuthor($"Nekos Life - NSFW IMG Database {nekotitle["data"]["response"]["text"]}",
                            "https://i.imgur.com/a36AMkG.png",
                            "http://nekos.life/")
                        .WithImageUrl($"{nekoimg["data"]["response"]["url"]}")).ConfigureAwait(false);
                else if (img_format.Contains("gif") && gif_cat.Contains(category))
                    await Channel.EmbedAsync(_eb.Create().WithOkColor()
                        .WithAuthor($"Nekos Life - NSFW GIF Database {nekotitle["data"]["response"]["text"]}",
                            "https://i.imgur.com/a36AMkG.png",
                            "http://nekos.life/")
                        .WithImageUrl($"{nekoimg["data"]["response"]["url"]}")).ConfigureAwait(false);
                else if (img_format.Contains("img") && gif_cat.Contains(category))
                    await Channel.EmbedAsync(_eb.Create().WithErrorColor()
                    .WithAuthor("Nekos Life - Invalid NSFW IMG Category","https://i.imgur.com/a36AMkG.png","http://nekos.life/")
                    .WithDescription("Seems the image category you was looking for could not be found. Please use the categories listed below.")
                    .AddField("NSFW IMG Categories", "`classic_lewd`, `piersing_lewd`, `shinobu_lewd`, `feet_lewd`, `keta_avatar`, `piersing_ero`, `yuri_ero`, `solo_lewd`, `pantyhose_lewd`, `kemonomimi_lewd`, `cosplay_lewd`, `peeing_lewd`, `ahegao_avatar`, `wallpaper_lewd`, `ero_wallpaper_ero`, `blowjob_lewd`, `holo_avatar`, `neko_lewd`, `futanari_lewd`, `kitsune_ero`, `trap_lewd`, `keta_lewd`, `neko_ero`, `pantyhose_ero`, `cum_lewd`, `anal_lewd`, `smallboobs_lewd`, `all_tags_lewd`, `yuri_lewd`, `kemonomimi_ero`, `anus_lewd`, `holo_ero`, `all_tags_ero`, `kitsune_lewd`, `pussy_lewd`, `feet_ero`, `yiff_lewd`, `hplay_ero`, `bdsm_lewd`, `femdom_lewd`, `holo_lewd`, `shinobu_ero`, `tits_lewd`", false)).ConfigureAwait(false);
                else if (img_format.Contains("gif") && img_cat.Contains(category))
                    await Channel.EmbedAsync(_eb.Create().WithErrorColor()
                    .WithAuthor("Nekos Life - Invalid NSFW GIF Category",
                        "https://i.imgur.com/a36AMkG.png",
                        "http://nekos.life/")
                    .WithDescription("Seems the gif category you was looking for could not be found. Please use the categories listed below.")
                    .AddField("NSFW GIF Categories", "`blow_job`, `pussy_wank`, `classic`, `kuni`, `tits`, `pussy`, `cum`, `spank`, `feet`, `all_tags`, `yuri`, `anal`, `neko`, `girls_solo`, `yiff`", false)).ConfigureAwait(false);
                else
                    await Channel.EmbedAsync(_eb.Create().WithErrorColor()
                    .WithAuthor("Nekos Life - Invalid NSFW Image Type or Category",
                        "https://i.imgur.com/a36AMkG.png",
                        "http://nekos.life/")
                    .WithDescription("Seems the image type or category you was looking for could not be found. Please use the image type or categories listed below.")
                    .AddField("NSFW IMG Types", "`img`, `gif`", false)
                    .AddField("NSFW IMG Categories", "`classic_lewd`, `piersing_lewd`, `shinobu_lewd`, `feet_lewd`, `keta_avatar`, `piersing_ero`, `yuri_ero`, `solo_lewd`, `pantyhose_lewd`, `kemonomimi_lewd`, `cosplay_lewd`, `peeing_lewd`, `ahegao_avatar`, `wallpaper_lewd`, `ero_wallpaper_ero`, `blowjob_lewd`, `holo_avatar`, `neko_lewd`, `futanari_lewd`, `kitsune_ero`, `trap_lewd`, `keta_lewd`, `neko_ero`, `pantyhose_ero`, `cum_lewd`, `anal_lewd`, `smallboobs_lewd`, `all_tags_lewd`, `yuri_lewd`, `kemonomimi_ero`, `anus_lewd`, `holo_ero`, `all_tags_ero`, `kitsune_lewd`, `pussy_lewd`, `feet_ero`, `yiff_lewd`, `hplay_ero`, `bdsm_lewd`, `femdom_lewd`, `holo_lewd`, `shinobu_ero`, `tits_lewd`", false)
                    .AddField("NSFW GIF Categories", "`blow_job`, `pussy_wank`, `classic`, `kuni`, `tits`, `pussy`, `cum`, `spank`, `feet`, `all_tags`, `yuri`, `anal`, `neko`, `girls_solo`, `yiff`", false)).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await SendErrorAsync(ex.Message).ConfigureAwait(false);
            }
        }

    [Cmd]
    [RequireNsfw]
    [RequireContext(ContextType.Guild)]
    [UserPerm(ChannelPerm.ManageMessages)]
    public async Task AutoHentai(int interval = 0, [Leftover] string tags = null)
    {
        Timer t;

        if (interval == 0)
        {
            if (!_service.AutoHentaiTimers.TryRemove(ctx.Channel.Id, out t))
                return;

            t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
            await ReplyConfirmLocalizedAsync(strs.stopped);
            return;
        }

        if (interval < 20)
            return;

        t = new(async _ =>
            {
                try
                {
                    if (tags is null || tags.Length == 0)
                        await InternalDapiCommand(null, true, _service.Hentai);
                    else
                    {
                        var groups = tags.Split('|');
                        var group = groups[_rng.Next(0, groups.Length)];
                        await InternalDapiCommand(group.Split(' '), true, _service.Hentai);
                    }
                }
                catch
                {
                    // ignored
                }
            },
            null,
            interval * 1000,
            interval * 1000);

        _service.AutoHentaiTimers.AddOrUpdate(ctx.Channel.Id,
            t,
            (_, old) =>
            {
                old.Change(Timeout.Infinite, Timeout.Infinite);
                return t;
            });

        await SendConfirmAsync($"Autohentai started. Interval: {interval}, Tags: {string.Join(", ", tags)}");
    }

    [Cmd]
    [RequireNsfw]
    [RequireContext(ContextType.Guild)]
    [UserPerm(ChannelPerm.ManageMessages)]
    public async Task AutoBoobs(int interval = 0)
    {
        Timer t;

        if (interval == 0)
        {
            if (!_service.AutoBoobTimers.TryRemove(ctx.Channel.Id, out t))
                return;

            t.Change(Timeout.Infinite, Timeout.Infinite);
            await ReplyConfirmLocalizedAsync(strs.stopped);
            return;
        }

        if (interval < 20)
            return;

        t = new(async _ =>
            {
                try
                {
                    await InternalBoobs();
                }
                catch
                {
                    // ignored
                }
            },
            null,
            interval * 1000,
            interval * 1000);

        _service.AutoBoobTimers.AddOrUpdate(ctx.Channel.Id,
            t,
            (_, old) =>
            {
                old.Change(Timeout.Infinite, Timeout.Infinite);
                return t;
            });

        await ReplyConfirmLocalizedAsync(strs.started(interval));
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    [UserPerm(ChannelPerm.ManageMessages)]
    public async Task AutoButts(int interval = 0)
    {
        Timer t;

        if (interval == 0)
        {
            if (!_service.AutoButtTimers.TryRemove(ctx.Channel.Id, out t))
                return;

            t.Change(Timeout.Infinite, Timeout.Infinite); //proper way to disable the timer
            await ReplyConfirmLocalizedAsync(strs.stopped);
            return;
        }

        if (interval < 20)
            return;

        t = new(async _ =>
            {
                try
                {
                    await InternalButts(ctx.Channel);
                }
                catch
                {
                    // ignored
                }
            },
            null,
            interval * 1000,
            interval * 1000);

        _service.AutoButtTimers.AddOrUpdate(ctx.Channel.Id,
            t,
            (_, old) =>
            {
                old.Change(Timeout.Infinite, Timeout.Infinite);
                return t;
            });

        await ReplyConfirmLocalizedAsync(strs.started(interval));
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Hentai(params string[] tags)
        => InternalDapiCommand(tags, true, _service.Hentai);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public async Task HentaiBomb(params string[] tags)
    {
        if (!_hentaiBombBlacklist.Add(ctx.Guild?.Id ?? ctx.User.Id))
            return;
        try
        {
            var images = await Task.WhenAll(_service.Yandere(ctx.Guild?.Id, true, tags),
                _service.Danbooru(ctx.Guild?.Id, true, tags),
                _service.Konachan(ctx.Guild?.Id, true, tags),
                _service.Gelbooru(ctx.Guild?.Id, true, tags));

            var linksEnum = images.Where(l => l is not null).ToArray();
            if (!linksEnum.Any())
            {
                await ReplyErrorLocalizedAsync(strs.no_results);
                return;
            }

            await ctx.Channel.SendMessageAsync(string.Join("\n\n", linksEnum.Select(x => x.Url)));
        }
        finally
        {
            _hentaiBombBlacklist.TryRemove(ctx.Guild?.Id ?? ctx.User.Id);
        }
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Yandere(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Yandere);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Konachan(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Konachan);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Sankaku(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Sankaku);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task E621(params string[] tags)
        => InternalDapiCommand(tags, false, _service.E621);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Rule34(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Rule34);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Danbooru(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Danbooru);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Gelbooru(params string[] tags)
        => InternalDapiCommand(tags, false, _service.Gelbooru);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Derpibooru(params string[] tags)
        => InternalDapiCommand(tags, false, _service.DerpiBooru);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public Task Safebooru(params string[] tags)
        => InternalDapiCommand(tags, false, _service.SafeBooru);

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public async Task Boobs()
    {
        try
        {
            JToken obj;
            using (var http = _httpFactory.CreateClient())
            {
                obj = JArray.Parse(
                    await http.GetStringAsync($"http://api.oboobs.ru/boobs/{new WizBotRandom().Next(0, 12000)}"))[0];
            }

            await ctx.Channel.SendMessageAsync($"http://media.oboobs.ru/{obj["preview"]}");
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message);
        }
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public async Task Butts()
    {
        try
        {
            JToken obj;
            using (var http = _httpFactory.CreateClient())
            {
                obj = JArray.Parse(
                    await http.GetStringAsync($"http://api.obutts.ru/butts/{new WizBotRandom().Next(0, 6100)}"))[0];
            }

            await ctx.Channel.SendMessageAsync($"http://media.obutts.ru/{obj["preview"]}");
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message);
        }
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm"), RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public async Task Neko(string format = "img", [Remainder] string category = "neko_lewd")
    {
        // List if category to pull an image from.
        string[] img_cat =
        {
            "classic_lewd", "piersing_lewd", "shinobu_lewd", "feet_lewd", "keta_avatar", "piersing_ero", "yuri_ero",
            "solo_lewd", "pantyhose_lewd", "kemonomimi_lewd", "cosplay_lewd", "peeing_lewd", "ahegao_avatar",
            "wallpaper_lewd", "ero_wallpaper_ero", "blowjob_lewd", "holo_avatar", "neko_lewd", "futanari_lewd",
            "kitsune_ero", "trap_lewd", "keta_lewd", "neko_ero", "pantyhose_ero", "cum_lewd", "anal_lewd",
            "smallboobs_lewd", "all_tags_lewd", "yuri_lewd", "kemonomimi_ero", "anus_lewd", "holo_ero",
            "all_tags_ero", "kitsune_lewd", "pussy_lewd", "feet_ero", "yiff_lewd", "hplay_ero", "bdsm_lewd",
            "femdom_lewd", "holo_lewd", "shinobu_ero", "tits_lewd"
        };

        string[] gif_cat =
        {
            "blow_job", "pussy_wank", "classic", "kuni", "tits", "pussy", "cum", "spank", "feet", "all_tags",
            "yuri", "anal", "neko", "girls_solo", "yiff"
        };

        // Check to see if the command is calling for a normal image or a gif.
        string[] img_format = { "img", "gif" };

        if (string.IsNullOrWhiteSpace(category))
            return;

        if (string.IsNullOrWhiteSpace(format))
            return;

        try
        {
            JToken nekotitle;
            JToken nekoimg;
            using (var http = _httpFactory.CreateClient())
            {
                nekotitle = JObject.Parse(await http.GetStringAsync($"https://api.nekos.dev/api/v3/text/cat_emote/")
                                                    .ConfigureAwait(false));
                nekoimg = JObject.Parse(await http
                                              .GetStringAsync(
                                                  $"https://api.nekos.dev/api/v3/images/nsfw/{format}/{category}/")
                                              .ConfigureAwait(false));
            }

            if (img_format.Contains("img") && img_cat.Contains(category))
                await ctx.Channel.EmbedAsync(_eb.Create()
                                                .WithOkColor()
                                                .WithAuthor(
                                                    $"Nekos Life - NSFW IMG Database {nekotitle["data"]["response"]["text"]}",
                                                    "https://i.imgur.com/a36AMkG.png",
                                                    "http://nekos.life/")
                                                .WithImageUrl($"{nekoimg["data"]["response"]["url"]}"))
                         .ConfigureAwait(false);
            else if (img_format.Contains("gif") && gif_cat.Contains(category))
                await ctx.Channel.EmbedAsync(_eb.Create()
                                                .WithOkColor()
                                                .WithAuthor(
                                                    $"Nekos Life - NSFW GIF Database {nekotitle["data"]["response"]["text"]}",
                                                    "https://i.imgur.com/a36AMkG.png",
                                                    "http://nekos.life/")
                                                .WithImageUrl($"{nekoimg["data"]["response"]["url"]}"))
                         .ConfigureAwait(false);
            else if (img_format.Contains("img") && gif_cat.Contains(category))
                await ctx.Channel.EmbedAsync(_eb.Create()
                                                .WithErrorColor()
                                                .WithAuthor("Nekos Life - Invalid NSFW IMG Category",
                                                    "https://i.imgur.com/a36AMkG.png", "http://nekos.life/")
                                                .WithDescription(
                                                    "Seems the image category you was looking for could not be found. Please use the categories listed below.")
                                                .AddField("NSFW IMG Categories",
                                                    "`classic_lewd`, `piersing_lewd`, `shinobu_lewd`, `feet_lewd`, `keta_avatar`, `piersing_ero`, `yuri_ero`, `solo_lewd`, `pantyhose_lewd`, `kemonomimi_lewd`, `cosplay_lewd`, `peeing_lewd`, `ahegao_avatar`, `wallpaper_lewd`, `ero_wallpaper_ero`, `blowjob_lewd`, `holo_avatar`, `neko_lewd`, `futanari_lewd`, `kitsune_ero`, `trap_lewd`, `keta_lewd`, `neko_ero`, `pantyhose_ero`, `cum_lewd`, `anal_lewd`, `smallboobs_lewd`, `all_tags_lewd`, `yuri_lewd`, `kemonomimi_ero`, `anus_lewd`, `holo_ero`, `all_tags_ero`, `kitsune_lewd`, `pussy_lewd`, `feet_ero`, `yiff_lewd`, `hplay_ero`, `bdsm_lewd`, `femdom_lewd`, `holo_lewd`, `shinobu_ero`, `tits_lewd`",
                                                    false))
                         .ConfigureAwait(false);
            else if (img_format.Contains("gif") && img_cat.Contains(category))
                await ctx.Channel.EmbedAsync(_eb.Create()
                                                .WithErrorColor()
                                                .WithAuthor("Nekos Life - Invalid NSFW GIF Category",
                                                    "https://i.imgur.com/a36AMkG.png",
                                                    "http://nekos.life/")
                                                .WithDescription(
                                                    "Seems the gif category you was looking for could not be found. Please use the categories listed below.")
                                                .AddField("NSFW GIF Categories",
                                                    "`blow_job`, `pussy_wank`, `classic`, `kuni`, `tits`, `pussy`, `cum`, `spank`, `feet`, `all_tags`, `yuri`, `anal`, `neko`, `girls_solo`, `yiff`",
                                                    false))
                         .ConfigureAwait(false);
            else
                await ctx.Channel.EmbedAsync(_eb.Create()
                                                .WithErrorColor()
                                                .WithAuthor("Nekos Life - Invalid NSFW Image Type or Category",
                                                    "https://i.imgur.com/a36AMkG.png",
                                                    "http://nekos.life/")
                                                .WithDescription(
                                                    "Seems the image type or category you was looking for could not be found. Please use the image type or categories listed below.")
                                                .AddField("NSFW IMG Types", "`img`, `gif`", false)
                                                .AddField("NSFW IMG Categories",
                                                    "`classic_lewd`, `piersing_lewd`, `shinobu_lewd`, `feet_lewd`, `keta_avatar`, `piersing_ero`, `yuri_ero`, `solo_lewd`, `pantyhose_lewd`, `kemonomimi_lewd`, `cosplay_lewd`, `peeing_lewd`, `ahegao_avatar`, `wallpaper_lewd`, `ero_wallpaper_ero`, `blowjob_lewd`, `holo_avatar`, `neko_lewd`, `futanari_lewd`, `kitsune_ero`, `trap_lewd`, `keta_lewd`, `neko_ero`, `pantyhose_ero`, `cum_lewd`, `anal_lewd`, `smallboobs_lewd`, `all_tags_lewd`, `yuri_lewd`, `kemonomimi_ero`, `anus_lewd`, `holo_ero`, `all_tags_ero`, `kitsune_lewd`, `pussy_lewd`, `feet_ero`, `yiff_lewd`, `hplay_ero`, `bdsm_lewd`, `femdom_lewd`, `holo_lewd`, `shinobu_ero`, `tits_lewd`",
                                                    false)
                                                .AddField("NSFW GIF Categories",
                                                    "`blow_job`, `pussy_wank`, `classic`, `kuni`, `tits`, `pussy`, `cum`, `spank`, `feet`, `all_tags`, `yuri`, `anal`, `neko`, `girls_solo`, `yiff`",
                                                    false))
                         .ConfigureAwait(false);
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message).ConfigureAwait(false);
        }
    }

    [Cmd]
    [RequireNsfw(Group = "nsfw_or_dm"), RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    public async Task Nudes()
    {
        try
        {
            await ctx.Channel.EmbedAsync(_eb.Create()
                                            .WithOkColor()
                                            .WithImageUrl(
                                                $"http://wizbot.cc/assets/wizbot/nsfw/wiz_{new WizBotRandom().Next(1, 18)}.jpg"))
                     .ConfigureAwait(false);
        }
        catch (Exception ex)
        {
            await SendErrorAsync(ex.Message).ConfigureAwait(false);
        }
    }

    [Cmd]
    [RequireContext(ContextType.Guild)]
    [UserPerm(GuildPerm.ManageMessages)]
    public async Task NsfwTagBlacklist([Leftover] string tag = null)
    {
        if (string.IsNullOrWhiteSpace(tag))
        {
            var blTags = await _service.GetBlacklistedTags(ctx.Guild.Id);
            await SendConfirmAsync(GetText(strs.blacklisted_tag_list), blTags.Any() ? string.Join(", ", blTags) : "-");
        }
        else
        {
            tag = tag.Trim().ToLowerInvariant();
            var added = await _service.ToggleBlacklistTag(ctx.Guild.Id, tag);

            if (added)
                await ReplyPendingLocalizedAsync(strs.blacklisted_tag_add(tag));
            else
                await ReplyPendingLocalizedAsync(strs.blacklisted_tag_remove(tag));
        }
    }

    [Cmd]
    [RequireContext(ContextType.Guild)]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    [Priority(1)]
    public async Task Nhentai(uint id)
    {
        var g = await _service.GetNhentaiByIdAsync(id);

        if (g is null)
        {
            await ReplyErrorLocalizedAsync(strs.not_found);
            return;
        }

        await SendNhentaiGalleryInternalAsync(g);
    }

    [Cmd]
    [RequireContext(ContextType.Guild)]
    [RequireNsfw(Group = "nsfw_or_dm")]
    [RequireContext(ContextType.DM, Group = "nsfw_or_dm")]
    [Priority(0)]
    public async Task Nhentai([Leftover] string query)
    {
        var g = await _service.GetNhentaiBySearchAsync(query);

        if (g is null)
        {
            await ReplyErrorLocalizedAsync(strs.not_found);
            return;
        }

        await SendNhentaiGalleryInternalAsync(g);
    }

    private async Task SendNhentaiGalleryInternalAsync(Gallery g)
    {
        var count = 0;
        var tagString = g.Tags.Shuffle()
                         .Select(tag => $"[{tag.Name}]({tag.Url})")
                         .TakeWhile(tag => (count += tag.Length) < 1000)
                         .Join(" ");

        var embed = _eb.Create()
                       .WithTitle(g.Title)
                       .WithDescription(g.FullTitle)
                       .WithImageUrl(g.Thumbnail)
                       .WithUrl(g.Url)
                       .AddField(GetText(strs.favorites), g.Likes, true)
                       .AddField(GetText(strs.pages), g.PageCount, true)
                       .AddField(GetText(strs.tags),
                           string.IsNullOrWhiteSpace(tagString)
                               ? "?"
                               : tagString,
                           true)
                       .WithFooter(g.UploadedAt.ToString("f"))
                       .WithOkColor();

        await ctx.Channel.EmbedAsync(embed);
    }

    private async Task InternalDapiCommand(
        string[] tags,
        bool forceExplicit,
        Func<ulong?, bool, string[], Task<UrlReply>> func)
    {
        var data = await func(ctx.Guild?.Id, forceExplicit, tags);

        if (data is null || !string.IsNullOrWhiteSpace(data.Error))
        {
            await ReplyErrorLocalizedAsync(strs.no_results);
            return;
        }

        await ctx.Channel.EmbedAsync(_eb.Create(ctx)
                                        .WithOkColor()
                                        .WithImageUrl(data.Url)
                                        .WithDescription($"[link]({data.Url})")
                                        .WithFooter(
                                            $"{data.Rating} ({data.Provider}) | {string.Join(" | ", data.Tags.Where(x => !string.IsNullOrWhiteSpace(x)).Take(5))}"));
    }
}


text:
package org.sindice.siren.solr.analysis;

import java.util.Map;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.sindice.siren.analysis.filter.URILocalnameFilter;

/**
 * Factory for {@link URILocalnameFilter}.
 *
 * <p>
 *
 * The property {@value #MAXLENGTH_KEY} can be set to define the maximum length
 * for a localname to be tokenized. The default positionIncrement value is
 * {@value URILocalnameFilter.DEFAULT_MAX_LENGTH.
 */
public class URILocalnameFilterFactory extends TokenFilterFactory {

  public static final String MAXLENGTH_KEY = "maxLength";

  private int maxLength = 0;

  @Override
  public void init(final Map<String,String> args) {
   super.init(args);
   final String maxArg = args.get(MAXLENGTH_KEY);
   maxLength = (maxArg != null ? Integer.parseInt(maxArg) : URILocalnameFilter.DEFAULT_MAX_LENGTH);
  }

  @Override
  public TokenStream create(final TokenStream input) {
    final URILocalnameFilter filter = new URILocalnameFilter(input);
    filter.setMaxLength(maxLength);
    return filter;
  }

}

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 * Created by PhpStorm.
 * User: garbi
 * Date: 21.04.17
 * Time: 18:46
 */
// src/DispatcherBundle/Services/iLabServiceBroker.php
namespace DispatcherBundle\Services;

use Doctrine\ORM\EntityManager;
use DispatcherBundle\Entity\LabSession;
use DispatcherBundle\Security\IsaRlmsAuthenticator;
use Symfony\Component\Security\Acl\Exception\Exception;

class iLabServiceBroker
{
    private $em;
    private $labServerId;//object of class LabServer
    private $rlmsGuid;
    private $brokerAuthenticator;
    private $serviceUrl;
    private $authorityId;
    private $lsServices;

    //private $labServerId;

    public function __construct(EntityManager $em, GenericLabServerServices $lsServices)
    {
        $this->em = $em;
        $this->lsServices = $lsServices;
    }

    public function  setServiceUrl($url)
    {
        $this->serviceUrl = $url;
    }

    public function getLabServerByGuid($labServerId)
    {
        $labServer = $this
            ->em
            ->getRepository('DispatcherBundle:LabServer')
            ->findOneBy(array('Guid' => $labServerId));

        if ($labServer == null){
            return array('exception' => true,
                'message' => 'Provided lab server GUID is incorrect or you do not have permissions to access this lab server');

        }
        $mapping = $this
            ->em
            ->getRepository('DispatcherBundle:LsToRlmsMapping')
            ->findOneBy(array('rlmsId' => $this->authorityId, 'labServerId' => $labServer->getId()));

        if ($this->authorityId != null){
            if ($mapping == null){
                return array('exception' => true,
                    'message' => 'The authority for which this session was issued does not have permissions to access this lab server.');
            }
        }

        return array('exception' => false,
            'labServer' => $labServer,
            'message' => 'Lab Server found');
    }

    // Authenticate call to the SB batch API
    public function sbAuthHeader($sbHeader)
    {
        $labSession = $this
            ->em
            ->getRepository('DispatcherBundle:LabSession')
            ->findOneBy(array('couponId' => $sbHeader->couponID, 'passkey' => $sbHeader->couponPassKey));

        if ($labSession == null){

            return new \SoapFault("Server", 'Invalid session: Provided credentials are not valid' );
        }

        $now = new \DateTime();
        if ($now < $labSession->getStartDate() OR $now > $labSession->getEndDate()){
            return new \SoapFault("Server", 'Invalid session: Session has expired' );
        }
        $this->labServerId = $labSession->getLabServerId();
        $this->authorityId = $labSession->getAuthorityId();
        //$this->couponID = $sbHeader->couponID;
        //$this->couponPassKey = $sbHeader->couponPassKey;
    }

    // Authenticate requests to LaunchLab service
    public function OperationAuthHeader($header)
    {
        $couponId = $header->coupon->couponId;
        $passkey = $header->coupon->passkey;

        $authority = $this
            ->em
            ->getRepository('DispatcherBundle:Rlms')
            ->findOneBy(array('authPassKey' => $passkey, 'authCouponId' => $couponId));

        if ($authority == null){
            return new \SoapFault("Server", 'Could not authenticate authority. CouponId or passkey are incorrect' );
        }
        //set authority ID
        $this->authorityId = $authority->getId();

    }

    public function GetLabInfo($params)
    {
        //get the lab server for GUID
        $labServerResp = $this->getLabServerByGuid($params->labServerID);
        if ($labServerResp['exception']){
            return new \SoapFault("Server", $labServerResp['message'] );
        }

        $labInfoRes = $this->lsServices->getLabInfo($labServerResp['labServer']->getId());

        if ($labInfoRes['exception']){
            return new \SoapFault("Server", $labInfoRes['message'] );
        }

        return array('GetLabInfoResult' => $labInfoRes['result']);
    }

    public function GetLabStatus($params){

        //get the lab server for GUID
        $labServerResp = $this->getLabServerByGuid($params->labServerID);
        if ($labServerResp['exception']){
            return new \SoapFault("Server", $labServerResp['message'] );
        }

        $response = array('GetLabStatusResult' => array(
            'online' => $labServerResp['labServer']->getActive(),
            'labStatusMessage' => "1:Powered up"));
        return $response;
    }

    public function GetLabConfiguration($params){

        //get the lab server for GUID
        $labServerResp = $this->getLabServerByGuid($params->labServerID);
        if ($labServerResp['exception']){
            return new \SoapFault("Server", $labServerResp['message'] );
        }

        //$response = array('GetLabConfigurationResult' => $labServerResp['labServer']->getConfiguration());
        $labConfigResp = $this->lsServices->getLabConfiguration($labServerResp['labServer']->getId());

        if ($labConfigResp['exception']){
            return new \SoapFault("Server", $labConfigResp['message'] );
        }

        $response = array('GetLabConfigurationResult' => $labConfigResp['labConfiguration']['labConfiguration']);

        return $response;
    }

    public function Submit($params)
    {
        //get the lab server for GUID
        $labServerResp = $this->getLabServerByGuid($params->labServerID);
        if ($labServerResp['exception']){
            return new \SoapFault("Server", $labServerResp['message'] );
        }

        $submitReport = $this->lsServices->submit(null, $params->experimentSpecification, 'Authority name', $params->priorityHint, $this->authorityId, $labServerResp['labServer']->getId());

        return array('SubmitResult' => $submitReport);
    }

    public function GetExperimentStatus($params)
    {
        $statusReport = $this->lsServices->getExperimentStatus($params->experimentID);

        if ($statusReport['exception']){
            return new \SoapFault("Server", $statusReport['message'] );
        }

        $response = array('GetExperimentStatusResult' => array(
            'statusReport' => array('statusCode' =>  $statusReport['statusCode'],
                'wait' => array('effectiveQueueLength' => $statusReport['effectiveQueueLength'],
                    'estWait' => $statusReport['estWait']),
                'estRuntime' => $statusReport['estRuntime'],
                'estRemainingRuntime' => $statusReport['estRemainingRuntime']),
            'minTimetoLive' => $statusReport['minTimetoLive']));
        return $response;
    }

    public function RetrieveResult($params)
    {
        $resultsReport = $this->lsServices->retrieveResult($params->experimentID);

        if ($resultsReport['exception']){
            return new \SoapFault("Server", $resultsReport['message'] );
        }

        return array('RetrieveResultResult' => array('statusCode' => $resultsReport['statusCode'],
            'experimentResults' => $resultsReport['experimentResults'],
            'xmlResultExtension' => $resultsReport['xmlResultExtension'],
            'xmlBlobExtension' => $resultsReport['xmlBlobExtension'],
            'warningMessages' => $resultsReport['warningMessages'],
            'errorMessage' => $resultsReport['errorMessage'])
        );
    }

    public function GetEffectiveQueueLength($params)
    {
        //get the lab server for GUID
        $labServerResp = $this->getLabServerByGuid($params->labServerID);
        if ($labServerResp['exception']){
            return new \SoapFault("Server", $labServerResp['message'] );
        }

        $repository = $this
            ->em
            ->getRepository('DispatcherBundle:JobRecord');

        //get the length of the queue considering the job priority
        $queueLength = $repository->createQueryBuilder('job')
            ->where('job.jobStatus = :jobStatus')
            ->andWhere('job.labServerId = :labServerId')
            ->andWhere('job.priority >= :priority')
            ->setParameter('jobStatus', 1)//STATUS 1 = QUEUED
            ->setParameter('labServerId', $labServerResp['labServer']->getId())
            ->setParameter('priority', $params->priorityHint)
            ->select('COUNT(job)')
            ->getQuery()
            ->getSingleScalarResult();

        $estWait = '';

        $response = array('GetEffectiveQueueLengthResult' => array('effectiveQueueLength' => $queueLength,
            'estWait' => $estWait));
        return $response;
    }

    public function Cancel($params)
    {
        $cancelResult = $this->lsServices->cancelExperiment($params->experimentID);
        return array('CancelResult' => $cancelResult['cancelled']);
    }

    public function Validate($params)
    {

        //Create experiment submission report
        $accepted = true;
        $warningMessage =  '';
        $errorMessage = '';
        $estRuntime = 20;

        $response = array('ValidateResult' => array('accepted' => $accepted,
            'warningMessages' => array('string' => $warningMessage),
            'errorMessage' => $errorMessage,
            'estRuntime' => $estRuntime));
        return $response;
    }

    public function LaunchLabClient($params)
    {

        //try to find the lab client for the provided GUID
        $labClient = $this
            ->em
            ->getRepository('DispatcherBundle:LabClient')
            ->findOneBy(array('Guid' => $params->clientGuid));

        if ($labClient == null){
            return new \SoapFault("Server", 'Lab Client not found' );
        }

        $labServer = $this
            ->em
            ->getRepository('DispatcherBundle:LabServer')
            ->findOneBy(array('id' => $labClient->getLabServerId()));

        if ($labServer == null){
            return new \SoapFault("Server", 'The lab server you are trying to access does not exist' );
        }

        $mapping = $this
            ->em
            ->getRepository('DispatcherBundle:LsToRlmsMapping')
            ->findOneBy(array('rlmsId' => $this->authorityId, 'labServerId' => $labClient->getLabServerId()));

        if ($mapping == null){
            return new \SoapFault("Server", 'This authority does not have permissions to use this lab server' );
        }

        if ($params->duration == '-1'){
            $session_duration = '604800';
        }
        else{
            $session_duration = (int)$params->duration;
        }

        $startDate = new \DateTime();
        $endDate = new \DateTime();
        $endDate->add( new \DateInterval('PT'.$session_duration.'S'));
        $labSession = new LabSession();
        $session = $labSession->createSession($labClient->getLabServerId(), $this->authorityId, $startDate, $endDate);

        try{
            $this->em->persist($labSession);
            $this->em->flush();
        }
        catch (Exception $e){
            return new \SoapFault("Server", $e->getMessage() );
        }

        $response = array('LaunchLabClientResult' => array(
            'id' => $session['couponId'],
            'tag' => $labClient->getClientUrl().'?coupon_id='.$session['couponId'].'&passkey='.$session['passkey'].'&labServerGuid='.$labServer->getGuid()));

        return $response;
    }

    }


text:
JavaScript 开发系列课程。

## JavaScript 异步编程

- [课程视频](https://ke.qq.com/course/230601)
- [课程 PPT](async.pptx)
- [通关任务](async-task.md)


text:
module Matplotlib
  PolarAxes = PyCall.import_module('matplotlib.projections.polar').PolarAxes
  PolarAxes.__send__ :register_python_type_mapping
end


text:
namespace blink {

const WrapperTypeInfo V8TestInterface5::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface5::domTemplate, V8TestInterface5::refObject, V8TestInterface5::derefObject, V8TestInterface5::trace, V8TestInterface5::toActiveDOMObject, V8TestInterface5::visitDOMWrapper, V8TestInterface5::preparePrototypeObject, V8TestInterface5::installConditionallyEnabledProperties, "TestInterface5", &V8TestInterfaceEmpty::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject };

// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface5Implementation.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h.
const WrapperTypeInfo& TestInterface5Implementation::s_wrapperTypeInfo = V8TestInterface5::wrapperTypeInfo;

namespace TestInterface5ImplementationV8Internal {

template<class CallbackInfo>
static void TestInterface5ImplementationForceSetAttributeOnThis(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const CallbackInfo& info)
{
    ASSERT(info.This()->IsObject());
    v8::Local<v8::Object>::Cast(info.This())->ForceSet(info.GetIsolate()->GetCurrentContext(), name, v8Value);
}

static void TestInterface5ImplementationConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    do {
        v8::Local<v8::Value> data = info.Data();
        ASSERT(data->IsExternal());
        V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
        if (!perContextData)
            break;
        const WrapperTypeInfo* wrapperTypeInfo = WrapperTypeInfo::unwrap(data);
        if (!wrapperTypeInfo)
            break;
        TestInterface5ImplementationForceSetAttributeOnThis(v8String(info.GetIsolate(), wrapperTypeInfo->interfaceName), v8Value, info);
    } while (false); // do ... while (false) just for use of break
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void testInterfaceAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValueFast(info, WTF::getPtr(impl->testInterfaceAttribute()), impl);
}

static void testInterfaceAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void testInterfaceAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "testInterfaceAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    TestInterface5Implementation* cppValue = V8TestInterface5::toImplWithTypeCheck(info.GetIsolate(), v8Value);
    if (!cppValue) {
        exceptionState.throwTypeError("The provided value is not of type 'TestInterface5'.");
        exceptionState.throwIfNeeded();
        return;
    }
    impl->setTestInterfaceAttribute(WTF::getPtr(cppValue));
}

static void testInterfaceAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void testInterfaceConstructorAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
    v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "testInterfaceConstructorAttribute");
    TestInterface5ImplementationForceSetAttributeOnThis(propertyName, v8Value, info);
}

static void testInterfaceConstructorAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::testInterfaceConstructorAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void doubleAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValue(info, impl->doubleAttribute());
}

static void doubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::doubleAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    double cppValue = toRestrictedDouble(info.GetIsolate(), v8Value, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setDoubleAttribute(cppValue);
}

static void doubleAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::doubleAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void floatAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValue(info, impl->floatAttribute());
}

static void floatAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::floatAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    float cppValue = toRestrictedFloat(info.GetIsolate(), v8Value, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setFloatAttribute(cppValue);
}

static void floatAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::floatAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void unrestrictedDoubleAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValue(info, impl->unrestrictedDoubleAttribute());
}

static void unrestrictedDoubleAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedDoubleAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    double cppValue = toDouble(info.GetIsolate(), v8Value, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setUnrestrictedDoubleAttribute(cppValue);
}

static void unrestrictedDoubleAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void unrestrictedFloatAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValue(info, impl->unrestrictedFloatAttribute());
}

static void unrestrictedFloatAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedFloatAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    float cppValue = toFloat(info.GetIsolate(), v8Value, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setUnrestrictedFloatAttribute(cppValue);
}

static void unrestrictedFloatAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void staticStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
    v8SetReturnValueString(info, TestInterface5Implementation::staticStringAttribute(), info.GetIsolate());
}

static void staticStringAttributeAttributeGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::staticStringAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void staticStringAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
    V8StringResource<> cppValue = v8Value;
    if (!cppValue.prepare())
        return;
    TestInterface5Implementation::setStaticStringAttribute(cppValue);
}

static void staticStringAttributeAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::staticStringAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void alwaysExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValueInt(info, impl->alwaysExposedAttribute());
}

static void alwaysExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void alwaysExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "alwaysExposedAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    int cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setAlwaysExposedAttribute(cppValue);
}

static void alwaysExposedAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void workerExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValueInt(info, impl->workerExposedAttribute());
}

static void workerExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void workerExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "workerExposedAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    int cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setWorkerExposedAttribute(cppValue);
}

static void workerExposedAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void windowExposedAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    v8SetReturnValueInt(info, impl->windowExposedAttribute());
}

static void windowExposedAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
    TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeGetter(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void windowExposedAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Object> holder = info.Holder();
    ExceptionState exceptionState(ExceptionState::SetterContext, "windowExposedAttribute", "TestInterface5", holder, info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
    int cppValue = toInt32(info.GetIsolate(), v8Value, NormalConversion, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    impl->setWindowExposedAttribute(cppValue);
}

static void windowExposedAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Local<v8::Value> v8Value = info[0];
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
    TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeSetter(v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodTestInterfaceEmptyArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (UNLIKELY(info.Length() < 1)) {
        V8ThrowException::throwException(createMinimumArityTypeErrorForMethod(info.GetIsolate(), "voidMethodTestInterfaceEmptyArg", "TestInterface5", 1, info.Length()), info.GetIsolate());
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    TestInterfaceEmpty* testInterfaceEmptyArg;
    {
        testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]);
        if (!testInterfaceEmptyArg) {
            V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::failedToExecute("voidMethodTestInterfaceEmptyArg", "TestInterface5", "parameter 1 is not of type 'TestInterfaceEmpty'."));
            return;
        }
    }
    impl->voidMethodTestInterfaceEmptyArg(testInterfaceEmptyArg);
}

static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDoubleArgFloatArg", "TestInterface5", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 2)) {
        setMinimumArityTypeError(exceptionState, 2, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    double doubleArg;
    float floatArg;
    {
        doubleArg = toRestrictedDouble(info.GetIsolate(), info[0], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        floatArg = toRestrictedFloat(info.GetIsolate(), info[1], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    impl->voidMethodDoubleArgFloatArg(doubleArg, floatArg);
}

static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodDoubleArgFloatArgMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface5", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 2)) {
        setMinimumArityTypeError(exceptionState, 2, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    double unrestrictedDoubleArg;
    float unrestrictedFloatArg;
    {
        unrestrictedDoubleArg = toDouble(info.GetIsolate(), info[0], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        unrestrictedFloatArg = toFloat(info.GetIsolate(), info[1], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDoubleArg, unrestrictedFloatArg);
}

static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->voidMethod();
}

static void voidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->voidMethod();
}

static void voidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodMethodForMainWorld(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void alwaysExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->alwaysExposedMethod();
}

static void alwaysExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::alwaysExposedMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void workerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->workerExposedMethod();
}

static void workerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::workerExposedMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void windowExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->windowExposedMethod();
}

static void windowExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::windowExposedMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void alwaysExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation::alwaysExposedStaticMethod();
}

static void alwaysExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::alwaysExposedStaticMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void workerExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation::workerExposedStaticMethod();
}

static void workerExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::workerExposedStaticMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void windowExposedStaticMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation::windowExposedStaticMethod();
}

static void windowExposedStaticMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::windowExposedStaticMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void windowAndServiceWorkerExposedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    impl->windowAndServiceWorkerExposedMethod();
}

static void windowAndServiceWorkerExposedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::windowAndServiceWorkerExposedMethodMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodBooleanOrDOMStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodBooleanOrDOMStringArg", "TestInterface5", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        setMinimumArityTypeError(exceptionState, 1, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    BooleanOrString arg;
    {
        V8BooleanOrString::toImpl(info.GetIsolate(), info[0], arg, exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    impl->voidMethodBooleanOrDOMStringArg(arg);
}

static void voidMethodBooleanOrDOMStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodBooleanOrDOMStringArgMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void voidMethodDoubleOrDOMStringArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDoubleOrDOMStringArg", "TestInterface5", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        setMinimumArityTypeError(exceptionState, 1, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    DoubleOrString arg;
    {
        V8DoubleOrString::toImpl(info.GetIsolate(), info[0], arg, exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    impl->voidMethodDoubleOrDOMStringArg(arg);
}

static void voidMethodDoubleOrDOMStringArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::voidMethodDoubleOrDOMStringArgMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "keys", "TestInterface5", info.Holder(), info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    RawPtr<Iterator> result = impl->keysForBinding(scriptState, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8SetReturnValue(info, result.release());
}

static void keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::keysMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void valuesMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "values", "TestInterface5", info.Holder(), info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    RawPtr<Iterator> result = impl->valuesForBinding(scriptState, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8SetReturnValue(info, result.release());
}

static void valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::valuesMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void entriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "entries", "TestInterface5", info.Holder(), info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    RawPtr<Iterator> result = impl->entriesForBinding(scriptState, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8SetReturnValue(info, result.release());
}

static void entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::entriesMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "forEach", "TestInterface5", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        setMinimumArityTypeError(exceptionState, 1, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    ScriptValue callback;
    ScriptValue thisArg;
    {
        if (!info[0]->IsFunction()) {
            exceptionState.throwTypeError("The callback provided as parameter 1 is not a function.");
            exceptionState.throwIfNeeded();
            return;
        }
        callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
        thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]);
    }
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    impl->forEachForBinding(scriptState, ScriptValue(scriptState, info.This()), callback, thisArg, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
}

static void forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::forEachMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    v8SetReturnValueString(info, impl->toString(), info.GetIsolate());
}

static void toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::toStringMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "iterator", "TestInterface5", info.Holder(), info.GetIsolate());
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    RawPtr<Iterator> result = impl->iterator(scriptState, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8SetReturnValue(info, result.release());
}

static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
    TestInterface5ImplementationV8Internal::iteratorMethod(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    String result = impl->anonymousIndexedGetter(index);
    if (result.isNull())
        return;
    v8SetReturnValueString(info, result, info.GetIsolate());
}

static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
    TestInterface5ImplementationV8Internal::indexedPropertyGetter(index, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    V8StringResource<> propertyValue = v8Value;
    if (!propertyValue.prepare())
        return;
    bool result = impl->anonymousIndexedSetter(index, propertyValue);
    if (!result)
        return;
    v8SetReturnValue(info, v8Value);
}

static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
    TestInterface5ImplementationV8Internal::indexedPropertySetter(index, v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    DeleteResult result = impl->anonymousIndexedDeleter(index);
    if (result != DeleteUnknownProperty)
        return v8SetReturnValueBool(info, result == DeleteSuccess);
}

static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty");
    TestInterface5ImplementationV8Internal::indexedPropertyDeleter(index, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    auto nameString = name.As<v8::String>();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    AtomicString propertyName = toCoreAtomicString(nameString);
    String result = impl->anonymousNamedGetter(propertyName);
    if (result.isNull())
        return;
    v8SetReturnValueString(info, result, info.GetIsolate());
}

static void namedPropertyGetterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
    TestInterface5ImplementationV8Internal::namedPropertyGetter(name, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    auto nameString = name.As<v8::String>();
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    V8StringResource<> propertyName(nameString);
    if (!propertyName.prepare())
        return;
    V8StringResource<> propertyValue = v8Value;
    if (!propertyValue.prepare())
        return;
    bool result = impl->anonymousNamedSetter(propertyName, propertyValue);
    if (!result)
        return;
    v8SetReturnValue(info, v8Value);
}

static void namedPropertySetterCallback(v8::Local<v8::Name> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
    TestInterface5ImplementationV8Internal::namedPropertySetter(name, v8Value, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
    v8::String::Utf8Value namedProperty(name);
    ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface5", info.Holder(), info.GetIsolate());
    bool result = impl->namedPropertyQuery(propertyName, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    if (!result)
        return;
    v8SetReturnValueInt(info, v8::None);
}

static void namedPropertyQueryCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
    TestInterface5ImplementationV8Internal::namedPropertyQuery(name, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
    DeleteResult result = impl->anonymousNamedDeleter(propertyName);
    if (result != DeleteUnknownProperty)
        return v8SetReturnValueBool(info, result == DeleteSuccess);
}

static void namedPropertyDeleterCallback(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Boolean>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
    TestInterface5ImplementationV8Internal::namedPropertyDeleter(name, info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
{
    TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
    Vector<String> names;
    ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestInterface5", info.Holder(), info.GetIsolate());
    impl->namedPropertyEnumerator(names, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    v8::Local<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size());
    for (size_t i = 0; i < names.size(); ++i) {
        if (!v8CallBoolean(v8names->Set(info.GetIsolate()->GetCurrentContext(), v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i]))))
            return;
    }
    v8SetReturnValue(info, v8names);
}

static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
{
    TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty");
    TestInterface5ImplementationV8Internal::namedPropertyEnumerator(info);
    TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}

} // namespace TestInterface5ImplementationV8Internal

void V8TestInterface5::visitDOMWrapper(v8::Isolate* isolate, ScriptWrappable* scriptWrappable, const v8::Persistent<v8::Object>& wrapper)
{
    TestInterface5Implementation* impl = scriptWrappable->toImpl<TestInterface5Implementation>();
    v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper);
    V8WrapperInstantiationScope scope(creationContext, isolate);
    TestInterface5Implementation* referencedName = impl->referencedName();
    if (referencedName) {
        if (!DOMDataStore::containsWrapper(referencedName, isolate))
            referencedName->wrap(isolate, creationContext);
        DOMDataStore::setWrapperReference(wrapper, referencedName, isolate);
    }
    setObjectGroup(isolate, scriptWrappable, wrapper);
}

static const V8DOMConfiguration::AttributeConfiguration V8TestInterface5Attributes[] = {
    {"testInterfaceConstructorAttribute", v8ConstructorAttributeGetter, TestInterface5ImplementationV8Internal::testInterfaceConstructorAttributeAttributeSetterCallback, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestInterface5::wrapperTypeInfo), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnInstance},
};

static const V8DOMConfiguration::AccessorConfiguration V8TestInterface5Accessors[] = {
    {"testInterfaceAttribute", TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::testInterfaceAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
    {"doubleAttribute", TestInterface5ImplementationV8Internal::doubleAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::doubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
    {"floatAttribute", TestInterface5ImplementationV8Internal::floatAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::floatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
    {"unrestrictedDoubleAttribute", TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::unrestrictedDoubleAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
    {"unrestrictedFloatAttribute", TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::unrestrictedFloatAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
    {"alwaysExposedAttribute", TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::alwaysExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder},
};

static const V8DOMConfiguration::MethodConfiguration V8TestInterface5Methods[] = {
    {"voidMethodTestInterfaceEmptyArg", TestInterface5ImplementationV8Internal::voidMethodTestInterfaceEmptyArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
    {"voidMethodDoubleArgFloatArg", TestInterface5ImplementationV8Internal::voidMethodDoubleArgFloatArgMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts},
    {"voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", TestInterface5ImplementationV8Internal::voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts},
    {"voidMethod", TestInterface5ImplementationV8Internal::voidMethodMethodCallback, TestInterface5ImplementationV8Internal::voidMethodMethodCallbackForMainWorld, 0, V8DOMConfiguration::ExposedToAllScripts},
    {"alwaysExposedMethod", TestInterface5ImplementationV8Internal::alwaysExposedMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
    {"voidMethodBooleanOrDOMStringArg", TestInterface5ImplementationV8Internal::voidMethodBooleanOrDOMStringArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
    {"voidMethodDoubleOrDOMStringArg", TestInterface5ImplementationV8Internal::voidMethodDoubleOrDOMStringArgMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
    {"keys", TestInterface5ImplementationV8Internal::keysMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
    {"values", TestInterface5ImplementationV8Internal::valuesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
    {"entries", TestInterface5ImplementationV8Internal::entriesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
    {"forEach", TestInterface5ImplementationV8Internal::forEachMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
};

static void installV8TestInterface5Template(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
    functionTemplate->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    if (!RuntimeEnabledFeatures::featureNameEnabled())
        defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "TestInterface5", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface5::internalFieldCount, 0, 0, 0, 0, 0, 0);
    else
        defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "TestInterface5", V8TestInterfaceEmpty::domTemplate(isolate), V8TestInterface5::internalFieldCount,
            V8TestInterface5Attributes, WTF_ARRAY_LENGTH(V8TestInterface5Attributes),
            V8TestInterface5Accessors, WTF_ARRAY_LENGTH(V8TestInterface5Accessors),
            V8TestInterface5Methods, WTF_ARRAY_LENGTH(V8TestInterface5Methods));
    v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
    ALLOW_UNUSED_LOCAL(instanceTemplate);
    v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
    ALLOW_UNUSED_LOCAL(prototypeTemplate);
    static const V8DOMConfiguration::ConstantConfiguration V8TestInterface5Constants[] = {
        {"UNSIGNED_LONG", 0, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedLong},
        {"CONST_JAVASCRIPT", 1, 0, 0, V8DOMConfiguration::ConstantTypeShort},
    };
    V8DOMConfiguration::installConstants(isolate, functionTemplate, prototypeTemplate, V8TestInterface5Constants, WTF_ARRAY_LENGTH(V8TestInterface5Constants));
    {
        v8::IndexedPropertyHandlerConfiguration config(TestInterface5ImplementationV8Internal::indexedPropertyGetterCallback, TestInterface5ImplementationV8Internal::indexedPropertySetterCallback, 0, TestInterface5ImplementationV8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterface5Implementation>);
        functionTemplate->InstanceTemplate()->SetHandler(config);
    }
    {
        v8::NamedPropertyHandlerConfiguration config(TestInterface5ImplementationV8Internal::namedPropertyGetterCallback, TestInterface5ImplementationV8Internal::namedPropertySetterCallback, TestInterface5ImplementationV8Internal::namedPropertyQueryCallback, TestInterface5ImplementationV8Internal::namedPropertyDeleterCallback, TestInterface5ImplementationV8Internal::namedPropertyEnumeratorCallback);
        config.flags = static_cast<v8::PropertyHandlerFlags>(static_cast<int>(config.flags) | static_cast<int>(v8::PropertyHandlerFlags::kOnlyInterceptStrings));
        config.flags = static_cast<v8::PropertyHandlerFlags>(static_cast<int>(config.flags) | static_cast<int>(v8::PropertyHandlerFlags::kNonMasking));
        functionTemplate->InstanceTemplate()->SetHandler(config);
    }
    static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, TestInterface5ImplementationV8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts };
    V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignature, v8::DontDelete, symbolKeyedIteratorConfiguration);
    functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterface5::legacyCallCustom);
    const V8DOMConfiguration::MethodConfiguration alwaysExposedStaticMethodMethodConfiguration = {
        "alwaysExposedStaticMethod", TestInterface5ImplementationV8Internal::alwaysExposedStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts,
    };
    V8DOMConfiguration::installMethod(isolate, functionTemplate, v8::Local<v8::Signature>(), v8::None, alwaysExposedStaticMethodMethodConfiguration);
    if (context && (context->isWorkerGlobalScope())) {
        const V8DOMConfiguration::MethodConfiguration workerExposedStaticMethodMethodConfiguration = {
            "workerExposedStaticMethod", TestInterface5ImplementationV8Internal::workerExposedStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts,
        };
        V8DOMConfiguration::installMethod(isolate, functionTemplate, v8::Local<v8::Signature>(), v8::None, workerExposedStaticMethodMethodConfiguration);
    }
    if (context && (context->isDocument())) {
        const V8DOMConfiguration::MethodConfiguration windowExposedStaticMethodMethodConfiguration = {
            "windowExposedStaticMethod", TestInterface5ImplementationV8Internal::windowExposedStaticMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts,
        };
        V8DOMConfiguration::installMethod(isolate, functionTemplate, v8::Local<v8::Signature>(), v8::None, windowExposedStaticMethodMethodConfiguration);
    }
    const V8DOMConfiguration::MethodConfiguration toStringMethodConfiguration = {
        "toString", TestInterface5ImplementationV8Internal::toStringMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts,
    };
    V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignature, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::DontEnum), toStringMethodConfiguration);
    functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "staticStringAttribute"), TestInterface5ImplementationV8Internal::staticStringAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::staticStringAttributeAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Local<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));

    // Custom toString template
    functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}

v8::Local<v8::FunctionTemplate> V8TestInterface5::domTemplate(v8::Isolate* isolate)
{
    return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterface5Template);
}

bool V8TestInterface5::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
    return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}

v8::Local<v8::Object> V8TestInterface5::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
    return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}

TestInterface5Implementation* V8TestInterface5::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
    return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0;
}

void V8TestInterface5::installConditionallyEnabledProperties(v8::Local<v8::Object> instanceObject, v8::Isolate* isolate)
{
    v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instanceObject->GetPrototype());
    ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext());

    if (context && (context->isWorkerGlobalScope())) {
        static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {"workerExposedAttribute", TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::workerExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder};
        V8DOMConfiguration::installAccessor(isolate, prototypeObject, accessorConfiguration);
    }
    if (context && (context->isDocument())) {
        static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {"windowExposedAttribute", TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeGetterCallback, TestInterface5ImplementationV8Internal::windowExposedAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::CheckHolder};
        V8DOMConfiguration::installAccessor(isolate, prototypeObject, accessorConfiguration);
    }
}

void V8TestInterface5::preparePrototypeObject(v8::Isolate* isolate, v8::Local<v8::Object> prototypeObject)
{
    v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTemplate(isolate));
    ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext());
    ASSERT(context);
    if (context && (context->isWorkerGlobalScope())) {
        v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::workerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0);
        v8::Local<v8::Function> function = ->GetFunction(isolate->GetCurrentContext())).ToLocalChecked();
        v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString(isolate, "workerExposedMethod"), function));
    }
    if (context && (context->isDocument())) {
        v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::windowExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0);
        v8::Local<v8::Function> function = ->GetFunction(isolate->GetCurrentContext())).ToLocalChecked();
        v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString(isolate, "windowExposedMethod"), function));
    }
    if (context && (context->isDocument() || context->isServiceWorkerGlobalScope())) {
        v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(isolate, TestInterface5ImplementationV8Internal::windowAndServiceWorkerExposedMethodMethodCallback, v8Undefined(), defaultSignature, 0);
        v8::Local<v8::Function> function = ->GetFunction(isolate->GetCurrentContext())).ToLocalChecked();
        v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString(isolate, "windowAndServiceWorkerExposedMethod"), function));
    }
}

ActiveDOMObject* V8TestInterface5::toActiveDOMObject(v8::Local<v8::Object> wrapper)
{
    return toImpl(wrapper);
}

void V8TestInterface5::refObject(ScriptWrappable* scriptWrappable)
{
    scriptWrappable->toImpl<TestInterface5Implementation>()->ref();
}

void V8TestInterface5::derefObject(ScriptWrappable* scriptWrappable)
{
    scriptWrappable->toImpl<TestInterface5Implementation>()->deref();
}

} // namespace blink
#endif // ENABLE(CONDITION)


text:
	Version 6.x.x

	 Source

Class UnicodeWriter

		__init__
        (self, encoding=utf-8)

No docs

		getvalue
        (self)

No docs

		writerow
        (self, row)

No docs

		frappe.utils.csvutils.check_record
        (d)

check for mandatory, select options, dates. these should ideally be in doclist

		frappe.utils.csvutils.getlink
        (doctype, name)

No docs

		frappe.utils.csvutils.import_doc
        (d, doctype, overwrite, row_idx, submit=False, ignore_links=False)

import main (non child) document

		frappe.utils.csvutils.read_csv_content
        (fcontent, ignore_encoding=False)

No docs

		frappe.utils.csvutils.read_csv_content_from_attached_file
        (doc)

No docs

		frappe.utils.csvutils.read_csv_content_from_uploaded_file
        (ignore_encoding=False)

No docs

Public API

/api/method/frappe.utils.csvutils.send_csv_to_client

		frappe.utils.csvutils.send_csv_to_client
        (args)

No docs

		frappe.utils.csvutils.to_csv
        (data)

No docs


text:
    Work

Perception Team Core Member2017 - Present

WATonomous - SAE Autodrive Challenge Team

    Researched and developed image classification algorithms that could be applied in real time to traffic sign recognition in an autonomous vehicle.

Graduate Research Assistant - Computer Science2015 - 2016

University of Guelph

    Developed a survey platform in collaboration with a team of public health researchers aimed at facilitating data collection from remote communities. I designed a survey builder that enables non-technical researchers to create complex, targeted, and dynamic surveys.

Graduate Research Assistant - Behavioural Neuroscience2014 - 2016

University of Guelph

    Led a research project investigating effects of prenatal exposure to testosterone on learning and social behaviour. I was responsible for training and mentoring a large team of undergraduate students.

Seminar Instructor2014 - 2016

University of Guelph

    Led a seminar on research and statistical analysis techniques for a class designed to prepare high-achieving students interested in graduate studies for an honours thesis research course.