LCOV - code coverage report
Current view: top level - modules - cairo-linear-gradient.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 81.8 % 11 9
Test Date: 2024-04-16 04:37:39 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 50.0 % 4 2

             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/PropertyDescriptor.h>  // for JSPROP_READONLY
      10                 :             : #include <js/PropertySpec.h>
      11                 :             : #include <js/RootingAPI.h>
      12                 :             : #include <js/TypeDecls.h>
      13                 :             : #include <jsapi.h>  // for JS_NewObjectWithGivenProto
      14                 :             : #include <jspubtd.h>  // for JSProtoKey
      15                 :             : 
      16                 :             : #include "gjs/jsapi-util-args.h"
      17                 :             : #include "modules/cairo-private.h"
      18                 :             : 
      19                 :             : namespace JS {
      20                 :             : class CallArgs;
      21                 :             : }
      22                 :             : 
      23                 :           2 : JSObject* CairoLinearGradient::new_proto(JSContext* cx, JSProtoKey) {
      24                 :           2 :     JS::RootedObject parent_proto(cx, CairoGradient::prototype(cx));
      25                 :           2 :     return JS_NewObjectWithGivenProto(cx, nullptr, parent_proto);
      26                 :           2 : }
      27                 :             : 
      28                 :           1 : cairo_pattern_t* CairoLinearGradient::constructor_impl(
      29                 :             :     JSContext* context, const JS::CallArgs& argv) {
      30                 :             :     double x0, y0, x1, y1;
      31                 :             :     cairo_pattern_t* pattern;
      32         [ -  + ]:           1 :     if (!gjs_parse_call_args(context, "LinearGradient", argv, "ffff",
      33                 :             :                              "x0", &x0,
      34                 :             :                              "y0", &y0,
      35                 :             :                              "x1", &x1,
      36                 :             :                              "y1", &y1))
      37                 :           0 :         return nullptr;
      38                 :             : 
      39                 :           1 :     pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
      40                 :             : 
      41         [ -  + ]:           1 :     if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
      42                 :           0 :         return nullptr;
      43                 :             : 
      44                 :           1 :     return pattern;
      45                 :             : }
      46                 :             : 
      47                 :             : const JSPropertySpec CairoLinearGradient::proto_props[] = {
      48                 :             :     JS_STRING_SYM_PS(toStringTag, "LinearGradient", JSPROP_READONLY),
      49                 :             :     JS_PS_END};
      50                 :             : 
      51                 :             : const JSFunctionSpec CairoLinearGradient::proto_funcs[] = {
      52                 :             :     // getLinearPoints
      53                 :             :     JS_FS_END};
        

Generated by: LCOV version 2.0-1