LCOV - code coverage report
Current view: top level - modules - cairo-path.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 80.0 % 15 12
Test Date: 2024-04-20 17:42:51 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50.0 % 6 3

             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 Red Hat, Inc.
       4                 :             : // SPDX-FileCopyrightText: 2020 Philip Chimento <philip.chimento@gmail.com>
       5                 :             : 
       6                 :             : #include <config.h>
       7                 :             : 
       8                 :             : #include <cairo.h>
       9                 :             : 
      10                 :             : #include <js/PropertyDescriptor.h>  // for JSPROP_READONLY
      11                 :             : #include <js/PropertySpec.h>
      12                 :             : #include <js/RootingAPI.h>
      13                 :             : #include <js/TypeDecls.h>
      14                 :             : #include <jsapi.h>  // for JS_NewObjectWithGivenProto
      15                 :             : 
      16                 :             : #include "modules/cairo-private.h"
      17                 :             : 
      18                 :             : // clang-format off
      19                 :             : const JSPropertySpec CairoPath::proto_props[] = {
      20                 :             :     JS_STRING_SYM_PS(toStringTag, "Path", JSPROP_READONLY),
      21                 :             :     JS_PS_END};
      22                 :             : // clang-format on
      23                 :             : 
      24                 :             : /*
      25                 :             :  * CairoPath::take_c_ptr():
      26                 :             :  * Same as CWrapper::from_c_ptr(), but always takes ownership of the pointer
      27                 :             :  * rather than copying it. It's not possible to copy a cairo_path_t*.
      28                 :             :  */
      29                 :           1 : JSObject* CairoPath::take_c_ptr(JSContext* cx, cairo_path_t* ptr) {
      30                 :           1 :     JS::RootedObject proto(cx, CairoPath::prototype(cx));
      31         [ -  + ]:           1 :     if (!proto)
      32                 :           0 :         return nullptr;
      33                 :             : 
      34                 :             :     JS::RootedObject wrapper(
      35                 :           1 :         cx, JS_NewObjectWithGivenProto(cx, &CairoPath::klass, proto));
      36         [ -  + ]:           1 :     if (!wrapper)
      37                 :           0 :         return nullptr;
      38                 :             : 
      39                 :           1 :     CairoPath::init_private(wrapper, ptr);
      40                 :             : 
      41                 :           1 :     debug_lifecycle(ptr, wrapper, "take_c_ptr");
      42                 :             : 
      43                 :           1 :     return wrapper;
      44                 :           1 : }
      45                 :             : 
      46                 :           1 : void CairoPath::finalize_impl(JS::GCContext*, cairo_path_t* path) {
      47         [ -  + ]:           1 :     if (!path)
      48                 :           0 :         return;
      49                 :           1 :     cairo_path_destroy(path);
      50                 :             : }
        

Generated by: LCOV version 2.0-1