static void add_widl_version_define(void) { unsigned int version; const char *p = PACKAGE_VERSION; /* major */ version = atoi(p) * 0x10000; p = strchr(p, '.'); /* minor */ if (p) { version += atoi(p + 1) * 0x100; p = strchr(p + 1, '.'); } /* build */ if (p) version += atoi(p + 1); if (version != 0) { char version_str[11]; snprintf(version_str, sizeof(version_str), "0x%x", version); wpp_add_define("__WIDL__", version_str); } else wpp_add_define("__WIDL__", NULL); }
/* add a command-line define of the form NAME=VALUE */ void wpp_add_cmdline_define( const char *value ) { char *str = pp_xstrdup(value); char *p = strchr( str, '=' ); if (p) *p++ = 0; wpp_add_define( str, p ); free( str ); }
/* add a command-line define of the form NAME=VALUE */ int wpp_add_cmdline_define( const char *value ) { char *p; char *str = pp_xstrdup(value); if(!str) return 1; p = strchr( str, '=' ); if (p) *p++ = 0; wpp_add_define( str, p ); free( str ); return 0; }
static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **error_messages) { int ret; HRESULT hr = S_OK; const D3D_SHADER_MACRO *def = defines; static const struct wpp_callbacks wpp_callbacks = { wpp_lookup_mem, wpp_open_mem, wpp_close_mem, wpp_read_mem, wpp_write_mem, wpp_error, wpp_warning, }; if (def != NULL) { while (def->Name != NULL) { wpp_add_define(def->Name, def->Definition); def++; } } current_include = include; includes_size = 0; wpp_output_size = wpp_output_capacity = 0; wpp_output = NULL; wpp_set_callbacks(&wpp_callbacks); wpp_messages_size = wpp_messages_capacity = 0; wpp_messages = NULL; current_shader.buffer = data; current_shader.size = data_size; initial_filename = filename ? filename : ""; ret = wpp_parse(initial_filename, NULL); if (!wpp_close_output()) ret = 1; if (ret) { TRACE("Error during shader preprocessing\n"); if (wpp_messages) { int size; ID3DBlob *buffer; TRACE("Preprocessor messages:\n%s\n", debugstr_a(wpp_messages)); if (error_messages) { size = strlen(wpp_messages) + 1; hr = D3DCreateBlob(size, &buffer); if (FAILED(hr)) goto cleanup; CopyMemory(ID3D10Blob_GetBufferPointer(buffer), wpp_messages, size); *error_messages = buffer; } } if (data) TRACE("Shader source:\n%s\n", debugstr_an(data, data_size)); hr = E_FAIL; } cleanup: /* Remove the previously added defines */ if (defines != NULL) { while (defines->Name != NULL) { wpp_del_define(defines->Name); defines++; } } HeapFree(GetProcessHeap(), 0, wpp_messages); return hr; }