cef icon indicating copy to clipboard operation
cef copied to clipboard

Add void* start support to the CEF translator tool

Open nik-sp opened this issue 1 year ago • 1 comments

In recent pull requests addressing issues #3502 and #3126 within the Chromium Embedded Framework (CEF) project, direct access to binary data through the void* pointer has been added to interfaces such as CefBinaryValue, CefV8Value, and CefSharedMemoryRegion. This direct access to binary data provides a possibility for improved performance and efficiency.

However, the current implementation of CEF translator tool lacks support for void* as a return type. This leads to manual implementation of these new "direct access" methods, which is prone to errors and is susceptible to being overlooked when making code changes or updates to the code generation.

For example, the manual implementation for the void* GetArrayBufferData() method:

void* CEF_CALLBACK v8value_get_array_buffer_data(struct _cef_v8value_t* self) {
  DCHECK(self);
  if (!self) {
    return NULL;
  }

  // Execute
  void* _retval = CefV8ValueCppToC::Get(self)->GetArrayBufferData();

  // Return type: simple_byaddr
  return _retval;
}

This manual implementation is essentially the same as the auto-generated implementation for size_t GetArrayBufferByteLength():

size_t CEF_CALLBACK
v8value_get_array_buffer_byte_length(struct _cef_v8value_t* self) {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  DCHECK(self);
  if (!self) {
    return 0;
  }

  // Execute
  size_t _retval = CefV8ValueCppToC::Get(self)->GetArrayBufferByteLength();

  // Return type: simple
  return _retval;
}

Given the similarity between these manual and auto-generated implementations, it is evident that it is possible to add support for void* to the translator and it is a reasonable and beneficial enhancement. Such support will streamline the codebase, reduce the potential for errors, and ensure that the void* or const void* return types are handled consistently across CEF interfaces.

nik-sp avatar Oct 24 '23 07:10 nik-sp

I encountered the same problem

EndoSakura avatar Mar 04 '24 03:03 EndoSakura