Changeset 372 for cpp/common


Ignore:
Timestamp:
04/22/15 04:14:59 (9 years ago)
Author:
sz
Message:

Renamed some classes and functions to make their purpose more obvious:

All MessageHandlers? must now be given the explicit "Enable" argument if you want them to automatically become active. This makes side effects clearly visible.

Location:
cpp/common
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • cpp/common/hmessage.cpp

    r371 r372  
    33// See LICENSE.txt for details.
    44
    5 #include "framsg.h"
     5#include "hmessage.h"
    66#include <common/nonstd_stdio.h>
    77#include "stl-util.h"
    88#include "Convert.h"
    99
    10 const char* MSG_LEVEL[]={"[DEBUG] ","","[WARN] ","[ERROR] ","[CRITICAL] "};
     10const char* HMSG_LEVEL[]={"[DEBUG] ","","[WARN] ","[ERROR] ","[CRITICAL] "};
    1111
    12 void FramMessage(const char *o, const char *m, const char *txt, int w)
     12void Hmessage(const char *o, const char *m, const char *txt, int w)
    1313{
    1414        int line = 0; //all lines except the first one get the "..." prefix
     
    2424                {
    2525                        if (*nextsep == 0) //there was only one line! no need to modify it in any way.
    26                                 _FramMessageSingleLine(o, m, txt, w);
     26                                _HmessageSingleLine(o, m, txt, w);
    2727                        else //first line from multi-line
    28                                 _FramMessageSingleLine(o, m, string(txt, nextsep - txt).c_str(), w);
     28                                _HmessageSingleLine(o, m, string(txt, nextsep - txt).c_str(), w);
    2929                }
    3030                else //consecutive lines from multi-line
    31                         _FramMessageSingleLine(o, m, (FRAMSG_MULTILINE_CONTINUATION + string(txt, nextsep - txt)).c_str(), w); //could also add line numbers like ...(3)... but let's keep the prefix short and simple
     31                        _HmessageSingleLine(o, m, (HMSG_MULTILINE_CONTINUATION + string(txt, nextsep - txt)).c_str(), w); //could also add line numbers like ...(3)... but let's keep the prefix short and simple
    3232                line++;
    3333                if ((nextsep[0] == '\r') && (nextsep[1] == '\n'))
     
    3939
    4040
    41 void FMprintf_va(const char *o,const char *m,int w,const char *bl,va_list va)
     41void Hprintf_va(const char *o,const char *m,int w,const char *bl,va_list va)
    4242{
    4343        string buf=ssprintf_va(bl,va);
    44         FramMessage(o,m,buf.c_str(),w);
     44        Hmessage(o,m,buf.c_str(),w);
    4545}
    4646
    47 void FMprintf(const char *o,const char *m,int w,const char *bl, ...)
     47void Hprintf(const char *o,const char *m,int w,const char *bl, ...)
    4848{
    4949        va_list argptr;
    5050        va_start(argptr,bl);
    51         FMprintf_va(o,m,w,bl,argptr);
     51        Hprintf_va(o,m,w,bl,argptr);
    5252        va_end(argptr);
    5353}
    5454
    55 void printFM(const char *bl,...)
     55void printH(const char *bl,...)
    5656{
    5757        va_list argptr;
    5858        va_start(argptr,bl);
    59         FMprintf_va("Message","printf",FMLV_INFO,bl,argptr);
     59        Hprintf_va("Message","printf",HMLV_INFO,bl,argptr);
    6060        va_end(argptr);
    6161}
  • cpp/common/hmessage.h

    r371 r372  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _FRAMSG_H_
    6 #define _FRAMSG_H_
     5#ifndef _HMESSAGE_H_
     6#define _HMESSAGE_H_
    77
    88#include <stdarg.h>
    99
    10 extern const char* MSG_LEVEL[];
    11 #define FRAMSG_FORMAT "%s%s.%s: %s"
    12 #define FRAMSG_MULTILINE_CONTINUATION "..."
     10extern const char* HMSG_LEVEL[];
     11#define HMSG_FORMAT "%s%s.%s: %s"
     12#define HMSG_MULTILINE_CONTINUATION "..."
    1313
    14 void FMprintf(const char *o,const char *m,int w,const char *bl, ...);
    15 void FMprintf_va(const char *o,const char *m,int w,const char *bl,va_list va); //a different name than FMprintf - otherwise the compiler could confuse the "string" parameter with va_list and could call the wrong function
    16 void printFM(const char *bl,...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match)
    17 void FramMessage(const char *o,const char *m,const char *txt,int w);
     14void Hprintf(const char *o,const char *m,int w,const char *bl, ...);
     15void Hprintf_va(const char *o,const char *m,int w,const char *bl,va_list va); //a different name than Hprintf - otherwise the compiler could confuse the "string" parameter with va_list and could call the wrong function
     16void printH(const char *bl,...); //a shorthand for printf (a different name again to avoid the risk of confusion with the two functions above. This would be unlikely but possible when the argument types would match)
     17void Hmessage(const char *o,const char *m,const char *txt,int w);
    1818
    19 void _FramMessageSingleLine(const char *o,const char *m,const char *txt,int w); //don't call this directly - it is used internally
     19void _HmessageSingleLine(const char *o,const char *m,const char *txt,int w); //don't call this directly - it is used internally
    2020
    21 #define FMLV_DEBUG -1
    22 #define FMLV_INFO 0
    23 #define FMLV_WARN 1
    24 #define FMLV_ERROR 2
    25 #define FMLV_CRITICAL 3
     21#define HMLV_DEBUG -1
     22#define HMLV_INFO 0
     23#define HMLV_WARN 1
     24#define HMLV_ERROR 2
     25#define HMLV_CRITICAL 3
    2626
    2727/*
  • cpp/common/nonstd_math.cpp

    r286 r372  
    8181// But it was resolved by restarting windows and cleaning all intermediate compilation files :o (restarting windows was the key element! restarting BC++Builder and deleting files would not help)
    8282
    83 #include "framsg.h"
     83#include "hmessage.h"
    8484
    8585unsigned int fp_control_word_std;
     
    8989{
    9090        //unsigned int was=_clear87();
    91         //FMprintf("","fpExceptInit",FMLV_INFO,"control87 status before clear was %08x", was);
     91        //Hprintf("","fpExceptInit",HMLV_INFO,"control87 status before clear was %08x", was);
    9292        fp_control_word_std=_control87(0, 0);             //4978 = 1001101110010
    9393        // Make the new fp env same as the old one, except for the changes we're going to make
     
    9898{
    9999        unsigned int was=_clear87(); //trzeba czyscic zeby nie bylo exception...
    100         //FMprintf("","fpExceptEnable ",FMLV_INFO,"control87 status before clear was %08x", was);
     100        //Hprintf("","fpExceptEnable ",HMLV_INFO,"control87 status before clear was %08x", was);
    101101        _control87(fp_control_word_std, 0xffffffff);
    102         //FMprintf("","fpExceptEnable ",FMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
     102        //Hprintf("","fpExceptEnable ",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
    103103}
    104104
     
    106106{
    107107        unsigned int was=_clear87(); //trzeba czyscic zeby nie bylo exception...
    108         //FMprintf("","fpExceptDisable",FMLV_INFO,"control87 status before clear was %08x", was);
     108        //Hprintf("","fpExceptDisable",HMLV_INFO,"control87 status before clear was %08x", was);
    109109        _control87(fp_control_word_muted, 0xffffffff);
    110         //FMprintf("","fpExceptDisable",FMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
     110        //Hprintf("","fpExceptDisable",HMLV_INFO,"control87 flags are %08x", _control87(0, 0)); //kontrola co sie ustawilo
    111111}
    112112
  • cpp/common/nonstd_stdio.cpp

    r297 r372  
    241241
    242242#ifdef __ANDROID__
    243 #include "framsg.h"
     243#include "hmessage.h"
    244244#include "nonstd.h"
    245245#include "nonstd_stl.h"
     
    247247{
    248248        string respath=getAppResourcesDir();
    249         //printFM("Opening '%s', mode='%s'",path,mode);
    250         //printFM("getAppResourcesDir()='%s'",respath.c_str());
     249        //printH("Opening '%s', mode='%s'",path,mode);
     250        //printH("getAppResourcesDir()='%s'",respath.c_str());
    251251        NvFile *rfile=NULL; //can only read
    252252        FILE *rwfile=NULL;
     
    255255                path+=respath.length(); //strip the prefix, we need a relative path in assets
    256256                if (strstr(mode,"w"))
    257                         printFM("Warning: attempt to open a read-only resource '%s' in writable mode '%s'",path,mode);
     257                        printH("Warning: attempt to open a read-only resource '%s' in writable mode '%s'",path,mode);
    258258                rfile=NvFOpen(path); //"mode" not supported! can only read
    259                 //printFM("Opened RES file as %p",rfile);
     259                //printH("Opened RES file as %p",rfile);
    260260                if (rfile==NULL) return NULL;
    261261        } else //a "normal" access (HOME)
    262262        {
    263263                rwfile=fopen(path,mode);
    264                 //printFM("Opened HOME file as %p",rwfile);
     264                //printH("Opened HOME file as %p",rwfile);
    265265                if (rwfile==NULL) return NULL;
    266266        }
  • cpp/common/stl-util.cpp

    r319 r372  
    99#include "Convert.h"
    1010#include "nonstd.h"
    11 #include "framsg.h"
     11#include "hmessage.h"
    1212#include <assert.h>
    1313#ifdef USE_VIRTFILE
     
    107107        }
    108108        if (warn_on_missing_file && !ok)
    109                 FMprintf("stl-util", "readCompleteFile", FMLV_WARN, "Couldn't open file '%s'", filename);
     109                Hprintf("stl-util", "readCompleteFile", HMLV_WARN, "Couldn't open file '%s'", filename);
    110110        return ok;
    111111}
     
    137137        }
    138138        if (warn_on_fail && !ok)
    139                 FMprintf("stl-util", "writeCompleteFile", FMLV_WARN, "couldn't write file '%s'", filename);
     139                Hprintf("stl-util", "writeCompleteFile", HMLV_WARN, "couldn't write file '%s'", filename);
    140140        return ok;
    141141}
Note: See TracChangeset for help on using the changeset viewer.