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: 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_PS_SURFACE
       9                 :             : #include <cairo.h>
      10                 :             : 
      11                 :             : #include <js/TypeDecls.h>
      12                 :             : 
      13                 :             : #include "gjs/jsapi-util.h"
      14                 :             : 
      15                 :             : #if CAIRO_HAS_PS_SURFACE
      16                 :             : #    include <cairo-ps.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* CairoPSSurface::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* CairoPSSurface::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, "PSSurface", argv, "Fff",
      42                 :             :                              "filename", &filename,
      43                 :             :                              "width", &width,
      44                 :             :                              "height", &height))
      45                 :           0 :         return nullptr;
      46                 :             : 
      47                 :           0 :     surface = cairo_ps_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 CairoPSSurface::proto_props[] = {
      58                 :             :     JS_STRING_SYM_PS(toStringTag, "PSSurface", JSPROP_READONLY),
      59                 :             :     JS_PS_END};
      60                 :             : // clang-format on
      61                 :             : 
      62                 :             : const JSFunctionSpec CairoPSSurface::proto_funcs[] = {
      63                 :             :     // restrictToLevel
      64                 :             :     // getLevels
      65                 :             :     // levelToString
      66                 :             :     // setEPS
      67                 :             :     // getEPS
      68                 :             :     // setSize
      69                 :             :     // dscBeginSetup
      70                 :             :     // dscBeginPageSetup
      71                 :             :     // dscComment
      72                 :             :     JS_FS_END};
      73                 :             : 
      74                 :             : #else
      75                 :             : JSObject* CairoPSSurface::from_c_ptr(JSContext* context,
      76                 :             :                                      cairo_surface_t* surface) {
      77                 :             :     gjs_throw(context,
      78                 :             :         "could not create PS surface, recompile cairo and gjs with "
      79                 :             :         "PS support.");
      80                 :             :     return nullptr;
      81                 :             : }
      82                 :             : #endif /* CAIRO_HAS_PS_SURFACE */
        

Generated by: LCOV version 2.0-1