@@ -199,7 +199,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
199199 num_exts = (uint32_t)n;
200200 if (num_exts > 0) {
201201 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
202- if (!exts) return 0;
202+ if (!exts)
203+ return 0;
203204 for (i = 0; i < num_exts; ++i) {
204205 const char *name = (const char *)context->GetStringi(GL_EXTENSIONS, i);
205206 if (name) exts[i] = gloam_hash_string(name, strlen(name));
@@ -213,9 +214,11 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
213214 const char *ext_str;
214215 const char *cur, *next;
215216 uint32_t j;
216- if (!context->GetString) return 0;
217+ if (!context->GetString)
218+ return 0;
217219 ext_str = (const char *)context->GetString(GL_EXTENSIONS);
218- if (!ext_str) return 0;
220+ if (!ext_str)
221+ return 0;
219222 for (j = 0; j < 2; ++j) {
220223 num_exts = 0;
221224 cur = ext_str;
@@ -232,7 +235,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
232235 }
233236 if (!exts) {
234237 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
235- if (!exts) return 0;
238+ if (!exts)
239+ return 0;
236240 }
237241 }
238242 }
@@ -250,9 +254,11 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
250254 const char *ext_str, *cur, *next;
251255 uint64_t *exts = NULL;
252256 uint32_t num_exts = 0, j;
253- if (!context->GetString) return 0;
257+ if (!context->GetString)
258+ return 0;
254259 ext_str = (const char *)context->GetString(GL_EXTENSIONS);
255- if (!ext_str) return 0;
260+ if (!ext_str)
261+ return 0;
256262 for (j = 0; j < 2; ++j) {
257263 num_exts = 0;
258264 cur = ext_str;
@@ -269,7 +275,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
269275 }
270276 if (!exts) {
271277 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
272- if (!exts) return 0;
278+ if (!exts)
279+ return 0;
273280 }
274281 }
275282 gloam_sort_hashes(exts, num_exts);
@@ -289,22 +296,26 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
289296 uint32_t num_exts = 0, j;
290297 size_t client_len, display_len;
291298
292- if (!context->QueryString) return 0;
299+ if (!context->QueryString)
300+ return 0;
293301
294302 /* Client extensions live at EGL_NO_DISPLAY. */
295303 client_str = (const char *)context->QueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
296304 display_str = (display == EGL_NO_DISPLAY) ? "" :
297305 (const char *)context->QueryString(display, EGL_EXTENSIONS);
298306
299- if (!client_str) return 0;
300- if (!display_str) return 0;
307+ if (!client_str)
308+ return 0;
309+ if (!display_str)
310+ return 0;
301311
302312 client_len = strlen(client_str);
303313 display_len = strlen(display_str);
304314
305315 /* Concatenate with a space separator. */
306316 concat = (char *)malloc(client_len + display_len + 2);
307- if (!concat) return 0;
317+ if (!concat)
318+ return 0;
308319 memcpy(concat, client_str, client_len);
309320 size_t pos = client_len;
310321 if (display_len) {
@@ -332,7 +343,10 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
332343 }
333344 if (!exts) {
334345 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
335- if (!exts) { free(concat); return 0; }
346+ if (!exts) {
347+ free(concat);
348+ return 0;
349+ }
336350 }
337351 }
338352
@@ -350,9 +364,11 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
350364 const char *ext_str, *cur, *next;
351365 uint64_t *exts = NULL;
352366 uint32_t num_exts = 0, j;
353- if (!context->QueryExtensionsString) return 0;
367+ if (!context->QueryExtensionsString)
368+ return 0;
354369 ext_str = (const char *)context->QueryExtensionsString(display, screen);
355- if (!ext_str) return 0;
370+ if (!ext_str)
371+ return 0;
356372 for (j = 0; j < 2; ++j) {
357373 num_exts = 0;
358374 cur = ext_str;
@@ -369,7 +385,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
369385 }
370386 if (!exts) {
371387 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
372- if (!exts) return 0;
388+ if (!exts)
389+ return 0;
373390 }
374391 }
375392 gloam_sort_hashes(exts, num_exts);
@@ -389,7 +406,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
389406 ext_str = (const char *)context->GetExtensionsStringARB(hdc);
390407 if (!ext_str && context->GetExtensionsStringEXT)
391408 ext_str = (const char *)context->GetExtensionsStringEXT();
392- if (!ext_str) return 0;
409+ if (!ext_str)
410+ return 0;
393411 for (j = 0; j < 2; ++j) {
394412 num_exts = 0;
395413 cur = ext_str;
@@ -406,7 +424,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
406424 }
407425 if (!exts) {
408426 exts = (uint64_t *)calloc(num_exts, sizeof(uint64_t));
409- if (!exts) return 0;
427+ if (!exts)
428+ return 0;
410429 }
411430 }
412431 gloam_sort_hashes(exts, num_exts);
@@ -430,7 +449,8 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
430449 VkExtensionProperties *props = NULL;
431450 uint64_t *exts = NULL;
432451
433- if (!context->EnumerateInstanceExtensionProperties) return 0;
452+ if (!context->EnumerateInstanceExtensionProperties)
453+ return 0;
434454
435455 context->EnumerateInstanceExtensionProperties(NULL, &inst_count, NULL);
436456 if (physical_device != NULL && context->EnumerateDeviceExtensionProperties != NULL)
@@ -444,7 +464,11 @@ static int gloam_{{ fs.spec_name }}_get_extensions_{{ api }}({{ u.ctx_arg(', ')
444464 props = (VkExtensionProperties *)calloc(
445465 (inst_count > dev_count ? inst_count : dev_count), sizeof(*props));
446466 exts = (uint64_t *)calloc(total, sizeof(uint64_t));
447- if (!props || !exts) { free(props); free(exts); return 0; }
467+ if (!props || !exts) {
468+ free(props);
469+ free(exts);
470+ return 0;
471+ }
448472
449473 context->EnumerateInstanceExtensionProperties(NULL, &inst_count, props);
450474 for (i = 0; i < inst_count; ++i)
@@ -475,8 +499,10 @@ static int gloam_{{ fs.spec_name }}_find_extensions_{{ api }}({{ u.ctx_arg(', ')
475499 uint32_t num_exts = 0, i;
476500
477501 /* Skip re-enumeration if we already have the right scope of extensions. */
478- if (physical_device != NULL && context->vk_found_device_exts) return 1;
479- if (physical_device == NULL && context->vk_found_instance_exts) return 1;
502+ if (physical_device != NULL && context->vk_found_device_exts)
503+ return 1;
504+ if (physical_device == NULL && context->vk_found_instance_exts)
505+ return 1;
480506
481507 if (!gloam_{{ fs.spec_name }}_get_extensions_{{ api }}(context, physical_device, &exts, &num_exts))
482508 return 0;
@@ -518,7 +544,8 @@ static int gloam_{{ fs.spec_name }}_find_core_{{ api }}({{ u.ctx_arg() }}) {
518544 "OpenGL SC ", "OpenGL ", NULL
519545 };
520546 const char *version = (const char *)context->GetString(GL_VERSION);
521- if (!version) return 0;
547+ if (!version)
548+ return 0;
522549 for (i = 0; kPrefixes[i]; ++i) {
523550 const size_t len = strlen(kPrefixes[i]);
524551 if (strncmp(version, kPrefixes[i], len) == 0) { version += len; break; }
@@ -631,9 +658,11 @@ static int gloam_{{ fs.spec_name }}_find_core_{{ api }}({{ u.ctx_arg(', ') }}EGL
631658 int major = 0, minor = 0;
632659 unsigned short version_value;
633660 const char *version;
634- if (!context->QueryString) return 0;
661+ if (!context->QueryString)
662+ return 0;
635663 version = (const char *)context->QueryString(display, EGL_VERSION);
636- if (!version) return 0;
664+ if (!version)
665+ return 0;
637666 GLOAM_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
638667 version_value = (unsigned short)((major << 8) | minor);
639668{% for feat in fs .features | selectattr ("api" , "equalto" , api ) %}
@@ -656,10 +685,12 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}GloamLoadFunc g
656685 /* Bootstrap: glGetString must be loaded before find_core can run. */
657686{% - for cmd in fs .commands %}{% if cmd .name == "glGetString" %}
658687 context->{{ cmd.short_name }} = ({{ cmd.pfn_type }})getProcAddr("glGetString");
659- if (!context->{{ cmd.short_name }}) return 0;
688+ if (!context->{{ cmd.short_name }})
689+ return 0;
660690{% endif %}{% - endfor %}
661691 version = gloam_{{ fs.spec_name }}_find_core_{{ api }}(context);
662- if (!version) return 0;
692+ if (!version)
693+ return 0;
663694
664695 /* Load PFNs for each enabled feature via the range table. */
665696 for (i = 0; i < GLOAM_ARRAYSIZE(kFeatPfnRanges_{{ fs.spec_name | spec_display }}); ++i) {
@@ -668,7 +699,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}GloamLoadFunc g
668699 gloam_load_pfn_range_{{ fs.spec_name }}(context, getProcAddr, r->start, r->count);
669700 }
670701{% if fs .extensions | length > 0 and subset | length > 0 %}
671- if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context)) return 0;
702+ if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context))
703+ return 0;
672704
673705 /* Load PFNs for each detected extension via the range table. */
674706 for (i = 0; i < GLOAM_ARRAYSIZE(kExtPfnRanges_{{ api }}); ++i) {
@@ -699,7 +731,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDisplay disp
699731 context->{{ cmd.short_name }} = ({{ cmd.pfn_type }})getProcAddr("{{ cmd.name }}");
700732{% endif %}{% - endfor %}
701733 version = gloam_{{ fs.spec_name }}_find_core_{{ api }}(context, display);
702- if (!version) return 0;
734+ if (!version)
735+ return 0;
703736
704737 /* Load PFNs for each enabled feature via the range table. */
705738 for (i = 0; i < GLOAM_ARRAYSIZE(kFeatPfnRanges_{{ fs.spec_name | spec_display }}); ++i) {
@@ -708,7 +741,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDisplay disp
708741 gloam_load_pfn_range_{{ fs.spec_name }}(context, getProcAddr, r->start, r->count);
709742 }
710743{% if fs .extensions | length > 0 and subset | length > 0 %}
711- if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, display)) return 0;
744+ if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, display))
745+ return 0;
712746
713747 for (i = 0; i < GLOAM_ARRAYSIZE(kExtPfnRanges_{{ api }}); ++i) {
714748 const GloamPfnRange_t *r = &kExtPfnRanges_{{ api }}[i];
@@ -734,7 +768,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}Display *displa
734768 context->{{ cmd.short_name }} = ({{ cmd.pfn_type }})getProcAddr("{{ cmd.name }}");
735769{% endif %}{% - endfor %}
736770 version = gloam_{{ fs.spec_name }}_find_core_{{ api }}(context, &display, &screen);
737- if (!version) return 0;
771+ if (!version)
772+ return 0;
738773
739774 /* Load all PFNs upfront. */
740775 for (i = 0; i < kFnCount_{{ fs.spec_name | spec_display }}; ++i)
@@ -749,7 +784,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}Display *displa
749784 if (ok) context->featArray[r->extension] = 1;
750785 }
751786{% if fs .extensions | length > 0 and subset | length > 0 %}
752- if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, display, screen)) return 0;
787+ if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, display, screen))
788+ return 0;
753789
754790 for (i = 0; i < GLOAM_ARRAYSIZE(kExtPfnRanges_{{ api }}); ++i) {
755791 const GloamPfnRange_t *r = &kExtPfnRanges_{{ api }}[i];
@@ -782,7 +818,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc, GloamL
782818{% - endfor %}
783819
784820 version = gloam_{{ fs.spec_name }}_find_core_{{ api }}(context);
785- if (!version) return 0;
821+ if (!version)
822+ return 0;
786823
787824 /* Load all PFNs upfront. */
788825 for (i = 0; i < kFnCount_{{ fs.spec_name | spec_display }}; ++i)
@@ -798,7 +835,8 @@ int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc, GloamL
798835 }
799836
800837{% if fs .extensions | length > 0 and subset | length > 0 %}
801- if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, hdc)) return 0;
838+ if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, hdc))
839+ return 0;
802840
803841 for (i = 0; i < GLOAM_ARRAYSIZE(kExtPfnRanges_{{ api }}); ++i) {
804842 const GloamPfnRange_t *r = &kExtPfnRanges_{{ api }}[i];
@@ -854,7 +892,8 @@ int gloamLoadVulkanContextUserPtr({{ u.ctx_arg(', ') }}VkInstance instance,
854892#endif
855893
856894 version = gloam_vk_find_core(context, physical_device);
857- if (!version) return 0;
895+ if (!version)
896+ return 0;
858897
859898 /* Load PFNs for every enabled feature via the range table. */
860899 for (i = 0; i < GLOAM_ARRAYSIZE(kFeatPfnRanges_{{ fs.spec_name | spec_display }}); ++i) {
@@ -863,7 +902,8 @@ int gloamLoadVulkanContextUserPtr({{ u.ctx_arg(', ') }}VkInstance instance,
863902 gloam_load_pfn_range_{{ fs.spec_name }}(context, load, userptr, r->start, r->count);
864903 }
865904{% if fs .extensions | length > 0 and subset | length > 0 %}
866- if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, physical_device)) return 0;
905+ if (!gloam_{{ fs.spec_name }}_find_extensions_{{ api }}(context, physical_device))
906+ return 0;
867907
868908 for (i = 0; i < GLOAM_ARRAYSIZE(kExtPfnRanges_{{ api }}); ++i) {
869909 const GloamPfnRange_t *r = &kExtPfnRanges_{{ api }}[i];
0 commit comments