July 19, 2007

Gathering and Researching (or: The Art Of Putting Together an Estimate)

Filed under: Distribute — Ryan Wilcox @ 8:45 pm

In case you haven’t noticed, the work so far in Project Distribute has simply been gathering components: finding a solid HTML control, finding a HTML template system. Part of this gathering is testing and research: making sure that we can do everything with the control that we’ll need to do with the control.

We’ve done that homework for wxWebKit. I haven’t yet finished evaluating Google CTemplate, and as soon as I find more than a few hours at a time to do some testing, that’ll be done as well.

Over the last few nights I’ve been sitting down, thinking about what I know so far, refining the Milestones I gave you before, and putting an estimate on each milestone. This thinking has uncovered some more questions I need to investigate, and more places we need to gather components.

I have one technical question left to resolve before I have a solid estimate for the first Milestone. With that line-item done I can gather up the components needed for the next steps, start learning and evaluating them, and estimate the next steps.

I can’t give you an estimate until I figure out if we can find good components or if we have to create something big from scratch. That’s where the research comes in (and why I’ve been poking hard at wxWebKit: it plays a pretty important part in the puzzle, we have to make sure it’s a good choice)

July 16, 2007

Shifting Gears

Filed under: Distribute — Ryan Wilcox @ 11:00 am

We know a lot about the JavaScript to/from C++ API in WebKit. We don’t have all the pieces yet (we don’t know how to call C++ from JavaScript, for example, and the code to convert a C++ value into a KJS::JSValue needs to be written), but for the sake of research let’s keep going forward for now.

We have a web control, but we need something to display in it. In our case (constructing HTML mostly from scratch) we really don’t want to code all that HTML into our C++ program: that would make the HTML much harder to change than it should be. Ideally we want to load the HTML from a file, run it through some HTML template system that replaces (markers we left in the HTML code) with values from the C++ program.

Over the weekend I looked into these systems, and I found two: ClearSilver and Google CTemplate. ClearSilver is a C based library, available for multiple languages (including C++ bindings). It looks well used from what I can see. It also looks really complex, and the C++ bindings are very involved.

Google’s CTemplate is much better: a very simple C++ facing API, and still a fairly powerful HTML templating language. It seems that Google is switching from ClearSilver over to this. This says two things to me: that it’s Fast Enough For Google, and There Has To Be A Reason Google Wrote Its Own When It Had ClearSilver. (I suspect the answer is: this is simpler).

So I’m going to take Google’s CTemplate out for a ride: see if we can get a very basic version of our main screen working.

July 9, 2007

Getting/Setting JavaScript variables with WebKit

Filed under: Distribute — Ryan Wilcox @ 8:53 pm

Further progress on the WebKit front. I’m working with Kevin Ollivier, the author of wxWebKit, to put C++ to JavaScript utilities into the framework itself. Right now this is focused mostly on calling JavaScript functions from C++, and translating C++ values into JSValues, but I suspect other things will come from this as well.

For example, this weekend (along with some C++ interface structuring) I was looking at my JavaScript function calling code and found something. Specifically, how to get and set JavaScript variables from C++. Not exactly what I was looking for, but very useful none-the-less.

void PutJSValue(const std::string& memberName, KJS::JSValue* val)  
{
WebCore::KJSProxy* js = m_frame->scriptProxy();
KJS::ScriptInterpreter* interp = js->interpreter();
KJS::ExecState* exec = interp->globalExec();
//TODO: error checking ASSERT(!exec->hadException()); 
KJS::JSLock lock;
//look up the object 
KJS::JSValue* JSMemberName = KJS::jsString( memberName.c_str() );
KJS::Identifier identifier( JSMemberName->toString(exec) );
KJS::JSObject* rootObj = interp->globalObject();
rootObj->put(exec, identifier, val);
if ( exec->hadException() )
{
KJS::JSValue* theEx = exec->exception();
//TODO: figure out how to convert UString to a wxString 
//use JSValue.toString() gives us a UString 
throw RuntimeJSError("Error while setting value in JavaScript");
}
}

There are still some things to do, of course. First, the matter of capturing exception information from JavaScript. Secondly, I don’t know if this method supports setting object members: say window.document.baseURI. I can access window.something, but I don’t know about anything more complex. Right now I’m not going to worry about it.

Next up: converting C++ values into JavaScript values (and back). Someday I will get to calling C++ functions from JavaScript…

Blog Now Matches Site (Again!)

Filed under: General Information — Ryan Wilcox @ 6:35 pm

My blog now looks like the rest of my site, almost a year after I moved to WordPress.

Thanks go to my sister, who, thanks to a bit of HTML knowledge from high school, was able to piece together this WordPress theme for me (while I was making money other places). Thanks Mara!