This file is indexed.

/usr/include/simgear/nasal/cppbind/NasalCallContext.hxx is in libsimgear-dev 3.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
///@file
/// Call context for Nasal extension functions
///
// Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA

#ifndef SG_NASAL_CALL_CONTEXT_HXX_
#define SG_NASAL_CALL_CONTEXT_HXX_

#include "from_nasal.hxx"
#include "to_nasal.hxx"

namespace nasal
{

  /**
   * Context passed to a function/method being called from Nasal
   */
  class CallContext
  {
    public:
      CallContext(naContext c, size_t argc, naRef* args):
        c(c),
        argc(argc),
        args(args)
      {}

      bool isNumeric(size_t index) const
      {
        return (index < argc && naIsNum(args[index]));
      }

      bool isString(size_t index) const
      {
        return (index < argc && naIsString(args[index]));
      }

      bool isHash(size_t index) const
      {
        return (index < argc && naIsHash(args[index]));
      }

      bool isVector(size_t index) const
      {
        return (index < argc && naIsVector(args[index]));
      }

      bool isGhost(size_t index) const
      {
        return (index < argc && naIsGhost(args[index]));
      }

      void popFront(size_t num = 1)
      {
        if( argc < num )
          return;

        args += num;
        argc -= num;
      }

      void popBack(size_t num = 1)
      {
        if( argc < num )
          return;

        argc -= num;
      }

      /**
       * Get the argument with given index if it exists. Otherwise returns the
       * passed default value.
       *
       * @tparam T    Type of argument (converted using ::from_nasal)
       * @param index Index of requested argument
       * @param def   Default value returned if too few arguments available
       */
      template<class T>
      typename from_nasal_ptr<T>::return_type
      getArg(size_t index, const T& def = T()) const
      {
        if( index >= argc )
          return def;

        return from_nasal<T>(args[index]);
      }

      /**
       * Get the argument with given index. Raises a Nasal runtime error if
       * there are to few arguments available.
       */
      template<class T>
      typename from_nasal_ptr<T>::return_type
      requireArg(size_t index) const
      {
        if( index >= argc )
          naRuntimeError(c, "Missing required arg #%d", index);

        return from_nasal<T>(args[index]);
      }

      template<class T>
      naRef to_nasal(T arg) const
      {
        return nasal::to_nasal(c, arg);
      }

      template<class T>
      typename from_nasal_ptr<T>::return_type
      from_nasal(naRef ref) const
      {
        return (*from_nasal_ptr<T>::get())(c, ref);
      }

      naContext   c;
      size_t      argc;
      naRef      *args;
  };

} // namespace nasal


#endif /* SG_NASAL_CALL_CONTEXT_HXX_ */