LCOV - code coverage report
Current view: top level - modules - cairo-private.h (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 68.0 % 25 17
Test Date: 2024-04-20 17:42:51 Functions: 73.3 % 15 11
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
       2                 :             : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       3                 :             : // SPDX-FileCopyrightText: 2010 litl, LLC.
       4                 :             : // SPDX-FileCopyrightText: 2020 Philip Chimento <philip.chimento@gmail.com>
       5                 :             : 
       6                 :             : #ifndef MODULES_CAIRO_PRIVATE_H_
       7                 :             : #define MODULES_CAIRO_PRIVATE_H_
       8                 :             : 
       9                 :             : #include <config.h>
      10                 :             : 
      11                 :             : #include <cairo-features.h>  // for CAIRO_HAS_PDF_SURFACE, CAIRO_HAS_PS_SURFACE
      12                 :             : #include <cairo-gobject.h>
      13                 :             : #include <cairo.h>
      14                 :             : #include <glib-object.h>
      15                 :             : 
      16                 :             : #include <js/Class.h>
      17                 :             : #include <js/PropertySpec.h>
      18                 :             : #include <js/TypeDecls.h>
      19                 :             : #include <jspubtd.h>  // for JSProtoKey
      20                 :             : 
      21                 :             : #include "gi/cwrapper.h"
      22                 :             : #include "gjs/global.h"
      23                 :             : #include "gjs/macros.h"
      24                 :             : #include "util/log.h"
      25                 :             : 
      26                 :             : namespace JS {
      27                 :             : class CallArgs;
      28                 :             : }
      29                 :             : 
      30                 :             : GJS_JSAPI_RETURN_CONVENTION
      31                 :             : bool             gjs_cairo_check_status                 (JSContext       *context,
      32                 :             :                                                          cairo_status_t   status,
      33                 :             :                                                          const char      *name);
      34                 :             : 
      35                 :             : class CairoRegion : public CWrapper<CairoRegion, cairo_region_t> {
      36                 :             :     friend CWrapperPointerOps<CairoRegion, cairo_region_t>;
      37                 :             :     friend CWrapper<CairoRegion, cairo_region_t>;
      38                 :             : 
      39                 :             :     CairoRegion() = delete;
      40                 :             :     CairoRegion(CairoRegion&) = delete;
      41                 :             :     CairoRegion(CairoRegion&&) = delete;
      42                 :             : 
      43                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
      44                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_region;
      45                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
      46                 :             :     static constexpr unsigned constructor_nargs = 0;
      47                 :             : 
      48                 :           2 :     static GType gtype() { return CAIRO_GOBJECT_TYPE_REGION; }
      49                 :             : 
      50                 :           0 :     static cairo_region_t* copy_ptr(cairo_region_t* region) {
      51                 :           0 :         return cairo_region_reference(region);
      52                 :             :     }
      53                 :             : 
      54                 :             :     GJS_JSAPI_RETURN_CONVENTION
      55                 :             :     static cairo_region_t* constructor_impl(JSContext* cx,
      56                 :             :                                             const JS::CallArgs& args);
      57                 :             : 
      58                 :             :     static void finalize_impl(JS::GCContext*, cairo_region_t* cr);
      59                 :             : 
      60                 :             :     static const JSFunctionSpec proto_funcs[];
      61                 :             :     static const JSPropertySpec proto_props[];
      62                 :             :     static constexpr js::ClassSpec class_spec = {
      63                 :             :         nullptr,  // createConstructor
      64                 :             :         nullptr,  // createPrototype
      65                 :             :         nullptr,  // constructorFunctions
      66                 :             :         nullptr,  // constructorProperties
      67                 :             :         CairoRegion::proto_funcs,
      68                 :             :         CairoRegion::proto_props,
      69                 :             :         CairoRegion::define_gtype_prop,
      70                 :             :     };
      71                 :             :     static constexpr JSClass klass = {
      72                 :             :         "Region", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
      73                 :             :         &CairoRegion::class_ops, &CairoRegion::class_spec};
      74                 :             : };
      75                 :             : 
      76                 :             : void gjs_cairo_region_init(void);
      77                 :             : 
      78                 :             : class CairoContext : public CWrapper<CairoContext, cairo_t> {
      79                 :             :     friend CWrapperPointerOps<CairoContext, cairo_t>;
      80                 :             :     friend CWrapper<CairoContext, cairo_t>;
      81                 :             : 
      82                 :             :     CairoContext() = delete;
      83                 :             :     CairoContext(CairoContext&) = delete;
      84                 :             :     CairoContext(CairoContext&&) = delete;
      85                 :             : 
      86                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
      87                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_context;
      88                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
      89                 :             :     static constexpr unsigned constructor_nargs = 1;
      90                 :             : 
      91                 :           2 :     static GType gtype() { return CAIRO_GOBJECT_TYPE_CONTEXT; }
      92                 :             : 
      93                 :           3 :     static cairo_t* copy_ptr(cairo_t* cr) { return cairo_reference(cr); }
      94                 :             : 
      95                 :             :     GJS_JSAPI_RETURN_CONVENTION
      96                 :             :     static cairo_t* constructor_impl(JSContext* cx, const JS::CallArgs& args);
      97                 :             : 
      98                 :             :     static void finalize_impl(JS::GCContext*, cairo_t* cr);
      99                 :             : 
     100                 :             :     static const JSFunctionSpec proto_funcs[];
     101                 :             :     static const JSPropertySpec proto_props[];
     102                 :             :     static constexpr js::ClassSpec class_spec = {
     103                 :             :         nullptr,  // createConstructor
     104                 :             :         nullptr,  // createPrototype
     105                 :             :         nullptr,  // constructorFunctions
     106                 :             :         nullptr,  // constructorProperties
     107                 :             :         CairoContext::proto_funcs,
     108                 :             :         CairoContext::proto_props,
     109                 :             :         CairoContext::define_gtype_prop,
     110                 :             :     };
     111                 :             :     static constexpr JSClass klass = {
     112                 :             :         "Context", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     113                 :             :         &CairoContext::class_ops, &CairoContext::class_spec};
     114                 :             : 
     115                 :             :     GJS_JSAPI_RETURN_CONVENTION
     116                 :             :     static bool dispose(JSContext* cx, unsigned argc, JS::Value* vp);
     117                 :             : };
     118                 :             : 
     119                 :             : void gjs_cairo_context_init(void);
     120                 :             : void gjs_cairo_surface_init(void);
     121                 :             : 
     122                 :             : /* path */
     123                 :             : 
     124                 :             : class CairoPath : public CWrapper<CairoPath, cairo_path_t> {
     125                 :             :     friend CWrapperPointerOps<CairoPath, cairo_path_t>;
     126                 :             :     friend CWrapper<CairoPath, cairo_path_t>;
     127                 :             : 
     128                 :             :     CairoPath() = delete;
     129                 :             :     CairoPath(CairoPath&) = delete;
     130                 :             :     CairoPath(CairoPath&&) = delete;
     131                 :             : 
     132                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     133                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_path;
     134                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     135                 :             : 
     136                 :             :     static void finalize_impl(JS::GCContext*, cairo_path_t* path);
     137                 :             : 
     138                 :             :     static const JSPropertySpec proto_props[];
     139                 :             :     static constexpr js::ClassSpec class_spec = {
     140                 :             :         CairoPath::create_abstract_constructor,
     141                 :             :         nullptr,  // createPrototype
     142                 :             :         nullptr,  // constructorFunctions
     143                 :             :         nullptr,  // constructorProperties
     144                 :             :         nullptr,  // prototypeFunctions
     145                 :             :         CairoPath::proto_props,
     146                 :             :         nullptr,  // finishInit
     147                 :             :     };
     148                 :             :     static constexpr JSClass klass = {
     149                 :             :         "Path", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     150                 :             :         &CairoPath::class_ops, &CairoPath::class_spec};
     151                 :             : 
     152                 :             :  public:
     153                 :             :     GJS_JSAPI_RETURN_CONVENTION
     154                 :             :     static JSObject* take_c_ptr(JSContext* cx, cairo_path_t* ptr);
     155                 :             : };
     156                 :             : 
     157                 :             : /* surface */
     158                 :             : 
     159                 :             : class CairoSurface : public CWrapper<CairoSurface, cairo_surface_t> {
     160                 :             :     friend CWrapperPointerOps<CairoSurface, cairo_surface_t>;
     161                 :             :     friend CWrapper<CairoSurface, cairo_surface_t>;
     162                 :             :     friend class CairoImageSurface;  // "inherits" from CairoSurface
     163                 :             :     friend class CairoPSSurface;
     164                 :             :     friend class CairoPDFSurface;
     165                 :             :     friend class CairoSVGSurface;
     166                 :             : 
     167                 :             :     CairoSurface() = delete;
     168                 :             :     CairoSurface(CairoSurface&) = delete;
     169                 :             :     CairoSurface(CairoSurface&&) = delete;
     170                 :             : 
     171                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     172                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_surface;
     173                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     174                 :             : 
     175                 :          10 :     static GType gtype() { return CAIRO_GOBJECT_TYPE_SURFACE; }
     176                 :             : 
     177                 :             :     static void finalize_impl(JS::GCContext*, cairo_surface_t* surface);
     178                 :             : 
     179                 :             :     static const JSFunctionSpec proto_funcs[];
     180                 :             :     static const JSPropertySpec proto_props[];
     181                 :             :     static constexpr js::ClassSpec class_spec = {
     182                 :             :         &CairoSurface::create_abstract_constructor,
     183                 :             :         nullptr,  // createPrototype
     184                 :             :         nullptr,  // constructorFunctions
     185                 :             :         nullptr,  // constructorProperties
     186                 :             :         CairoSurface::proto_funcs,
     187                 :             :         CairoSurface::proto_props,
     188                 :             :         &CairoSurface::define_gtype_prop,
     189                 :             :     };
     190                 :             :     static constexpr JSClass klass = {
     191                 :             :         "Surface", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     192                 :             :         &CairoSurface::class_ops, &CairoSurface::class_spec};
     193                 :             : 
     194                 :           1 :     static cairo_surface_t* copy_ptr(cairo_surface_t* surface) {
     195                 :           1 :         return cairo_surface_reference(surface);
     196                 :             :     }
     197                 :             : 
     198                 :             :     GJS_JSAPI_RETURN_CONVENTION
     199                 :             :     static bool getType_func(JSContext* context, unsigned argc, JS::Value* vp);
     200                 :             : 
     201                 :             :  public:
     202                 :             :     GJS_JSAPI_RETURN_CONVENTION
     203                 :             :     static JSObject* from_c_ptr(JSContext* cx, cairo_surface_t* surface);
     204                 :             : 
     205                 :             :     GJS_JSAPI_RETURN_CONVENTION
     206                 :             :     static cairo_surface_t* for_js(JSContext* cx,
     207                 :             :                                    JS::HandleObject surface_wrapper);
     208                 :             : };
     209                 :             : 
     210                 :             : class CairoImageSurface : public CWrapper<CairoImageSurface, cairo_surface_t> {
     211                 :             :     friend CWrapperPointerOps<CairoImageSurface, cairo_surface_t>;
     212                 :             :     friend CWrapper<CairoImageSurface, cairo_surface_t>;
     213                 :             : 
     214                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     215                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_image_surface;
     216                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     217                 :             :     static constexpr unsigned constructor_nargs = 3;
     218                 :             : 
     219                 :             :     GJS_JSAPI_RETURN_CONVENTION
     220                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     221                 :             : 
     222                 :             :     static const JSFunctionSpec static_funcs[];
     223                 :             :     static const JSFunctionSpec proto_funcs[];
     224                 :             :     static const JSPropertySpec proto_props[];
     225                 :             :     static constexpr js::ClassSpec class_spec = {
     226                 :             :         nullptr,  // createConstructor,
     227                 :             :         &CairoImageSurface::new_proto,
     228                 :             :         CairoImageSurface::static_funcs,
     229                 :             :         nullptr,  // constructorProperties
     230                 :             :         CairoImageSurface::proto_funcs,
     231                 :             :         CairoImageSurface::proto_props,
     232                 :             :         &CairoSurface::define_gtype_prop,
     233                 :             :     };
     234                 :             :     static constexpr JSClass klass = {
     235                 :             :         "ImageSurface",
     236                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     237                 :             :         &CairoSurface::class_ops, &CairoImageSurface::class_spec};
     238                 :             : 
     239                 :           5 :     static cairo_surface_t* copy_ptr(cairo_surface_t* surface) {
     240                 :           5 :         return cairo_surface_reference(surface);
     241                 :             :     }
     242                 :             : 
     243                 :             :     static void finalize_impl(JS::GCContext*, cairo_surface_t*) {}
     244                 :             : 
     245                 :             :     GJS_JSAPI_RETURN_CONVENTION
     246                 :             :     static cairo_surface_t* constructor_impl(JSContext* cx,
     247                 :             :                                              const JS::CallArgs& args);
     248                 :             : };
     249                 :             : 
     250                 :             : #ifdef CAIRO_HAS_PS_SURFACE
     251                 :             : class CairoPSSurface : public CWrapper<CairoPSSurface, cairo_surface_t> {
     252                 :             :     friend CWrapperPointerOps<CairoPSSurface, cairo_surface_t>;
     253                 :             :     friend CWrapper<CairoPSSurface, cairo_surface_t>;
     254                 :             : 
     255                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     256                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_ps_surface;
     257                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     258                 :             :     static constexpr unsigned constructor_nargs = 3;
     259                 :             : 
     260                 :             :     GJS_JSAPI_RETURN_CONVENTION
     261                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     262                 :             : 
     263                 :             :     static const JSFunctionSpec proto_funcs[];
     264                 :             :     static const JSPropertySpec proto_props[];
     265                 :             :     static constexpr js::ClassSpec class_spec = {
     266                 :             :         nullptr,  // createConstructor,
     267                 :             :         &CairoPSSurface::new_proto,
     268                 :             :         nullptr,  // constructorFunctions
     269                 :             :         nullptr,  // constructorProperties
     270                 :             :         CairoPSSurface::proto_funcs,
     271                 :             :         CairoPSSurface::proto_props,
     272                 :             :         &CairoSurface::define_gtype_prop,
     273                 :             :     };
     274                 :             :     static constexpr JSClass klass = {
     275                 :             :         "PSSurface",
     276                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     277                 :             :         &CairoSurface::class_ops, &CairoPSSurface::class_spec};
     278                 :             : 
     279                 :           0 :     static cairo_surface_t* copy_ptr(cairo_surface_t* surface) {
     280                 :           0 :         return cairo_surface_reference(surface);
     281                 :             :     }
     282                 :             : 
     283                 :             :     static void finalize_impl(JS::GCContext*, cairo_surface_t*) {}
     284                 :             : 
     285                 :             :     GJS_JSAPI_RETURN_CONVENTION
     286                 :             :     static cairo_surface_t* constructor_impl(JSContext* cx,
     287                 :             :                                              const JS::CallArgs& args);
     288                 :             : };
     289                 :             : #else
     290                 :             : class CairoPSSurface {
     291                 :             :     GJS_JSAPI_RETURN_CONVENTION
     292                 :             :     static JSObject* from_c_ptr(JSContext* cx, cairo_surface_t* surface);
     293                 :             : };
     294                 :             : #endif  // CAIRO_HAS_PS_SURFACE
     295                 :             : 
     296                 :             : #ifdef CAIRO_HAS_PDF_SURFACE
     297                 :             : class CairoPDFSurface : public CWrapper<CairoPDFSurface, cairo_surface_t> {
     298                 :             :     friend CWrapperPointerOps<CairoPDFSurface, cairo_surface_t>;
     299                 :             :     friend CWrapper<CairoPDFSurface, cairo_surface_t>;
     300                 :             : 
     301                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     302                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_pdf_surface;
     303                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     304                 :             :     static constexpr unsigned constructor_nargs = 3;
     305                 :             : 
     306                 :             :     GJS_JSAPI_RETURN_CONVENTION
     307                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     308                 :             : 
     309                 :             :     static const JSFunctionSpec proto_funcs[];
     310                 :             :     static const JSPropertySpec proto_props[];
     311                 :             :     static constexpr js::ClassSpec class_spec = {
     312                 :             :         nullptr,  // createConstructor,
     313                 :             :         &CairoPDFSurface::new_proto,
     314                 :             :         nullptr,  // constructorFunctions
     315                 :             :         nullptr,  // constructorProperties
     316                 :             :         CairoSurface::proto_funcs,
     317                 :             :         CairoSurface::proto_props,
     318                 :             :         &CairoSurface::define_gtype_prop,
     319                 :             :     };
     320                 :             :     static constexpr JSClass klass = {
     321                 :             :         "PDFSurface",
     322                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     323                 :             :         &CairoSurface::class_ops, &CairoPDFSurface::class_spec};
     324                 :             : 
     325                 :           0 :     static cairo_surface_t* copy_ptr(cairo_surface_t* surface) {
     326                 :           0 :         return cairo_surface_reference(surface);
     327                 :             :     }
     328                 :             : 
     329                 :             :     static void finalize_impl(JS::GCContext*, cairo_surface_t*) {}
     330                 :             : 
     331                 :             :     GJS_JSAPI_RETURN_CONVENTION
     332                 :             :     static cairo_surface_t* constructor_impl(JSContext* cx,
     333                 :             :                                              const JS::CallArgs& args);
     334                 :             : };
     335                 :             : #else
     336                 :             : class CairoPDFSurface {
     337                 :             :  public:
     338                 :             :     GJS_JSAPI_RETURN_CONVENTION
     339                 :             :     static JSObject* from_c_ptr(JSContext* cx, cairo_surface_t* surface);
     340                 :             : };
     341                 :             : #endif  // CAIRO_HAS_PDF_SURFACE
     342                 :             : 
     343                 :             : #ifdef CAIRO_HAS_SVG_SURFACE
     344                 :             : class CairoSVGSurface : public CWrapper<CairoSVGSurface, cairo_surface_t> {
     345                 :             :     friend CWrapperPointerOps<CairoSVGSurface, cairo_surface_t>;
     346                 :             :     friend CWrapper<CairoSVGSurface, cairo_surface_t>;
     347                 :             : 
     348                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     349                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_svg_surface;
     350                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     351                 :             :     static constexpr unsigned constructor_nargs = 3;
     352                 :             : 
     353                 :             :     GJS_JSAPI_RETURN_CONVENTION
     354                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     355                 :             : 
     356                 :             :     static const JSPropertySpec proto_props[];
     357                 :             :     static constexpr js::ClassSpec class_spec = {
     358                 :             :         nullptr,  // createConstructor,
     359                 :             :         &CairoSVGSurface::new_proto,
     360                 :             :         nullptr,  // constructorFunctions
     361                 :             :         nullptr,  // constructorProperties
     362                 :             :         nullptr,  // prototypeFunctions
     363                 :             :         CairoSVGSurface::proto_props,
     364                 :             :         &CairoSurface::define_gtype_prop,
     365                 :             :     };
     366                 :             :     static constexpr JSClass klass = {
     367                 :             :         "SVGSurface",
     368                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     369                 :             :         &CairoSurface::class_ops, &CairoSVGSurface::class_spec};
     370                 :             : 
     371                 :           0 :     static cairo_surface_t* copy_ptr(cairo_surface_t* surface) {
     372                 :           0 :         return cairo_surface_reference(surface);
     373                 :             :     }
     374                 :             : 
     375                 :             :     static void finalize_impl(JS::GCContext*, cairo_surface_t*) {}
     376                 :             : 
     377                 :             :     GJS_JSAPI_RETURN_CONVENTION
     378                 :             :     static cairo_surface_t* constructor_impl(JSContext* cx,
     379                 :             :                                              const JS::CallArgs& args);
     380                 :             : };
     381                 :             : #else
     382                 :             : class CairoSVGSurface {
     383                 :             :  public:
     384                 :             :     GJS_JSAPI_RETURN_CONVENTION
     385                 :             :     static JSObject* from_c_ptr(JSContext* cx, cairo_surface_t* surface);
     386                 :             : };
     387                 :             : #endif  // CAIRO_HAS_SVG_SURFACE
     388                 :             : 
     389                 :             : /* pattern */
     390                 :             : 
     391                 :             : class CairoPattern : public CWrapper<CairoPattern, cairo_pattern_t> {
     392                 :             :     friend CWrapperPointerOps<CairoPattern, cairo_pattern_t>;
     393                 :             :     friend CWrapper<CairoPattern, cairo_pattern_t>;
     394                 :             :     friend class CairoGradient;  // "inherits" from CairoPattern
     395                 :             :     friend class CairoLinearGradient;
     396                 :             :     friend class CairoRadialGradient;
     397                 :             :     friend class CairoSurfacePattern;
     398                 :             :     friend class CairoSolidPattern;
     399                 :             : 
     400                 :             :     CairoPattern() = delete;
     401                 :             :     CairoPattern(CairoPattern&) = delete;
     402                 :             :     CairoPattern(CairoPattern&&) = delete;
     403                 :             : 
     404                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     405                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_pattern;
     406                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     407                 :             : 
     408                 :             :     static const JSFunctionSpec proto_funcs[];
     409                 :             :     static const JSPropertySpec proto_props[];
     410                 :             :     static constexpr js::ClassSpec class_spec = {
     411                 :             :         &CairoPattern::create_abstract_constructor,
     412                 :             :         nullptr,  // createPrototype
     413                 :             :         nullptr,  // constructorFunctions
     414                 :             :         nullptr,  // constructorProperties
     415                 :             :         CairoPattern::proto_funcs,
     416                 :             :         CairoPattern::proto_props,
     417                 :             :         &CairoPattern::define_gtype_prop,
     418                 :             :     };
     419                 :             :     static constexpr JSClass klass = {
     420                 :             :         "Pattern", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     421                 :             :         &CairoPattern::class_ops, &CairoPattern::class_spec};
     422                 :             : 
     423                 :          12 :     static GType gtype() { return CAIRO_GOBJECT_TYPE_PATTERN; }
     424                 :             : 
     425                 :             :     static cairo_pattern_t* copy_ptr(cairo_pattern_t* pattern) {
     426                 :             :         return cairo_pattern_reference(pattern);
     427                 :             :     }
     428                 :             : 
     429                 :             :     GJS_JSAPI_RETURN_CONVENTION
     430                 :             :     static bool getType_func(JSContext* context, unsigned argc, JS::Value* vp);
     431                 :             : 
     432                 :             :  protected:
     433                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t* pattern);
     434                 :             : 
     435                 :             :  public:
     436                 :             :     static cairo_pattern_t* for_js(JSContext* cx,
     437                 :             :                                    JS::HandleObject pattern_wrapper);
     438                 :             : };
     439                 :             : 
     440                 :             : GJS_JSAPI_RETURN_CONVENTION
     441                 :             : JSObject*        gjs_cairo_pattern_from_pattern         (JSContext       *context,
     442                 :             :                                                          cairo_pattern_t *pattern);
     443                 :             : 
     444                 :             : class CairoGradient : public CWrapper<CairoGradient, cairo_pattern_t> {
     445                 :             :     friend CWrapperPointerOps<CairoGradient, cairo_pattern_t>;
     446                 :             :     friend CWrapper<CairoGradient, cairo_pattern_t>;
     447                 :             :     friend class CairoLinearGradient;  // "inherits" from CairoGradient
     448                 :             :     friend class CairoRadialGradient;
     449                 :             : 
     450                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     451                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_gradient;
     452                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     453                 :             : 
     454                 :             :     GJS_JSAPI_RETURN_CONVENTION
     455                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     456                 :             : 
     457                 :             :     static const JSFunctionSpec proto_funcs[];
     458                 :             :     static const JSPropertySpec proto_props[];
     459                 :             :     static constexpr js::ClassSpec class_spec = {
     460                 :             :         &CairoGradient::create_abstract_constructor,
     461                 :             :         &CairoGradient::new_proto,
     462                 :             :         nullptr,  // constructorFunctions
     463                 :             :         nullptr,  // constructorProperties
     464                 :             :         CairoGradient::proto_funcs,
     465                 :             :         CairoGradient::proto_props,
     466                 :             :         &CairoPattern::define_gtype_prop,
     467                 :             :     };
     468                 :             :     static constexpr JSClass klass = {
     469                 :             :         "Gradient", JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     470                 :             :         &CairoPattern::class_ops, &CairoGradient::class_spec};
     471                 :             : 
     472                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t*) {}
     473                 :             : };
     474                 :             : 
     475                 :             : class CairoLinearGradient
     476                 :             :     : public CWrapper<CairoLinearGradient, cairo_pattern_t> {
     477                 :             :     friend CWrapperPointerOps<CairoLinearGradient, cairo_pattern_t>;
     478                 :             :     friend CWrapper<CairoLinearGradient, cairo_pattern_t>;
     479                 :             : 
     480                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     481                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_linear_gradient;
     482                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     483                 :             :     static constexpr unsigned constructor_nargs = 4;
     484                 :             : 
     485                 :             :     GJS_JSAPI_RETURN_CONVENTION
     486                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     487                 :             : 
     488                 :             :     static const JSFunctionSpec proto_funcs[];
     489                 :             :     static const JSPropertySpec proto_props[];
     490                 :             :     static constexpr js::ClassSpec class_spec = {
     491                 :             :         nullptr,  // createConstructor
     492                 :             :         &CairoLinearGradient::new_proto,
     493                 :             :         nullptr,  // constructorFunctions
     494                 :             :         nullptr,  // constructorProperties
     495                 :             :         CairoLinearGradient::proto_funcs,
     496                 :             :         CairoLinearGradient::proto_props,
     497                 :             :         &CairoPattern::define_gtype_prop,
     498                 :             :     };
     499                 :             :     static constexpr JSClass klass = {
     500                 :             :         "LinearGradient",
     501                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     502                 :             :         &CairoPattern::class_ops, &CairoLinearGradient::class_spec};
     503                 :             : 
     504                 :           1 :     static cairo_pattern_t* copy_ptr(cairo_pattern_t* pattern) {
     505                 :           1 :         return cairo_pattern_reference(pattern);
     506                 :             :     }
     507                 :             : 
     508                 :             :     GJS_JSAPI_RETURN_CONVENTION
     509                 :             :     static cairo_pattern_t* constructor_impl(JSContext* cx,
     510                 :             :                                              const JS::CallArgs& args);
     511                 :             : 
     512                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t*) {}
     513                 :             : };
     514                 :             : 
     515                 :             : class CairoRadialGradient
     516                 :             :     : public CWrapper<CairoRadialGradient, cairo_pattern_t> {
     517                 :             :     friend CWrapperPointerOps<CairoRadialGradient, cairo_pattern_t>;
     518                 :             :     friend CWrapper<CairoRadialGradient, cairo_pattern_t>;
     519                 :             : 
     520                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     521                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_radial_gradient;
     522                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     523                 :             :     static constexpr unsigned constructor_nargs = 6;
     524                 :             : 
     525                 :             :     GJS_JSAPI_RETURN_CONVENTION
     526                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     527                 :             : 
     528                 :             :     static const JSFunctionSpec proto_funcs[];
     529                 :             :     static const JSPropertySpec proto_props[];
     530                 :             :     static constexpr js::ClassSpec class_spec = {
     531                 :             :         nullptr,  // createConstructor
     532                 :             :         &CairoRadialGradient::new_proto,
     533                 :             :         nullptr,  // constructorFunctions
     534                 :             :         nullptr,  // constructorProperties
     535                 :             :         CairoRadialGradient::proto_funcs,
     536                 :             :         CairoRadialGradient::proto_props,
     537                 :             :         &CairoPattern::define_gtype_prop,
     538                 :             :     };
     539                 :             :     static constexpr JSClass klass = {
     540                 :             :         "RadialGradient",
     541                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     542                 :             :         &CairoPattern::class_ops, &CairoRadialGradient::class_spec};
     543                 :             : 
     544                 :           1 :     static cairo_pattern_t* copy_ptr(cairo_pattern_t* pattern) {
     545                 :           1 :         return cairo_pattern_reference(pattern);
     546                 :             :     }
     547                 :             : 
     548                 :             :     GJS_JSAPI_RETURN_CONVENTION
     549                 :             :     static cairo_pattern_t* constructor_impl(JSContext* cx,
     550                 :             :                                              const JS::CallArgs& args);
     551                 :             : 
     552                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t*) {}
     553                 :             : };
     554                 :             : 
     555                 :             : class CairoSurfacePattern
     556                 :             :     : public CWrapper<CairoSurfacePattern, cairo_pattern_t> {
     557                 :             :     friend CWrapperPointerOps<CairoSurfacePattern, cairo_pattern_t>;
     558                 :             :     friend CWrapper<CairoSurfacePattern, cairo_pattern_t>;
     559                 :             : 
     560                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     561                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_surface_pattern;
     562                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     563                 :             :     static constexpr unsigned constructor_nargs = 1;
     564                 :             : 
     565                 :             :     GJS_JSAPI_RETURN_CONVENTION
     566                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     567                 :             : 
     568                 :             :     static const JSFunctionSpec proto_funcs[];
     569                 :             :     static const JSPropertySpec proto_props[];
     570                 :             :     static constexpr js::ClassSpec class_spec = {
     571                 :             :         nullptr,  // createConstructor
     572                 :             :         &CairoSurfacePattern::new_proto,
     573                 :             :         nullptr,  // constructorFunctions
     574                 :             :         nullptr,  // constructorProperties
     575                 :             :         CairoSurfacePattern::proto_funcs,
     576                 :             :         CairoSurfacePattern::proto_props,
     577                 :             :         &CairoPattern::define_gtype_prop,
     578                 :             :     };
     579                 :             :     static constexpr JSClass klass = {
     580                 :             :         "SurfacePattern",
     581                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     582                 :             :         &CairoPattern::class_ops, &CairoSurfacePattern::class_spec};
     583                 :             : 
     584                 :           2 :     static cairo_pattern_t* copy_ptr(cairo_pattern_t* pattern) {
     585                 :           2 :         return cairo_pattern_reference(pattern);
     586                 :             :     }
     587                 :             : 
     588                 :             :     GJS_JSAPI_RETURN_CONVENTION
     589                 :             :     static cairo_pattern_t* constructor_impl(JSContext* cx,
     590                 :             :                                              const JS::CallArgs& args);
     591                 :             : 
     592                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t*) {}
     593                 :             : };
     594                 :             : 
     595                 :             : class CairoSolidPattern : public CWrapper<CairoSolidPattern, cairo_pattern_t> {
     596                 :             :     friend CWrapperPointerOps<CairoSolidPattern, cairo_pattern_t>;
     597                 :             :     friend CWrapper<CairoSolidPattern, cairo_pattern_t>;
     598                 :             : 
     599                 :             :     static constexpr GjsGlobalSlot PROTOTYPE_SLOT =
     600                 :             :         GjsGlobalSlot::PROTOTYPE_cairo_solid_pattern;
     601                 :             :     static constexpr GjsDebugTopic DEBUG_TOPIC = GJS_DEBUG_CAIRO;
     602                 :             : 
     603                 :             :     GJS_JSAPI_RETURN_CONVENTION
     604                 :             :     static JSObject* new_proto(JSContext* cx, JSProtoKey);
     605                 :             : 
     606                 :             :     static const JSFunctionSpec static_funcs[];
     607                 :             :     static const JSPropertySpec proto_props[];
     608                 :             :     static constexpr js::ClassSpec class_spec = {
     609                 :             :         &CairoSolidPattern::create_abstract_constructor,
     610                 :             :         &CairoSolidPattern::new_proto,
     611                 :             :         CairoSolidPattern::static_funcs,
     612                 :             :         nullptr,  // constructorProperties
     613                 :             :         nullptr,  // prototypeFunctions
     614                 :             :         CairoSolidPattern::proto_props,
     615                 :             :         &CairoPattern::define_gtype_prop,
     616                 :             :     };
     617                 :             :     static constexpr JSClass klass = {
     618                 :             :         "SolidPattern",
     619                 :             :         JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_BACKGROUND_FINALIZE,
     620                 :             :         &CairoPattern::class_ops, &CairoSolidPattern::class_spec};
     621                 :             : 
     622                 :           7 :     static cairo_pattern_t* copy_ptr(cairo_pattern_t* pattern) {
     623                 :           7 :         return cairo_pattern_reference(pattern);
     624                 :             :     }
     625                 :             : 
     626                 :             :     static void finalize_impl(JS::GCContext*, cairo_pattern_t*) {}
     627                 :             : };
     628                 :             : 
     629                 :             : #endif  // MODULES_CAIRO_PRIVATE_H_
        

Generated by: LCOV version 2.0-1