Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove a ton of cruft in favor of the much simpler techniques invente…

…d by github user kazimuth.
  • Loading branch information...
commit 7871d36e74985c3d765253da2a541845cf7e00f8 1 parent fcc923b
@jdf authored
View
1  .classpath
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="runtime/src"/>
<classpathentry kind="src" path="testing/src"/>
- <classpathentry kind="src" path="runtime/generated"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="buildtime/lib/jython/jython.jar" sourcepath="buildtime/lib/jython/jython-2.5.3-sources.jar"/>
View
2  .gitmodules
@@ -1,3 +1,5 @@
[submodule "externals/processing"]
path = externals/processing
url = git@github.com:processing/processing.git
+ ignore = dirty
+
View
27 build.xml
@@ -65,11 +65,10 @@
</jar>
</target>
- <target name="build" depends="generate-driver,build-processing">
+ <target name="build" depends="build-processing">
<mkdir dir="bin"/>
<javac destdir="bin" includeantruntime="false">
<src path="runtime/src"/>
- <src path="runtime/generated"/>
<classpath>
<pathelement location="${jython}"/>
<pathelement location="${corejar}"/>
@@ -109,27 +108,6 @@
<ant dir="externals/processing/build" target="build"/>
</target>
- <target name="check-driver-required">
- <uptodate property="driver-is-generated"
- srcfile="buildtime/template/DriverImpl.java.cog"
- targetfile="runtime/generated/jycessing/DriverImpl.java"/>
- </target>
- <target name="generate-driver"
- depends="check-driver-required,build-processing"
- unless="driver-is-generated"
- description="Generate DriverImpl class">
- <java
- classpath="${jython}:${corejar}:${joglall}:${gluegenrt}"
- classname="org.python.util.jython"
- fork="true">
- <arg value="buildtime/py/cog.py"/>
- <arg value="-U"/>
- <arg value="-o"/>
- <arg value="runtime/generated/jycessing/DriverImpl.java"/>
- <arg value="buildtime/template/DriverImpl.java.cog"/>
- </java>
- </target>
-
<target name="clean">
<ant dir="externals/processing/build" target="clean"/>
<rm-rf target="bin"/>
@@ -140,9 +118,6 @@
<delete>
<fileset dir="buildtime/py" includes="*.class"/>
</delete>
- <delete>
- <fileset dir="buildtime/lib/jython/Lib/cogapp" includes="*.class"/>
- </delete>
<exec executable="find" failonerror="true">
<arg line=". -name .DS_Store -depth -exec rm {} ;"/>
</exec>
View
7 buildtime/lib/jython/Lib/cogapp/__init__.py
@@ -1,7 +0,0 @@
-""" Cog code generation tool.
- http://nedbatchelder.com/code/cog
-
- Copyright 2004-2005, Ned Batchelder.
-"""
-
-from cogapp import *
View
709 buildtime/lib/jython/Lib/cogapp/cogapp.py
@@ -1,709 +0,0 @@
-""" Cog code generation tool.
- http://nedbatchelder.com/code/cog
-
- Copyright 2004-2009, Ned Batchelder.
-"""
-
-import copy, getopt, imp, os, string, shlex, sys, traceback
-from cStringIO import StringIO
-
-# The recommended way to compute md5's changed in Python 2.5
-try:
- import hashlib
- hash_factory = hashlib.md5
-except ImportError:
- import md5
- hash_factory = md5.new
-
-__all__ = ['Cog', 'CogUsageError']
-
-__version__ = '2.2' # History at the end of the file.
-
-usage = """\
-cog - generate code with inlined Python code.
-
-cog [OPTIONS] [INFILE | @FILELIST] ...
-
-INFILE is the name of an input file.
-FILELIST is the name of a text file containing file names or
- other @FILELISTs.
-
-OPTIONS:
- -c Checksum the output to protect it against accidental change.
- -d Delete the generator code from the output file.
- -D name=val Define a global string available to your generator code.
- -e Warn if a file has no cog code in it.
- -I PATH Add PATH to the list of directories for data files and modules.
- -o OUTNAME Write the output to OUTNAME.
- -r Replace the input file with the output.
- -s STRING Suffix all generated output lines with STRING.
- -U Write the output with Unix newlines (only LF line-endings).
- -w CMD Use CMD if the output file needs to be made writable.
- A %s in the CMD will be filled with the filename.
- -x Excise all the generated output without running the generators.
- -z The [[[end]]] marker can be omitted, and is assumed at eof.
- -v Print the version of cog and exit.
- -h Print this help.
-"""
-
-# Other package modules
-from whiteutils import *
-
-class CogError(Exception):
- """ Any exception raised by Cog.
- """
- def __init__(self, msg, file='', line=0):
- if file:
- Exception.__init__(self, "%s(%d): %s" % (file, line, msg))
- else:
- Exception.__init__(self, msg)
-
-class CogUsageError(CogError):
- """ An error in usage of command-line arguments in cog.
- """
- pass #pragma: no cover
-
-class CogInternalError(CogError):
- """ An error in the coding of Cog. Should never happen.
- """
- pass #pragma: no cover
-
-class CogGeneratedError(CogError):
- """ An error raised by a user's cog generator.
- """
- pass #pragma: no cover
-
-class Redirectable:
- """ An object with its own stdout and stderr files.
- """
- def __init__(self):
- self.stdout = sys.stdout
- self.stderr = sys.stderr
-
- def setOutput(self, stdout=None, stderr=None):
- """ Assign new files for standard out and/or standard error.
- """
- if stdout:
- self.stdout = stdout
- if stderr:
- self.stderr = stderr
-
-class CogGenerator(Redirectable):
- """ A generator pulled from a source file.
- """
- def __init__(self):
- Redirectable.__init__(self)
- self.markers = []
- self.lines = []
-
- def parseMarker(self, l):
- self.markers.append(l)
-
- def parseLine(self, l):
- self.lines.append(l.strip('\n'))
-
- def getCode(self):
- """ Extract the executable Python code from the generator.
- """
- # If the markers and lines all have the same prefix
- # (end-of-line comment chars, for example),
- # then remove it from all the lines.
- prefIn = commonPrefix(self.markers + self.lines)
- if prefIn:
- self.markers = [ l.replace(prefIn, '', 1) for l in self.markers ]
- self.lines = [ l.replace(prefIn, '', 1) for l in self.lines ]
-
- return reindentBlock(self.lines, '')
-
- def evaluate(self, cog, globals, fname='cog generator'):
- # figure out the right whitespace prefix for the output
- prefOut = whitePrefix(self.markers)
-
- intext = self.getCode()
- if not intext:
- return ''
-
- # In Python 2.2, the last line has to end in a newline.
- intext = "import cog\n" + intext + "\n"
- code = compile(intext, str(fname), 'exec')
-
- # Make sure the "cog" module has our state.
- cog.cogmodule.msg = self.msg
- cog.cogmodule.out = self.out
- cog.cogmodule.outl = self.outl
- cog.cogmodule.error = self.error
-
- self.outstring = ''
- eval(code, globals)
-
- # We need to make sure that the last line in the output
- # ends with a newline, or it will be joined to the
- # end-output line, ruining cog's idempotency.
- if self.outstring and self.outstring[-1] != '\n':
- self.outstring += '\n'
-
- return reindentBlock(self.outstring, prefOut)
-
- def msg(self, s):
- print >>self.stdout, "Message: "+s
-
- def out(self, sOut='', dedent=False, trimblanklines=False):
- """ The cog.out function.
- """
- if trimblanklines and ('\n' in sOut):
- lines = sOut.split('\n')
- if lines[0].strip() == '':
- del lines[0]
- if lines and lines[-1].strip() == '':
- del lines[-1]
- sOut = '\n'.join(lines)+'\n'
- if dedent:
- sOut = reindentBlock(sOut)
- self.outstring += sOut
-
- def outl(self, sOut='', **kw):
- """ The cog.outl function.
- """
- self.out(sOut, **kw)
- self.out('\n')
-
- def error(self, msg='Error raised by cog generator.'):
- """ The cog.error function.
- Instead of raising standard python errors, cog generators can use
- this function. It will display the error without a scary Python
- traceback.
- """
- raise CogGeneratedError(msg)
-
-
-class NumberedFileReader:
- """ A decorator for files that counts the readline()'s called.
- """
- def __init__(self, f):
- self.f = f
- self.n = 0
-
- def readline(self):
- l = self.f.readline()
- if l:
- self.n += 1
- return l
-
- def linenumber(self):
- return self.n
-
-
-class CogOptions:
- """ Options for a run of cog.
- """
- def __init__(self):
- # Defaults for argument values.
- self.args = []
- self.includePath = []
- self.defines = {}
- self.bShowVersion = False
- self.sMakeWritableCmd = None
- self.bReplace = False
- self.bNoGenerate = False
- self.sOutputName = None
- self.bWarnEmpty = False
- self.bHashOutput = False
- self.bDeleteCode = False
- self.bEofCanBeEnd = False
- self.sSuffix = None
- self.bNewlines = False
-
- def __cmp__(self, other):
- """ Comparison operator for tests to use.
- """
- return self.__dict__.__cmp__(other.__dict__)
-
- def clone(self):
- """ Make a clone of these options, for further refinement.
- """
- return copy.deepcopy(self)
-
- def addToIncludePath(self, dirs):
- """ Add directories to the include path.
- """
- dirs = dirs.split(os.pathsep)
- self.includePath.extend(dirs)
-
- def parseArgs(self, argv):
- # Parse the command line arguments.
- try:
- opts, self.args = getopt.getopt(argv, 'cdD:eI:o:rs:Uvw:xz')
- except getopt.error, msg:
- raise CogUsageError(msg)
-
- # Handle the command line arguments.
- for o, a in opts:
- if o == '-c':
- self.bHashOutput = True
- elif o == '-d':
- self.bDeleteCode = True
- elif o == '-D':
- if a.count('=') < 1:
- raise CogUsageError("-D takes a name=value argument")
- name, value = a.split('=', 1)
- self.defines[name] = value
- elif o == '-e':
- self.bWarnEmpty = True
- elif o == '-I':
- self.addToIncludePath(a)
- elif o == '-o':
- self.sOutputName = a
- elif o == '-r':
- self.bReplace = True
- elif o == '-s':
- self.sSuffix = a
- elif o == '-U':
- self.bNewlines = True
- elif o == '-v':
- self.bShowVersion = True
- elif o == '-w':
- self.sMakeWritableCmd = a
- elif o == '-x':
- self.bNoGenerate = True
- elif o == '-z':
- self.bEofCanBeEnd = True
- else:
- # Since getopt.getopt is given a list of possible flags,
- # this is an internal error.
- raise CogInternalError("Don't understand argument %s" % o)
-
- def validate(self):
- """ Does nothing if everything is OK, raises CogError's if it's not.
- """
- if self.bReplace and self.bDeleteCode:
- raise CogUsageError("Can't use -d with -r (or you would delete all your source!)")
-
- if self.bReplace and self.sOutputName:
- raise CogUsageError("Can't use -o with -r (they are opposites)")
-
-
-class Cog(Redirectable):
- """ The Cog engine.
- """
- def __init__(self):
- Redirectable.__init__(self)
- self.sBeginSpec = '[[[cog'
- self.sEndSpec = ']]]'
- self.sEndOutput = '[[[end]]]'
- self.reEndOutput = re.compile(r'\[\[\[end]]](?P<hashsect> *\(checksum: (?P<hash>[a-f0-9]+)\))')
- self.sEndFormat = '[[[end]]] (checksum: %s)'
-
- self.options = CogOptions()
- self.sOutputMode = 'w'
-
- self.installCogModule()
-
- def showWarning(self, msg):
- print >>self.stdout, "Warning:", msg
-
- def isBeginSpecLine(self, s):
- return string.find(s, self.sBeginSpec) >= 0
-
- def isEndSpecLine(self, s):
- return string.find(s, self.sEndSpec) >= 0 and \
- not self.isEndOutputLine(s)
-
- def isEndOutputLine(self, s):
- return string.find(s, self.sEndOutput) >= 0
-
- def installCogModule(self):
- """ Magic mumbo-jumbo so that imported Python modules
- can say "import cog" and get our state.
- """
- self.cogmodule = imp.new_module('cog')
- self.cogmodule.path = []
- sys.modules['cog'] = self.cogmodule
-
- def processFile(self, fIn, fOut, fname=None, globals=None):
- """ Process an input file object to an output file object.
- fIn and fOut can be file objects, or file names.
- """
-
- sFileIn = fname or ''
- sFileOut = fname or ''
- fInToClose = fOutToClose = None
- # Convert filenames to files.
- if isinstance(fIn, basestring):
- # Open the input file.
- sFileIn = fIn
- fIn = fInToClose = open(fIn, 'r')
- if isinstance(fOut, basestring):
- # Open the output file.
- sFileOut = fOut
- fOut = fOutToClose = open(fOut, self.sOutputMode)
-
- try:
- fIn = NumberedFileReader(fIn)
-
- bSawCog = False
-
- self.cogmodule.inFile = sFileIn
- self.cogmodule.outFile = sFileOut
-
- # The globals dict we'll use for this file.
- if globals is None:
- globals = {}
-
- # If there are any global defines, put them in the globals.
- globals.update(self.options.defines)
-
- # loop over generator chunks
- l = fIn.readline()
- while l:
- # Find the next spec begin
- while l and not self.isBeginSpecLine(l):
- if self.isEndSpecLine(l):
- raise CogError("Unexpected '%s'" % self.sEndSpec,
- file=sFileIn, line=fIn.linenumber())
- if self.isEndOutputLine(l):
- raise CogError("Unexpected '%s'" % self.sEndOutput,
- file=sFileIn, line=fIn.linenumber())
- fOut.write(l)
- l = fIn.readline()
- if not l:
- break
- if not self.options.bDeleteCode:
- fOut.write(l)
-
- # l is the begin spec
- gen = CogGenerator()
- gen.setOutput(stdout=self.stdout)
- gen.parseMarker(l)
- firstLineNum = fIn.linenumber()
- self.cogmodule.firstLineNum = firstLineNum
-
- # If the spec begin is also a spec end, then process the single
- # line of code inside.
- if self.isEndSpecLine(l):
- beg = string.find(l, self.sBeginSpec)
- end = string.find(l, self.sEndSpec)
- if beg > end:
- raise CogError("Cog code markers inverted",
- file=sFileIn, line=firstLineNum)
- else:
- sCode = l[beg+len(self.sBeginSpec):end].strip()
- gen.parseLine(sCode)
- else:
- # Deal with an ordinary code block.
- l = fIn.readline()
-
- # Get all the lines in the spec
- while l and not self.isEndSpecLine(l):
- if self.isBeginSpecLine(l):
- raise CogError("Unexpected '%s'" % self.sBeginSpec,
- file=sFileIn, line=fIn.linenumber())
- if self.isEndOutputLine(l):
- raise CogError("Unexpected '%s'" % self.sEndOutput,
- file=sFileIn, line=fIn.linenumber())
- if not self.options.bDeleteCode:
- fOut.write(l)
- gen.parseLine(l)
- l = fIn.readline()
- if not l:
- raise CogError(
- "Cog block begun but never ended.",
- file=sFileIn, line=firstLineNum)
-
- if not self.options.bDeleteCode:
- fOut.write(l)
- gen.parseMarker(l)
-
- l = fIn.readline()
-
- # Eat all the lines in the output section. While reading past
- # them, compute the md5 hash of the old output.
- hasher = hash_factory()
- while l and not self.isEndOutputLine(l):
- if self.isBeginSpecLine(l):
- raise CogError("Unexpected '%s'" % self.sBeginSpec,
- file=sFileIn, line=fIn.linenumber())
- if self.isEndSpecLine(l):
- raise CogError("Unexpected '%s'" % self.sEndSpec,
- file=sFileIn, line=fIn.linenumber())
- hasher.update(l)
- l = fIn.readline()
- curHash = hasher.hexdigest()
-
- if not l and not self.options.bEofCanBeEnd:
- # We reached end of file before we found the end output line.
- raise CogError("Missing '%s' before end of file." % self.sEndOutput,
- file=sFileIn, line=fIn.linenumber())
-
- # Write the output of the spec to be the new output if we're
- # supposed to generate code.
- hasher = hash_factory()
- if not self.options.bNoGenerate:
- sFile = "%s+%d" % (sFileIn, firstLineNum)
- sGen = gen.evaluate(cog=self, globals=globals, fname=sFile)
- sGen = self.suffixLines(sGen)
- hasher.update(sGen)
- fOut.write(sGen)
- newHash = hasher.hexdigest()
-
- bSawCog = True
-
- # Write the ending output line
- hashMatch = self.reEndOutput.search(l)
- if self.options.bHashOutput:
- if hashMatch:
- oldHash = hashMatch.groupdict()['hash']
- if oldHash != curHash:
- raise CogError("Output has been edited! Delete old checksum to unprotect.",
- file=sFileIn, line=fIn.linenumber())
- # Create a new end line with the correct hash.
- endpieces = l.split(hashMatch.group(0), 1)
- else:
- # There was no old hash, but we want a new hash.
- endpieces = l.split(self.sEndOutput, 1)
- l = (self.sEndFormat % newHash).join(endpieces)
- else:
- # We don't want hashes output, so if there was one, get rid of
- # it.
- if hashMatch:
- l = l.replace(hashMatch.groupdict()['hashsect'], '', 1)
-
- if not self.options.bDeleteCode:
- fOut.write(l)
- l = fIn.readline()
-
- if not bSawCog and self.options.bWarnEmpty:
- self.showWarning("no cog code found in %s" % sFileIn)
- finally:
- if fInToClose:
- fInToClose.close()
- if fOutToClose:
- fOutToClose.close()
-
-
- # A regex for non-empty lines, used by suffixLines.
- reNonEmptyLines = re.compile("^\s*\S+.*$", re.MULTILINE)
-
- def suffixLines(self, text):
- """ Add suffixes to the lines in text, if our options desire it.
- text is many lines, as a single string.
- """
- if self.options.sSuffix:
- # Find all non-blank lines, and add the suffix to the end.
- repl = r"\g<0>" + self.options.sSuffix.replace('\\', '\\\\')
- text = self.reNonEmptyLines.sub(repl, text)
- return text
-
- def processString(self, sInput, fname=None):
- """ Process sInput as the text to cog.
- Return the cogged output as a string.
- """
- fOld = StringIO(sInput)
- fNew = StringIO()
- self.processFile(fOld, fNew, fname=fname)
- return fNew.getvalue()
-
- def replaceFile(self, sOldPath, sNewText):
- """ Replace file sOldPath with the contents sNewText
- """
- if not os.access(sOldPath, os.W_OK):
- # Need to ensure we can write.
- if self.options.sMakeWritableCmd:
- # Use an external command to make the file writable.
- cmd = self.options.sMakeWritableCmd.replace('%s', sOldPath)
- self.stdout.write(os.popen(cmd).read())
- if not os.access(sOldPath, os.W_OK):
- raise CogError("Couldn't make %s writable" % sOldPath)
- else:
- # Can't write!
- raise CogError("Can't overwrite %s" % sOldPath)
- f = open(sOldPath, self.sOutputMode)
- f.write(sNewText)
- f.close()
-
- def saveIncludePath(self):
- self.savedInclude = self.options.includePath[:]
- self.savedSysPath = sys.path[:]
-
- def restoreIncludePath(self):
- self.options.includePath = self.savedInclude
- self.cogmodule.path = self.options.includePath
- sys.path = self.savedSysPath
-
- def addToIncludePath(self, includePath):
- self.cogmodule.path.extend(includePath)
- sys.path.extend(includePath)
-
- def processOneFile(self, sFile):
- """ Process one filename through cog.
- """
-
- self.saveIncludePath()
-
- try:
- self.addToIncludePath(self.options.includePath)
- # Since we know where the input file came from,
- # push its directory onto the include path.
- self.addToIncludePath([os.path.dirname(sFile)])
-
- # Set the file output mode based on whether we want \n or native
- # line endings.
- self.sOutputMode = 'w'
- if self.options.bNewlines:
- self.sOutputMode = 'wb'
-
- # How we process the file depends on where the output is going.
- if self.options.sOutputName:
- self.processFile(sFile, self.options.sOutputName, sFile)
- elif self.options.bReplace:
- # We want to replace the cog file with the output,
- # but only if they differ.
- print >>self.stdout, "Cogging %s" % sFile,
- bNeedNewline = True
-
- try:
- fOldFile = open(sFile)
- sOldText = fOldFile.read()
- fOldFile.close()
- sNewText = self.processString(sOldText, fname=sFile)
- if sOldText != sNewText:
- print >>self.stdout, " (changed)"
- bNeedNewline = False
- self.replaceFile(sFile, sNewText)
- finally:
- # The try-finally block is so we can print a partial line
- # with the name of the file, and print (changed) on the
- # same line, but also make sure to break the line before
- # any traceback.
- if bNeedNewline:
- print >>self.stdout
- else:
- self.processFile(sFile, self.stdout, sFile)
- finally:
- self.restoreIncludePath()
-
- def processFileList(self, sFileList):
- """ Process the files in a file list.
- """
- flist = open(sFileList)
- lines = flist.readlines()
- flist.close()
- for l in lines:
- # Use shlex to parse the line like a shell.
- lex = shlex.shlex(l, posix=True)
- lex.whitespace_split = True
- lex.commenters = '#'
- # No escapes, so that backslash can be part of the path
- lex.escape = ''
- args = list(lex)
- if args:
- self.processArguments(args)
-
- def processArguments(self, args):
- """ Process one command-line.
- """
- saved_options = self.options
- self.options = self.options.clone()
-
- self.options.parseArgs(args[1:])
- self.options.validate()
-
- if args[0][0] == '@':
- if self.options.sOutputName:
- raise CogUsageError("Can't use -o with @file")
- self.processFileList(args[0][1:])
- else:
- self.processOneFile(args[0])
-
- self.options = saved_options
-
- def callableMain(self, argv):
- """ All of command-line cog, but in a callable form.
- This is used by main.
- argv is the equivalent of sys.argv.
- """
- argv.pop(0)
-
- # Provide help if asked for anywhere in the command line.
- if '-?' in argv or '-h' in argv:
- print >>self.stderr, usage,
- return
-
- self.options.parseArgs(argv)
- self.options.validate()
-
- if self.options.bShowVersion:
- print >>self.stdout, "Cog version %s" % __version__
- return
-
- if self.options.args:
- for a in self.options.args:
- self.processArguments([a])
- else:
- raise CogUsageError("No files to process")
-
- def main(self, argv):
- """ Handle the command-line execution for cog.
- """
-
- try:
- self.callableMain(argv)
- return 0
- except CogUsageError, err:
- print >>self.stderr, err
- print >>self.stderr, "(for help use -?)"
- return 2
- except CogGeneratedError, err:
- print >>self.stderr, "Error: %s" % err
- return 3
- except CogError, err:
- print >>self.stderr, err
- return 1
- except:
- traceback.print_exc(None, self.stderr)
- return 1
-
-# History:
-# 20040210: First public version.
-# 20040220: Text preceding the start and end marker are removed from Python lines.
-# -v option on the command line shows the version.
-# 20040311: Make sure the last line of output is properly ended with a newline.
-# 20040605: Fixed some blank line handling in cog.
-# Fixed problems with assigning to xml elements in handyxml.
-# 20040621: Changed all line-ends to LF from CRLF.
-# 20041002: Refactor some option handling to simplify unittesting the options.
-# 20041118: cog.out and cog.outl have optional string arguments.
-# 20041119: File names weren't being properly passed around for warnings, etc.
-# 20041122: Added cog.firstLineNum: a property with the line number of the [[[cog line.
-# Added cog.inFile and cog.outFile: the names of the input and output file.
-# 20041218: Single-line cog generators, with start marker and end marker on
-# the same line.
-# 20041230: Keep a single globals dict for all the code fragments in a single
-# file so they can share state.
-# 20050206: Added the -x switch to remove all generated output.
-# 20050218: Now code can be on the marker lines as well.
-# 20050219: Added -c switch to checksum the output so that edits can be
-# detected before they are obliterated.
-# 20050521: Added cog.error, contributed by Alexander Belchenko.
-# 20050720: Added code deletion and settable globals contributed by Blake Winton.
-# 20050724: Many tweaks to improve code coverage.
-# 20050726: Error messages are now printed with no traceback.
-# Code can no longer appear on the marker lines,
-# except for single-line style.
-# -z allows omission of the [[[end]]] marker, and it will be assumed
-# at the end of the file.
-# 20050729: Refactor option parsing into a separate class, in preparation for
-# future features.
-# 20050805: The cogmodule.path wasn't being properly maintained.
-# 20050808: Added the -D option to define a global value.
-# 20050810: The %s in the -w command is dealt with more robustly.
-# Added the -s option to suffix output lines with a marker.
-# 20050817: Now @files can have arguments on each line to change the cog's
-# behavior for that line.
-# 20051006: Version 2.0
-# 20080521: -U options lets you create Unix newlines on Windows. Thanks,
-# Alexander Belchenko.
-# 20080522: It's now ok to have -d with output to stdout, and now we validate
-# the args after each line of an @file.
-# 20090520: Use hashlib where it's available, to avoid a warning.
-# Use the builtin compile() instead of compiler, for Jython.
-# Explicitly close files we opened, Jython likes this.
View
63 buildtime/lib/jython/Lib/cogapp/whiteutils.py
@@ -1,63 +0,0 @@
-""" Indentation utilities for Cog.
- http://nedbatchelder.com/code/cog
-
- Copyright 2004-2009, Ned Batchelder.
-"""
-
-import re
-
-def whitePrefix(strings):
- """ Determine the whitespace prefix common to all non-blank lines
- in the argument list.
- """
- # Remove all blank lines from the list
- strings = [s for s in strings if s.strip() != '']
-
- if not strings: return ''
-
- # Find initial whitespace chunk in the first line.
- # This is the best prefix we can hope for.
- prefix = re.match(r'\s*', strings[0]).group(0)
-
- # Loop over the other strings, keeping only as much of
- # the prefix as matches each string.
- for s in strings:
- for i in range(len(prefix)):
- if prefix[i] != s[i]:
- prefix = prefix[:i]
- break
- return prefix
-
-def reindentBlock(lines, newIndent=''):
- """ Take a block of text as a string or list of lines.
- Remove any common whitespace indentation.
- Re-indent using newIndent, and return it as a single string.
- """
- if isinstance(lines, basestring):
- lines = lines.split('\n')
- oldIndent = whitePrefix(lines)
- outLines = []
- for l in lines:
- if oldIndent:
- l = l.replace(oldIndent, '', 1)
- if l and newIndent:
- l = newIndent + l
- outLines.append(l)
- return '\n'.join(outLines)
-
-def commonPrefix(strings):
- """ Find the longest string that is a prefix of all the strings.
- """
- if not strings:
- return ''
- prefix = strings[0]
- for s in strings:
- if len(s) < len(prefix):
- prefix = prefix[:len(s)]
- if not prefix:
- return ''
- for i in range(len(prefix)):
- if prefix[i] != s[i]:
- prefix = prefix[:i]
- break
- return prefix
View
17 buildtime/py/cog.py
@@ -1,17 +0,0 @@
-#!/usr/bin/python
-""" Cog code generation tool.
- http://nedbatchelder.com/code/cog
-
- Copyright 2004-2005, Ned Batchelder.
-"""
-
-import time
-start = time.clock()
-
-import sys
-from cogapp import Cog
-
-ret = Cog().main(sys.argv)
-
-#print "Time: %.2f sec" % (time.clock() - start)
-sys.exit(ret)
View
285 buildtime/py/processing_parser.py
@@ -1,285 +0,0 @@
-import re
-
-import cog
-
-from java.lang.reflect import Modifier
-from java.lang import Class, Void
-from processing.core import PApplet
-
-
-"""
-A field is bad if it happens to be marked public in the PApplet source,
-but is undocumented or implementation-private.
-The "key" field is implemented by hand in the PAppletJythonDriver, since
-it's a chimera int/Unicode character.
-"""
-BAD_FIELD = re.compile(r'''
- ^(
- screen|args|recorder|frame|g|selectedFile|keyEvent|mouseEvent
- |sketchPath|screen(Width|Height)|defaultSize|firstMouse|finished
- |requestImageMax|online|key
- )$
- ''', re.X)
-
-"""
-A method is "bad" if either there's already a native python implementation
-of it (as in max()) or if it's private to the implementation of PApplet, but
-is marked public as a subclass of Component or Applet.
-"""
-BAD_METHOD = re.compile(r'''
- ^(
- init|handleDraw|draw|parse[A-Z].*|arraycopy|openStream|str|.*Pressed
- |.*Released|(un)?register[A-Z].*|print|setup[A-Z].+|thread
- |(get|set|remove)Cache|update|destroy|main|flush|addListeners|dataFile
- |die|setup|mouseE(ntered|xited)|paint|sketch[A-Z].*|stop|save(File|Path)
- |displayable|method|runSketch|start|focus(Lost|Gained)|(data|create)Path
- |round|abs|max|min|open|append|splice|expand|contract|set|exit|link|param
- |status
- )$
- ''', re.X)
-
-
-# I don't know of any other way to refer to primitive classes in Jython.
-def prim(type_name):
- return Class.forName("java.lang.%s" % type_name).getField("TYPE").get(None)
-
-"""
-Here we map from mnemonic type names to the actual Java classes that implement
-those types.
-"""
-PRIMITIVES = { 'int': prim("Integer"),
- 'char': prim("Character"),
- 'byte': prim("Byte"),
- 'long': prim("Long"),
- 'double': prim("Double"),
- 'float': prim("Float"),
- 'boolean': prim("Boolean") }
-
-USELESS_TYPES = (PRIMITIVES['char'], Class.forName('[C'), PRIMITIVES['byte'])
-
-"""
-We want to create Jython wrappers for all public methods of PApplet except
-those in "BAD_METHOD". Also, if we have both foo(int) and foo(char), we throw
-away the char variant, and always call the int variant. Same with foo(byte).
-Sadly, Java has no unsigned types, so the distinction is weird.
-"""
-WANTED_METHODS = [m for m in Class.getDeclaredMethods(PApplet)
- if Modifier.isPublic(m.getModifiers())
- and not m.getExceptionTypes()
- and not BAD_METHOD.match(m.getName())
- and not any(k in USELESS_TYPES for k in m.getParameterTypes())]
-
-"""
-We want to create Jython wrappers for all variables visible during the
-Processing runtime.
-"""
-WANTED_FIELDS = [f for f in Class.getDeclaredFields(PApplet)
- if Modifier.isPublic(f.getModifiers())
- and not Modifier.isStatic(f.getModifiers())
- and not BAD_FIELD.match(f.getName())]
-
-
-class ClassConversionInfo(object):
- """
- A structure to keep in one place all of the templates for generating
- code for going back and forth between Python and Java.
- """
- def __init__(self, to_python_prefix, to_java_format, typecheck_format):
- self.to_python_prefix = to_python_prefix
- self.to_java_format = to_java_format
- self.typecheck_format = typecheck_format
-
-"""
-Map from java types to various expressions needed in code
-generation around those types.
-"""
-CONVERSIONS = {
- PRIMITIVES['int']:
- ClassConversionInfo('new PyInteger',
- '%s.asInt()',
- '%(name)s == PyInteger.TYPE'),
- PRIMITIVES['byte']:
- ClassConversionInfo(None,
- '(byte)%s.asInt()',
- '%(name)s == PyInteger.TYPE'),
- PRIMITIVES['float']:
- ClassConversionInfo('new PyFloat',
- '(float)%s.asDouble()',
- '(%(name)s == PyFloat.TYPE '
- '|| %(name)s == PyInteger.TYPE '
- '|| %(name)s == PyLong.TYPE)'),
- PRIMITIVES['double']:
- ClassConversionInfo('new PyFloat',
- '%s.asDouble()',
- '%(name)s == PyFloat.TYPE'),
- PRIMITIVES['long']:
- ClassConversionInfo('new PyLong',
- '%s.asLong()',
- '%(name)s == PyLong.TYPE'),
- Class.forName("java.lang.String"):
- ClassConversionInfo('new PyUnicode',
- '%s.asString()',
- '(%(name)s == PyString.TYPE'
- '|| %(name)s == PyUnicode.TYPE)'),
- PRIMITIVES['char']:
- ClassConversionInfo('new PyInteger',
- '%s.asInt()',
- None),
- PRIMITIVES['boolean']:
- ClassConversionInfo('new PyBoolean',
- '%s.__nonzero__()',
- '%(name)s == PyBoolean.TYPE')
-}
-
-def emit_python_prefix(klass):
- try:
- cog.out(CONVERSIONS[klass].to_python_prefix)
- except (KeyError, AttributeError):
- if klass.isPrimitive():
- raise Exception("You need a converter for %s" % klass.getName())
- cog.out('Py.java2py')
- cog.out('(')
-
-def emit_java_expression(klass, name):
- try:
- cog.out(CONVERSIONS[klass].to_java_format % name)
- except KeyError:
- if klass.isPrimitive():
- raise Exception("You need a converter for %s" % klass.getName())
- simpleName = Class.getName(klass)
- if klass.isArray():
- simpleName = Class.getSimpleName(klass)
- if simpleName != 'java.lang.Object':
- cog.out('(%s)' % simpleName)
- cog.out('%s.__tojava__(%s.class)' % (name, simpleName))
-
-def emit_typecheck_expression(klass, name):
- try:
- cog.out(CONVERSIONS[klass].typecheck_format % {'name': name})
- except (TypeError, KeyError):
- if klass.isPrimitive():
- raise Exception("You need a converter for %s" % klass.getName())
- cog.out('%s.getProxyType() != null '
- '&& %s.getProxyType() == %s.class' % (name,
- name,
- Class.getSimpleName(klass)))
-
-def is_builtin(name):
- return name in ('map', 'filter', 'set', 'str')
-
-
-# TODO: replace this insanity with a decent templating system. What was I thinking?
-
-class PolymorphicMethod(object):
- def __init__(self, name, arity):
- self.name = name
- self.arity = arity
- self.methods = []
-
- def add_method(self, m):
- assert len(m.getParameterTypes()) == self.arity
- self.methods.append(m)
-
- def emit_method(self, m):
- if m.getReturnType() is not Void.TYPE:
- cog.out('return ')
- emit_python_prefix(m.getReturnType())
- cog.out('%s(' % self.name)
- for i in range(self.arity):
- if i > 0:
- cog.out(', ')
- emit_java_expression(m.getParameterTypes()[i], 'args[%d]' % i)
- cog.out(')')
- if m.getReturnType() is Void.TYPE:
- cog.outl(';')
- cog.outl('\t\t\t\treturn Py.None;')
- else:
- cog.outl(');')
-
- def emit(self):
- cog.outl('\t\t\tcase %d: {' % self.arity)
- if len(self.methods) == 1 and not is_builtin(self.name):
- cog.out('\t\t\t\t')
- self.emit_method(self.methods[0])
- else:
- for i in range(self.arity):
- cog.outl('\t\t\t\tfinal PyType t%d = args[%d].getType();' % (i, i))
- self.methods.sort(key=lambda p: [m.getSimpleName()
- for m in p.getParameterTypes()],
- reverse=True)
- for i in range(len(self.methods)):
- m = self.methods[i]
- if i > 0:
- cog.out(' else ')
- else:
- cog.out('\t\t\t\t')
- if self.arity > 0:
- cog.out('if (')
- for j in range(self.arity):
- if j > 0:
- cog.out(' && ')
- emit_typecheck_expression(m.getParameterTypes()[j],
- 't%d' % j)
- cog.out(') {\n\t\t\t\t\t')
- self.emit_method(m)
- if self.arity > 0:
- cog.out('\t\t\t\t}')
- if is_builtin(self.name):
- cog.outl(' else { return %s_builtin.__call__(args, kws); }' % self.name)
- elif self.arity > 0:
- cog.outl(' else { throw new UnexpectedInvocationError'
- '("%s", args, kws); }' % self.name)
- cog.outl('\t\t\t}')
-
-
-class Binding(object):
- def __init__(self, name):
- self.name = name
- self.field = None
- self.methods = {}
-
- def add_method(self, m):
- arity = len(m.getParameterTypes())
- pm = self.methods.setdefault(arity, PolymorphicMethod(self.name, arity))
- pm.add_method(m)
-
- def set_field(self, f):
- if self.field:
- raise Exception("Binding %s's field was already set!" % self.name)
- self.field = f
-
- def emit(self):
- has_methods = len(self.methods.values()) > 0
- n = self.name
- if is_builtin(n):
- cog.outl('final PyObject %s_builtin = builtins.__getitem__("%s");' % (n, n))
- cog.out('builtins.__setitem__("%s",' % n)
- if self.field:
- emit_python_prefix(self.field.getType())
- cog.out('%s)' % n)
- else:
- cog.out('new PyObject()')
- if has_methods:
- cog.outl('{')
- if has_methods:
- cog.outl('\tpublic PyObject __call__(final PyObject[] args, final String[] kws) {')
- cog.outl('\t\tswitch(args.length) {')
- cog.outl('\t\t\tdefault: ');
- cog.out('\t\t\t\t')
- if is_builtin(n):
- cog.outl('return %s_builtin.__call__(args, kws);' % n)
- else:
- cog.outl('throw new RuntimeException("Can\'t call \\"%s\\" with "'
- ' + args.length + " parameters."); ' % n)
- for k in sorted(self.methods.keys()):
- self.methods[k].emit()
- cog.outl('\t\t}\n\t}')
- if has_methods:
- cog.out('}')
- cog.outl(');')
-
-bindings = {}
-for m in WANTED_METHODS:
- bindings.setdefault(m.getName(), Binding(m.getName())).add_method(m)
-
-simple_method_bindings = [b for b in bindings.values() if not b.field]
View
47 buildtime/template/DriverImpl.java.cog
@@ -1,47 +0,0 @@
-/*
- * Copyright 2010 Jonathan Feinberg
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-/*[[[cog
- import processing_parser as p
- import cog
- ]]]
- [[[end]]] */
-package jycessing;
-
-import org.python.util.InteractiveConsole;
-import org.python.core.*;
-import processing.core.*;
-import processing.event.*;
-import processing.opengl.*;
-import java.io.*;
-
-@SuppressWarnings("serial")
-public class DriverImpl extends PAppletJythonDriver {
-
- public DriverImpl(final InteractiveConsole interp,
- final String sketchPath, final String programText) {
- super(interp, sketchPath, programText);
- }
-
-
- @Override
- protected void populateBuiltins() {
- /*[[[cog
- for b in p.simple_method_bindings:
- b.emit()
- ]]]*/
- /*[[[end]]]*/
- }
-}
View
58 runtime/src/jycessing/PAppletJythonDriver.java
@@ -43,19 +43,7 @@
import processing.core.PApplet;
import processing.core.PConstants;
-import processing.core.PFont;
-import processing.core.PGraphics;
-import processing.core.PGraphicsJava2D;
import processing.core.PImage;
-import processing.core.PMatrix2D;
-import processing.core.PMatrix3D;
-import processing.core.PShape;
-import processing.core.PShapeSVG;
-import processing.core.PStyle;
-import processing.opengl.PGraphics2D;
-import processing.opengl.PGraphics3D;
-import processing.opengl.PGraphicsOpenGL;
-import processing.opengl.PShader;
import fisica.FContact;
import fisica.FContactResult;
@@ -65,9 +53,7 @@
*
*/
@SuppressWarnings("serial")
-abstract public class PAppletJythonDriver extends PApplet {
-
- abstract protected void populateBuiltins();
+public class PAppletJythonDriver extends PApplet {
protected final PyStringMap builtins;
protected final InteractiveConsole interp;
@@ -92,13 +78,12 @@
// These are all of the methods that PApplet might call in your sketch. If
// you have implemented a method, we save it and call it.
- private final PyObject setupMeth, drawMeth, mousePressedMeth, mouseClickedMeth, mouseMovedMeth,
+ private PyObject setupMeth, drawMeth, mousePressedMeth, mouseClickedMeth, mouseMovedMeth,
mouseReleasedMeth, mouseDraggedMeth, keyPressedMeth, keyReleasedMeth, keyTypedMeth, initMeth,
stopMeth, sketchFullScreenMeth, sketchWidthMeth, sketchHeightMeth, sketchRendererMeth;
// Callbacks from the Fisica library.
- private final PyObject contactStartedMeth, contactPersistedMeth, contactEndedMeth,
- contactResultMeth;
+ private PyObject contactStartedMeth, contactPersistedMeth, contactEndedMeth, contactResultMeth;
// Adapted from Jython's PythonInterpreter.java exec(String s) to preserve
// the source file name, so that errors have the file name instead of
@@ -130,8 +115,6 @@ public PAppletJythonDriver(final InteractiveConsole interp, final String sketchP
this.interp = interp;
initializeStatics(builtins);
setSet();
- populateBuiltins();
- builtins.__setitem__("this", Py.java2py(this));
builtins.__setitem__("g", Py.java2py(g));
builtins.__setitem__("exit", new PyObject() {
@Override
@@ -140,9 +123,17 @@ public PyObject __call__(final PyObject[] args, final String[] kws) {
return Py.None;
}
});
- exposeProcessingClasses();
wrapProcessingVariables();
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentHidden(final ComponentEvent e) {
+ finishedLatch.countDown();
+ }
+ });
+ }
+
+ public void findSketchMethods() {
if (mode == Mode.DRAW_LOOP) {
// Executing the sketch will bind method names ("draw") to PyCode
// objects (the sketch's draw method), which can then be invoked
@@ -171,31 +162,6 @@ public PyObject __call__(final PyObject[] args, final String[] kws) {
contactPersistedMeth = interp.get("contactPersisted");
contactResultMeth = interp.get("contactResult");
contactStartedMeth = interp.get("contactStarted");
-
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentHidden(final ComponentEvent e) {
- finishedLatch.countDown();
- }
- });
- }
-
- protected void exposeProcessingClasses() {
- builtins.__setitem__("PApplet", Py.java2py(PApplet.class));
- builtins.__setitem__("PConstants", Py.java2py(PConstants.class));
- builtins.__setitem__("PFont", Py.java2py(PFont.class));
- builtins.__setitem__("PGraphics", Py.java2py(PGraphics.class));
- builtins.__setitem__("PGraphics2D", Py.java2py(PGraphics2D.class));
- builtins.__setitem__("PGraphics3D", Py.java2py(PGraphics3D.class));
- builtins.__setitem__("PGraphicsJava2D", Py.java2py(PGraphicsJava2D.class));
- builtins.__setitem__("PGraphicsOpenGL", Py.java2py(PGraphicsOpenGL.class));
- builtins.__setitem__("PImage", Py.java2py(PImage.class));
- builtins.__setitem__("PMatrix2D", Py.java2py(PMatrix2D.class));
- builtins.__setitem__("PMatrix3D", Py.java2py(PMatrix3D.class));
- builtins.__setitem__("PShader", Py.java2py(PShader.class));
- builtins.__setitem__("PShape", Py.java2py(PShape.class));
- builtins.__setitem__("PShapeSVG", Py.java2py(PShapeSVG.class));
- builtins.__setitem__("PStyle", Py.java2py(PStyle.class));
}
protected void wrapProcessingVariables() {
View
9 runtime/src/jycessing/Runner.java
@@ -381,11 +381,16 @@ public static void runSketch(final String[] args, final String sketchPath,
// For error messages
interp.set("__file__", sketchPath);
- interp.exec(read(Runner.class.getResourceAsStream("core.py")));
interp.exec(read(LaunchHelper.class.getResourceAsStream("launcher.py")));
+ interp.set("__interp__", interp);
+ interp.set("__path__", sketchPath);
+ interp.set("__source__", sketchSource);
+ interp.exec(read(Runner.class.getResourceAsStream("core.py")));
// Bind the sketch to a PApplet
- final PAppletJythonDriver applet = new DriverImpl(interp, sketchPath, sketchSource);
+ final PAppletJythonDriver applet =
+ (PAppletJythonDriver)interp.get("__papplet__").__tojava__(PAppletJythonDriver.class);
+ applet.findSketchMethods();
// Hide the splash, if possible
final SplashScreen splash = SplashScreen.getSplashScreen();
View
17 runtime/src/jycessing/WrappedInteger.java
@@ -1,17 +0,0 @@
-package jycessing;
-
-import org.python.core.PyInteger;
-
-abstract public class WrappedInteger extends PyInteger {
-
- @Override
- abstract public int getValue();
-
- public WrappedInteger() {
- super(0);
- }
-
- public static void main(final String[] args) throws Exception {
- System.err.println(Class.forName("int"));
- }
-}
View
290 runtime/src/jycessing/core.py
@@ -1,14 +1,37 @@
import __builtin__
+from jycessing import PAppletJythonDriver
+
+from processing.core import PApplet
+from processing.core import PConstants
+from processing.core import PFont
+from processing.core import PGraphics
+from processing.core import PGraphicsJava2D
+from processing.core import PGraphicsRetina2D
+from processing.core import PImage
+from processing.core import PMatrix
+from processing.core import PMatrix2D
+from processing.core import PMatrix3D
+from processing.core import PShape
+from processing.core import PShapeOBJ
+from processing.core import PShapeSVG
+from processing.core import PStyle
from processing.core import PVector as RealPVector
-# Thanks, Guido!
-# http://mail.python.org/pipermail/python-dev/2008-January/076194.html
-def monkeypatch_method(cls):
- def decorator(func):
- setattr(cls, func.__name__, func)
- return func
- return decorator
+__builtin__.PApplet = PApplet
+__builtin__.PApplet = PConstants
+__builtin__.PApplet = PFont
+__builtin__.PApplet = PGraphics
+__builtin__.PApplet = PGraphicsJava2D
+__builtin__.PApplet = PGraphicsRetina2D
+__builtin__.PApplet = PImage
+__builtin__.PApplet = PMatrix
+__builtin__.PApplet = PMatrix2D
+__builtin__.PApplet = PMatrix3D
+__builtin__.PApplet = PShape
+__builtin__.PApplet = PShapeOBJ
+__builtin__.PApplet = PShapeSVG
+__builtin__.PApplet = PStyle
class PVector(object):
@classmethod
@@ -47,6 +70,14 @@ def dot(cls, a, b):
def angleBetween(cls, a, b):
return RealPVector.angleBetween(a, b)
+# Thanks, Guido!
+# http://mail.python.org/pipermail/python-dev/2008-January/076194.html
+def monkeypatch_method(cls):
+ def decorator(func):
+ setattr(cls, func.__name__, func)
+ return func
+ return decorator
+
@monkeypatch_method(RealPVector)
def __sub__(a, b):
return PVector(a.x - b.x, a.y - b.y, a.z - b.z)
@@ -63,9 +94,254 @@ def __mul__(a, b):
__builtin__.PVector = PVector
+__papplet__ = PAppletJythonDriver(__interp__, __path__, __source__)
+__builtin__.this = __papplet__
+
+__builtin__.alpha = __papplet__.alpha
+__builtin__.ambient = __papplet__.ambient
+__builtin__.ambientLight = __papplet__.ambientLight
+__builtin__.applyMatrix = __papplet__.applyMatrix
+__builtin__.arc = __papplet__.arc
+__builtin__.background = __papplet__.background
+__builtin__.beginCamera = __papplet__.beginCamera
+__builtin__.beginContour = __papplet__.beginContour
+__builtin__.beginRaw = __papplet__.beginRaw
+__builtin__.beginRecord = __papplet__.beginRecord
+__builtin__.beginShape = __papplet__.beginShape
+__builtin__.bezier = __papplet__.bezier
+__builtin__.bezierDetail = __papplet__.bezierDetail
+__builtin__.bezierPoint = __papplet__.bezierPoint
+__builtin__.bezierTangent = __papplet__.bezierTangent
+__builtin__.bezierVertex = __papplet__.bezierVertex
+__builtin__.blend = __papplet__.blend
+__builtin__.blendMode = __papplet__.blendMode
+__builtin__.blue = __papplet__.blue
+__builtin__.box = __papplet__.box
+__builtin__.brightness = __papplet__.brightness
+__builtin__.camera = __papplet__.camera
+__builtin__.clear = __papplet__.clear
+__builtin__.color = __papplet__.color
+__builtin__.colorMode = __papplet__.colorMode
+__builtin__.copy = __papplet__.copy
+__builtin__.createFont = __papplet__.createFont
+__builtin__.createGraphics = __papplet__.createGraphics
+__builtin__.createImage = __papplet__.createImage
+__builtin__.createInput = __papplet__.createInput
+__builtin__.createOutput = __papplet__.createOutput
+__builtin__.createReader = __papplet__.createReader
+__builtin__.createShape = __papplet__.createShape
+__builtin__.createWriter = __papplet__.createWriter
+__builtin__.cursor = __papplet__.cursor
+__builtin__.curve = __papplet__.curve
+__builtin__.curveDetail = __papplet__.curveDetail
+__builtin__.curvePoint = __papplet__.curvePoint
+__builtin__.curveTangent = __papplet__.curveTangent
+__builtin__.curveTightness = __papplet__.curveTightness
+__builtin__.curveVertex = __papplet__.curveVertex
+__builtin__.directionalLight = __papplet__.directionalLight
+__builtin__.ellipse = __papplet__.ellipse
+__builtin__.ellipseMode = __papplet__.ellipseMode
+__builtin__.emissive = __papplet__.emissive
+__builtin__.endCamera = __papplet__.endCamera
+__builtin__.endContour = __papplet__.endContour
+__builtin__.endRaw = __papplet__.endRaw
+__builtin__.endRecord = __papplet__.endRecord
+__builtin__.endShape = __papplet__.endShape
+__builtin__.exit = __papplet__.exit
+__builtin__.fill = __papplet__.fill
+__builtin__.filter = __papplet__.filter
+__builtin__.frameRate = __papplet__.frameRate
+__builtin__.frustum = __papplet__.frustum
+__builtin__.get = __papplet__.get
+__builtin__.hint = __papplet__.hint
+__builtin__.hue = __papplet__.hue
+__builtin__.image = __papplet__.image
+__builtin__.imageMode = __papplet__.imageMode
+__builtin__.lerpColor = __papplet__.lerpColor
+__builtin__.lightFalloff = __papplet__.lightFalloff
+__builtin__.lightSpecular = __papplet__.lightSpecular
+__builtin__.lights = __papplet__.lights
+__builtin__.line = __papplet__.line
+__builtin__.loadBytes = __papplet__.loadBytes
+__builtin__.loadFont = __papplet__.loadFont
+__builtin__.loadImage = __papplet__.loadImage
+__builtin__.loadJSONArray = __papplet__.loadJSONArray
+__builtin__.loadJSONObject = __papplet__.loadJSONObject
+__builtin__.loadPixels = __papplet__.loadPixels
+__builtin__.loadShader = __papplet__.loadShader
+__builtin__.loadShape = __papplet__.loadShape
+__builtin__.loadStrings = __papplet__.loadStrings
+__builtin__.loadTable = __papplet__.loadTable
+__builtin__.loadXML = __papplet__.loadXML
+__builtin__.loop = __papplet__.loop
+__builtin__.millis = __papplet__.millis
+__builtin__.modelX = __papplet__.modelX
+__builtin__.modelY = __papplet__.modelY
+__builtin__.modelZ = __papplet__.modelZ
+__builtin__.noCursor = __papplet__.noCursor
+__builtin__.noFill = __papplet__.noFill
+__builtin__.noLights = __papplet__.noLights
+__builtin__.noLoop = __papplet__.noLoop
+__builtin__.noSmooth = __papplet__.noSmooth
+__builtin__.noStroke = __papplet__.noStroke
+__builtin__.noTint = __papplet__.noTint
+__builtin__.noise = __papplet__.noise
+__builtin__.noiseDetail = __papplet__.noiseDetail
+__builtin__.noiseSeed = __papplet__.noiseSeed
+__builtin__.normal = __papplet__.normal
+__builtin__.ortho = __papplet__.ortho
+__builtin__.parseXML = __papplet__.parseXML
+__builtin__.perspective = __papplet__.perspective
+__builtin__.point = __papplet__.point
+__builtin__.pointLight = __papplet__.pointLight
+__builtin__.popMatrix = __papplet__.popMatrix
+__builtin__.popStyle = __papplet__.popStyle
+__builtin__.printCamera = __papplet__.printCamera
+__builtin__.printMatrix = __papplet__.printMatrix
+__builtin__.printProjection = __papplet__.printProjection
+__builtin__.pushMatrix = __papplet__.pushMatrix
+__builtin__.pushStyle = __papplet__.pushStyle
+__builtin__.quad = __papplet__.quad
+__builtin__.quadraticVertex = __papplet__.quadraticVertex
+__builtin__.random = __papplet__.random
+__builtin__.randomGaussian = __papplet__.randomGaussian
+__builtin__.randomSeed = __papplet__.randomSeed
+__builtin__.rect = __papplet__.rect
+__builtin__.rectMode = __papplet__.rectMode
+__builtin__.red = __papplet__.red
+__builtin__.redraw = __papplet__.redraw
+__builtin__.requestImage = __papplet__.requestImage
+__builtin__.resetMatrix = __papplet__.resetMatrix
+__builtin__.resetShader = __papplet__.resetShader
+__builtin__.rotate = __papplet__.rotate
+__builtin__.rotateX = __papplet__.rotateX
+__builtin__.rotateY = __papplet__.rotateY
+__builtin__.saturation = __papplet__.saturation
+__builtin__.save = __papplet__.save
+__builtin__.saveBytes = __papplet__.saveBytes
+__builtin__.saveFrame = __papplet__.saveFrame
+__builtin__.saveJSONArray = __papplet__.saveJSONArray
+__builtin__.saveJSONObject = __papplet__.saveJSONObject
+__builtin__.saveStream = __papplet__.saveStream
+__builtin__.saveStrings = __papplet__.saveStrings
+__builtin__.saveTable = __papplet__.saveTable
+__builtin__.saveXML = __papplet__.saveXML
+__builtin__.scale = __papplet__.scale
+__builtin__.screenX = __papplet__.screenX
+__builtin__.screenY = __papplet__.screenY
+__builtin__.screenZ = __papplet__.screenZ
+__builtin__.selectFolder = __papplet__.selectFolder
+__builtin__.selectInput = __papplet__.selectInput
+__builtin__.selectOutput = __papplet__.selectOutput
+__builtin__.shader = __papplet__.shader
+__builtin__.shape = __papplet__.shape
+__builtin__.shapeMode = __papplet__.shapeMode
+__builtin__.shearX = __papplet__.shearX
+__builtin__.shearY = __papplet__.shearY
+__builtin__.shininess = __papplet__.shininess
+__builtin__.size = __papplet__.size
+__builtin__.smooth = __papplet__.smooth
+__builtin__.specular = __papplet__.specular
+__builtin__.sphere = __papplet__.sphere
+__builtin__.sphereDetail = __papplet__.sphereDetail
+__builtin__.spotLight = __papplet__.spotLight
+__builtin__.stroke = __papplet__.stroke
+__builtin__.strokeCap = __papplet__.strokeCap
+__builtin__.strokeJoin = __papplet__.strokeJoin
+__builtin__.strokeWeight = __papplet__.strokeWeight
+__builtin__.text = __papplet__.text
+__builtin__.textAlign = __papplet__.textAlign
+__builtin__.textAscent = __papplet__.textAscent
+__builtin__.textDescent = __papplet__.textDescent
+__builtin__.textFont = __papplet__.textFont
+__builtin__.textLeading = __papplet__.textLeading
+__builtin__.textMode = __papplet__.textMode
+__builtin__.textSize = __papplet__.textSize
+__builtin__.textWidth = __papplet__.textWidth
+__builtin__.texture = __papplet__.texture
+__builtin__.textureMode = __papplet__.textureMode
+__builtin__.tint = __papplet__.tint
+__builtin__.translate = __papplet__.translate
+__builtin__.triangle = __papplet__.triangle
+__builtin__.updatePixels = __papplet__.updatePixels
+__builtin__.vertex = __papplet__.vertex
+
+__builtin__.abs = PApplet.abs
+__builtin__.acos = PApplet.acos
+__builtin__.append = PApplet.append
+__builtin__.arrayCopy = PApplet.arrayCopy
+__builtin__.asin = PApplet.asin
+__builtin__.atan = PApplet.atan
+__builtin__.atan2 = PApplet.atan2
+__builtin__.binary = PApplet.binary
+__builtin__.blendColor = PApplet.blendColor
+__builtin__.ceil = PApplet.ceil
+__builtin__.concat = PApplet.concat
+__builtin__.constrain = PApplet.constrain
+__builtin__.cos = PApplet.cos
+__builtin__.createInput = PApplet.createInput
+__builtin__.createOutput = PApplet.createOutput
+__builtin__.createReader = PApplet.createReader
+__builtin__.createWriter = PApplet.createWriter
+__builtin__.day = PApplet.day
+__builtin__.debug = PApplet.debug
+__builtin__.degrees = PApplet.degrees
+__builtin__.dist = PApplet.dist
+#__builtin__.exec = PApplet.exec
+__builtin__.exp = PApplet.exp
+__builtin__.expand = PApplet.expand
+__builtin__.floor = PApplet.floor
+__builtin__.hex = PApplet.hex
+__builtin__.hour = PApplet.hour
+__builtin__.join = PApplet.join
+__builtin__.lerp = PApplet.lerp
+__builtin__.lerpColor = PApplet.lerpColor
+__builtin__.loadBytes = PApplet.loadBytes
+__builtin__.loadStrings = PApplet.loadStrings
+__builtin__.log = PApplet.log
+__builtin__.mag = PApplet.mag
+__builtin__.map = PApplet.map
+__builtin__.match = PApplet.match
+__builtin__.matchAll = PApplet.matchAll
+#__builtin__.max = PApplet.max
+#__builtin__.min = PApplet.min
+__builtin__.minute = PApplet.minute
+__builtin__.month = PApplet.month
+__builtin__.nf = PApplet.nf
+__builtin__.nfc = PApplet.nfc
+__builtin__.nfp = PApplet.nfp
+__builtin__.nfs = PApplet.nfs
+__builtin__.norm = PApplet.norm
+__builtin__.pow = PApplet.pow
+#__builtin__.print = PApplet.print
+__builtin__.println = PApplet.println
+__builtin__.radians = PApplet.radians
+__builtin__.reverse = PApplet.reverse
+__builtin__.round = PApplet.round
+__builtin__.saveBytes = PApplet.saveBytes
+__builtin__.saveStream = PApplet.saveStream
+__builtin__.saveStrings = PApplet.saveStrings
+__builtin__.second = PApplet.second
+__builtin__.shorten = PApplet.shorten
+__builtin__.sin = PApplet.sin
+__builtin__.sort = PApplet.sort
+__builtin__.splice = PApplet.splice
+__builtin__.split = PApplet.split
+__builtin__.splitTokens = PApplet.splitTokens
+__builtin__.sq = PApplet.sq
+__builtin__.sqrt = PApplet.sqrt
+__builtin__.subset = PApplet.subset
+__builtin__.tan = PApplet.tan
+__builtin__.trim = PApplet.trim
+__builtin__.unbinary = PApplet.unbinary
+__builtin__.unhex = PApplet.unhex
+__builtin__.year = PApplet.year
+
# Extra helper functions go here
def pwd(name = ""):
"""Returns the script's path, or the path for some data close to the script."""
import java.lang.System as System
return System.getProperty("python.main.root") + "/" + name
__builtin__.pwd = pwd
+
+del monkeypatch_method, PAppletJythonDriver
Please sign in to comment.
Something went wrong with that request. Please try again.