Exemplo n.º 1
0
bool HLSLGenerator::ChooseUniqueName(const char* base, char* dst, int dstLength) const
{
    for (int i = 0; i < 1024; ++i)
    {
        String_Printf(dst, dstLength, "%s%d", base, i);
        if (!m_tree->GetContainsString(dst))
        {
            return true;
        }
    }
    return false;
}
Exemplo n.º 2
0
void CodeWriter::Write(const char* format, ...)
{
    va_list args;
    va_start(args, format);

    char buffer[_maxLineLength];
    String_Printf(buffer, sizeof(buffer), format, args);

    m_buffer += buffer;

    va_end(args);      
}
Exemplo n.º 3
0
void Log_Error(const char* format, ...)
{
    va_list args;
    va_start(args, format);

    char buffer[1024];
    int count = String_Printf(buffer, sizeof(buffer), format, args);

    va_end(args);

    std::cerr << "ERROR: " << buffer << '\n';
}
Exemplo n.º 4
0
void CodeWriter::BeginLine(int indent, const char* fileName, int lineNumber)
{

    if (m_writeLines)
    {

        bool outputLine = false;
        bool outputFile = false;

        // Output a line number pragma if necessary.
        if (fileName != NULL && m_currentFileName != fileName)
        {
            m_currentFileName = fileName;
            fileName = m_currentFileName;
            outputFile = true;
        }
        if (lineNumber != -1 && m_currentLine != lineNumber)
        {
            m_currentLine = lineNumber;
            outputLine = true;
        }
        if (outputLine || outputFile)
        {
            char buffer[256];
            String_Printf(buffer, sizeof(buffer), "#line %d", lineNumber);
            m_buffer += buffer;
            if (outputFile && m_writeFileNames)
            {
                m_buffer += " \"";
                m_buffer += fileName;
                m_buffer += "\"\n";
            }
            else
            {
                m_buffer += "\n";
            }
        }

    }

    // Handle the indentation.
    for (int i = 0; i < indent * m_spacesPerIndent; ++i)
    {
        m_buffer += " ";
    }
}
Exemplo n.º 5
0
void CodeWriter::WriteLine(int indent, const char* fileName, int lineNumber, const char* format, ...)
{
    va_list args;
    va_start(args, format);

    BeginLine(indent, fileName, lineNumber);

    char buffer[_maxLineLength];
    int result = String_Printf(buffer, sizeof(buffer), format, args);
    ASSERT(result != -1);

    m_buffer += buffer;

    EndLine();

    va_end(args);        
}
Exemplo n.º 6
0
void CodeWriter::WriteLine(int indent, const char* format, ...)
{
    va_list args;
    va_start(args, format);

    char buffer[_maxLineLength];

    int result = String_Printf(buffer, sizeof(buffer), format, args);
    ASSERT(result != -1);

    for (int i = 0; i < indent * m_spacesPerIndent; ++i)
    {
        m_buffer += " ";
    }
    m_buffer += buffer;

    EndLine();

    va_end(args);        
}