How does this code snippet actually create an object

Link to code: https://github.com/buglloc/brick/blob/master/include/capi/cef_request_context_capi.h


cef_request_context_capi.h
1
2
3
4
5
6
7
8
///
// Creates a new context object with the specified |settings| and optional
// |handler|.
///
CEF_EXPORT cef_request_context_t* cef_request_context_create_context(
    const struct _cef_request_context_settings_t* settings,
struct _cef_request_context_handler_t* handler); 


I am referencing the Above Code in my application. Of course I want to create and use this object with as little overhead as possible. But I am not sure how this piece of code actually creates "a new context object," as the comment states. There are pointers to structs but how or where does the object actually get created?


The above function is implemented below. I could not find a direct implementation of the header file. but the "request_context_ctocpp.h" file overrides the function and includes the "cef_request_context_capi.h" file from above in its own header.

Point being, The implementation has a return value. Does declaring and returning struct actually create an object? Isn't that basically what is happening here. if so, doesn't that blur the line between variable and object?

https://github.com/buglloc/brick/blob/master/libcef_dll/ctocpp/request_context_ctocpp.cc

request_context_ctocpp.cc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CefRefPtr<CefRequestContext> CefRequestContext::CreateContext(
    const CefRequestContextSettings& settings,
    CefRefPtr<CefRequestContextHandler> handler) {
  // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

  // Unverified params: handler

  // Execute
  cef_request_context_t* _retval = cef_request_context_create_context(
      &settings,
      CefRequestContextHandlerCppToC::Wrap(handler));

  // Return type: refptr_same
  return CefRequestContextCToCpp::Wrap(_retval);
}


Many thanks

I am just not sure how the struct is initialized here. I imagine that would technically be an object.
Last edited on
That is because it is a class constructor.
Topic archived. No new replies allowed.