Check-in [b74a460519]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix NPE for rewrites; Minor work on table section output.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b74a46051965b973da4ca6db33c71dabb39cc6fd
User & Date: stephanie.gawroriski 2019-08-24 15:20:53
Context
2019-08-24
16:18
Record write address and size into sections. check-in: 7032868ffb user: stephanie.gawroriski tags: trunk
15:20
Fix NPE for rewrites; Minor work on table section output. check-in: b74a460519 user: stephanie.gawroriski tags: trunk
14:02
Make sections references in Rewrite because it will be recursive and we need to be able to garbage collect. check-in: 10e5d9198f user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/libs/io/net/multiphasicapps/io/TableSectionOutputStream.java.

174
175
176
177
178
179
180



















181
182
183
184
185
186
187
...
205
206
207
208
209
210
211
212
213
214
215
216




217
218
219
220
221
222
223
...
230
231
232
233
234
235
236







237
238
239
240
241
242
243
...
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
...
324
325
326
327
328
329
330
331
332
333
334
335

336
337
338
339
340
341
342
	 * @since 2019/08/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");



















		
		throw new todo.TODO();
	}
	
	/**
	 * This represents a single section within the output.
	 *
................................................................................
		protected final boolean isvariable;
		
		/** Data rewrites which are possible. */
		private final List<__Rewrite__> _rewrites =
			new LinkedList<>();
		
		/** The byte buffer data. */
		private byte[] _data =
			new byte[_BUFFER_SIZE];
		
		/** The current size of the section. */
		private int _size;




		
		/**
		 * Initializes the written section.
		 *
		 * @param __size The size to use.
		 * @param __align The alignment to use.
		 * @throws IllegalArgumentException If the size is zero or negative.
................................................................................
			if (__size != VARIABLE_SIZE && __size <= 0)
				throw new IllegalArgumentException("BD3l " + __size);
			
			// Set
			this.fixedsize = __size;
			this.alignment = (__align >= 1 ? __align : 1);
			this.isvariable = (__size == VARIABLE_SIZE);







		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
................................................................................
		{
			// {@squirreljme.error BD3m Size of section exceeded. (The size
			// of the section)}
			int size = this._size;
			if (!this.isvariable && size + 1 > this.fixedsize)
				throw new IOException("BD3m " + size);
			
			// Possibly resize the data array
			byte[] data = this._data;
			if (size >= data.length)
			{
				data = Arrays.copyOf(data, size + _BUFFER_SIZE);
				this._data = data;
			}
			
			// Write into the data
			data[size] = (byte)__b;
................................................................................
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BD3p Size of section exceeded.}
			int size = this._size;
			if (!this.isvariable && size + __l > this.fixedsize)
				throw new IOException("BD3p");
			
			// Possibly resize the data array
			byte[] data = this._data;
			if (size + __l >= data.length)
			{
				data = Arrays.copyOf(data, size + __l + _BUFFER_SIZE);

				this._data = data;
			}
			
			// Write into the data
			for (int i = 0; i < __l; i++)
				data[size++] = __b[__o++];
			







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<



>
>
>
>







 







>
>
>
>
>
>
>







 







|

|







 







|

|

|
>







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
...
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
	 * @since 2019/08/11
	 */
	public final void writeTo(OutputStream __os)
		throws IOException, NullPointerException
	{
		if (__os == null)
			throw new NullPointerException("NARG");
		
		// Our current file size
		int filesize = 0;
		
		// We must go through all of the sections, perform their required
		// alignment while additionally calculating their addresses within
		// the file for section references.
		List<Section> sections = this._sections;
		for (int i = 0, n = sections.size(); i < n; i++)
		{
			Section section = sections.get(i);
			
			throw new todo.TODO();
		}
		
		/*
		private int _size;
		private int _address =
		*/
		
		throw new todo.TODO();
	}
	
	/**
	 * This represents a single section within the output.
	 *
................................................................................
		protected final boolean isvariable;
		
		/** Data rewrites which are possible. */
		private final List<__Rewrite__> _rewrites =
			new LinkedList<>();
		
		/** The byte buffer data. */
		private byte[] _data;

		
		/** The current size of the section. */
		private int _size;
		
		/** The address of this section. */
		private int _address =
			-1;
		
		/**
		 * Initializes the written section.
		 *
		 * @param __size The size to use.
		 * @param __align The alignment to use.
		 * @throws IllegalArgumentException If the size is zero or negative.
................................................................................
			if (__size != VARIABLE_SIZE && __size <= 0)
				throw new IllegalArgumentException("BD3l " + __size);
			
			// Set
			this.fixedsize = __size;
			this.alignment = (__align >= 1 ? __align : 1);
			this.isvariable = (__size == VARIABLE_SIZE);
			
			// If this is a fixed size section, we never have to expand it
			// so we can allocate all the needed data!
			if (__size != VARIABLE_SIZE)
				this._data = new byte[__size];
			else
				this._data = new byte[_BUFFER_SIZE];
		}
		
		/**
		 * {@inheritDoc}
		 * @since 2019/08/11
		 */
		@Override
................................................................................
		{
			// {@squirreljme.error BD3m Size of section exceeded. (The size
			// of the section)}
			int size = this._size;
			if (!this.isvariable && size + 1 > this.fixedsize)
				throw new IOException("BD3m " + size);
			
			// Possibly resize the data array, only when variable
			byte[] data = this._data;
			if (this.isvariable && size >= data.length)
			{
				data = Arrays.copyOf(data, size + _BUFFER_SIZE);
				this._data = data;
			}
			
			// Write into the data
			data[size] = (byte)__b;
................................................................................
				throw new IndexOutOfBoundsException("IOOB");
			
			// {@squirreljme.error BD3p Size of section exceeded.}
			int size = this._size;
			if (!this.isvariable && size + __l > this.fixedsize)
				throw new IOException("BD3p");
			
			// Possibly resize the data array (only when variable)
			byte[] data = this._data;
			if (this.isvariable && size + __l >= data.length)
			{
				data = Arrays.copyOf(data,
					size + (__l < _BUFFER_SIZE ? _BUFFER_SIZE : __l));
				this._data = data;
			}
			
			// Write into the data
			for (int i = 0; i < __l; i++)
				data[size++] = __b[__o++];
			

Changes to runt/libs/io/net/multiphasicapps/io/__Rewrite__.java.

47
48
49
50
51
52
53

54
55
56
57
	{
		if (__type == null || __value == null)
			throw new NullPointerException("NARG");
		
		this._address = __addr;
		this._type = __type;
		this._value = __value;

		this._section = new WeakReference<>(__section);
	}
}








>
|



47
48
49
50
51
52
53
54
55
56
57
58
	{
		if (__type == null || __value == null)
			throw new NullPointerException("NARG");
		
		this._address = __addr;
		this._type = __type;
		this._value = __value;
		this._section = (__section == null ? null :
			new WeakReference<>(__section));
	}
}