Created
June 28, 2021 14:12
-
-
Save unxmaal/bac79b53ca12e63b622a5dadf15f4d69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int | |
output_generated_attribute_user_setter(struct opctx *outc, | |
struct ir_entry *interfacee, | |
struct ir_attribute_entry *atributee) | |
{ | |
UNUSED(interfacee); | |
if ((atributee->typev[0].name != NULL) && | |
strlen(atributee->typev[0].name) >= 12 && | |
strcmp(atributee->typev[0].name + strlen(atributee->typev[0].name) - 12, | |
"EventHandler") == 0) { | |
/* this can generate for onxxx event handlers */ | |
if ((atributee->name[0] != 'o') || | |
(atributee->name[1] != 'n')) { | |
return -1; /* not onxxx */ | |
} | |
if (interfacee->u.interface.primary_global) { | |
outputf(outc, | |
"\tdom_element *et = NULL;\n"); | |
} else { | |
outputf(outc, | |
"\tdom_element *et = (dom_element *)(((node_private_t *)priv)->node);\n"); | |
} | |
outputf(outc, | |
"\t/* handlerfn */\n" | |
"\tduk_push_this(ctx);\n" | |
"\t/* handlerfn this */\n" | |
"\tduk_get_prop_string(ctx, -1, HANDLER_MAGIC);\n" | |
"\t/* handlerfn this handlers */\n" | |
"\tduk_push_lstring(ctx, \"%s\", %ld);\n" | |
"\t/* handlerfn this handlers %s */\n" | |
"\tduk_dup(ctx, -4);\n" | |
"\t/* handlerfn this handlers %s handlerfn */\n" | |
"\tduk_put_prop(ctx, -3);\n" | |
"\t/* handlerfn this handlers */\n" | |
"\tdukky_register_event_listener_for(ctx, et,\n" | |
"\t\tcorestring_dom_%s, false);\n" | |
"\treturn 0;\n", | |
atributee->name + 2, | |
strlen(atributee->name + 2), | |
atributee->name + 2, | |
atributee->name + 2, | |
atributee->name + 2); | |
return 0; | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment