Skip to content

Commit e0dfafd

Browse files
committed
Merge branch 'refactor/tokenizer' into autobuild/tokenizer
2 parents b003df4 + 99ce66a commit e0dfafd

File tree

15 files changed

+588
-371
lines changed

15 files changed

+588
-371
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
//******************************************************************************
2+
///
3+
/// @file backend/control/parsertask.cpp
4+
///
5+
/// This module implements the parser task in a multi-threaded architecture.
6+
///
7+
/// @copyright
8+
/// @parblock
9+
///
10+
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
12+
///
13+
/// POV-Ray is free software: you can redistribute it and/or modify
14+
/// it under the terms of the GNU Affero General Public License as
15+
/// published by the Free Software Foundation, either version 3 of the
16+
/// License, or (at your option) any later version.
17+
///
18+
/// POV-Ray is distributed in the hope that it will be useful,
19+
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
/// GNU Affero General Public License for more details.
22+
///
23+
/// You should have received a copy of the GNU Affero General Public License
24+
/// along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
///
26+
/// ----------------------------------------------------------------------------
27+
///
28+
/// POV-Ray is based on the popular DKB raytracer version 2.12.
29+
/// DKBTrace was originally written by David K. Buck.
30+
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
31+
///
32+
/// @endparblock
33+
///
34+
//******************************************************************************
35+
36+
// Unit header file must be the first file included within POV-Ray *.cpp files (pulls in config)
37+
#include "backend/control/parsertask.h"
38+
39+
// C++ variants of C standard header files
40+
// C++ standard header files
41+
// Boost header files
42+
// POV-Ray header files (base module)
43+
// (none at the moment)
44+
45+
// POV-Ray header files (core module)
46+
#include "core/scene/tracethreaddata.h"
47+
48+
// POV-Ray header files (parser module)
49+
#include "parser/parser.h"
50+
51+
// POV-Ray header files (backend module)
52+
#include "backend/scene/backendscenedata.h"
53+
54+
// this must be the last file included
55+
#include "base/povdebug.h"
56+
57+
namespace pov
58+
{
59+
60+
using namespace pov_parser;
61+
62+
ParserTask::ParserTask(std::shared_ptr<BackendSceneData> sd, const ParserOptions& opts) :
63+
SceneTask(new TraceThreadData(sd, opts.randomSeed), boost::bind(&ParserTask::SendFatalError, this, _1), "Parse", sd),
64+
mpParser(nullptr),
65+
mpBackendSceneData(sd),
66+
mOptions(opts),
67+
mLastProgressElapsedTime(0)
68+
{}
69+
70+
void ParserTask::Run()
71+
{
72+
mpParser.reset(new Parser(mpBackendSceneData, mOptions, messageFactory, *this, *this, *reinterpret_cast<TraceThreadData *>(GetDataPtr())));
73+
mpParser->Run();
74+
}
75+
76+
void ParserTask::Stopped()
77+
{
78+
mpParser.reset();
79+
RenderBackend::SendSceneFailedResult(mpBackendSceneData->sceneId, kUserAbortErr, mpBackendSceneData->frontendAddress);
80+
}
81+
82+
void ParserTask::Finish()
83+
{
84+
if (mpParser != nullptr)
85+
{
86+
mpParser->GetParserDataPtr()->timeType = TraceThreadData::kParseTime;
87+
mpParser->GetParserDataPtr()->realTime = ConsumedRealTime();
88+
mpParser->GetParserDataPtr()->cpuTime = ConsumedCPUTime();
89+
mpParser->Finish();
90+
mpParser.reset();
91+
}
92+
}
93+
94+
void ParserTask::SendFatalError(Exception& e)
95+
{
96+
if (mpParser != nullptr)
97+
mpParser->SendFatalError(e);
98+
}
99+
100+
UCS2String ParserTask::FindFile(UCS2String parsedFileName, unsigned int fileType)
101+
{
102+
return mpBackendSceneData->FindFile(GetPOVMSContext(), parsedFileName, fileType);
103+
}
104+
105+
IStream* ParserTask::ReadFile(const UCS2String& parsedFileName, const UCS2String& foundFileName, unsigned int fileType)
106+
{
107+
return mpBackendSceneData->ReadFile(GetPOVMSContext(), parsedFileName, foundFileName, fileType);
108+
}
109+
110+
OStream* ParserTask::CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append)
111+
{
112+
return mpBackendSceneData->CreateFile(GetPOVMSContext(), parsedFileName, fileType, append);
113+
}
114+
115+
void ParserTask::ReportProgress(POV_LONG tokenCount)
116+
{
117+
POV_LONG elapsedTime = ElapsedRealTime();
118+
if ((elapsedTime - mLastProgressElapsedTime) > kMinProgressReportInterval)
119+
{
120+
POVMS_Object obj(kPOVObjectClass_ParserProgress);
121+
obj.SetLong(kPOVAttrib_RealTime, elapsedTime);
122+
obj.SetLong(kPOVAttrib_CurrentTokenCount, tokenCount);
123+
RenderBackend::SendSceneOutput(mpBackendSceneData->sceneId, mpBackendSceneData->frontendAddress, kPOVMsgIdent_Progress, obj);
124+
Cooperate();
125+
mLastProgressElapsedTime = ElapsedRealTime();
126+
}
127+
}
128+
129+
} // end of namespace pov
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//******************************************************************************
2+
///
3+
/// @file backend/control/parsertask.h
4+
///
5+
/// Declarations related to the parser task.
6+
///
7+
/// @copyright
8+
/// @parblock
9+
///
10+
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
12+
///
13+
/// POV-Ray is free software: you can redistribute it and/or modify
14+
/// it under the terms of the GNU Affero General Public License as
15+
/// published by the Free Software Foundation, either version 3 of the
16+
/// License, or (at your option) any later version.
17+
///
18+
/// POV-Ray is distributed in the hope that it will be useful,
19+
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+
/// GNU Affero General Public License for more details.
22+
///
23+
/// You should have received a copy of the GNU Affero General Public License
24+
/// along with this program. If not, see <http://www.gnu.org/licenses/>.
25+
///
26+
/// ----------------------------------------------------------------------------
27+
///
28+
/// POV-Ray is based on the popular DKB raytracer version 2.12.
29+
/// DKBTrace was originally written by David K. Buck.
30+
/// DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
31+
///
32+
/// @endparblock
33+
///
34+
//******************************************************************************
35+
36+
#ifndef POVRAY_BACKEND_PARSERTASK_H
37+
#define POVRAY_BACKEND_PARSERTASK_H
38+
39+
// Module config header file must be the first file included within POV-Ray unit header files
40+
#include "backend/configbackend.h"
41+
42+
// C++ variants of C standard header files
43+
// (none at the moment)
44+
45+
// C++ standard header files
46+
#include <memory>
47+
48+
// Boost header files
49+
// POV-Ray header files (base module)
50+
// POV-Ray header files (core module)
51+
// (none at the moment)
52+
53+
// POV-Ray header files (parser module)
54+
#include "parser/parser.h"
55+
56+
// POV-Ray header files (backend module)
57+
#include "backend/support/task.h"
58+
59+
namespace pov
60+
{
61+
62+
using namespace pov_base;
63+
using namespace pov;
64+
65+
class ParserTask : public SceneTask, public pov_parser::Parser::FileResolver, public pov_parser::Parser::ProgressReporter
66+
{
67+
public:
68+
69+
ParserTask(std::shared_ptr<BackendSceneData> sd, const pov_parser::ParserOptions& opts);
70+
71+
/// @name @ref SceneTask related.
72+
/// @{
73+
74+
virtual void Run() override;
75+
virtual void Stopped() override;
76+
virtual void Finish() override;
77+
void SendFatalError(Exception& e);
78+
79+
/// @}
80+
/// @name @ref Parser::FileResolver related.
81+
/// @{
82+
83+
virtual UCS2String FindFile(UCS2String parsedFileName, unsigned int fileType) override;
84+
virtual IStream* ReadFile(const UCS2String& parsedFileName, const UCS2String& foundFileName, unsigned int fileType) override;
85+
virtual OStream* CreateFile(const UCS2String& parsedFileName, unsigned int fileType, bool append) override;
86+
87+
/// @}
88+
/// @name @ref Parser::ProgressReporter related.
89+
/// @{
90+
91+
static constexpr auto kMinProgressReportInterval = 1000; /// Minimum delay between progress reports (in milliseconds).
92+
virtual void ReportProgress(POV_LONG tokenCount) override;
93+
94+
/// @}
95+
96+
private:
97+
98+
std::unique_ptr<pov_parser::Parser> mpParser;
99+
std::shared_ptr<BackendSceneData> mpBackendSceneData;
100+
pov_parser::ParserOptions mOptions;
101+
POV_LONG mLastProgressElapsedTime;
102+
};
103+
104+
} // end of namespace pov
105+
106+
#endif // POVRAY_BACKEND_PARSERTASK_H

