LCOV - code coverage report
Current view: top level - modules - cairo-svg-surface.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 30.8 % 13 4
Test Date: 2024-03-26 02:45:07 Functions: 50.0 % 2 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0.0 % 4 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                 :             : #include <config.h>
       7                 :             : 
       8                 :             : #include <cairo-features.h>  // for CAIRO_HAS_SVG_SURFACE
       9                 :             : #include <cairo.h>
      10                 :             : 
      11                 :             : #include <js/TypeDecls.h>
      12                 :             : 
      13                 :             : #include "gjs/jsapi-util.h"
      14                 :             : 
      15                 :             : #if CAIRO_HAS_SVG_SURFACE
      16                 :             : #    include <cairo-svg.h>
      17                 :             : 
      18                 :             : #    include <js/PropertyDescriptor.h>  // for JSPROP_READONLY
      19                 :             : #    include <js/PropertySpec.h>
      20                 :             : #    include <js/RootingAPI.h>
      21                 :             : #    include <jsapi.h>  // for JS_NewObjectWithGivenProto
      22                 :             : #    include <jspubtd.h>  // for JSProtoKey
      23                 :             : 
      24                 :             : #    include "gjs/jsapi-util-args.h"
      25                 :             : #    include "modules/cairo-private.h"
      26                 :             : 
      27                 :             : namespace JS {
      28                 :             : class CallArgs;
      29                 :             : }
      30                 :             : 
      31                 :           2 : JSObject* CairoSVGSurface::new_proto(JSContext* cx, JSProtoKey) {
      32                 :           2 :     JS::RootedObject parent_proto(cx, CairoSurface::prototype(cx));
      33                 :           2 :     return JS_NewObjectWithGivenProto(cx, nullptr, parent_proto);
      34                 :           2 : }
      35                 :             : 
      36                 :           0 : cairo_surface_t* CairoSVGSurface::constructor_impl(JSContext* context,
      37                 :             :                                                    const JS::CallArgs& argv) {
      38                 :           0 :     GjsAutoChar filename;
      39                 :             :     double width, height;
      40                 :             :     cairo_surface_t *surface;
      41         [ #  # ]:           0 :     if (!gjs_parse_call_args(context, "SVGSurface", argv, "Fff",
      42                 :             :                              "filename", &filename,
      43                 :             :                              "width", &width,
      44                 :             :                              "height", &height))
      45                 :           0 :         return nullptr;
      46                 :             : 
      47                 :           0 :     surface = cairo_svg_surface_create(filename, width, height);
      48                 :             : 
      49         [ #  # ]:           0 :     if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
      50                 :             :                                 "surface"))
      51                 :           0 :         return nullptr;
      52                 :             : 
      53                 :           0 :     return surface;
      54                 :           0 : }
      55                 :             : 
      56                 :             : // clang-format off
      57                 :             : const JSPropertySpec CairoSVGSurface::proto_props[] = {
      58                 :             :     JS_STRING_SYM_PS(toStringTag, "SVGSurface", JSPROP_READONLY),
      59                 :             :     JS_PS_END};
      60                 :             : // clang-format on
      61                 :             : 
      62                 :             : #else
      63                 :             : JSObject* CairoSVGSurface::from_c_ptr(JSContext* context,
      64                 :             :                                       cairo_surface_t* surface) {
      65                 :             :     gjs_throw(context,
      66                 :             :         "could not create SVG surface, recompile cairo and gjs with "
      67                 :             :         "SVG support.");
      68                 :             :     return nullptr;
      69                 :             : }
      70                 :             : #endif /* CAIRO_HAS_SVG_SURFACE */
        

Generated by: LCOV version 2.0-1