@@ -59,7 +59,7 @@ String String::Printf(char const *format, va_list ap) | |||
/* vsnprintf() tells us how many character we need, and we need to | |||
* add one for the terminating null byte. */ | |||
size_t needed = vsnprintf(NULL, 0, format, ap2) + 1; | |||
size_t needed = vsnprintf(nullptr, 0, format, ap2) + 1; | |||
((Super &)ret).Reserve(needed); | |||
ret.m_count = needed; | |||
@@ -45,6 +45,18 @@ | |||
# define FP_USE(x) (void)(x) | |||
#endif | |||
/* Ensure we have nullptr */ | |||
#if defined nullptr | |||
/* do nothing */ | |||
#elif defined __GNUC__ | |||
# define nullptr __null | |||
#else | |||
# include <cstddef> | |||
# define nullptr NULL | |||
#endif | |||
/* Ensure isnan() is present even on systems that don't define it, or | |||
* when -ffast-math is being used. */ | |||
#include <cmath> | |||
@@ -44,12 +44,12 @@ DebugFps::DebugFps(int x, int y) | |||
#if 0 | |||
for (int i = 0; i < 5; i ++) | |||
{ | |||
data->lines[i] = new Text(NULL, "data/font/ascii.png"); | |||
data->lines[i] = new Text(nullptr, "data/font/ascii.png"); | |||
data->lines[i]->SetPos(ivec3(x, y + (i ? 8 : 0) + 16 * i, 0)); | |||
Ticker::Ref(data->lines[i]); | |||
} | |||
#else | |||
data->lines[0] = new Text(NULL, "data/font/ascii.png"); | |||
data->lines[0] = new Text(nullptr, "data/font/ascii.png"); | |||
data->lines[0]->SetPos(ivec3(x, y, 100)); | |||
Ticker::Ref(data->lines[0]); | |||
#endif | |||
@@ -56,7 +56,7 @@ DebugRecord::DebugRecord(char const *path, float fps) | |||
data->size = ivec2(0); | |||
data->fps = (int)(fps + 0.5f); | |||
#if defined USE_PIPI | |||
data->sequence = NULL; | |||
data->sequence = nullptr; | |||
#endif | |||
m_drawgroup = DRAWGROUP_CAPTURE; | |||
@@ -106,10 +106,10 @@ int Dict::MakeSlot(char const *name) | |||
if (slotid == data->m_entities.Count()) | |||
{ | |||
empty = data->m_entities.Count(); | |||
data->m_entities.Push(NULL); | |||
data->m_entities.Push(nullptr); | |||
} | |||
data->m_entities[empty] = NULL; | |||
data->m_entities[empty] = nullptr; | |||
slotid = empty; | |||
data->nentities++; | |||
} | |||
@@ -125,7 +125,7 @@ void Dict::RemoveSlot(int slotid) | |||
{ | |||
if (Ticker::Unref(data->m_entities[slotid]) == 0) | |||
{ | |||
data->m_entities[slotid] = NULL; | |||
data->m_entities[slotid] = nullptr; | |||
data->nentities--; | |||
} | |||
} | |||
@@ -110,14 +110,14 @@ at { return token::T_TRIANGLE; } | |||
ato { return token::T_TORUS; } | |||
#[0-9a-fA-F]{3} { | |||
uint32_t tmp = std::strtol(yytext + 1, NULL, 16); | |||
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16); | |||
yylval->u32val = 0x11000000u * (tmp >> 8) | |||
| 0x00110000u * ((tmp >> 4) & 0xf) | |||
| 0x00001100u * (tmp & 0xf) | |||
| 0x000000ffu; | |||
return token::COLOR; } | |||
#[0-9a-fA-F]{4} { | |||
uint32_t tmp = std::strtol(yytext + 1, NULL, 16); | |||
uint32_t tmp = std::strtol(yytext + 1, nullptr, 16); | |||
yylval->u32val = 0x11000000u * (tmp >> 12) | |||
| 0x00110000u * ((tmp >> 8) & 0xf) | |||
| 0x00001100u * ((tmp >> 4) & 0xf) | |||
@@ -125,10 +125,10 @@ ato { return token::T_TORUS; } | |||
return token::COLOR; } | |||
#[0-9a-fA-F]{6} { | |||
yylval->u32val = 0xffu | |||
| 0x100u * (uint32_t)std::strtol(yytext + 1, NULL, 16); | |||
| 0x100u * (uint32_t)std::strtol(yytext + 1, nullptr, 16); | |||
return token::COLOR; } | |||
#[0-9a-fA-F]{8} { | |||
yylval->u32val = (uint32_t)std::strtol(yytext + 1, NULL, 16); | |||
yylval->u32val = (uint32_t)std::strtol(yytext + 1, nullptr, 16); | |||
return token::COLOR; } | |||
[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)? { | |||
yylval->fval = std::atof(yytext); return token::NUMBER; } | |||
@@ -85,7 +85,7 @@ ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | |||
for (int i = 0; i < m_shader_uniform.Count(); ++i) | |||
if (m_shader_uniform[i].m1 == uniform) | |||
return &m_shader_uniform[i].m2; | |||
return NULL; | |||
return nullptr; | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -94,7 +94,7 @@ ShaderAttrib const *GpuShaderData::GetAttribute(const lol::String &attribute) | |||
for (int i = 0; i < m_shader_attrib.Count(); ++i) | |||
if (m_shader_attrib[i].m1 == attribute) | |||
return &m_shader_attrib[i].m2; | |||
return NULL; | |||
return nullptr; | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -181,7 +181,7 @@ GpuEasyMeshData::GpuEasyMeshData() | |||
{ | |||
m_vertexcount = 0; | |||
m_indexcount = 0; | |||
m_ibo = NULL; | |||
m_ibo = nullptr; | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -220,7 +220,7 @@ void GpuEasyMeshData::AddGpuData(GpuShaderData* gpudata, EasyMesh* src_mesh) | |||
{ | |||
m_gpudatas.Reserve(DebugRenderMode::Max); | |||
for (int i = 0; i < DebugRenderMode::Max; i++) | |||
m_gpudatas << NULL; | |||
m_gpudatas << nullptr; | |||
} | |||
m_gpudatas[gpudata->m_render_mode] = gpudata; | |||
} | |||
@@ -232,9 +232,9 @@ void GpuEasyMeshData::SetupVertexData(uint16_t vdecl_flags, EasyMesh* src_mesh) | |||
if (m_vdatas[i].m1 == vdecl_flags) | |||
return; | |||
VertexDeclaration* new_vdecl = NULL; | |||
VertexBuffer* new_vbo = NULL; | |||
void *vbo_data = NULL; | |||
VertexDeclaration* new_vdecl = nullptr; | |||
VertexBuffer* new_vbo = nullptr; | |||
void *vbo_data = nullptr; | |||
int vbo_bytes = 0; | |||
#define COPY_VBO \ | |||
@@ -364,7 +364,7 @@ void GpuEasyMeshData::RenderMeshData(mat4 const &model) | |||
//----------------------------------------------------------------------------- | |||
EasyMesh::EasyMesh() | |||
: m_build_data(NULL) | |||
: m_build_data(nullptr) | |||
{ | |||
m_cursors.Push(0, 0); | |||
} | |||
@@ -391,7 +391,7 @@ void EasyMesh::CloseBrace() | |||
void EasyMesh::MeshConvert(GpuShaderData* new_gpu_sdata) | |||
{ | |||
delete(m_build_data); | |||
m_build_data = NULL; | |||
m_build_data = nullptr; | |||
if (new_gpu_sdata) | |||
{ | |||
@@ -2250,7 +2250,7 @@ void EasyMesh::Chamfer(float f) | |||
} | |||
//----------------------------------------------------------------------------- | |||
void EasyMesh::SplitTriangles(int pass) { SplitTriangles(pass, NULL); } | |||
void EasyMesh::SplitTriangles(int pass) { SplitTriangles(pass, nullptr); } | |||
//----------------------------------------------------------------------------- | |||
void EasyMesh::SplitTriangles(int pass, VertexDictionnary *vert_dict) | |||
@@ -487,10 +487,10 @@ class VertexDictionnary | |||
public: | |||
int FindVertexMaster(const int search_idx); | |||
bool FindMatchingVertices(const int search_idx, Array<int> &matching_ids); | |||
bool FindConnectedVertices(const int search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_vert, Array<int> const *ignored_tri = NULL); | |||
bool FindConnectedTriangles(const int search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL); | |||
bool FindConnectedTriangles(const ivec2 &search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL); | |||
bool FindConnectedTriangles(const ivec3 &search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL); | |||
bool FindConnectedVertices(const int search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_vert, Array<int> const *ignored_tri = nullptr); | |||
bool FindConnectedTriangles(const int search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = nullptr); | |||
bool FindConnectedTriangles(const ivec2 &search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = nullptr); | |||
bool FindConnectedTriangles(const ivec3 &search_idx, const Array<uint16_t> &tri_list, const int tri0, Array<int> &connected_tri, Array<int> const *ignored_tri = nullptr); | |||
void AddVertex(int vert_id, vec3 vert_coord); | |||
bool GetMasterList(Array<int> &ret_master_list) { ret_master_list = master_list; return ret_master_list.Count() > 0; } | |||
void Clear() { vertex_list.Empty(); } | |||
@@ -524,7 +524,7 @@ public: | |||
bool Compile(char const *command); | |||
void MeshConvert(GpuShaderData* new_gpu_sdata); | |||
void MeshConvert(Shader* ProvidedShader = NULL); | |||
void MeshConvert(Shader* ProvidedShader = nullptr); | |||
void Render(mat4 const &model); | |||
private: | |||
@@ -78,8 +78,8 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) : | |||
data->egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); | |||
# else | |||
data->dpy = XOpenDisplay(NULL); | |||
if (data->dpy == NULL) | |||
data->dpy = XOpenDisplay(nullptr); | |||
if (data->dpy == nullptr) | |||
{ | |||
Log::Error("cannot connect to X server\n"); | |||
exit(EXIT_FAILURE); | |||
@@ -115,7 +115,7 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) : | |||
exit(EXIT_FAILURE); | |||
} | |||
if (!eglInitialize(data->egl_dpy, NULL, NULL)) | |||
if (!eglInitialize(data->egl_dpy, nullptr, nullptr)) | |||
{ | |||
Log::Error("cannot initialize EGL\n"); | |||
exit(EXIT_FAILURE); | |||
@@ -187,11 +187,11 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) : | |||
vc_dispmanx_update_submit_sync(dispman_update); | |||
data->egl_surf = eglCreateWindowSurface(data->egl_dpy, ecfg, | |||
&data->nativewindow, NULL); | |||
&data->nativewindow, nullptr); | |||
# else | |||
data->egl_surf = eglCreateWindowSurface(data->egl_dpy, ecfg, | |||
(EGLNativeWindowType)data->win, | |||
NULL); | |||
nullptr); | |||
# endif | |||
if (data->egl_surf == EGL_NO_SURFACE) | |||
{ | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Skeleton interface for Bison LALR(1) parsers in C++ | |||
Copyright (C) 2002-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -40,20 +40,6 @@ | |||
#include <string> | |||
#include <iostream> | |||
#include "stack.hh" | |||
namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 49 "generated/easymesh-parser.h" | |||
class position; | |||
class location; | |||
} // lol | |||
/* Line 34 of lalr1.cc */ | |||
#line 56 "generated/easymesh-parser.h" | |||
#include "location.hh" | |||
/* Enabling traces. */ | |||
@@ -74,30 +60,11 @@ namespace lol { | |||
# define YYTOKEN_TABLE 0 | |||
#endif | |||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | |||
If N is 0, then set CURRENT to the empty location which ends | |||
the previous symbol: RHS[0] (always defined). */ | |||
#ifndef YYLLOC_DEFAULT | |||
# define YYLLOC_DEFAULT(Current, Rhs, N) \ | |||
do { \ | |||
if (N) \ | |||
{ \ | |||
(Current).begin = (Rhs)[1].begin; \ | |||
(Current).end = (Rhs)[N].end; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(Current).begin = (Current).end = (Rhs)[0].end; \ | |||
} \ | |||
} while (false) | |||
#endif | |||
namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 101 "generated/easymesh-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 68 "generated/easymesh-parser.h" | |||
/// A Bison parser. | |||
class EasyMeshParser | |||
@@ -108,7 +75,7 @@ namespace lol { | |||
union semantic_type | |||
{ | |||
/* Line 34 of lalr1.cc */ | |||
/* Line 35 of lalr1.cc */ | |||
#line 36 "easymesh/easymesh-parser.y" | |||
float fval; | |||
@@ -118,8 +85,8 @@ namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 123 "generated/easymesh-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 90 "generated/easymesh-parser.h" | |||
}; | |||
#else | |||
typedef YYSTYPE semantic_type; | |||
@@ -265,6 +232,14 @@ namespace lol { | |||
/// The location stack. | |||
location_stack_type yylocation_stack_; | |||
/// Whether the given \c yypact_ value indicates a defaulted state. | |||
/// \param yyvalue the value to check | |||
static bool yy_pact_value_is_default_ (int yyvalue); | |||
/// Whether the given \c yytable_ value indicates a syntax error. | |||
/// \param yyvalue the value to check | |||
static bool yy_table_value_is_error_ (int yyvalue); | |||
/// Internal symbol numbers. | |||
typedef unsigned char token_number_type; | |||
/* Tables. */ | |||
@@ -272,7 +247,7 @@ namespace lol { | |||
static const signed char yypact_[]; | |||
static const signed char yypact_ninf_; | |||
/// For a state, default rule to reduce. | |||
/// For a state, default reduction number. | |||
/// Unless\a yytable_ specifies something else to do. | |||
/// Zero means the default is an error. | |||
static const unsigned char yydefact_[]; | |||
@@ -303,10 +278,8 @@ namespace lol { | |||
static const char* const yytname_[]; | |||
#endif | |||
#if YYERROR_VERBOSE | |||
/// Convert the symbol name \a n to a form suitable for a diagnostic. | |||
virtual std::string yytnamerr_ (const char *n); | |||
#endif | |||
static std::string yytnamerr_ (const char *n); | |||
#if YYDEBUG | |||
/// A type to store symbol numbers and -1. | |||
@@ -364,8 +337,8 @@ namespace lol { | |||
} // lol | |||
/* Line 34 of lalr1.cc */ | |||
#line 369 "generated/easymesh-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 342 "generated/easymesh-parser.h" | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Locations for Bison parsers in C++ | |||
Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Skeleton implementation for Bison LALR(1) parsers in C++ | |||
Copyright (C) 2002-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -35,7 +35,7 @@ | |||
/* First part of user declarations. */ | |||
/* Line 310 of lalr1.cc */ | |||
/* Line 293 of lalr1.cc */ | |||
#line 1 "gpu/lolfx-parser.y" | |||
// | |||
@@ -58,7 +58,7 @@ | |||
/* Line 310 of lalr1.cc */ | |||
/* Line 293 of lalr1.cc */ | |||
#line 63 "generated/lolfx-parser.cpp" | |||
@@ -66,7 +66,7 @@ | |||
/* User implementation prologue. */ | |||
/* Line 316 of lalr1.cc */ | |||
/* Line 299 of lalr1.cc */ | |||
#line 241 "gpu/lolfx-parser.y" | |||
#include "gpu/lolfx-compiler.h" | |||
@@ -75,7 +75,7 @@ | |||
#define yylex mc.m_lexer->lex | |||
/* Line 316 of lalr1.cc */ | |||
/* Line 299 of lalr1.cc */ | |||
#line 80 "generated/lolfx-parser.cpp" | |||
#ifndef YY_ | |||
@@ -90,6 +90,26 @@ | |||
# endif | |||
#endif | |||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | |||
If N is 0, then set CURRENT to the empty location which ends | |||
the previous symbol: RHS[0] (always defined). */ | |||
#define YYRHSLOC(Rhs, K) ((Rhs)[K]) | |||
#ifndef YYLLOC_DEFAULT | |||
# define YYLLOC_DEFAULT(Current, Rhs, N) \ | |||
do \ | |||
if (N) \ | |||
{ \ | |||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \ | |||
(Current).end = YYRHSLOC (Rhs, N).end; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ | |||
} \ | |||
while (false) | |||
#endif | |||
/* Suppress unused-variable warnings by "using" E. */ | |||
#define YYUSE(e) ((void) (e)) | |||
@@ -141,9 +161,8 @@ do { \ | |||
namespace lol { | |||
/* Line 379 of lalr1.cc */ | |||
#line 146 "generated/lolfx-parser.cpp" | |||
#if YYERROR_VERBOSE | |||
/* Line 382 of lalr1.cc */ | |||
#line 166 "generated/lolfx-parser.cpp" | |||
/* Return YYSTR after stripping away unnecessary quotes and | |||
backslashes, so that it's suitable for yyerror. The heuristic is | |||
@@ -182,7 +201,6 @@ namespace lol { | |||
return yystr; | |||
} | |||
#endif | |||
/// Build a parser object. | |||
LolFxParser::LolFxParser (class LolFxCompiler& mc_yyarg) | |||
@@ -283,6 +301,18 @@ namespace lol { | |||
} | |||
#endif | |||
inline bool | |||
LolFxParser::yy_pact_value_is_default_ (int yyvalue) | |||
{ | |||
return yyvalue == yypact_ninf_; | |||
} | |||
inline bool | |||
LolFxParser::yy_table_value_is_error_ (int yyvalue) | |||
{ | |||
return yyvalue == yytable_ninf_; | |||
} | |||
int | |||
LolFxParser::parse () | |||
{ | |||
@@ -304,7 +334,7 @@ namespace lol { | |||
/// Location of the lookahead. | |||
location_type yylloc; | |||
/// The locations where the error started and ended. | |||
location_type yyerror_range[2]; | |||
location_type yyerror_range[3]; | |||
/// $$. | |||
semantic_type yyval; | |||
@@ -342,7 +372,7 @@ namespace lol { | |||
/* Try to take a decision without lookahead. */ | |||
yyn = yypact_[yystate]; | |||
if (yyn == yypact_ninf_) | |||
if (yy_pact_value_is_default_ (yyn)) | |||
goto yydefault; | |||
/* Read a lookahead token. */ | |||
@@ -375,8 +405,8 @@ namespace lol { | |||
yyn = yytable_[yyn]; | |||
if (yyn <= 0) | |||
{ | |||
if (yyn == 0 || yyn == yytable_ninf_) | |||
goto yyerrlab; | |||
if (yy_table_value_is_error_ (yyn)) | |||
goto yyerrlab; | |||
yyn = -yyn; | |||
goto yyreduce; | |||
} | |||
@@ -432,46 +462,57 @@ namespace lol { | |||
{ | |||
case 202: | |||
/* Line 677 of lalr1.cc */ | |||
/* Line 690 of lalr1.cc */ | |||
#line 728 "gpu/lolfx-parser.y" | |||
{ std::cout << "New tech " << std::endl; } | |||
break; | |||
case 203: | |||
/* Line 677 of lalr1.cc */ | |||
/* Line 690 of lalr1.cc */ | |||
#line 736 "gpu/lolfx-parser.y" | |||
{ std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } | |||
break; | |||
case 204: | |||
/* Line 677 of lalr1.cc */ | |||
/* Line 690 of lalr1.cc */ | |||
#line 737 "gpu/lolfx-parser.y" | |||
{ std::cout << "New name " << (yysemantic_stack_[(1) - (1)].sval) << std::endl; } | |||
break; | |||
case 207: | |||
/* Line 677 of lalr1.cc */ | |||
/* Line 690 of lalr1.cc */ | |||
#line 750 "gpu/lolfx-parser.y" | |||
{ std::cout << "New pass " << std::endl; } | |||
break; | |||
case 226: | |||
/* Line 677 of lalr1.cc */ | |||
/* Line 690 of lalr1.cc */ | |||
#line 786 "gpu/lolfx-parser.y" | |||
{ std::cout << "new shader" << std::endl; } | |||
break; | |||
/* Line 677 of lalr1.cc */ | |||
#line 472 "generated/lolfx-parser.cpp" | |||
/* Line 690 of lalr1.cc */ | |||
#line 502 "generated/lolfx-parser.cpp" | |||
default: | |||
break; | |||
} | |||
/* User semantic actions sometimes alter yychar, and that requires | |||
that yytoken be updated with the new translation. We take the | |||
approach of translating immediately before every use of yytoken. | |||
One alternative is translating here after every semantic action, | |||
but that translation would be missed if the semantic action | |||
invokes YYABORT, YYACCEPT, or YYERROR immediately after altering | |||
yychar. In the case of YYABORT or YYACCEPT, an incorrect | |||
destructor might then be invoked immediately. In the case of | |||
YYERROR, subsequent parser actions might lead to an incorrect | |||
destructor call or verbose syntax error message before the | |||
lookahead is translated. */ | |||
YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); | |||
yypop_ (yylen); | |||
@@ -495,14 +536,20 @@ namespace lol { | |||
| yyerrlab -- here on detecting error | | |||
`------------------------------------*/ | |||
yyerrlab: | |||
/* Make sure we have latest lookahead translation. See comments at | |||
user semantic actions for why this is necessary. */ | |||
yytoken = yytranslate_ (yychar); | |||
/* If not already recovering from an error, report this error. */ | |||
if (!yyerrstatus_) | |||
{ | |||
++yynerrs_; | |||
if (yychar == yyempty_) | |||
yytoken = yyempty_; | |||
error (yylloc, yysyntax_error_ (yystate, yytoken)); | |||
} | |||
yyerror_range[0] = yylloc; | |||
yyerror_range[1] = yylloc; | |||
if (yyerrstatus_ == 3) | |||
{ | |||
/* If just tried and failed to reuse lookahead token after an | |||
@@ -537,7 +584,7 @@ namespace lol { | |||
if (false) | |||
goto yyerrorlab; | |||
yyerror_range[0] = yylocation_stack_[yylen - 1]; | |||
yyerror_range[1] = yylocation_stack_[yylen - 1]; | |||
/* Do not reclaim the symbols of the rule which action triggered | |||
this YYERROR. */ | |||
yypop_ (yylen); | |||
@@ -554,7 +601,7 @@ namespace lol { | |||
for (;;) | |||
{ | |||
yyn = yypact_[yystate]; | |||
if (yyn != yypact_ninf_) | |||
if (!yy_pact_value_is_default_ (yyn)) | |||
{ | |||
yyn += yyterror_; | |||
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) | |||
@@ -569,7 +616,7 @@ namespace lol { | |||
if (yystate_stack_.height () == 1) | |||
YYABORT; | |||
yyerror_range[0] = yylocation_stack_[0]; | |||
yyerror_range[1] = yylocation_stack_[0]; | |||
yydestruct_ ("Error: popping", | |||
yystos_[yystate], | |||
&yysemantic_stack_[0], &yylocation_stack_[0]); | |||
@@ -578,10 +625,10 @@ namespace lol { | |||
YY_STACK_PRINT (); | |||
} | |||
yyerror_range[1] = yylloc; | |||
yyerror_range[2] = yylloc; | |||
// Using YYLLOC is tempting, but would change the location of | |||
// the lookahead. YYLOC is available though. | |||
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); | |||
YYLLOC_DEFAULT (yyloc, yyerror_range, 2); | |||
yysemantic_stack_.push (yylval); | |||
yylocation_stack_.push (yyloc); | |||
@@ -604,7 +651,13 @@ namespace lol { | |||
yyreturn: | |||
if (yychar != yyempty_) | |||
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); | |||
{ | |||
/* Make sure we have latest lookahead translation. See comments | |||
at user semantic actions for why this is necessary. */ | |||
yytoken = yytranslate_ (yychar); | |||
yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, | |||
&yylloc); | |||
} | |||
/* Do not reclaim the symbols of the rule which action triggered | |||
this YYABORT or YYACCEPT. */ | |||
@@ -623,51 +676,97 @@ namespace lol { | |||
// Generate an error message. | |||
std::string | |||
LolFxParser::yysyntax_error_ (int yystate, int tok) | |||
LolFxParser::yysyntax_error_ (int yystate, int yytoken) | |||
{ | |||
std::string res; | |||
YYUSE (yystate); | |||
#if YYERROR_VERBOSE | |||
int yyn = yypact_[yystate]; | |||
if (yypact_ninf_ < yyn && yyn <= yylast_) | |||
std::string yyres; | |||
// Number of reported tokens (one for the "unexpected", one per | |||
// "expected"). | |||
size_t yycount = 0; | |||
// Its maximum. | |||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | |||
// Arguments of yyformat. | |||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | |||
/* There are many possibilities here to consider: | |||
- If this state is a consistent state with a default action, then | |||
the only way this function was invoked is if the default action | |||
is an error action. In that case, don't check for expected | |||
tokens because there are none. | |||
- The only way there can be no lookahead present (in yytoken) is | |||
if this state is a consistent state with a default action. | |||
Thus, detecting the absence of a lookahead is sufficient to | |||
determine that there is no unexpected or expected token to | |||
report. In that case, just report a simple "syntax error". | |||
- Don't assume there isn't a lookahead just because this state is | |||
a consistent state with a default action. There might have | |||
been a previous inconsistent state, consistent state with a | |||
non-default action, or user semantic action that manipulated | |||
yychar. | |||
- Of course, the expected token list depends on states to have | |||
correct lookahead information, and it depends on the parser not | |||
to perform extra reductions after fetching a lookahead from the | |||
scanner and before detecting a syntax error. Thus, state | |||
merging (from LALR or IELR) and default reductions corrupt the | |||
expected token list. However, the list is correct for | |||
canonical LR with one exception: it will still contain any | |||
token that will not be accepted due to an error action in a | |||
later state. | |||
*/ | |||
if (yytoken != yyempty_) | |||
{ | |||
/* Start YYX at -YYN if negative to avoid negative indexes in | |||
YYCHECK. */ | |||
int yyxbegin = yyn < 0 ? -yyn : 0; | |||
/* Stay within bounds of both yycheck and yytname. */ | |||
int yychecklim = yylast_ - yyn + 1; | |||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; | |||
int count = 0; | |||
for (int x = yyxbegin; x < yyxend; ++x) | |||
if (yycheck_[x + yyn] == x && x != yyterror_) | |||
++count; | |||
// FIXME: This method of building the message is not compatible | |||
// with internationalization. It should work like yacc.c does it. | |||
// That is, first build a string that looks like this: | |||
// "syntax error, unexpected %s or %s or %s" | |||
// Then, invoke YY_ on this string. | |||
// Finally, use the string as a format to output | |||
// yytname_[tok], etc. | |||
// Until this gets fixed, this message appears in English only. | |||
res = "syntax error, unexpected "; | |||
res += yytnamerr_ (yytname_[tok]); | |||
if (count < 5) | |||
{ | |||
count = 0; | |||
for (int x = yyxbegin; x < yyxend; ++x) | |||
if (yycheck_[x + yyn] == x && x != yyterror_) | |||
{ | |||
res += (!count++) ? ", expecting " : " or "; | |||
res += yytnamerr_ (yytname_[x]); | |||
} | |||
} | |||
yyarg[yycount++] = yytname_[yytoken]; | |||
int yyn = yypact_[yystate]; | |||
if (!yy_pact_value_is_default_ (yyn)) | |||
{ | |||
/* Start YYX at -YYN if negative to avoid negative indexes in | |||
YYCHECK. In other words, skip the first -YYN actions for | |||
this state because they are default actions. */ | |||
int yyxbegin = yyn < 0 ? -yyn : 0; | |||
/* Stay within bounds of both yycheck and yytname. */ | |||
int yychecklim = yylast_ - yyn + 1; | |||
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; | |||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx) | |||
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ | |||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn])) | |||
{ | |||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | |||
{ | |||
yycount = 1; | |||
break; | |||
} | |||
else | |||
yyarg[yycount++] = yytname_[yyx]; | |||
} | |||
} | |||
} | |||
else | |||
#endif | |||
res = YY_("syntax error"); | |||
return res; | |||
char const* yyformat = 0; | |||
switch (yycount) | |||
{ | |||
#define YYCASE_(N, S) \ | |||
case N: \ | |||
yyformat = S; \ | |||
break | |||
YYCASE_(0, YY_("syntax error")); | |||
YYCASE_(1, YY_("syntax error, unexpected %s")); | |||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | |||
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | |||
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | |||
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | |||
#undef YYCASE_ | |||
} | |||
// Argument number. | |||
size_t yyi = 0; | |||
for (char const* yyp = yyformat; *yyp; ++yyp) | |||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) | |||
{ | |||
yyres += yytnamerr_ (yyarg[yyi++]); | |||
++yyp; | |||
} | |||
else | |||
yyres += *yyp; | |||
return yyres; | |||
} | |||
@@ -746,9 +845,9 @@ namespace lol { | |||
-68, -559, -559, -559, -559 | |||
}; | |||
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE | |||
doesn't specify something else to do. Zero means the default is an | |||
error. */ | |||
/* YYDEFACT[S] -- default reduction number in state S. Performed when | |||
YYTABLE doesn't specify something else to do. Zero means the | |||
default is an error. */ | |||
const unsigned short int | |||
LolFxParser::yydefact_[] = | |||
{ | |||
@@ -855,7 +954,7 @@ namespace lol { | |||
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | |||
positive, shift that token. If negative, reduce the rule which | |||
number is the opposite. If zero, do what YYDEFACT says. */ | |||
number is the opposite. If YYTABLE_NINF_, syntax error. */ | |||
const short int LolFxParser::yytable_ninf_ = -323; | |||
const short int | |||
LolFxParser::yytable_[] = | |||
@@ -3791,11 +3890,11 @@ namespace lol { | |||
} // lol | |||
/* Line 1053 of lalr1.cc */ | |||
#line 3796 "generated/lolfx-parser.cpp" | |||
/* Line 1136 of lalr1.cc */ | |||
#line 3895 "generated/lolfx-parser.cpp" | |||
/* Line 1055 of lalr1.cc */ | |||
/* Line 1138 of lalr1.cc */ | |||
#line 1298 "gpu/lolfx-parser.y" | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Skeleton interface for Bison LALR(1) parsers in C++ | |||
Copyright (C) 2002-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -40,20 +40,6 @@ | |||
#include <string> | |||
#include <iostream> | |||
#include "stack.hh" | |||
namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 49 "generated/lolfx-parser.h" | |||
class position; | |||
class location; | |||
} // lol | |||
/* Line 34 of lalr1.cc */ | |||
#line 56 "generated/lolfx-parser.h" | |||
#include "location.hh" | |||
/* Enabling traces. */ | |||
@@ -74,30 +60,11 @@ namespace lol { | |||
# define YYTOKEN_TABLE 0 | |||
#endif | |||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. | |||
If N is 0, then set CURRENT to the empty location which ends | |||
the previous symbol: RHS[0] (always defined). */ | |||
#ifndef YYLLOC_DEFAULT | |||
# define YYLLOC_DEFAULT(Current, Rhs, N) \ | |||
do { \ | |||
if (N) \ | |||
{ \ | |||
(Current).begin = (Rhs)[1].begin; \ | |||
(Current).end = (Rhs)[N].end; \ | |||
} \ | |||
else \ | |||
{ \ | |||
(Current).begin = (Current).end = (Rhs)[0].end; \ | |||
} \ | |||
} while (false) | |||
#endif | |||
namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 101 "generated/lolfx-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 68 "generated/lolfx-parser.h" | |||
/// A Bison parser. | |||
class LolFxParser | |||
@@ -108,7 +75,7 @@ namespace lol { | |||
union semantic_type | |||
{ | |||
/* Line 34 of lalr1.cc */ | |||
/* Line 35 of lalr1.cc */ | |||
#line 34 "gpu/lolfx-parser.y" | |||
int ival; | |||
@@ -118,8 +85,8 @@ namespace lol { | |||
/* Line 34 of lalr1.cc */ | |||
#line 123 "generated/lolfx-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 90 "generated/lolfx-parser.h" | |||
}; | |||
#else | |||
typedef YYSTYPE semantic_type; | |||
@@ -640,6 +607,14 @@ namespace lol { | |||
/// The location stack. | |||
location_stack_type yylocation_stack_; | |||
/// Whether the given \c yypact_ value indicates a defaulted state. | |||
/// \param yyvalue the value to check | |||
static bool yy_pact_value_is_default_ (int yyvalue); | |||
/// Whether the given \c yytable_ value indicates a syntax error. | |||
/// \param yyvalue the value to check | |||
static bool yy_table_value_is_error_ (int yyvalue); | |||
/// Internal symbol numbers. | |||
typedef unsigned short int token_number_type; | |||
/* Tables. */ | |||
@@ -647,7 +622,7 @@ namespace lol { | |||
static const short int yypact_[]; | |||
static const short int yypact_ninf_; | |||
/// For a state, default rule to reduce. | |||
/// For a state, default reduction number. | |||
/// Unless\a yytable_ specifies something else to do. | |||
/// Zero means the default is an error. | |||
static const unsigned short int yydefact_[]; | |||
@@ -678,10 +653,8 @@ namespace lol { | |||
static const char* const yytname_[]; | |||
#endif | |||
#if YYERROR_VERBOSE | |||
/// Convert the symbol name \a n to a form suitable for a diagnostic. | |||
virtual std::string yytnamerr_ (const char *n); | |||
#endif | |||
static std::string yytnamerr_ (const char *n); | |||
#if YYDEBUG | |||
/// A type to store symbol numbers and -1. | |||
@@ -739,8 +712,8 @@ namespace lol { | |||
} // lol | |||
/* Line 34 of lalr1.cc */ | |||
#line 744 "generated/lolfx-parser.h" | |||
/* Line 35 of lalr1.cc */ | |||
#line 717 "generated/lolfx-parser.h" | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Positions for Bison parsers in C++ | |||
Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -1,8 +1,8 @@ | |||
/* A Bison parser, made by GNU Bison 2.4.2. */ | |||
/* A Bison parser, made by GNU Bison 2.5. */ | |||
/* Stack handling for Bison parsers in C++ | |||
Copyright (C) 2002-2010 Free Software Foundation, Inc. | |||
Copyright (C) 2002-2011 Free Software Foundation, Inc. | |||
This program is free software: you can redistribute it and/or modify | |||
it under the terms of the GNU General Public License as published by | |||
@@ -38,7 +38,7 @@ | |||
namespace lol { | |||
/* Line 1066 of lalr1.cc */ | |||
/* Line 1149 of lalr1.cc */ | |||
#line 43 "generated/stack.hh" | |||
template <class T, class S = std::deque<T> > | |||
class stack | |||
@@ -128,7 +128,7 @@ namespace lol { | |||
} // lol | |||
/* Line 1152 of lalr1.cc */ | |||
/* Line 1235 of lalr1.cc */ | |||
#line 133 "generated/stack.hh" | |||
#endif // not BISON_STACK_HH[]dnl | |||
@@ -67,19 +67,19 @@ FrameBuffer::FrameBuffer(ivec2 size) | |||
if (FAILED(g_d3ddevice->CreateTexture(size.x, size.y, 1, | |||
D3DUSAGE_RENDERTARGET, | |||
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, | |||
&m_data->m_texture, NULL))) | |||
&m_data->m_texture, nullptr))) | |||
Abort(); | |||
if (FAILED(m_data->m_texture->GetSurfaceLevel(0, &m_data->m_surface))) | |||
Abort(); | |||
#elif defined _XBOX | |||
if (FAILED(g_d3ddevice->CreateTexture(size.x, size.y, 1, 0, | |||
D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, | |||
&m_data->m_texture, NULL))) | |||
&m_data->m_texture, nullptr))) | |||
Abort(); | |||
if (FAILED(g_d3ddevice->CreateRenderTarget(size.x, size.y, | |||
D3DFMT_A8R8G8B8, | |||
D3DMULTISAMPLE_NONE, 0, 0, | |||
&m_data->m_surface, NULL))) | |||
&m_data->m_surface, nullptr))) | |||
Abort(); | |||
#else | |||
# if GL_VERSION_1_1 | |||
@@ -114,7 +114,7 @@ FrameBuffer::FrameBuffer(ivec2 size) | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLenum)filtering); | |||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLenum)filtering); | |||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size.x, size.y, 0, | |||
format, GL_UNSIGNED_BYTE, NULL); | |||
format, GL_UNSIGNED_BYTE, nullptr); | |||
# if GL_VERSION_1_1 || GL_ES_VERSION_2_0 | |||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |||
@@ -200,9 +200,9 @@ void FrameBuffer::Unbind() | |||
Abort(); | |||
m_data->m_back_surface->Release(); | |||
#elif defined _XBOX | |||
if (FAILED(g_d3ddevice->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, | |||
m_data->m_texture, NULL, 0, 0, NULL, | |||
0, 0, NULL))) | |||
if (FAILED(g_d3ddevice->Resolve(D3DRESOLVE_RENDERTARGET0, nullptr, | |||
m_data->m_texture, nullptr, 0, 0, nullptr, | |||
0, 0, nullptr))) | |||
Abort(); | |||
if (FAILED(g_d3ddevice->SetRenderTarget(0, m_data->m_back_surface))) | |||
Abort(); | |||
@@ -67,7 +67,7 @@ IndexBuffer::IndexBuffer(size_t size) | |||
#if defined USE_D3D9 || defined _XBOX | |||
if (FAILED(g_d3ddevice->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY, | |||
D3DFMT_INDEX16, D3DPOOL_MANAGED, | |||
&m_data->m_ibo, NULL))) | |||
&m_data->m_ibo, nullptr))) | |||
Abort(); | |||
#else | |||
glGenBuffers(1, &m_data->m_ibo); | |||
@@ -93,7 +93,7 @@ IndexBuffer::~IndexBuffer() | |||
void *IndexBuffer::Lock(size_t offset, size_t size) | |||
{ | |||
if (!m_data->m_size) | |||
return NULL; | |||
return nullptr; | |||
#if defined USE_D3D9 || defined _XBOX | |||
void *ret; | |||
@@ -142,7 +142,7 @@ void IndexBuffer::Unbind() | |||
return; | |||
#if defined USE_D3D9 || defined _XBOX | |||
if (FAILED(g_d3ddevice->SetIndices(NULL))) | |||
if (FAILED(g_d3ddevice->SetIndices(nullptr))) | |||
Abort(); | |||
#else | |||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); | |||
@@ -91,10 +91,10 @@ Shader *Shader::Create(char const *lolfx) | |||
/* Parse the crap */ | |||
Array<char const *, char const *> sections; | |||
char *key = NULL; | |||
char *key = nullptr; | |||
for (char *parser = src; *parser; ) | |||
{ | |||
if (key == NULL && (parser[0] == '\n' || parser[0] == '\r') | |||
if (key == nullptr && (parser[0] == '\n' || parser[0] == '\r') | |||
&& parser[1] == '[') | |||
{ | |||
*parser = '\0'; | |||
@@ -109,7 +109,7 @@ Shader *Shader::Create(char const *lolfx) | |||
{ | |||
sections.Push(key, parser); | |||
parser++; | |||
key = NULL; | |||
key = nullptr; | |||
} | |||
else | |||
{ | |||
@@ -117,7 +117,7 @@ Shader *Shader::Create(char const *lolfx) | |||
} | |||
} | |||
char const *vert = NULL, *frag = NULL; | |||
char const *vert = nullptr, *frag = nullptr; | |||
for (int i = 0; i < sections.Count(); i++) | |||
{ | |||
#if !defined __CELLOS_LV2__ && !defined _XBOX && !defined USE_D3D9 | |||
@@ -177,7 +177,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
#if defined _XBOX | |||
{ "_XBOX", "1" }, | |||
#endif | |||
{ NULL, NULL } | |||
{ nullptr, nullptr } | |||
}; | |||
#elif !defined __CELLOS_LV2__ | |||
char buf[4096], errbuf[4096]; | |||
@@ -193,7 +193,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
/* Compile vertex shader */ | |||
data->vert_crc = ShaderData::hash(vert); | |||
#if defined USE_D3D9 || defined _XBOX | |||
hr = D3DXCompileShader(vert, (UINT)strlen(vert), macros, NULL, "main", | |||
hr = D3DXCompileShader(vert, (UINT)strlen(vert), macros, nullptr, "main", | |||
"vs_3_0", 0, &shader_code, &error_msg, | |||
&data->vert_table); | |||
if (FAILED(hr)) | |||
@@ -206,9 +206,9 @@ Shader::Shader(char const *vert, char const *frag) | |||
&data->vert_shader); | |||
shader_code->Release(); | |||
#elif !defined __CELLOS_LV2__ | |||
ShaderData::Patch(buf, vert, NULL); | |||
ShaderData::Patch(buf, vert, nullptr); | |||
data->vert_id = glCreateShader(GL_VERTEX_SHADER); | |||
glShaderSource(data->vert_id, 1, &shader, NULL); | |||
glShaderSource(data->vert_id, 1, &shader, nullptr); | |||
glCompileShader(data->vert_id); | |||
glGetShaderInfoLog(data->vert_id, sizeof(errbuf), &len, errbuf); | |||
@@ -226,8 +226,8 @@ Shader::Shader(char const *vert, char const *frag) | |||
#else | |||
data->vert_id = cgCreateProgram(cgCreateContext(), CG_SOURCE, vert, | |||
cgGLGetLatestProfile(CG_GL_VERTEX), | |||
NULL, NULL); | |||
if (data->vert_id == NULL) | |||
nullptr, nullptr); | |||
if (data->vert_id == nullptr) | |||
{ | |||
Log::Error("failed to compile vertex shader"); | |||
Log::Error("shader source:\n%s\n", vert); | |||
@@ -237,7 +237,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
/* Compile fragment shader */ | |||
data->frag_crc = ShaderData::hash(frag); | |||
#if defined USE_D3D9 || defined _XBOX | |||
hr = D3DXCompileShader(frag, (UINT)strlen(frag), macros, NULL, "main", | |||
hr = D3DXCompileShader(frag, (UINT)strlen(frag), macros, nullptr, "main", | |||
"ps_3_0", 0, &shader_code, &error_msg, | |||
&data->frag_table); | |||
if (FAILED(hr)) | |||
@@ -250,9 +250,9 @@ Shader::Shader(char const *vert, char const *frag) | |||
&data->frag_shader); | |||
shader_code->Release(); | |||
#elif !defined __CELLOS_LV2__ | |||
ShaderData::Patch(buf, NULL, frag); | |||
ShaderData::Patch(buf, nullptr, frag); | |||
data->frag_id = glCreateShader(GL_FRAGMENT_SHADER); | |||
glShaderSource(data->frag_id, 1, &shader, NULL); | |||
glShaderSource(data->frag_id, 1, &shader, nullptr); | |||
glCompileShader(data->frag_id); | |||
glGetShaderInfoLog(data->frag_id, sizeof(errbuf), &len, errbuf); | |||
@@ -270,8 +270,8 @@ Shader::Shader(char const *vert, char const *frag) | |||
#else | |||
data->frag_id = cgCreateProgram(cgCreateContext(), CG_SOURCE, frag, | |||
cgGLGetLatestProfile(CG_GL_FRAGMENT), | |||
NULL, NULL); | |||
if (data->frag_id == NULL) | |||
nullptr, nullptr); | |||
if (data->frag_id == nullptr) | |||
{ | |||
Log::Error("failed to compile fragment shader"); | |||
Log::Error("shader source:\n%s\n", frag); | |||
@@ -286,7 +286,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
{ | |||
D3DXCONSTANT_DESC cdesc; | |||
UINT count = 1; | |||
D3DXHANDLE h = data->frag_table->GetConstant(NULL, i); | |||
D3DXHANDLE h = data->frag_table->GetConstant(nullptr, i); | |||
data->frag_table->GetConstantDesc(h, &cdesc, &count); | |||
} | |||
data->vert_table->GetDesc(&desc); | |||
@@ -294,7 +294,7 @@ Shader::Shader(char const *vert, char const *frag) | |||
{ | |||
D3DXCONSTANT_DESC cdesc; | |||
UINT count = 1; | |||
D3DXHANDLE h = data->vert_table->GetConstant(NULL, i); | |||
D3DXHANDLE h = data->vert_table->GetConstant(nullptr, i); | |||
data->frag_table->GetConstantDesc(h, &cdesc, &count); | |||
} | |||
#elif !defined __CELLOS_LV2__ | |||
@@ -351,7 +351,7 @@ ShaderUniform Shader::GetUniformLocation(char const *uni) const | |||
UINT count; | |||
count = 0; | |||
hr = data->frag_table->GetConstantByName(NULL, tmpname); | |||
hr = data->frag_table->GetConstantByName(nullptr, tmpname); | |||
if (hr) | |||
data->frag_table->GetConstantDesc(hr, &cdesc, &count); | |||
if (count) | |||
@@ -361,7 +361,7 @@ ShaderUniform Shader::GetUniformLocation(char const *uni) const | |||
} | |||
count = 0; | |||
hr = data->vert_table->GetConstantByName(NULL, tmpname); | |||
hr = data->vert_table->GetConstantByName(nullptr, tmpname); | |||
if (hr) | |||
data->vert_table->GetConstantDesc(hr, &cdesc, &count); | |||
if (count) | |||
@@ -675,8 +675,8 @@ void Shader::Unbind() const | |||
{ | |||
#if defined USE_D3D9 || defined _XBOX | |||
HRESULT hr; | |||
hr = g_d3ddevice->SetVertexShader(NULL); | |||
hr = g_d3ddevice->SetPixelShader(NULL); | |||
hr = g_d3ddevice->SetVertexShader(nullptr); | |||
hr = g_d3ddevice->SetPixelShader(nullptr); | |||
#elif !defined __CELLOS_LV2__ | |||
/* FIXME: untested */ | |||
glUseProgram(0); | |||
@@ -728,7 +728,7 @@ int ShaderData::GetVersion() | |||
char const *test130 = | |||
"#version 130\n" | |||
"void main() { gl_Position = vec4(0.0, 0.0, 0.0, 0.0); }"; | |||
glShaderSource(id, 1, &test130, NULL); | |||
glShaderSource(id, 1, &test130, nullptr); | |||
glCompileShader(id); | |||
glGetShaderInfoLog(id, sizeof(buf), &len, buf); | |||
if (len <= 0) | |||
@@ -740,7 +740,7 @@ int ShaderData::GetVersion() | |||
char const *test120 = | |||
"#version 120\n" | |||
"void main() { gl_Position = vec4(0.0, 0.0, 0.0, 0.0); }"; | |||
glShaderSource(id, 1, &test120, NULL); | |||
glShaderSource(id, 1, &test120, nullptr); | |||
glCompileShader(id); | |||
glGetShaderInfoLog(id, sizeof(buf), &len, buf); | |||
if (len <= 0) | |||
@@ -835,7 +835,7 @@ void ShaderData::Patch(char *dst, char const *vert, char const *frag) | |||
"vec2 in_MultiTexCoord7 = gl_MultiTexCoord7.xy;", | |||
#endif | |||
NULL | |||
nullptr | |||
}; | |||
for (char const * const *rep = main_replaces; rep[0]; rep += 2) | |||
@@ -865,7 +865,7 @@ void ShaderData::Patch(char *dst, char const *vert, char const *frag) | |||
"out vec3", "varying vec3", | |||
"out vec4", "varying vec4", | |||
"out mat4", "varying mat4", | |||
NULL | |||
nullptr | |||
}; | |||
for (char const * const *rep = fast_replaces; rep[0]; rep += 2) | |||
@@ -115,7 +115,7 @@ Texture::Texture(ivec2 size, PixelFormat format) | |||
g_d3ddevice->CreateTexture(m_data->m_size.x, m_data->m_size.y, 1, | |||
d3d_usage, d3d_format, | |||
D3DPOOL_DEFAULT, &m_data->m_texture, NULL); | |||
D3DPOOL_DEFAULT, &m_data->m_texture, nullptr); | |||
m_data->m_bytes_per_elem = GET_CLAMPED(d3d_formats, format).bytes; | |||
#else | |||
static struct | |||
@@ -196,9 +196,9 @@ void Texture::SetData(void *data) | |||
#if defined _XBOX || defined USE_D3D9 | |||
D3DLOCKED_RECT rect; | |||
# if defined USE_D3D9 | |||
m_data->m_texture->LockRect(0, &rect, NULL, D3DLOCK_DISCARD); | |||
m_data->m_texture->LockRect(0, &rect, nullptr, D3DLOCK_DISCARD); | |||
# else | |||
m_data->m_texture->LockRect(0, &rect, NULL, 0); | |||
m_data->m_texture->LockRect(0, &rect, nullptr, 0); | |||
# endif | |||
memcpy(rect.pBits, data, rect.Pitch * m_data->m_size.y); | |||
@@ -216,7 +216,7 @@ void Texture::SetSubData(ivec2 origin, ivec2 size, void *data) | |||
{ | |||
#if defined _XBOX || defined USE_D3D9 | |||
D3DLOCKED_RECT rect; | |||
m_data->m_texture->LockRect(0, &rect, NULL, 0); | |||
m_data->m_texture->LockRect(0, &rect, nullptr, 0); | |||
int stride = size.x * m_data->m_bytes_per_elem; | |||
for (int j = 0; j < size.y; j++) | |||
@@ -612,8 +612,8 @@ VertexBuffer::VertexBuffer(size_t size) | |||
if (!size) | |||
return; | |||
#if defined USE_D3D9 || defined _XBOX | |||
if (FAILED(g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, NULL, | |||
D3DPOOL_MANAGED, &m_data->m_vbo, NULL))) | |||
if (FAILED(g_d3ddevice->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, nullptr, | |||
D3DPOOL_MANAGED, &m_data->m_vbo, nullptr))) | |||
Abort(); | |||
#else | |||
glGenBuffers(1, &m_data->m_vbo); | |||
@@ -639,7 +639,7 @@ VertexBuffer::~VertexBuffer() | |||
void *VertexBuffer::Lock(size_t offset, size_t size) | |||
{ | |||
if (!m_data->m_size) | |||
return NULL; | |||
return nullptr; | |||
#if defined USE_D3D9 || defined _XBOX | |||
void *ret; | |||
if (FAILED(m_data->m_vbo->Lock(offset, size, (void **)&ret, 0))) | |||
@@ -48,7 +48,7 @@ Gradient::Gradient(vec3 aa, vec3 bb) | |||
m_bbox[0] = aa; | |||
m_bbox[1] = bb; | |||
data->shader = NULL; | |||
data->shader = nullptr; | |||
} | |||
void Gradient::TickGame(float seconds) | |||
@@ -55,7 +55,7 @@ bool AndroidImageData::Open(char const *path) | |||
#if !LOL_RELEASE | |||
Log::Error("JVM environment not found, trying to attach thread\n"); | |||
#endif | |||
res = g_vm->AttachCurrentThread(&env, NULL); | |||
res = g_vm->AttachCurrentThread(&env, nullptr); | |||
} | |||
if (res < 0) | |||
{ | |||
@@ -53,7 +53,7 @@ bool GdiPlusImageData::Open(char const *path) | |||
Gdiplus::Status status; | |||
ULONG_PTR token; | |||
Gdiplus::GdiplusStartupInput input; | |||
status = Gdiplus::GdiplusStartup(&token, &input, NULL); | |||
status = Gdiplus::GdiplusStartup(&token, &input, nullptr); | |||
if (status != Gdiplus::Ok) | |||
{ | |||
#if !LOL_RELEASE | |||
@@ -63,11 +63,11 @@ bool GdiPlusImageData::Open(char const *path) | |||
} | |||
Array<String> pathlist = System::GetPathList(path); | |||
m_bitmap = NULL; | |||
m_bitmap = nullptr; | |||
for (int i = 0; i < pathlist.Count(); ++i) | |||
{ | |||
size_t len; | |||
len = mbstowcs(NULL, pathlist[i].C(), 0); | |||
len = mbstowcs(nullptr, pathlist[i].C(), 0); | |||
wchar_t *wpath = new wchar_t[len + 1]; | |||
if (mbstowcs(wpath, pathlist[i].C(), len + 1) == (size_t)-1) | |||
{ | |||
@@ -92,7 +92,7 @@ bool GdiPlusImageData::Open(char const *path) | |||
status, pathlist[i].C()); | |||
#endif | |||
delete m_bitmap; | |||
m_bitmap = NULL; | |||
m_bitmap = nullptr; | |||
} | |||
} | |||
@@ -77,9 +77,9 @@ bool Ps3ImageData::Open(char const *path) | |||
in_param.ppuThreadPriority = 1000; | |||
in_param.spuThreadPriority = 200; | |||
in_param.cbCtrlMallocFunc = Ps3ImageData::Malloc; | |||
in_param.cbCtrlMallocArg = NULL; | |||
in_param.cbCtrlMallocArg = nullptr; | |||
in_param.cbCtrlFreeFunc = Ps3ImageData::Free; | |||
in_param.cbCtrlFreeArg = NULL; | |||
in_param.cbCtrlFreeArg = nullptr; | |||
CellPngDecThreadOutParam out_param; | |||
err = cellPngDecCreate(&hmain, &in_param, &out_param); | |||
if (err != CELL_OK) | |||
@@ -95,7 +95,7 @@ bool Ps3ImageData::Open(char const *path) | |||
dec_src.srcSelect = CELL_PNGDEC_FILE; | |||
dec_src.fileOffset = 0; | |||
dec_src.fileSize = 0; | |||
dec_src.streamPtr = NULL; | |||
dec_src.streamPtr = nullptr; | |||
dec_src.streamSize = 0; | |||
dec_src.spuThreadEnable = CELL_PNGDEC_SPU_THREAD_ENABLE; | |||
CellPngDecSubHandle hsub; | |||
@@ -129,7 +129,7 @@ bool Ps3ImageData::Open(char const *path) | |||
} | |||
CellPngDecInParam in_dec_param; | |||
in_dec_param.commandPtr = NULL; | |||
in_dec_param.commandPtr = nullptr; | |||
in_dec_param.outputMode = CELL_PNGDEC_TOP_TO_BOTTOM; | |||
in_dec_param.outputColorSpace = CELL_PNGDEC_RGBA; | |||
in_dec_param.outputBitDepth = 8; | |||
@@ -78,7 +78,7 @@ bool SdlImageData::Open(char const *path) | |||
if (m_img->format->BytesPerPixel != 4) | |||
{ | |||
SDL_Surface *tmp = Create32BppSurface(size); | |||
SDL_BlitSurface(m_img, NULL, tmp, NULL); | |||
SDL_BlitSurface(m_img, nullptr, tmp, nullptr); | |||
SDL_FreeSurface(m_img); | |||
m_img = tmp; | |||
} | |||
@@ -39,8 +39,8 @@ public: | |||
private: | |||
static ImageData *Load(char const *path) | |||
{ | |||
ImageLoader *parser = Helper(NULL); | |||
ImageData *ret = NULL; | |||
ImageLoader *parser = Helper(nullptr); | |||
ImageData *ret = nullptr; | |||
while (parser && !ret) | |||
{ | |||
@@ -53,7 +53,7 @@ private: | |||
static ImageLoader *Helper(ImageLoader *set) | |||
{ | |||
static ImageLoader *loaders = NULL; | |||
static ImageLoader *loaders = nullptr; | |||
if (!set) | |||
return loaders; | |||
@@ -64,7 +64,7 @@ private: | |||
set->next = *parser; | |||
*parser = set; | |||
return NULL; | |||
return nullptr; | |||
} | |||
}; | |||
@@ -106,7 +106,7 @@ protected: | |||
if (!ret->Open(path)) \ | |||
{ \ | |||
delete ret; \ | |||
return NULL; \ | |||
return nullptr; \ | |||
} \ | |||
return ret; \ | |||
} \ | |||
@@ -31,7 +31,7 @@ namespace lol | |||
* Input implementation class | |||
*/ | |||
InputTracker* Input::m_input_tracker = NULL; | |||
InputTracker* Input::m_input_tracker = nullptr; | |||
static class InputData | |||
{ | |||
@@ -116,9 +116,9 @@ void InputTracker::UpdateActionStatus(float seconds) | |||
{ | |||
#if defined USE_SDL | |||
# if SDL_VERSION_ATLEAST(1,3,0) | |||
Uint8 *keystate = SDL_GetKeyboardState(NULL); | |||
Uint8 *keystate = SDL_GetKeyboardState(nullptr); | |||
# else | |||
Uint8 *keystate = SDL_GetKeyState(NULL); | |||
Uint8 *keystate = SDL_GetKeyState(nullptr); | |||
# endif | |||
//SOOOoooo ugly. | |||
for (int i = 0; i < Key::Last; ++i) | |||
@@ -270,9 +270,9 @@ vec2 Input::GetAxis(int axis) | |||
#if defined USE_SDL | |||
/* Simulate a joystick using the keyboard. This SDL call is free. */ | |||
# if SDL_VERSION_ATLEAST(1,3,0) | |||
Uint8 *keystate = SDL_GetKeyboardState(NULL); | |||
Uint8 *keystate = SDL_GetKeyboardState(nullptr); | |||
# else | |||
Uint8 *keystate = SDL_GetKeyState(NULL); | |||
Uint8 *keystate = SDL_GetKeyState(nullptr); | |||
# endif | |||
int left = keystate[SDLK_d] - (keystate[SDLK_a] | keystate[SDLK_q]); | |||
int up = (keystate[SDLK_w] | keystate[SDLK_z]) - keystate[SDLK_s] ; | |||
@@ -303,9 +303,9 @@ int Input::GetButtonState(int button) | |||
{ | |||
#if defined USE_SDL | |||
# if SDL_VERSION_ATLEAST(1,3,0) | |||
Uint8 *keystate = SDL_GetKeyboardState(NULL); | |||
Uint8 *keystate = SDL_GetKeyboardState(nullptr); | |||
# else | |||
Uint8 *keystate = SDL_GetKeyState(NULL); | |||
Uint8 *keystate = SDL_GetKeyState(nullptr); | |||
# endif | |||
return keystate[button]; | |||
#else | |||
@@ -401,7 +401,7 @@ void Input::SetMousePos(ivec2 coord) | |||
{ | |||
data->mouse = coord; | |||
WorldEntity *top = NULL; | |||
WorldEntity *top = nullptr; | |||
/* Find the top “widget” amongst all entities that match the | |||
* mouse coordinates */ | |||
@@ -486,7 +486,7 @@ Stick *Input::TrackStick(int desired) | |||
{ | |||
/* FIXME: add the possibility to choose amongst sticks */ | |||
if (desired >= data->m_sticks.Count()) | |||
return NULL; | |||
return nullptr; | |||
Ticker::Ref(data->m_sticks[desired]); | |||
return data->m_sticks[desired]; | |||
} | |||
@@ -19,7 +19,7 @@ namespace lol | |||
static inline void Abort() | |||
{ | |||
#if defined __CELLOS_LV2__ | |||
*(uint32_t *)NULL = 0xdead; | |||
*(uint32_t *)nullptr = 0xdead; | |||
#else | |||
std::abort(); | |||
#endif | |||
@@ -120,7 +120,7 @@ protected: | |||
template<typename T> inline void AddStream(int n, VertexUsage usage) | |||
{ | |||
m_streams[n].stream_type = GetType((T *)NULL); | |||
m_streams[n].stream_type = GetType((T *)nullptr); | |||
m_streams[n].usage = usage; | |||
m_streams[n].size = sizeof(T); | |||
} | |||
@@ -74,7 +74,7 @@ public: | |||
inline void Run(T a, T b, RealFunc *func, int decimals) | |||
{ | |||
Run(a, b, func, NULL, decimals); | |||
Run(a, b, func, nullptr, decimals); | |||
} | |||
T EvalCheby(T const &x) | |||
@@ -56,7 +56,7 @@ LevelMap::LevelMap(char const *path) | |||
char tmp[BUFSIZ]; | |||
int gids[LevelMapData::MAX_TILESETS]; | |||
uint32_t *tiles = NULL; | |||
uint32_t *tiles = nullptr; | |||
int level = 0, orientation = 0, ntiles = 0; | |||
FILE *fp = fopen(path, "r"); | |||
@@ -118,7 +118,7 @@ LevelMap::LevelMap(char const *path) | |||
Layer *l = new Layer(data->width, data->height, | |||
level, orientation, tiles); | |||
data->m_layers.Push(l); | |||
tiles = NULL; | |||
tiles = nullptr; | |||
//Log::Debug("new layer %ix%i\n", data->width, data->height); | |||
} | |||
} | |||
@@ -69,15 +69,15 @@ void AndroidApp::Tick() | |||
void *AndroidApp::MainRun(void *data) | |||
{ | |||
int argc = 1; | |||
char *argv[] = { "", NULL }; | |||
char *env[] = { NULL }; | |||
char *argv[] = { "", nullptr }; | |||
char *env[] = { nullptr }; | |||
/* Call the user's main() function. One of these will work. */ | |||
lol_android_main(); | |||
lol_android_main(argc, argv); | |||
lol_android_main(argc, argv, env); | |||
return NULL; | |||
return nullptr; | |||
} | |||
AndroidApp::~AndroidApp() | |||
@@ -107,7 +107,7 @@ Java_org_zoy_LolEngine_LolRenderer_nativeInit(JNIEnv* env) | |||
{ | |||
/* Initialise app thread and wait for it to be ready, ie. set | |||
* the FPS value at least. */ | |||
g_main_thread = new Thread(lol::AndroidApp::MainRun, NULL);; | |||
g_main_thread = new Thread(lol::AndroidApp::MainRun, nullptr); | |||
g_main_queue.Pop(); | |||
/* Launch our ticker */ | |||
@@ -91,13 +91,13 @@ bool NaClInstance::Init(uint32_t argc, | |||
{ | |||
/* Ensure only one NaClInstance does Init() at the same time. */ | |||
main_mutex.Lock(); | |||
char *env[] = { NULL }; | |||
char *env[] = { nullptr }; | |||
Args arglist(argc, const_cast<char **>(argv), const_cast<char **>(env)); | |||
main_queue.Push(&arglist); | |||
m_main_thread = new Thread(MainRun, NULL); | |||
m_main_thread = new Thread(MainRun, nullptr); | |||
/* Push so that only MainSignal() can unblock us */ | |||
main_queue.Push(NULL); | |||
main_queue.Push(NULL); | |||
main_queue.Push(nullptr); | |||
main_queue.Push(nullptr); | |||
main_mutex.Unlock(); | |||
// My timer callback | |||
@@ -120,7 +120,7 @@ void * NaClInstance::MainRun(void *data) | |||
lol_nacl_main(arglist->m_argc, arglist->m_argv); | |||
lol_nacl_main(arglist->m_argc, arglist->m_argv, arglist->m_env); | |||
return NULL; | |||
return nullptr; | |||
} | |||
void NaClInstance::MainSignal() | |||
@@ -145,7 +145,7 @@ void NaClInstance::DidChangeView(const pp::Rect& position, const pp::Rect& clip) | |||
m_size = ivec2(position.size().width(), position.size().height()); | |||
if (m_opengl_ctx == NULL) | |||
if (m_opengl_ctx == nullptr) | |||
m_opengl_ctx.reset(new OpenGLContext(this)); | |||
m_opengl_ctx->InvalidateContext(this); | |||
m_opengl_ctx->ResizeContext(position.size()); | |||
@@ -177,7 +177,7 @@ bool NaClInstance::HandleInputEvent(const pp::InputEvent& event) | |||
void NaClInstance::DrawSelf() | |||
{ | |||
if (m_opengl_ctx == NULL) | |||
if (m_opengl_ctx == nullptr) | |||
return; | |||
m_opengl_ctx->MakeContextCurrent(this); | |||
@@ -38,8 +38,10 @@ OpenGLContext::~OpenGLContext() { | |||
glSetCurrentContextPPAPI(0); | |||
} | |||
bool OpenGLContext::MakeContextCurrent(pp::Instance* instance) { | |||
if (instance == NULL) { | |||
bool OpenGLContext::MakeContextCurrent(pp::Instance* instance) | |||
{ | |||
if (instance == nullptr) | |||
{ | |||
glSetCurrentContextPPAPI(0); | |||
return false; | |||
} | |||
@@ -63,7 +63,7 @@ Ps3App::Ps3App(char const *title, ivec2 res, float fps) : | |||
cellSysmoduleLoadModule(CELL_SYSMODULE_USBD); | |||
cellSysmoduleLoadModule(CELL_SYSMODULE_IO); | |||
cellSysutilRegisterCallback(0, Ps3AppData::SysCallBack, NULL); | |||
cellSysutilRegisterCallback(0, Ps3AppData::SysCallBack, nullptr); | |||
PSGLinitOptions psglio; | |||
psglio.enable = PSGL_INIT_MAX_SPUS | |||
@@ -136,7 +136,7 @@ public: | |||
virtual ~ThreadBase() | |||
{ | |||
sys_ppu_thread_join(m_thread, NULL); | |||
sys_ppu_thread_join(m_thread, nullptr); | |||
} | |||
private: | |||
@@ -33,7 +33,7 @@ | |||
#endif | |||
#if defined USE_SDL && defined USE_D3D9 | |||
HWND g_hwnd = NULL; | |||
HWND g_hwnd = nullptr; | |||
extern IDirect3DDevice9 *g_d3ddevice; | |||
#endif | |||
@@ -87,7 +87,7 @@ SdlApp::SdlApp(char const *title, ivec2 res, float fps) : | |||
exit(EXIT_FAILURE); | |||
} | |||
SDL_WM_SetCaption(title, NULL); | |||
SDL_WM_SetCaption(title, nullptr); | |||
/* Initialise everything */ | |||
Ticker::Setup(fps); | |||
@@ -126,7 +126,7 @@ void SdlApp::Tick() | |||
hr = g_d3ddevice->EndScene(); | |||
if (FAILED(hr)) | |||
Abort(); | |||
hr = g_d3ddevice->Present(NULL, NULL, NULL, NULL); | |||
hr = g_d3ddevice->Present(nullptr, nullptr, nullptr, nullptr); | |||
if (FAILED(hr)) | |||
Abort(); | |||
# else | |||
@@ -196,7 +196,7 @@ void SdlInputData::Tick(float seconds) | |||
/* Send the whole keyboard state to the input system */ | |||
#if 0 | |||
Uint8 *keystate = SDL_GetKeyState(NULL); | |||
Uint8 *keystate = SDL_GetKeyState(nullptr); | |||
for (int i = 0; i < 256; i++) | |||
if (keystate[i]) | |||
Input::KeyPressed(i, seconds); | |||
@@ -67,7 +67,7 @@ void XboxApp::Tick() | |||
Ticker::TickDraw(); | |||
#if defined _XBOX | |||
g_d3ddevice->Present(NULL, NULL, NULL, NULL); | |||
g_d3ddevice->Present(nullptr, nullptr, nullptr, nullptr); | |||
#endif | |||
} | |||
@@ -75,7 +75,7 @@ private: | |||
static Scene *scene; | |||
}; | |||
Scene *SceneData::scene = NULL; | |||
Scene *SceneData::scene = nullptr; | |||
/* | |||
* Public Scene class | |||
@@ -56,7 +56,7 @@ class FileData | |||
#elif HAVE_STDIO_H | |||
if (m_fd) | |||
fclose(m_fd); | |||
m_fd = NULL; | |||
m_fd = nullptr; | |||
#endif | |||
} | |||
@@ -49,11 +49,11 @@ void Init(int argc, char *argv[], | |||
*/ | |||
#if defined HAVE_GETCWD | |||
char *cwd = getcwd(NULL, 0); | |||
char *cwd = getcwd(nullptr, 0); | |||
#elif defined HAVE__GETCWD || (defined _WIN32 && !defined _XBOX) | |||
char *cwd = _getcwd(NULL, 0); | |||
char *cwd = _getcwd(nullptr, 0); | |||
#else | |||
char *cwd = NULL; | |||
char *cwd = nullptr; | |||
#endif | |||
String binarydir = String(cwd ? cwd : ".") + SEPARATOR; | |||
free(cwd); | |||
@@ -39,7 +39,7 @@ public: | |||
MutexBase() | |||
{ | |||
#if defined HAVE_PTHREAD_H | |||
pthread_mutex_init(&m_mutex, NULL); | |||
pthread_mutex_init(&m_mutex, nullptr); | |||
#elif defined _WIN32 | |||
InitializeCriticalSection(&m_mutex); | |||
#endif | |||
@@ -88,12 +88,12 @@ public: | |||
m_start = m_count = 0; | |||
#if defined HAVE_PTHREAD_H | |||
m_poppers = m_pushers = 0; | |||
pthread_mutex_init(&m_mutex, NULL); | |||
pthread_cond_init(&m_empty_cond, NULL); | |||
pthread_cond_init(&m_full_cond, NULL); | |||
pthread_mutex_init(&m_mutex, nullptr); | |||
pthread_cond_init(&m_empty_cond, nullptr); | |||
pthread_cond_init(&m_full_cond, nullptr); | |||
#elif defined _WIN32 | |||
m_empty_sem = CreateSemaphore(NULL, CAPACITY, CAPACITY, NULL); | |||
m_full_sem = CreateSemaphore(NULL, 0, CAPACITY, NULL); | |||
m_empty_sem = CreateSemaphore(nullptr, CAPACITY, CAPACITY, nullptr); | |||
m_full_sem = CreateSemaphore(nullptr, 0, CAPACITY, nullptr); | |||
InitializeCriticalSection(&m_mutex); | |||
#endif | |||
} | |||
@@ -136,7 +136,7 @@ public: | |||
pthread_mutex_unlock(&m_mutex); | |||
#elif defined _WIN32 | |||
LeaveCriticalSection(&m_mutex); | |||
ReleaseSemaphore(m_full_sem, 1, NULL); | |||
ReleaseSemaphore(m_full_sem, 1, nullptr); | |||
#endif | |||
} | |||
@@ -168,7 +168,7 @@ public: | |||
pthread_mutex_unlock(&m_mutex); | |||
#else | |||
LeaveCriticalSection(&m_mutex); | |||
ReleaseSemaphore(m_empty_sem, 1, NULL); | |||
ReleaseSemaphore(m_empty_sem, 1, nullptr); | |||
#endif | |||
return ret; | |||
@@ -200,7 +200,7 @@ public: | |||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); | |||
pthread_create(&m_thread, &attr, fn, data); | |||
#elif defined _WIN32 | |||
m_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)fn, | |||
m_thread = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)fn, | |||
data, 0, &m_tid); | |||
#endif | |||
} | |||
@@ -208,7 +208,7 @@ public: | |||
virtual ~ThreadBase() | |||
{ | |||
#if defined HAVE_PTHREAD_H | |||
pthread_join(m_thread, NULL); | |||
pthread_join(m_thread, nullptr); | |||
#elif defined _WIN32 | |||
WaitForSingleObject(m_thread, INFINITE); | |||
#endif | |||
@@ -59,7 +59,7 @@ private: | |||
float GetSeconds(bool reset) | |||
{ | |||
struct timeval tv, tv0 = m_tv; | |||
gettimeofday(&tv, NULL); | |||
gettimeofday(&tv, nullptr); | |||
if (reset) | |||
m_tv = tv; | |||
return 1e-6f * (tv.tv_usec - tv0.tv_usec) + (tv.tv_sec - tv0.tv_sec); | |||
@@ -45,7 +45,7 @@ Text::Text(char const *text, char const *font) | |||
: data(new TextData()) | |||
{ | |||
data->font = Forge::Register(font); | |||
data->text = text ? strdup(text) : NULL; | |||
data->text = text ? strdup(text) : nullptr; | |||
data->length = text ? strlen(text) : 0; | |||
data->pos = vec3(0, 0, 0); | |||
@@ -56,7 +56,7 @@ void Text::SetText(char const *text) | |||
{ | |||
if (data->text) | |||
free(data->text); | |||
data->text = text ? strdup(text) : NULL; | |||
data->text = text ? strdup(text) : nullptr; | |||
data->length = text ? strlen(text) : 0; | |||
} | |||
@@ -39,7 +39,7 @@ public: | |||
quit(0), quitframe(0), quitdelay(20), panic(0) | |||
{ | |||
for (int i = 0; i < Entity::ALLGROUP_END; i++) | |||
list[i] = NULL; | |||
list[i] = nullptr; | |||
} | |||
~TickerData() | |||
@@ -114,7 +114,7 @@ void Ticker::Register(Entity *entity) | |||
void Ticker::Ref(Entity *entity) | |||
{ | |||
ASSERT(entity, "dereferencing NULL entity\n"); | |||
ASSERT(entity, "dereferencing nullptr entity\n"); | |||
ASSERT(!entity->m_destroy, | |||
"referencing entity scheduled for destruction %s\n", | |||
entity->GetName()); | |||
@@ -124,7 +124,7 @@ void Ticker::Ref(Entity *entity) | |||
/* Get the entity out of the m_autorelease list. This is usually | |||
* very fast since the first entry in autolist is the last | |||
* registered entity. */ | |||
for (Entity *e = data->autolist, *prev = NULL; e; | |||
for (Entity *e = data->autolist, *prev = nullptr; e; | |||
prev = e, e = e->m_autonext) | |||
{ | |||
if (e == entity) | |||
@@ -141,7 +141,7 @@ void Ticker::Ref(Entity *entity) | |||
int Ticker::Unref(Entity *entity) | |||
{ | |||
ASSERT(entity, "dereferencing NULL entity\n"); | |||
ASSERT(entity, "dereferencing null entity\n"); | |||
ASSERT(entity->m_ref > 0, "dereferencing unreferenced entity %s\n", | |||
entity->GetName()) | |||
ASSERT(!entity->m_autorelease, "dereferencing autoreleased entity %s\n", | |||
@@ -247,7 +247,7 @@ void *TickerData::GameThreadMain(void * /* p */) | |||
* before inserting awaiting objects, because only objects already | |||
* inthe tick lists can be marked for destruction. */ | |||
for (int i = 0; i < Entity::ALLGROUP_END; i++) | |||
for (Entity *e = data->list[i], *prev = NULL; e; ) | |||
for (Entity *e = data->list[i], *prev = nullptr; e; ) | |||
{ | |||
if (e->m_destroy && i < Entity::GAMEGROUP_END) | |||
{ | |||
@@ -321,7 +321,7 @@ void *TickerData::GameThreadMain(void * /* p */) | |||
Log::Info("ticker game thread terminated\n"); | |||
#endif | |||
return NULL; | |||
return nullptr; | |||
} | |||
void *TickerData::DrawThreadMain(void * /* p */) | |||
@@ -335,7 +335,7 @@ void *TickerData::DrawThreadMain(void * /* p */) | |||
data->gametick.Push(1); | |||
} | |||
return NULL; | |||
return nullptr; | |||
} | |||
void *TickerData::DiskThreadMain(void * /* p */) | |||
@@ -343,7 +343,7 @@ void *TickerData::DiskThreadMain(void * /* p */) | |||
/* FIXME: temporary hack to avoid crashes on the PS3 */ | |||
data->disktick.Pop(); | |||
return NULL; | |||
return nullptr; | |||
} | |||
void Ticker::SetState(Entity * /* entity */, uint32_t /* state */) | |||
@@ -361,10 +361,10 @@ void Ticker::Setup(float fps) | |||
{ | |||
data->fps = fps; | |||
data->gamethread = new Thread(TickerData::GameThreadMain, NULL); | |||
data->gamethread = new Thread(TickerData::GameThreadMain, nullptr); | |||
data->gametick.Push(1); | |||
data->diskthread = new Thread(TickerData::DiskThreadMain, NULL); | |||
data->diskthread = new Thread(TickerData::DiskThreadMain, nullptr); | |||
} | |||
void Ticker::TickDraw() | |||
@@ -70,7 +70,7 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count) | |||
data->path = data->name + 10; | |||
sprintf(data->name, "<tileset> %s", path); | |||
data->tiles = NULL; | |||
data->tiles = nullptr; | |||
data->m_texture = 0; | |||
data->img = new Image(path); | |||
data->isize = data->img->GetSize(); | |||
@@ -153,7 +153,7 @@ void TileSet::TickDraw(float seconds) | |||
if (pixels != data->img->GetData()) | |||
free(pixels); | |||
delete data->img; | |||
data->img = NULL; | |||
data->img = nullptr; | |||
} | |||
} | |||
@@ -307,7 +307,7 @@ void Video::Clear(ClearMask m) | |||
mask |= D3DCLEAR_ZBUFFER; | |||
if (m & ClearMask::Stencil) | |||
mask |= D3DCLEAR_STENCIL; | |||
if (FAILED(VideoData::d3d_dev->Clear(0, NULL, mask, | |||
if (FAILED(VideoData::d3d_dev->Clear(0, nullptr, mask, | |||
VideoData::clear_color, | |||
VideoData::clear_depth, 0))) | |||
Abort(); | |||
@@ -39,6 +39,11 @@ au Syntax cpp | |||
\ int2 int3 int4 int2x2 int3x3 int4x4 | |||
\ float2 float3 float4 float2x2 float3x3 float4x4 | |||
" Ensure we know about nullptr | |||
au Syntax cpp | |||
\ syn keyword cConstant | |||
\ nullptr | |||
""" | |||
""" LolFx language handler | |||