billroper: (Default)
The substantially rewritten parser is now running.

It is not yet running properly, but that's what debugging is for. :)

(I've already fixed about half-a-dozen minor bugs, mostly introduced by having to use new String handling functions that are different from the ones I used in C++. More to fix on Monday, to be sure...)
billroper: (Default)
I added another new helper class to the parser -- actually to the Parseable helper class. This will fetch a function call and any / all of its arguments and store them in the class, which allows the code to be much simpler and more consistent. So you call the getFunction() method on a Parseable object and, if the Parseable object is a function call, it passes back a FunctionInfo object with the correct Function enum member and an array of arguments to the function as Argument objects (which extend Parseable, so any of them can be parsed themselves).

Then I just pick off the Function enum and route the FunctionInfo object to the specific parser method that generates the correct byte codes for the function and its arguments.

Patching all of this in is a bit tedious, but I suspect it will greatly improve my debugging and testing later. :)
billroper: (Default)
I had just about finished rearranging the parser logic in Java, when I realized that I could substantially improve my life by adding a helper class that keeps track of the current bit of the string that's being parsed, the position of that string relative to the original string (for error messaging), and the operator to apply to the bit of string once the parsing is complete.

So I'm refactoring. The resulting code will be much easier to live with and quite likely much easier to convert to some "standard" parsing system in the future, if that proves to be helpful.
billroper: (Default)
Last week, I started browsing through the source code for the Apache POI library, because the examples and documentation that I'd been finding were woefully inadequate for the task I was working on. Today, everything finally clicked when I came to realize that there just doesn't seem to be a way to use POI to write a compound document back out into the original file. (Maybe there's something that will do it there, but I haven't found it yet.)

So I've now managed to recode everything to write the changed streams out to a new file, along with all of the unchanged streams from the old file. And that seems to be working fine now.

On to the next little bit... :)

51,201

Feb. 11th, 2014 06:17 pm
billroper: (Default)
Not counting the smaller (but, in some cases, still significant) side packages that amount to another 9000 lines of code, I have now ported 51,201 lines of C++ code to Java.

Using this code base, I am able to open up two entities, add them up into a third entity, and write the results back to disk in a way that our current product can read.

And there was much rejoicing. :)
billroper: (Default)
After getting the Java code to compile, I started trying to use some of the 48,000 lines of code that I'd ported for something other than serialization in and back out. This started showing up the places where I'd stopped the port and stubbed things out and where there are differences between the Java and C++ basic architecture that I'd planned when I started this many months ago.

I can now locate members of the Account and Time dimensions. I can't actually retrieve data yet, because that runs into a stub in the Account class, but I think I will refactor and delegate that problem to the data storage class that the Accounts contain.

And then all of this will start doing something hypothetically useful. :)
billroper: (Default)
At some point late this morning, I came to the horrible realization that the absence of the "const" keyword in Java, coupled with the absence of operator overloading, meant that all of the code that I was porting across from C++ had an ugly, ugly hole in it.

I have ID classes that I use to locate several types of objects in the C++ code. In C++, I would write code like:


const CPdID& id = pPd->GetID();
PdID modifiableID = pPd->GetID();


The first case wouldn't make a copy of the const reference that GetID() returns and I wouldn't be allowed to change it, while the second line would assign the contents of the const reference to my new PdID, since I'd overloaded operator=. And all was right with the world.

Except when I converted that to Java, I ended up with:


PdID id = pPd.GetID();
PdID modifiableID = pPd.GetID();


Now in this case, I have taken the reference that pPd.GetID() has returned that I did not want to modify and am happily going to modify it, because I didn't -- and couldn't -- define the function return as const. Ick.

So I have now made PdID immutable by removing all of the mutators that belong to the class. And I've added a MutablePdID which extends PdID and contains all of the mutators that are no longer in PdID. Add toMutable() and toImmutable() methods to each class that will create new objects as required, and my IDs Formerly Known As Const are now safe from the ravages of clueless coding.

The result looks like:


PdID id = pPd.GetID();
MutablePdID modifiableID = new MutablePdID( pPd.GetID());
// The case below is not preferred (by me), because if GetID() returned a MutablePdID,
// I could change the returned object without intending to. Oops.
//MutablePdID modifiableID = pPd.GetID().toMutable();


This was an exciting way to spend a day of work...

Back At It

Jan. 29th, 2014 10:16 pm
billroper: (Default)
Katie and Julie piled into the van with us and were dropped off at school this morning, resuming normal schedules. :)

In other news, I have been cleaning out the compilation errors in my Java port. The end is in sight, although the nasty tendency of JDeveloper to hide vast tracts of errors until something else has been cleaned up makes estimating how far I am from the end just a bit more difficult.

*sigh*
billroper: (Default)
It's just amazing how many compile errors you can pile up when you're frantically converting code and not even trying to compile, because the compiler only gives you the first hundred errors and most of those are due to functions that you haven't ported yet.

