LCOV - code coverage report
Current view: top level - modules - cairo-gradient.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 13.3 % 30 4
Test Date: 2024-03-26 02:45:07 Functions: 33.3 % 3 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0.0 % 16 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                 :             : 
       5                 :             : #include <config.h>
       6                 :             : 
       7                 :             : #include <cairo.h>
       8                 :             : 
       9                 :             : #include <js/CallArgs.h>
      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                 :             : #include <jspubtd.h>  // for JSProtoKey
      16                 :             : 
      17                 :             : #include "gjs/jsapi-util-args.h"
      18                 :             : #include "gjs/jsapi-util.h"
      19                 :             : #include "gjs/macros.h"
      20                 :             : #include "modules/cairo-private.h"
      21                 :             : 
      22                 :           2 : JSObject* CairoGradient::new_proto(JSContext* cx, JSProtoKey) {
      23                 :           2 :     JS::RootedObject parent_proto(cx, CairoPattern::prototype(cx));
      24                 :           2 :     return JS_NewObjectWithGivenProto(cx, nullptr, parent_proto);
      25                 :           2 : }
      26                 :             : 
      27                 :             : /* Properties */
      28                 :             : // clang-format off
      29                 :             : const JSPropertySpec CairoGradient::proto_props[] = {
      30                 :             :     JS_STRING_SYM_PS(toStringTag, "Gradient", JSPROP_READONLY),
      31                 :             :     JS_PS_END};
      32                 :             : // clang-format on
      33                 :             : 
      34                 :             : /* Methods */
      35                 :             : 
      36                 :             : GJS_JSAPI_RETURN_CONVENTION
      37                 :             : static bool
      38                 :           0 : addColorStopRGB_func(JSContext *context,
      39                 :             :                      unsigned   argc,
      40                 :             :                      JS::Value *vp)
      41                 :             : {
      42         [ #  # ]:           0 :     GJS_GET_THIS(context, argc, vp, argv, obj);
      43                 :             :     double offset, red, green, blue;
      44                 :             : 
      45         [ #  # ]:           0 :     if (!gjs_parse_call_args(context, "addColorStopRGB", argv, "ffff",
      46                 :             :                              "offset", &offset,
      47                 :             :                              "red", &red,
      48                 :             :                              "green", &green,
      49                 :             :                              "blue", &blue))
      50                 :           0 :         return false;
      51                 :             : 
      52                 :           0 :     cairo_pattern_t* pattern = CairoPattern::for_js(context, obj);
      53         [ #  # ]:           0 :     if (!pattern)
      54                 :           0 :         return false;
      55                 :             : 
      56                 :           0 :     cairo_pattern_add_color_stop_rgb(pattern, offset, red, green, blue);
      57                 :             : 
      58         [ #  # ]:           0 :     if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
      59                 :           0 :         return false;
      60                 :             : 
      61                 :           0 :     argv.rval().setUndefined();
      62                 :           0 :     return true;
      63                 :           0 : }
      64                 :             : 
      65                 :             : GJS_JSAPI_RETURN_CONVENTION
      66                 :             : static bool
      67                 :           0 : addColorStopRGBA_func(JSContext *context,
      68                 :             :                       unsigned   argc,
      69                 :             :                       JS::Value *vp)
      70                 :             : {
      71         [ #  # ]:           0 :     GJS_GET_THIS(context, argc, vp, argv, obj);
      72                 :             :     double offset, red, green, blue, alpha;
      73                 :             : 
      74         [ #  # ]:           0 :     if (!gjs_parse_call_args(context, "addColorStopRGBA", argv, "fffff",
      75                 :             :                              "offset", &offset,
      76                 :             :                              "red", &red,
      77                 :             :                              "green", &green,
      78                 :             :                              "blue", &blue,
      79                 :             :                              "alpha", &alpha))
      80                 :           0 :         return false;
      81                 :             : 
      82                 :           0 :     cairo_pattern_t* pattern = CairoPattern::for_js(context, obj);
      83         [ #  # ]:           0 :     if (!pattern)
      84                 :           0 :         return false;
      85                 :             : 
      86                 :           0 :     cairo_pattern_add_color_stop_rgba(pattern, offset, red, green, blue, alpha);
      87                 :             : 
      88         [ #  # ]:           0 :     if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
      89                 :           0 :         return false;
      90                 :             : 
      91                 :           0 :     argv.rval().setUndefined();
      92                 :           0 :     return true;
      93                 :           0 : }
      94                 :             : 
      95                 :             : const JSFunctionSpec CairoGradient::proto_funcs[] = {
      96                 :             :     JS_FN("addColorStopRGB", addColorStopRGB_func, 0, 0),
      97                 :             :     JS_FN("addColorStopRGBA", addColorStopRGBA_func, 0, 0),
      98                 :             :     // getColorStopRGB
      99                 :             :     // getColorStopRGBA
     100                 :             :     JS_FS_END};
        

Generated by: LCOV version 2.0-1