2021-01-04 23:38:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <PropertyList.h>
|
|
|
|
|
|
|
|
#include "vkgen.h"
|
|
|
|
#include "vkhandle.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
output_handle (string name, PLItem *handle)
|
|
|
|
{
|
|
|
|
string symtab = str_hold ([[handle getObjectForKey:"symtab"] string]);
|
|
|
|
string class = str_hold ([[handle getObjectForKey:"class"] string]);
|
|
|
|
string create = str_hold ([[handle getObjectForKey:"create"] string]);
|
2021-01-05 05:15:35 +00:00
|
|
|
string custom = str_hold ([[handle getObjectForKey:"custom"] string]);
|
|
|
|
if (!custom) {
|
2021-01-05 14:42:30 +00:00
|
|
|
fprintf (output_file, "static int parse_%s (const plitem_t *item, void **data, plitem_t *messages, parsectx_t *context)\n", name);
|
2021-01-05 05:15:35 +00:00
|
|
|
fprintf (output_file, "{\n");
|
2021-01-05 14:42:30 +00:00
|
|
|
fprintf (output_file, "\t__auto_type handle = (%s *) data[0];\n", name);
|
|
|
|
fprintf (output_file, "\tvulkan_ctx_t *ctx = context->vctx;\n");
|
2021-01-05 05:15:35 +00:00
|
|
|
fprintf (output_file, "\tqfv_device_t *device = ctx->device;\n");
|
|
|
|
fprintf (output_file, "\tqfv_devfuncs_t *dfunc = device->funcs;\n");
|
|
|
|
fprintf (output_file, "\tif (PL_Type (item) == QFString) {\n");
|
|
|
|
fprintf (output_file, "\t\tconst char *name = PL_String (item);\n");
|
|
|
|
fprintf (output_file, "\t\thandleref_t *hr = Hash_Find (ctx->%s, name);\n", symtab);
|
|
|
|
fprintf (output_file, "\t\tif (!hr) {\n");
|
|
|
|
fprintf (output_file, "\t\t\tPL_Message (messages, item, \"undefined %s %%s\", name);\n", class);
|
|
|
|
fprintf (output_file, "\t\t\treturn 0;\n");
|
|
|
|
fprintf (output_file, "\t\t}\n");
|
|
|
|
fprintf (output_file, "\t\t*handle = (%s) hr->handle;\n", name);
|
|
|
|
fprintf (output_file, "\t\treturn 1;\n");
|
|
|
|
fprintf (output_file, "\t}\n");
|
2021-01-04 23:38:35 +00:00
|
|
|
|
2021-01-05 05:15:35 +00:00
|
|
|
fprintf (output_file, "\t%sCreateInfo createInfo = {};\n", name);
|
2021-01-04 23:38:35 +00:00
|
|
|
|
2021-01-05 05:15:35 +00:00
|
|
|
fprintf (output_file, "\tif (!parse_%sCreateInfo (0, item, &createInfo, messages, context)) {\n", name);
|
|
|
|
fprintf (output_file, "\t\treturn 0;\n");
|
|
|
|
fprintf (output_file, "\t}\n");
|
|
|
|
fprintf (output_file, "\tVkResult res;\n");
|
|
|
|
fprintf (output_file, "\tres = dfunc->%s (device->dev, &createInfo, 0, handle);\n", create);
|
|
|
|
fprintf (output_file, "\tif (res != VK_SUCCESS) {\n");
|
|
|
|
fprintf (output_file, "\t\tPL_Message (messages, item, \"could not create %s\");\n", class);
|
|
|
|
fprintf (output_file, "\t\treturn 0;\n");
|
|
|
|
fprintf (output_file, "\t}\n");
|
|
|
|
fprintf (output_file, "\treturn 1;\n");
|
|
|
|
fprintf (output_file, "}\n");
|
|
|
|
}
|
2021-01-04 23:38:35 +00:00
|
|
|
|
|
|
|
fprintf (output_file, "int parse_%s_handleref (const plfield_t *field, const plitem_t *item, void *data, plitem_t *messages, void *context)\n", name);
|
|
|
|
fprintf (output_file, "{\n");
|
|
|
|
fprintf (output_file, "\thandleref_t *handleref = data;\n");
|
2021-01-05 14:42:30 +00:00
|
|
|
fprintf (output_file, "\tvoid *hrdata[] = { &handleref->handle };\n");
|
2021-01-04 23:38:35 +00:00
|
|
|
fprintf (output_file, "\thandleref->name = strdup (field->name);\n");
|
2021-01-05 05:15:35 +00:00
|
|
|
if (custom) {
|
2021-01-05 14:42:30 +00:00
|
|
|
fprintf (output_file, "\treturn %s (item, hrdata, messages, context);\n", custom);
|
2021-01-05 05:15:35 +00:00
|
|
|
} else {
|
2021-01-05 14:42:30 +00:00
|
|
|
fprintf (output_file, "\treturn parse_%s (item, hrdata, messages, context);\n", name);
|
2021-01-05 05:15:35 +00:00
|
|
|
}
|
2021-01-04 23:38:35 +00:00
|
|
|
fprintf (output_file, "}\n");
|
|
|
|
|
2021-01-05 14:42:30 +00:00
|
|
|
if (!custom) {
|
|
|
|
fprintf (header_file, "static int parse_%s (const plitem_t *item, void **data, plitem_t *messages, parsectx_t *context);\n", name);
|
|
|
|
}
|
2021-01-04 23:38:35 +00:00
|
|
|
fprintf (header_file, "int parse_%s_handleref (const plfield_t *field, const plitem_t *item, void *data, plitem_t *messages, void *context);\n", name);
|
2021-01-05 05:15:35 +00:00
|
|
|
str_free (custom);
|
2021-01-04 23:38:35 +00:00
|
|
|
str_free (symtab);
|
|
|
|
str_free (class);
|
|
|
|
str_free (create);
|
|
|
|
}
|