The number of errors is going down pretty quickly now, but it's a slog.
billroper: (Default)
Well, I thought that Apache MINA was going to solve my problem of wanting an expandable ByteBuffer. However, when I read another bit of the documentation, it seems they've decided that trying to solve their particular problem with an expandable ByteBuffer was a bad idea, so they'll be taking it out of the next major release of the project. *sigh*

So I will roll my own. It's not inherently that complex. It's just tedious.

Because I needed to be writing some more tedious code right now...
billroper: (Default)
I'm working on bringing the formula processor up in Java right now. This requires interpreting a byte array as a variety of different kinds of values, while keeping track of whether the byte array contains values in big endian or little endian order. ByteBuffer would seem like a fine choice, but it doesn't automatically expand as I write to it, nor does it retrieve all of the types of values that I'd like to store in the array.

Apparently, someone working on the Apache MINA project had the same warm thoughts about ByteBuffer and rolled their own extension, IoBuffer, which appears to do all of the things that I'd like it to do.

This makes me happy. :)
billroper: (Default)
So I'm still working on porting my code from C++ to Java. I'm over the 40,000 line mark now, which is good, but there is still a lot of stuff left to port. I've been working through the Var class for several days and am nearing the 6000 line mark there. (It's a large and important class with many methods.) And as I work down through it, I run into many other classes that aren't completed where I either go "I'll fix that later" or "I should go fix that now".

So I needed to copy an object that held an array of other complex objects that held still more complex objects along with a metric ton of ordinary data. And I was about to swear and write yet another copy constructor (because I am a recalcitrant C++ programmer apparently) when I suddenly realized that I was about to do way too much work.

If I implement the Cloneable interface and the clone() method on these objects, then I get a free bitwise copy of everything that they contain. So for that object with a metric ton of ordinary data, I just call super.clone() and I have now copied the metric ton of ordinary data and only need to fix up and clone the complex objects that I want to have new copies of, since my intent is to do a deep copy when calling clone().

So I ran around and implemented all of the necessary clone functions for half a dozen classes.

And the code base got 47 lines longer. Instead of a whole lot more lines of mechanical copying which would have pumped up the line count, but not actually done any more work.

Oh.

OK. I guess I'm not yet too old to learn some new tricks. :)
billroper: (Default)
With a few adjustments to get everything into alignment, my Java-based reader/writer for our old file format is working nicely. I managed to read a 90 MB file and write it back out so that the old application could successfully read it, so I'm going to count that as a success.

It is amazing how much faster the file writing got when I wrappered the FileOutputStream with a BufferedOutputStream. :)

I also managed to save about 7% (which was much less impressive, but nice to have) by fetching and storing the default constructor for the class and calling Constructor.newInstance instead of Class.newInstance.

Since I promised this bit of coding would be done this week, I'm feeling pretty good about it...

It Lives!

Nov. 6th, 2013 06:30 pm
billroper: (Default)
I can now read -- to a first approximation! -- the old binary format for our data in Java.

Next is to be able to write the format successfully, which will take a little bit longer, because some of the code that I copied in from the previous version of this didn't implement writing. I will need to add the necessary logic there.

And there are some classes that are missing in the test data that I'm working with that I'll have to test with some different data.

Later.
billroper: (Default)
In more ways than one.

Windycon starts setting up Thursday night and gets into full swing on Friday. I hope I'll see a lot of you there!

And I keep on pushing through new Java classes. Today, I successfully read all of the account-related classes, which is the vast majority of the classes that needed to be written. Sadly, not all of them.
billroper: (Default)
I can now read many of the classes in my binary file, but I stopped somewhere over 300 variables in due to a serialization error of some kind.

Tomorrow, I'll figure out which class has the bum instruction in it and see what fails next...

(The previous failure was because I forgot to declare one of my variables as static. *oops*)
billroper: (Default)
The set of Java classes that I'm working on are not yet complete, but I was able to read a chunk of the old binary file format successfully today. Of course, this required fixing a bunch of little buglets.

For example, Unicode characters on an Intel box in C++ are stored in little endian format. In Java, Unicode characters are stored in big endian format. All of the stored binary strings have to have bytes flipped both inbound and outbound. Also, Java does not have unsigned primitive types and the legacy binary format that I'm using makes extensive use of unsigned math when reading the data.

All of this makes life exciting. :)
billroper: (Default)
I am coding up Java classes at what seems like a tremendous pace. It is not a fast enough pace, but I am making progress.

The problem is that it's very hard to see the progress until everything is done.

*sigh*
billroper: (Default)
I'm shuffling the XML generation and reading code that I've been working on to try to produce an XML format that is more satisfactory to others in the group. Unfortunately, this requires a lot of cutting, pasting, and assorted editing. With any luck, I'll finish it up tomorrow and then I'll be able to see what I've got.

XML Hell

Jul. 10th, 2013 11:10 pm
billroper: (Default)
Everyone appears to have a different idea about what well-formatted XML looks like. This makes life entertaining.

Profile

billroper: (Default)
billroper

March 2026

S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25262728
293031    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 26th, 2026 04:42 pm
Powered by Dreamwidth Studios