Processing.js source code

Today, Feb 1st, I’ve been going through the JavaScript source for Processing.js, and I think I’ve figured out what I have to do, and how I have to do it, I’m just tno sure where.

I’m enabling the private keyword to be usable in Processing.js, bug number #133.

Last post I mentioned how I would just need to use the basis behind the public keyword, that I could just “flip that”, whatever that meant… I figured if public is working in Processing.js, the same concepts could be applied to private. Oh, how wrong I was.

What I have to do is, wherever a private variable is declared, I need to change the JavaScript to specify as a var. This link was helpful in refreshing my memory. An example.

private int i; //Java

var i; //JavaScript

I believe this is the concept. I should find where in the source a public variable is converted.

public int i;



and add a regex that does this feature, but with private.

There are a few things I have not fully thought through, yet, like if a variable is created in java without the use of public, the JavaScript probably finds the int word, and creates this.i anyway, and I don’t want to just look for all private and switch it with var, that would leave me with var this.i.

I don’t know exactly where in the source this needs to be done, but starting on line 71 there is a var called aCode going through multiple regex’s. What this is, is a string containing Java source, being parsed into JavaScript.

// Remove end-of-line comments
aCode = aCode.replace( /\/\/ .*\n/g, “\n” );

I’m going to replace instances of private with a regex in this manner.

I also must consider private functions, so a small check list, of things to consider.

  • Consider private member functions
  • Consider private member variables
  • Consider variations in the syntax

That seems to be all for now, I don’t think getting something working is going to take much longer, hopefully it’ll be done by Wed night.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: