LCOV - code coverage report
Current view: top level - modules - cairo-ps-surface.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 30.8 % 13 4
Test Date: 2025-01-23 05:25:52 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_PS_SURFACE
       9                 :             : #include <cairo.h>
      10                 :             : 
      11                 :             : #if CAIRO_HAS_PS_SURFACE
      12                 :             : #    include <cairo-ps.h>
      13                 :             : #endif
      14                 :             : 
      15                 :             : #include <js/TypeDecls.h>
      16                 :             : 
      17                 :             : #if CAIRO_HAS_PS_SURFACE
      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/auto.h"
      25                 :             : #    include "gjs/jsapi-util-args.h"
      26                 :             : #    include "modules/cairo-private.h"
      27                 :             : 
      28                 :             : namespace JS {
      29                 :             : class CallArgs;
      30                 :             : }
      31                 :             : 
      32                 :           2 : JSObject* CairoPSSurface::new_proto(JSContext* cx, JSProtoKey) {
      33                 :           2 :     JS::RootedObject parent_proto(cx, CairoSurface::prototype(cx));
      34                 :           2 :     return JS_NewObjectWithGivenProto(cx, nullptr, parent_proto);
      35                 :           2 : }
      36                 :             : 
      37                 :           0 : cairo_surface_t* CairoPSSurface::constructor_impl(JSContext* context,
      38                 :             :                                                   const JS::CallArgs& argv) {
      39                 :           0 :     Gjs::AutoChar filename;
      40                 :             :     double width, height;
      41                 :             :     cairo_surface_t *surface;
      42         [ #  # ]:           0 :     if (!gjs_parse_call_args(context, "PSSurface", argv, "Fff",
      43                 :             :                              "filename", &filename,
      44                 :             :                              "width", &width,
      45                 :             :                              "height", &height))
      46                 :           0 :         return nullptr;
      47                 :             : 
      48                 :           0 :     surface = cairo_ps_surface_create(filename, width, height);
      49                 :             : 
      50         [ #  # ]:           0 :     if (!gjs_cairo_check_status(context, cairo_surface_status(surface),
      51                 :             :                                 "surface"))
      52                 :           0 :         return nullptr;
      53                 :             : 
      54                 :           0 :     return surface;
      55                 :           0 : }
      56                 :             : 
      57                 :             : // clang-format off
      58                 :             : const JSPropertySpec CairoPSSurface::proto_props[] = {
      59                 :             :     JS_STRING_SYM_PS(toStringTag, "PSSurface", JSPROP_READONLY),
      60                 :             :     JS_PS_END};
      61                 :             : // clang-format on
      62                 :             : 
      63                 :             : const JSFunctionSpec CairoPSSurface::proto_funcs[] = {
      64                 :             :     // restrictToLevel
      65                 :             :     // getLevels
      66                 :             :     // levelToString
      67                 :             :     // setEPS
      68                 :             :     // getEPS
      69                 :             :     // setSize
      70                 :             :     // dscBeginSetup
      71                 :             :     // dscBeginPageSetup
      72                 :             :     // dscComment
      73                 :             :     JS_FS_END};
      74                 :             : 
      75                 :             : #else
      76                 :             : JSObject* CairoPSSurface::from_c_ptr(JSContext* context,
      77                 :             :                                      cairo_surface_t* surface) {
      78                 :             :     gjs_throw(context,
      79                 :             :         "could not create PS surface, recompile cairo and gjs with "
      80                 :             :         "PS support.");
      81                 :             :     return nullptr;
      82                 :             : }
      83                 :             : #endif /* CAIRO_HAS_PS_SURFACE */
        

Generated by: LCOV version 2.0-1