Commit Graph

14 Commits

Author SHA1 Message Date
Neil Roberts
185630085c Add -Wmissing-declarations to maintainer flags and fix problems
This option to GCC makes it give a warning whenever a global function
is defined without a declaration. This should catch cases were we've
defined a function but forgot to put it in a header. In that case it
is either only used within one file so we should make it static or we
should declare it in a header.

The following changes where made to fix problems:

• Some functions were made static

• cogl-path.h (the one containing the 1.0 API) was split into two
  files, one defining the functions and one defining the enums so that
  cogl-path.c can include the enum and function declarations from the
  2.0 API as well as the function declarations from the 1.0 API.

• cogl2-clip-state has been removed. This only had one experimental
  function called cogl_clip_push_from_path but as this is unstable we
  might as well remove it favour of the equivalent cogl_framebuffer_*
  API.

• The GLX, SDL and WGL winsys's now have a private header to define
  their get_vtable function instead of directly declaring in the C
  file where it is called.

• All places that were calling COGL_OBJECT_DEFINE need to have the
  cogl_is_whatever function declared so these have been added either
  as a public function or in a private header.

• Some files that were not including the header containing their
  function declarations have been fixed to do so.

• Any unused error quark functions have been removed. If we later want
  them we should add them back one by one and add a declaration for
  them in a header.

• _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and
  made a public function with a declaration in cogl-framebuffer.h

• Similarly for CoglOnscreen.

• cogl_vdraw_indexed_attributes is called
  cogl_framebuffer_vdraw_indexed_attributes in the header. The
  definition has been changed to match the header.

• cogl_index_buffer_allocate has been removed. This had no declaration
  and I'm not sure what it's supposed to do.

• CoglJournal has been changed to use the internal CoglObject macro so
  that it won't define an exported cogl_is_journal symbol.

• The _cogl_blah_pointer_from_handle functions have been removed.
  CoglHandle isn't used much anymore anyway and in the few places
  where it is used I think it's safe to just use the implicit cast
  from void* to the right type.

• The test-utils.h header for the conformance tests explicitly
  disables the -Wmissing-declaration option using a pragma because all
  of the tests declare their main function without a header. Any
  mistakes relating to missing declarations aren't really important
  for the tests.

• cogl_quaternion_init_from_quaternion and init_from_matrix have been
  given declarations in cogl-quaternion.h

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-06 18:45:44 +00:00
Neil Roberts
688a3e196b object: Add a virtual pointer for the unref function
The virtual function gets called in cogl_object_unref. Any definition
of a CoglObject type can replace the default unref function by using
COGL_OBJECT_DEFINE_WITH_CODE to directly manipulate the
CoglObjectClass struct. The generated object constructors set the
pointer to the default implementation. The default implementation is
exported in the private header so that any overriding implementations
can chain up to it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:22:57 +00:00
Neil Roberts
139421de19 object: Remove the type member of CoglObjectClass
Unlike in GObject the type number for a CoglObject is entirely an
internal implementation detail so there is no need to make a GQuark to
make it safe to export out of the library. Instead we can just
directly use a fixed pointer address as the identifier for the type.
This patch makes it use the address of the class struct of the
identifier. This should make it faster to do type checks because it
does not need to call a function every time it wants to get the type
number.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:18:32 +00:00
Neil Roberts
c39333a2c6 object: Reorder the CoglObject members by size
This moves the pointer members of CoglObject to the top and the int
members to the bottom so that there won't be any padding inserted on
64-bit machines. This reduces the size of the struct from 80 bytes to
72.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:18:32 +00:00
Lionel Landwerlin
5dc42284a5 cogl-debug: add instrumentation to track the number of objects
This allows to track the number of objects allocated by Cogl. The
results are displayed on the standard output by calling :

cogl_debug_print_instances ();

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@linux.intel.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-14 12:14:02 +01:00
Robert Bragg
5f35bd7b67 cogl-object: Adds an internal _cogl_object_set_user_data
This adds an internal alternative to cogl_object_set_user_data that also
passes an instance pointer to destroy notify callbacks.

When setting private data on a CoglObject it's often desirable to know
the instance being destroyed when we are being notified to free the
private data due to the object being freed. The typical solution to this
is to track a pointer to the instance in the private data itself so it
can be identified but that usually requires an extra micro allocation
for the private data that could have been avoided if only the callback
were given an instance pointer.

The new internal _cogl_object_set_user_data passes the instance pointer
as a second argument which means it is ABI compatible for us to layer
the public version on top of this internal function.
2011-01-21 16:18:10 +00:00
Neil Roberts
0b2985ad66 cogl-object-private.h: Include cogl-debug.h
If COGL_OBJECT_DEBUG is defined then cogl-object-private.h will call
COGL_NOTE in the ref and unref macros. For this to work the debug
header needs to also be included or COGL_NOTE won't necessarily be
defined.
2010-09-17 17:22:16 +01:00
Neil Roberts
2c8bf00995 Don't define public cogl_is_* functions for internal types
This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
2010-07-09 18:57:54 +01:00
Neil Roberts
b25035ad2d cogl: Don't define the deprecated ref/unref accessors for new types
Previously COGL_OBJECT_DEFINE would always define deprecated
cogl_$type_{ref,unref} functions even if the type is new or if the
type is entirely internal. An application would still find it
difficult to use these because they wouldn't be in the headers, but it
still looks bad that they are exported from the shared library. This
patch changes it so that the deprecated ref counting functions are
defined using a separate macro and only the types that have these
functions in the headers call this macro.
2010-07-09 18:57:54 +01:00
Robert Bragg
51e4245ce1 cogl-object: cogl_is_XYZ prototype should take void *
This changes the cogl_is_XYZ function prototypes generated when using
the COGL_OBJECT_DEFINE macro to take a void * argument instead of a
CoglHandle argument.
2010-07-05 15:47:02 +01:00
Robert Bragg
0b3c45396b cogl-object-private.h: #include glib.h and cogl-types.h
cogl-object-private.h was only working in places that had already
included glib.h and cogl-types.h
2010-07-05 14:51:28 +01:00
Neil Roberts
2f286446af Add COGL_{OBJECT,HANDLE}_DEFINE_WITH_CODE
This macro is similar to COGL_HANDLE_DEFINE_WITH_CODE except that it
allows a snippet of code to be inserted into the _get_type()
function. This is similar to how G_DEFINE_TYPE_WITH_CODE
works. COGL_HANDLE_DEFINE is now just a wrapper around
COGL_HANDLE_DEFINE_WITH_CODE.
2010-06-22 11:47:33 +01:00
Robert Bragg
7dbcb82622 cogl-object-private.h: white space cleanup
simply replaces tabs with spaces
2010-06-04 14:44:15 +01:00
Robert Bragg
5af3ead3a2 CoglObject: Adds cogl_object_{get,set}_user_data
This provides a mechanism for associating private data with any
CoglObject. We expect Clutter will use this to associate weak materials
with normal materials.
2010-06-04 14:44:15 +01:00