LCOV - code coverage report
Current view: top level - gjs - native.h (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 100.0 % 4 4
Test Date: 2024-03-26 02:45:07 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 75.0 % 4 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: 2008 litl, LLC
       4                 :             : 
       5                 :             : #ifndef GJS_NATIVE_H_
       6                 :             : #define GJS_NATIVE_H_
       7                 :             : 
       8                 :             : #include <config.h>
       9                 :             : #include <string>
      10                 :             : #include <unordered_map>
      11                 :             : 
      12                 :             : #include <js/RootingAPI.h>
      13                 :             : #include <js/TypeDecls.h>
      14                 :             : 
      15                 :             : #include "gjs/macros.h"
      16                 :             : 
      17                 :             : namespace Gjs {
      18                 :             : class NativeModuleDefineFuncs {
      19                 :         103 :     NativeModuleDefineFuncs() {}
      20                 :             :     typedef bool (*GjsDefineModuleFunc)(JSContext* context,
      21                 :             :                                         JS::MutableHandleObject module_out);
      22                 :             : 
      23                 :             :     std::unordered_map<std::string, GjsDefineModuleFunc> m_modules;
      24                 :             : 
      25                 :             :  public:
      26                 :        1620 :     static NativeModuleDefineFuncs& get() {
      27   [ +  +  +  - ]:        1620 :         static NativeModuleDefineFuncs the_singleton;
      28                 :        1620 :         return the_singleton;
      29                 :             :     }
      30                 :             : 
      31                 :             :     /* called on context init */
      32                 :             :     void add(const char* module_id, GjsDefineModuleFunc func);
      33                 :             : 
      34                 :             :     // called by importer.cpp to to check for already loaded modules
      35                 :             :     [[nodiscard]] bool is_registered(const char* name) const;
      36                 :             : 
      37                 :             :     // called by importer.cpp to load a built-in native module
      38                 :             :     GJS_JSAPI_RETURN_CONVENTION
      39                 :             :     bool define(JSContext* cx, const char* name,
      40                 :             :                 JS::MutableHandleObject module_out) const;
      41                 :             : };
      42                 :             : };  // namespace Gjs
      43                 :             : 
      44                 :             : #endif  // GJS_NATIVE_H_
        

Generated by: LCOV version 2.0-1