Changeset 762 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src/DataTableGenerator.cpp
- Timestamp:
- Nov 5, 2008, 1:27:28 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/DataTableGenerator.cpp
r750 r762 1 1 #include "stdafx.h" 2 #include <boost/scoped_array.hpp> 2 3 3 4 using namespace ActiveBasic::Compiler; … … 147 148 } 148 149 149 int DataTableGenerator::MakeConstStringObjectToProcessStaticBuffer( DataTable &dataTable, const char *str ) 150 namespace 151 { 152 153 //仕様通りのStringオブジェクトにするため、strには\0終端の文字列を渡すこと。 154 int MakeConstStringObjectToProcessStaticBufferImpl( DataTable &dataTable, const void *str, int len, int charSize ) 150 155 { 151 156 const CClass &strClass = *compiler.GetObjectModule().meta.GetClasses().GetStringClassPtr(); 152 const CClass &objClass = strClass.GetSuperClass();153 157 154 158 // クラスに必要なバッファサイズを取得 … … 164 168 165 169 // クラスのバッファイメージを作成 166 BYTE *buffer = (BYTE *)calloc( size, 1);167 *(long *) (buffer + offsetForLength) = lstrlen( str );168 *(LONG_PTR *) (buffer + offsetForChars)= headOffset + size;170 boost::scoped_array<BYTE> buffer(new BYTE[size]); 171 *(long *)&buffer[offsetForLength] = len; 172 *(LONG_PTR *)&buffer[offsetForChars] = headOffset + size; 169 173 170 174 // クラスのバッファイメージをデータ領域へ追加 171 int dataTableOffset = dataTable.AddBinary( buffer, size );175 int dataTableOffset = dataTable.AddBinary( &buffer[0], size ); 172 176 173 177 // スケジューリング … … 178 182 179 183 // 文字列バッファをデータ領域へ追加 180 compiler.AddStringToDataTable( str);184 dataTable.AddBinary( str, (len + 1) * charSize ); 181 185 182 186 return dataTableOffset; 187 } 188 189 } 190 191 int DataTableGenerator::MakeConstStringObjectToProcessStaticBuffer( DataTable &dataTable, const char *str ) 192 { 193 if ( compiler.IsUnicode() ) 194 { 195 std::wstring ws = Jenga::Common::ToWString( str ); 196 return MakeConstStringObjectToProcessStaticBufferImpl( 197 dataTable, ws.c_str(), static_cast<int>(ws.size()), sizeof (wchar_t) ); 198 } 199 else 200 { 201 int len = (int)strlen( str ); 202 return MakeConstStringObjectToProcessStaticBufferImpl( dataTable, str, len, sizeof (char) ); 203 } 183 204 } 184 205
Note:
See TracChangeset
for help on using the changeset viewer.