[Scummvm-cvs-logs] SF.net SVN: scummvm:[49511] tools/branches/gsoc2010-decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Tue Jun 8 20:17:01 CEST 2010
Revision: 49511
http://scummvm.svn.sourceforge.net/scummvm/?rev=49511&view=rev
Author: pidgeot
Date: 2010-06-08 18:17:00 +0000 (Tue, 08 Jun 2010)
Log Message:
-----------
Add namespaces to engine-specific classes and refactor to use an Engine
class for all engine-specific object creation
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/Makefile.common
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h
tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h
Added Paths:
-----------
tools/branches/gsoc2010-decompiler/decompiler/engine.h
tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp
tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h
Modified: tools/branches/gsoc2010-decompiler/Makefile.common
===================================================================
--- tools/branches/gsoc2010-decompiler/Makefile.common 2010-06-08 17:24:29 UTC (rev 49510)
+++ tools/branches/gsoc2010-decompiler/Makefile.common 2010-06-08 18:17:00 UTC (rev 49511)
@@ -267,7 +267,8 @@
decompiler/disassembler.o \
decompiler/simple_disassembler.o \
decompiler/unknown_opcode.o \
- decompiler/scummv6/disassembler.o
+ decompiler/scummv6/disassembler.o \
+ decompiler/scummv6/engine.o
decompile_LIBS := \
-lboost_program_options
Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-06-08 17:24:29 UTC (rev 49510)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-06-08 18:17:00 UTC (rev 49511)
@@ -27,18 +27,20 @@
#include "objectFactory.h"
#include "disassembler.h"
-#include "scummv6/disassembler.h"
+#include "engine.h"
+#include "scummv6/engine.h"
+
namespace po = boost::program_options;
-#define ENGINE(id, description, disasmClass) engines[std::string(id)] = description; disassemblerFactory.addEntry<disasmClass>(std::string(id));
+#define ENGINE(id, description, engineClass) engines[std::string(id)] = description; engineFactory.addEntry<engineClass>(std::string(id));
int main(int argc, char** argv) {
try {
std::map<std::string, std::string> engines;
- ObjectFactory<Disassembler> disassemblerFactory;
+ ObjectFactory<Engine> engineFactory;
- ENGINE("scummv6", "SCUMM v6", ScummV6Disassembler);
+ ENGINE("scummv6", "SCUMM v6", Scumm::v6::Engine);
po::options_description visible("Options");
visible.add_options()
@@ -88,11 +90,11 @@
return 2;
}
- std::string engine = vm["engine"].as<std::string>();
+ Engine *engine = engineFactory.create(vm["engine"].as<std::string>());
std::string inputFile = vm["input-file"].as<std::string>();
//TODO: Process file
- Disassembler* disassembler = disassemblerFactory.create(engine);
+ Disassembler *disassembler = engine->getDisassembler();
disassembler->open(inputFile.c_str());
std::vector<Instruction> insts = disassembler->disassemble();
Added: tools/branches/gsoc2010-decompiler/decompiler/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/engine.h (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/engine.h 2010-06-08 18:17:00 UTC (rev 49511)
@@ -0,0 +1,33 @@
+/* ScummVM Tools
+ * Copyright (C) 2010 The ScummVM project
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef ENGINE_H
+#define ENGINE_H
+
+#include "disassembler.h"
+
+class Engine {
+public:
+ virtual Disassembler* getDisassembler() = 0;
+};
+
+#endif
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/engine.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp 2010-06-08 17:24:29 UTC (rev 49510)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.cpp 2010-06-08 18:17:00 UTC (rev 49511)
@@ -25,7 +25,7 @@
#include "disassembler.h"
-std::vector<Instruction> ScummV6Disassembler::disassemble() {
+std::vector<Instruction> Scumm::v6::Disassembler::disassemble() {
std::string blockName;
for (int i = 0; i < 4; i++) {
blockName += _f.readChar();
@@ -422,7 +422,7 @@
return _insts;
}
-void ScummV6Disassembler::readParameter(Parameter *p, char type) {
+void Scumm::v6::Disassembler::readParameter(Parameter *p, char type) {
switch (type) {
case 'c': //Character string
{
Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h 2010-06-08 17:24:29 UTC (rev 49510)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/disassembler.h 2010-06-08 18:17:00 UTC (rev 49511)
@@ -25,14 +25,18 @@
#include "decompiler/simple_disassembler.h"
-/**
- * Disassembler for SCUMMv6.
- */
-class ScummV6Disassembler : public SimpleDisassembler {
-public:
- std::vector<Instruction> disassemble();
+namespace Scumm {
+ namespace v6 {
+ /**
+ * Disassembler for SCUMMv6.
+ */
+ class Disassembler : public SimpleDisassembler {
+ public:
+ std::vector<Instruction> disassemble();
- void readParameter(Parameter *p, char type);
-};
+ void readParameter(Parameter *p, char type);
+ };
+ }
+}
#endif
Added: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp 2010-06-08 18:17:00 UTC (rev 49511)
@@ -0,0 +1,28 @@
+/* ScummVM Tools
+ * Copyright (C) 2010 The ScummVM project
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "engine.h"
+#include "disassembler.h"
+
+::Disassembler *Scumm::v6::Engine::getDisassembler() {
+ return new Disassembler();
+}
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h (rev 0)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h 2010-06-08 18:17:00 UTC (rev 49511)
@@ -0,0 +1,37 @@
+/* ScummVM Tools
+ * Copyright (C) 2010 The ScummVM project
+ *
+ * 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 the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCUMM_V6_ENGINE_H
+#define SCUMM_V6_ENGINE_H
+
+#include "../engine.h"
+
+namespace Scumm {
+ namespace v6 {
+ class Engine : public ::Engine {
+ public:
+ ::Disassembler *getDisassembler();
+ };
+ }
+}
+
+#endif
Property changes on: tools/branches/gsoc2010-decompiler/decompiler/scummv6/engine.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Modified: tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h 2010-06-08 17:24:29 UTC (rev 49510)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/disassembler_test.h 2010-06-08 18:17:00 UTC (rev 49511)
@@ -75,7 +75,7 @@
//1ab08298c9c8fb4c77953756989c7449 *script-15.dmp
void testScummv6DisassemblerScript15() {
try {
- ScummV6Disassembler s;
+ Scumm::v6::Disassembler s;
s.open("decompiler/test/script-15.dmp");
std::vector<Instruction> insts = s.disassemble();
TS_ASSERT(insts.size() == 11);
@@ -99,7 +99,7 @@
//f75f7ce110f378735d449f8eeb4a68e5 *script-31.dmp
void testScummv6DisassemblerScript31() {
try {
- ScummV6Disassembler s;
+ Scumm::v6::Disassembler s;
s.open("decompiler/test/script-31.dmp");
std::vector<Instruction> insts = s.disassemble();
TS_ASSERT(insts.size() == 5);
@@ -117,7 +117,7 @@
//9f09418bf34abbdec0ec54f388d8dca4 *script-33.dmp
void testScummv6DisassemblerScript33() {
try {
- ScummV6Disassembler s;
+ Scumm::v6::Disassembler s;
s.open("decompiler/test/script-33.dmp");
std::vector<Instruction> insts = s.disassemble();
TS_ASSERT(insts.size() == 10);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list