source/backend/control/scene.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// @parblock
99
///
1010
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1212
///
1313
/// POV-Ray is free software: you can redistribute it and/or modify
1414
/// it under the terms of the GNU Affero General Public License as
@@ -40,11 +40,12 @@
4040

4141
// frame.h must always be the first POV file included (pulls in platform config)
4242
#include "backend/frame.h"
43+
#include "backend/control/parsertask.h"
4344
#include "backend/control/scene.h"
4445

4546
#include "core/scene/tracethreaddata.h"
4647

47-
#include "parser/parser.h"
48+
#include "parser/parsertypes.h"
4849

4950
#include "backend/bounding/boundingtask.h"
5051
#include "backend/scene/view.h"
@@ -162,8 +163,8 @@ void Scene::StartParser(POVMS_Object& parseOptions)
162163
}
163164

164165
// do parsing
165-
sceneThreadData.push_back(dynamic_cast<TraceThreadData *>(parserTasks.AppendTask(new pov_parser::Parser(
166-
sceneData, bool(parseOptions.Exist(kPOVAttrib_Clock)), parseOptions.TryGetFloat(kPOVAttrib_Clock, 0.0), seed
166+
sceneThreadData.push_back(dynamic_cast<TraceThreadData *>(parserTasks.AppendTask(new pov_parser::ParserTask(
167+
sceneData, pov_parser::ParserOptions(bool(parseOptions.Exist(kPOVAttrib_Clock)), parseOptions.TryGetFloat(kPOVAttrib_Clock, 0.0), seed)
167168
))));
168169

169170
// wait for parsing

source/backend/frame.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/// @parblock
1212
///
1313
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
14-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
14+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1515
///
1616
/// POV-Ray is free software: you can redistribute it and/or modify
1717
/// it under the terms of the GNU Affero General Public License as
@@ -122,20 +122,6 @@ inline void Destroy_Float(DBL *x)
122122
delete x;
123123
}
124124

125-
/// @}
126-
///
127-
//******************************************************************************
128-
///
129-
/// @name Image Stuff
130-
/// @{
131-
132-
// Image types.
133-
134-
#define IMAGE_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
135-
#define NORMAL_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
136-
#define MATERIAL_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
137-
#define HF_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+POT_FILE
138-
139125
/// @}
140126
///
141127
//******************************************************************************

source/base/types.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// @parblock
99
///
1010
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1212
///
1313
/// POV-Ray is free software: you can redistribute it and/or modify
1414
/// it under the terms of the GNU Affero General Public License as
@@ -191,6 +191,20 @@ namespace pov_base
191191
/// @remark This value's type is unsigned.
192192
#define INTEGER64_SIGN_MASK (0x8000000000000000u)
193193

194+
/// @}
195+
///
196+
//******************************************************************************
197+
///
198+
/// @name Image Stuff
199+
/// @{
200+
201+
// Image types.
202+
203+
#define IMAGE_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
204+
#define NORMAL_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
205+
#define MATERIAL_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+IFF_FILE+GRAD_FILE
206+
#define HF_FILE GIF_FILE+SYS_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+BMP_FILE+EXR_FILE+HDR_FILE+POT_FILE
207+
194208
/// @}
195209
///
196210
//******************************************************************************

source/base/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/// @parblock
1313
///
1414
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
15-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
15+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1616
///
1717
/// POV-Ray is free software: you can redistribute it and/or modify
1818
/// it under the terms of the GNU Affero General Public License as
@@ -66,7 +66,7 @@
6666
/// @{
6767

6868
/// Copyright string.
69-
#define POV_RAY_COPYRIGHT "Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd."
69+
#define POV_RAY_COPYRIGHT "Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd."
7070

7171
/// First numerical component of official source code version ("major version") as integer.
7272
/// Increment this field (and set all subsequent fields to zero) to indicate a groundbreaking
@@ -100,7 +100,7 @@
100100
/// where `N` is a serial number starting at 1 in each phase, `TIME` is the number of minutes
101101
/// since 2000-01-01 00:00, and `FEATURE` is an arbitrary alphanumeric moniker for a particular
102102
/// experimental feature.
103-
#define POV_RAY_PRERELEASE "x.tokenizer.9971030"
103+
#define POV_RAY_PRERELEASE "x.tokenizer.9996595"
104104

105105
#if defined(DOXYGEN) && !defined(POV_RAY_PRERELEASE)
106106
// Work around doxygen being unable to document undefined macros.

0 commit comments

Comments
 (0)