LCOV - code coverage report
Current view: top level - Core/Scripting - OOJSSpecialFunctions.m (source / functions) Hit Total Coverage
Test: coverxygen.info Lines: 0 6 0.0 %
Date: 2025-05-28 07:50:54 Functions: 0 0 -

          Line data    Source code
       1           0 : /*
       2             : 
       3             : OOJSSpecialFunctions.m
       4             : 
       5             : 
       6             : Oolite
       7             : Copyright (C) 2004-2013 Giles C Williams and contributors
       8             : 
       9             : This program is free software; you can redistribute it and/or
      10             : modify it under the terms of the GNU General Public License
      11             : as published by the Free Software Foundation; either version 2
      12             : of the License, or (at your option) any later version.
      13             : 
      14             : This program is distributed in the hope that it will be useful,
      15             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             : GNU General Public License for more details.
      18             : 
      19             : You should have received a copy of the GNU General Public License
      20             : along with this program; if not, write to the Free Software
      21             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
      22             : MA 02110-1301, USA.
      23             : 
      24             : */
      25             : 
      26             : #include <jsdbgapi.h>
      27             : #import "OOJSSpecialFunctions.h"
      28             : 
      29             : 
      30             : static JSBool SpecialJSWarning(JSContext *context, uintN argc, jsval *vp);
      31             : #ifndef NDEBUG
      32             : static JSBool SpecialMarkConsoleEntryPoint(JSContext *context, uintN argc, jsval *vp);
      33             : #endif
      34             : 
      35             : 
      36           0 : static JSFunctionSpec sSpecialFunctionsMethods[] =
      37             : {
      38             :         // JS name                                      Function                                                min args
      39             :         { "jsWarning",                                SpecialJSWarning,                               1 },
      40             : #ifndef NDEBUG
      41             :         { "markConsoleEntryPoint",    SpecialMarkConsoleEntryPoint,   0 },
      42             : #endif
      43             :         { 0 }
      44             : };
      45             : 
      46             : 
      47           0 : void InitOOJSSpecialFunctions(JSContext *context, JSObject *global)
      48             : {
      49             : }
      50             : 
      51             : 
      52           0 : OOJSValue *JSSpecialFunctionsObjectWrapper(JSContext *context)
      53             : {
      54             :         /*
      55             :                 Special object is created on the fly so it can be GCed (the debug
      56             :                 console script keeps a reference to its copy, but the prefix script
      57             :                 doesn't) and so we don't need to clean up a root on JS engine reset.
      58             :                 -- Ahruman 2011-03-30
      59             :         */
      60             :         
      61             :         JSObject *special = NULL;
      62             :         OOJSAddGCObjectRoot(context, &special, "OOJSSpecialFunctions");
      63             :         
      64             :         special = JS_NewObject(context, NULL, NULL, NULL);
      65             :         JS_DefineFunctions(context, special, sSpecialFunctionsMethods);
      66             :         JS_FreezeObject(context, special);
      67             :         
      68             :         OOJSValue *result = [OOJSValue valueWithJSObject:special inContext:context];
      69             :         
      70             :         JS_RemoveObjectRoot(context, &special);
      71             :         
      72             :         return result;
      73             : }
      74             : 
      75             : 
      76           0 : static JSBool SpecialJSWarning(JSContext *context, uintN argc, jsval *vp)
      77             : {
      78             :         OOJS_PROFILE_ENTER      // These functions are exception-safe
      79             :         
      80             :         if (EXPECT_NOT(argc < 1))
      81             :         {
      82             :                 OOJSReportBadArguments(context, @"special", @"jsWarning", argc, OOJS_ARGV, nil, @"string");
      83             :                 return NO;
      84             :         }
      85             :         
      86             :         OOJSSetWarningOrErrorStackSkip(1);
      87             :         OOJSReportWarning(context, @"%@", OOStringFromJSValue(context, OOJS_ARGV[0]));
      88             :         OOJSSetWarningOrErrorStackSkip(0);
      89             :         
      90             :         OOJS_RETURN_VOID;
      91             :         
      92             :         OOJS_PROFILE_EXIT
      93             : }
      94             : 
      95             : 
      96             : #ifndef NDEBUG
      97           0 : static JSBool SpecialMarkConsoleEntryPoint(JSContext *context, uintN argc, jsval *vp)
      98             : {
      99             :         // First stack frame will be in eval() in console.script.evaluate(), unless someone is playing silly buggers.
     100             :         
     101             :         JSStackFrame *frame = NULL;
     102             :         if (JS_FrameIterator(context, &frame) != NULL)
     103             :         {
     104             :                 OOJSMarkConsoleEvalLocation(context, frame);
     105             :         }
     106             :         
     107             :         OOJS_RETURN_VOID;
     108             : }
     109             : #endif

Generated by: LCOV version 1.14