LCOV - code coverage report
Current view: top level - gjs - atoms.h (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 100.0 % 5 5
Test Date: 2024-04-20 17:42:51 Functions: 100.0 % 4 4
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 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: 2018 Philip Chimento <philip.chimento@gmail.com>
       4                 :             : // SPDX-FileCopyrightText: 2018 Marco Trevisan <marco.trevisan@canonical.com>
       5                 :             : 
       6                 :             : #ifndef GJS_ATOMS_H_
       7                 :             : #define GJS_ATOMS_H_
       8                 :             : 
       9                 :             : #include <config.h>
      10                 :             : 
      11                 :             : #include <js/Id.h>
      12                 :             : #include <js/RootingAPI.h>
      13                 :             : #include <js/TypeDecls.h>
      14                 :             : 
      15                 :             : #include "gjs/macros.h"
      16                 :             : 
      17                 :             : class JSTracer;
      18                 :             : 
      19                 :             : // clang-format off
      20                 :             : #define FOR_EACH_ATOM(macro) \
      21                 :             :     macro(cause, "cause") \
      22                 :             :     macro(code, "code") \
      23                 :             :     macro(column_number, "columnNumber") \
      24                 :             :     macro(connect_after, "connect_after") \
      25                 :             :     macro(constructor, "constructor") \
      26                 :             :     macro(debuggee, "debuggee") \
      27                 :             :     macro(detail, "detail") \
      28                 :             :     macro(emit, "emit") \
      29                 :             :     macro(file, "__file__") \
      30                 :             :     macro(file_name, "fileName") \
      31                 :             :     macro(func, "func") \
      32                 :             :     macro(gc_bytes, "gcBytes") \
      33                 :             :     macro(gi, "gi") \
      34                 :             :     macro(gio, "Gio") \
      35                 :             :     macro(glib, "GLib") \
      36                 :             :     macro(gobject, "GObject") \
      37                 :             :     macro(gtype, "$gtype") \
      38                 :             :     macro(height, "height") \
      39                 :             :     macro(imports, "imports") \
      40                 :             :     macro(importSync, "importSync") \
      41                 :             :     macro(init, "_init") \
      42                 :             :     macro(instance_init, "_instance_init") \
      43                 :             :     macro(interact, "interact") \
      44                 :             :     macro(internal, "internal") \
      45                 :             :     macro(length, "length") \
      46                 :             :     macro(line_number, "lineNumber") \
      47                 :             :     macro(malloc_bytes, "mallocBytes") \
      48                 :             :     macro(message, "message") \
      49                 :             :     macro(module_init, "__init__") \
      50                 :             :     macro(module_name, "__moduleName__") \
      51                 :             :     macro(module_path, "__modulePath__") \
      52                 :             :     macro(name, "name") \
      53                 :             :     macro(new_, "new") \
      54                 :             :     macro(new_internal, "_new_internal") \
      55                 :             :     macro(override, "override") \
      56                 :             :     macro(overrides, "overrides") \
      57                 :             :     macro(param_spec, "ParamSpec") \
      58                 :             :     macro(parent_module, "__parentModule__") \
      59                 :             :     macro(program_args, "programArgs") \
      60                 :             :     macro(program_invocation_name, "programInvocationName") \
      61                 :             :     macro(program_path, "programPath") \
      62                 :             :     macro(prototype, "prototype") \
      63                 :             :     macro(search_path, "searchPath") \
      64                 :             :     macro(signal_id, "signalId") \
      65                 :             :     macro(stack, "stack") \
      66                 :             :     macro(to_string, "toString") \
      67                 :             :     macro(uri, "uri") \
      68                 :             :     macro(url, "url") \
      69                 :             :     macro(value_of, "valueOf") \
      70                 :             :     macro(version, "version") \
      71                 :             :     macro(versions, "versions") \
      72                 :             :     macro(width, "width") \
      73                 :             :     macro(window, "window") \
      74                 :             :     macro(x, "x") \
      75                 :             :     macro(y, "y") \
      76                 :             :     macro(zone, "zone")
      77                 :             : 
      78                 :             : #define FOR_EACH_SYMBOL_ATOM(macro) \
      79                 :             :     macro(gobject_prototype, "__GObject__prototype") \
      80                 :             :     macro(hook_up_vfunc, "__GObject__hook_up_vfunc") \
      81                 :             :     macro(private_ns_marker, "__gjsPrivateNS") \
      82                 :             :     macro(signal_find, "__GObject__signal_find") \
      83                 :             :     macro(signals_block, "__GObject__signals_block") \
      84                 :             :     macro(signals_disconnect, "__GObject__signals_disconnect") \
      85                 :             :     macro(signals_unblock, "__GObject__signals_unblock")
      86                 :             : // clang-format on
      87                 :             : 
      88                 :             : struct GjsAtom {
      89                 :             :     GJS_JSAPI_RETURN_CONVENTION bool init(JSContext* cx, const char* str);
      90                 :             : 
      91                 :             :     /* It's OK to return JS::HandleId here, to avoid an extra root, with the
      92                 :             :      * caveat that you should not use this value after the GjsContext has been
      93                 :             :      * destroyed.*/
      94                 :      119943 :     [[nodiscard]] JS::HandleId operator()() const {
      95                 :      119943 :         return JS::HandleId::fromMarkedLocation(&m_jsid.get());
      96                 :             :     }
      97                 :             : 
      98                 :       20286 :     [[nodiscard]] JS::Heap<jsid>* id() { return &m_jsid; }
      99                 :             : 
     100                 :             :  protected:
     101                 :             :     JS::Heap<jsid> m_jsid;
     102                 :             : };
     103                 :             : 
     104                 :             : struct GjsSymbolAtom : GjsAtom {
     105                 :             :     GJS_JSAPI_RETURN_CONVENTION bool init(JSContext* cx, const char* str);
     106                 :             : };
     107                 :             : 
     108                 :             : class GjsAtoms {
     109                 :             :  public:
     110                 :         241 :     GjsAtoms(void) {}
     111                 :         239 :     ~GjsAtoms(void) {}  // prevents giant destructor from being inlined
     112                 :             :     GJS_JSAPI_RETURN_CONVENTION bool init_atoms(JSContext* cx);
     113                 :             : 
     114                 :             :     void trace(JSTracer* trc);
     115                 :             : 
     116                 :             : #define DECLARE_ATOM_MEMBER(identifier, str) GjsAtom identifier;
     117                 :             : #define DECLARE_SYMBOL_ATOM_MEMBER(identifier, str) GjsSymbolAtom identifier;
     118                 :             :     FOR_EACH_ATOM(DECLARE_ATOM_MEMBER)
     119                 :             :     FOR_EACH_SYMBOL_ATOM(DECLARE_SYMBOL_ATOM_MEMBER)
     120                 :             : #undef DECLARE_ATOM_MEMBER
     121                 :             : #undef DECLARE_SYMBOL_ATOM_MEMBER
     122                 :             : };
     123                 :             : 
     124                 :             : #if !defined(GJS_USE_ATOM_FOREACH) && !defined(USE_UNITY_BUILD)
     125                 :             : #    undef FOR_EACH_ATOM
     126                 :             : #    undef FOR_EACH_SYMBOL_ATOM
     127                 :             : #endif
     128                 :             : 
     129                 :             : #endif  // GJS_ATOMS_H_
        

Generated by: LCOV version 2.0-1