00001 00002 /* 00003 Copyright (c) 2008 Mathias Gottschlag 00004 00005 Permission is hereby granted, free of charge, to any person obtaining a copy 00006 of this software and associated documentation files (the "Software"), to deal 00007 in the Software without restriction, including without limitation the rights 00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 copies of the Software, and to permit persons to whom the Software is 00010 furnished to do so, subject to the following conditions: 00011 00012 The above copyright notice and this permission notice shall be included in 00013 all copies or substantial portions of the Software. 00014 00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 THE SOFTWARE. 00022 */ 00023 00024 #ifndef _STRUCTINFO_HPP_ 00025 #define _STRUCTINFO_HPP_ 00026 00027 #include <string> 00028 #include <vector> 00029 00030 #include "typeinfo.hpp" 00031 00032 namespace ps 00033 { 00037 class MemberInfo 00038 { 00039 public: 00040 std::string name; 00041 TypeInfo type; 00042 int offset; 00043 int size; 00044 }; 00048 class FunctionInfo 00049 { 00050 public: 00051 std::string name; 00052 void *function; 00053 TypeInfo rettype; 00054 std::vector<TypeInfo> arguments; 00055 }; 00063 class StructInfo 00064 { 00065 public: 00066 StructInfo(); 00067 ~StructInfo(); 00068 00069 void setSize(int size) 00070 { 00071 this->size = size; 00072 } 00073 00080 template <typename T> void setConstructor(void (*constructor)(T*)) 00081 { 00082 this->constructor = (void*)constructor; 00083 } 00090 template <typename T> void setDestructor(void (*destructor)(T*)) 00091 { 00092 this->destructor = (void*)destructor; 00093 } 00105 template <typename T> void setOpEqual(void (*opequal)(T*, int, char*, void*)) 00106 { 00107 this->opequal = (void*)opequal; 00108 } 00109 00117 void addMember(std::string name, TypeInfo type, int offset, int size); 00128 void addFunction(std::string name, void *function, 00129 TypeInfo rettype = TypeInfo(ETC_None), 00130 std::vector<TypeInfo> arguments = std::vector<TypeInfo>()); 00131 00132 int size; 00133 void *constructor; 00134 void *destructor; 00135 void *opequal; 00136 std::vector<MemberInfo> members; 00137 std::vector<FunctionInfo> functions; 00138 }; 00139 } 00140 00141 #endif 00142