LCOV - code coverage report
Current view: directory - gfx/graphite2/src - gr_logging.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 5 0 0.0 %
Date: 2012-06-02 Functions: 2 0 0.0 %

       1                 : /*  GRAPHITE2 LICENSING
       2                 : 
       3                 :     Copyright 2010, SIL International
       4                 :     All rights reserved.
       5                 : 
       6                 :     This library is free software; you can redistribute it and/or modify
       7                 :     it under the terms of the GNU Lesser General Public License as published
       8                 :     by the Free Software Foundation; either version 2.1 of License, or
       9                 :     (at your option) any later version.
      10                 : 
      11                 :     This program is distributed in the hope that it will be useful,
      12                 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14                 :     Lesser General Public License for more details.
      15                 : 
      16                 :     You should also have received a copy of the GNU Lesser General Public
      17                 :     License along with this library in the file named "LICENSE".
      18                 :     If not, write to the Free Software Foundation, 51 Franklin Street, 
      19                 :     Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
      20                 :     internet at http://www.fsf.org/licenses/lgpl.html.
      21                 : 
      22                 : Alternatively, the contents of this file may be used under the terms of the
      23                 : Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
      24                 : License, as published by the Free Software Foundation, either version 2
      25                 : of the License or (at your option) any later version.
      26                 : */
      27                 : #include "graphite2/Log.h"
      28                 : #include "inc/debug.h"
      29                 : #include "inc/CharInfo.h"
      30                 : #include "inc/Slot.h"
      31                 : #include "inc/Segment.h"
      32                 : 
      33                 : using namespace graphite2;
      34                 : 
      35                 : extern "C" {
      36                 : 
      37                 : 
      38               0 : bool graphite_start_logging(FILE * logFile, GrLogMask mask)
      39                 : {
      40               0 :         if (!logFile || !mask)  return false;
      41                 : 
      42                 : #if !defined GRAPHITE2_NTRACING
      43                 :         dbgout = new json(logFile);
      44                 :         return dbgout;
      45                 : #else
      46               0 :         return false;
      47                 : #endif
      48                 : }
      49                 : 
      50               0 : void graphite_stop_logging()
      51                 : {
      52                 : #if !defined GRAPHITE2_NTRACING
      53                 :         delete dbgout;
      54                 : #endif
      55               0 : }
      56                 : 
      57                 : 
      58                 : } // extern "C"
      59                 : 
      60                 : #if !defined GRAPHITE2_NTRACING
      61                 : 
      62                 : json *graphite2::dbgout = 0;
      63                 : 
      64                 : 
      65                 : json & graphite2::operator << (json & j, const CharInfo & ci) throw()
      66                 : {
      67                 :         return j << json::object
      68                 :                                 << "offset"                     << ci.base()
      69                 :                                 << "unicode"            << ci.unicodeChar()
      70                 :                                 << "break"                      << ci.breakWeight()
      71                 :                                 << "slot" << json::flat << json::object
      72                 :                                         << "before"     << ci.before()
      73                 :                                         << "after"      << ci.after()
      74                 :                                         << json::close
      75                 :                                 << json::close;
      76                 : }
      77                 : 
      78                 : 
      79                 : json & graphite2::operator << (json & j, const dslot & ds) throw()
      80                 : {
      81                 :         assert(ds.first);
      82                 :         assert(ds.second);
      83                 :         Segment & seg = *ds.first;
      84                 :         Slot & s = *ds.second;
      85                 : 
      86                 :         j << json::object
      87                 :                 << "id"                         << slotid(&s)
      88                 :                 << "gid"                        << s.gid()
      89                 :                 << "charinfo" << json::flat << json::object
      90                 :                         << "original"           << s.original()
      91                 :                         << "before"                     << s.before()
      92                 :                         << "after"                      << s.after()
      93                 :                         << json::close
      94                 :                 << "origin"                     << s.origin()
      95                 :                 << "shift"                      << Position(s.getAttr(0, gr_slatShiftX, 0), s.getAttr(0, gr_slatShiftY, 0))
      96                 :                 << "advance"            << s.advancePos()
      97                 :                 << "insert"                     << s.isInsertBefore()
      98                 :                 << "break"                      << s.getAttr(&seg, gr_slatBreak, 0);
      99                 :         if (s.just() > 0)
     100                 :                 j << "justification"    << s.just();
     101                 :         if (s.getBidiLevel() > 0)
     102                 :                 j << "bidi"             << s.getBidiLevel();
     103                 :         if (!s.isBase())
     104                 :                 j << "parent" << json::flat << json::object
     105                 :                         << "id"                         << slotid(s.attachedTo())
     106                 :                         << "level"                      << s.getAttr(0, gr_slatAttLevel, 0)
     107                 :                         << "offset"                     << s.attachOffset()
     108                 :                         << json::close;
     109                 :         j << "user" << json::flat << json::array;
     110                 :         for (int n = 0; n!= seg.numAttrs(); ++n)
     111                 :                 j       << s.userAttrs()[n];
     112                 :                 j       << json::close;
     113                 :         if (s.firstChild())
     114                 :         {
     115                 :                 j       << "children" << json::flat << json::array;
     116                 :                 for (const Slot *c = s.firstChild(); c; c = c->nextSibling())  j << slotid(c);
     117                 :                 j               << json::close;
     118                 :         }
     119                 :         return j << json::close;
     120                 : }
     121                 : 
     122                 : 
     123                 : graphite2::slotid::slotid(const Slot * const p) throw()
     124                 : {
     125                 :         uint32 s = reinterpret_cast<size_t>(p);
     126                 :         sprintf(name, "%.4x-%.2x-%.4hx", uint16(s >> 16), uint16(p ? p->index() : 0), uint16(s));
     127                 :         name[sizeof name-1] = 0;
     128                 : }
     129                 : 
     130                 : #endif

Generated by: LCOV version 1.7