1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | int DataTable::AddBinary( const void *buffer, int size ){
|
---|
4 | int retSize = this->size;
|
---|
5 |
|
---|
6 | Realloc( this->size + size );
|
---|
7 | memcpy( (char *)this->buffer + retSize, buffer, size );
|
---|
8 |
|
---|
9 | return retSize;
|
---|
10 | }
|
---|
11 | int DataTable::Add( _int64 i64data ){
|
---|
12 | int retSize = size;
|
---|
13 | AddBinary( &i64data, sizeof( _int64 ) );
|
---|
14 | return retSize;
|
---|
15 | }
|
---|
16 | int DataTable::Add( int i32data ){
|
---|
17 | int retSize = size;
|
---|
18 | AddBinary( &i32data, sizeof( int ) );
|
---|
19 | return retSize;
|
---|
20 | }
|
---|
21 | int DataTable::Add( double dbl ){
|
---|
22 | int retSize = size;
|
---|
23 | AddBinary( &dbl, sizeof( double ) );
|
---|
24 | return retSize;
|
---|
25 | }
|
---|
26 | int DataTable::Add( float flt ){
|
---|
27 | int retSize = size;
|
---|
28 | AddBinary( &flt, sizeof( float ) );
|
---|
29 | return retSize;
|
---|
30 | }
|
---|
31 | int DataTable::AddString( const char *str )
|
---|
32 | {
|
---|
33 | return AddBinary( str, strlen( str ) + sizeof(char) );
|
---|
34 | }
|
---|
35 | int DataTable::AddString( const std::string &str )
|
---|
36 | {
|
---|
37 | return AddBinary( str.c_str(), static_cast<int>(str.size()) + sizeof(char) );
|
---|
38 | }
|
---|
39 | int DataTable::AddWString( const std::wstring &wstr )
|
---|
40 | {
|
---|
41 | return AddBinary( wstr.c_str(), static_cast<int>((wstr.length()+1)*sizeof(wchar_t)));
|
---|
42 | }
|
---|
43 | int DataTable::AddSpace( int size )
|
---|
44 | {
|
---|
45 | int retSize = this->size;
|
---|
46 | Realloc( this->size + size );
|
---|
47 | return retSize;
|
---|
48 | }
|
---|
49 | void DataTable::AddAlignment( int size )
|
---|
50 | {
|
---|
51 | if( this->size % size == 0 )
|
---|
52 | {
|
---|
53 | // 既に境界のとき
|
---|
54 | return;
|
---|
55 | }
|
---|
56 | Realloc( this->size + ( size - (int)(this->size%size) ) );
|
---|
57 | }
|
---|
58 |
|
---|
59 | void DataTable::ResetDataSectionBaseOffset( long dataSectionBaseOffset )
|
---|
60 | {
|
---|
61 | foreach( const Schedule &schedule, schedules )
|
---|
62 | {
|
---|
63 | if( schedule.GetType() == Schedule::DataTable )
|
---|
64 | {
|
---|
65 | #ifdef _WIN64
|
---|
66 | OverwriteInt64(
|
---|
67 | schedule.GetOffset(),
|
---|
68 | GetInt64( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
69 | );
|
---|
70 | #else
|
---|
71 | Overwrite(
|
---|
72 | schedule.GetOffset(),
|
---|
73 | GetLong( schedule.GetOffset() ) + dataSectionBaseOffset
|
---|
74 | );
|
---|
75 | #endif
|
---|
76 | }
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | void DataTable::Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors )
|
---|
81 | {
|
---|
82 | BOOST_FOREACH( Schedule &schedule, schedules )
|
---|
83 | {
|
---|
84 | schedule.Resolve( resolver, resolveErrors );
|
---|
85 | }
|
---|
86 | }
|
---|