-/*
- * Loader.h
- *
- * Created on: Sep 13, 2012
- * Author: holy
- */
-
#ifndef LOADER_LOADER_H_
#define LOADER_LOADER_H_
#include "ObjectFile.h"
#include "TypeDescription.h"
-namespace loader {
-
+#include <iosfwd>
#include <map>
#include <string>
#include <vector>
+#include <SDL.h>
+
+namespace loader {
class Loader {
public:
void Load(const std::string &file);
+ const std::map<std::string, LoadedExport> &Exports() const { return exports; }
+
+ std::ostream &Dump(std::ostream &) const;
+
private:
- void LoadHeader(LoadedObjectFile &);
- void LoadExports(LoadedObjectFile &);
- void LinkExternals(LoadedObjectFile &);
- void LoadImages(LoadedObjectFile &);
- void LinkObjects(LoadedObjectFile &);
- void LinkObject(LoadedObjectFile &, const TypeDescription &, char *object);
+ void LoadExports(char *src, Export *begin, Export *end);
+ void LoadExternals(char *src, External *begin, External *end);
+ void LoadImages(char *src, Image *begin, Image *end);
+ void LoadObjects(char *src, Object *begin, Object *end);
+ void LoadObject(char *src, char *dest, const TypeDescription &);
+ void LoadArrays(char *src, Array *begin, Array *end);
+ void LoadScripts(char *src, Script *begin, Script *end);
+
+ void InitObjects(Object *begin, Object *end);
+ void InitObject(char *object, const TypeDescription &);
+ void InitArrays(Array *begin, Array *end);
+
+ struct MissingExternal {
+ std::string identifier;
+ char *dest;
+ int typeId;
+ bool inlined;
+ };
+ void LinkExternal(const MissingExternal &, const LoadedExport &);
private:
- std::map<std::string, LoadedObjectFile> objectFiles;
+ std::map<std::string, char *> objectFiles;
std::map<std::string, LoadedExport> exports;
+ std::map<std::string, SDL_Surface *> images;
+ std::vector<MissingExternal> unlinked;
};
}
-#endif /* LOADER_LOADER_H_ */
+
+
+namespace std {
+
+inline ostream &operator <<(ostream &o, const loader::Loader &l) {
+ return l.Dump(o);
+}
+
+}
+
+#endif