Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New formatting rules.

  • Loading branch information...
commit a938b66a0bcb8b0c4c7686de7a686fc344079d71 1 parent 7292c0e
@jdf authored
View
23 .settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,3 @@
-#Thu Dec 15 15:41:18 EST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
@@ -82,7 +81,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18|-1|16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=18|-1|16
org.eclipse.jdt.core.formatter.alignment_for_assignment=16
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
@@ -97,14 +96,16 @@ org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration=24
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class=2
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18|-1|16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16|-1|16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=18|-1|16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=18|-1|16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=18
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
@@ -162,7 +163,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
-org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
@@ -237,12 +238,14 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invoca
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
@@ -266,6 +269,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invoc
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
@@ -321,6 +325,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invoc
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
@@ -330,6 +335,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=inser
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
@@ -345,7 +351,7 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=80
+org.eclipse.jdt.core.formatter.lineSplit=100
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
@@ -357,10 +363,11 @@ org.eclipse.jdt.core.formatter.sort_package_annotations=false
org.eclipse.jdt.core.formatter.sort_parameter_annotations=false
org.eclipse.jdt.core.formatter.sort_type_annotations=false
org.eclipse.jdt.core.formatter.tabulation.char=space
-org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_comment_inline_tags=false
org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation=true
org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation=true
View
134 misc/eclipse/processing-py-formatter.xml
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<profiles version="11">
-<profile kind="CodeFormatterProfile" name="processing.py" version="11">
+<profiles version="12">
+<profile kind="CodeFormatterProfile" name="processing.py" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
@@ -9,62 +10,57 @@
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_comment_inline_tags" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_local_variable_declaration" value="24"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="24"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="18|-1|16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="18"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.sort_type_annotations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
-<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type_declaration" value="569"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="18|-1|16"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.sort_parameter_annotations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16|-1|16"/>
@@ -78,34 +74,38 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_type_annotation" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_field_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
@@ -118,32 +118,34 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_generic_type_arguments" value="18"/>
-<setting id="org.eclipse.jdt.core.formatter.comment_new_line_at_start_of_html_paragraph" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.sort_package_annotations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_parameter_annotation" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
@@ -151,37 +153,32 @@
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_member" value="569"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="18|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.force_if_else_statement_brace" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_package_annotation" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.sort_member_annotations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="18|-1|16"/>
-<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="18|-1|16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_new_anonymous_class" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
@@ -194,98 +191,101 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="18|-1|16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="18|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16|-1|16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="18|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18|-1|16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
-<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16|-1|0"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.sort_local_variable_annotations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_member_annotation" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="569"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package_declaration" value="569"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_for_statement" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
</profile>
</profiles>
View
638 runtime/src/jycessing/PAppletJythonDriver.java
@@ -50,344 +50,340 @@
@SuppressWarnings("serial")
abstract public class PAppletJythonDriver extends PApplet {
- abstract protected void populateBuiltins();
-
- protected final PyStringMap builtins;
- protected final InteractiveConsole interp;
- private final String pySketchPath;
- private final String programText;
-
- private final CountDownLatch finishedLatch = new CountDownLatch(1);
-
- // A static-mode sketch must be interpreted from with the setup() method.
- // All others are interpreted during construction in order to harvest method
- // definitions, which we then invoke during the run loop.
- private final boolean isStaticMode;
-
- // The presence of either setup() or draw() indicates that this is not a
- // static sketch.
- private static final Pattern ACTIVE_METHOD_DEF = Pattern.compile(
- "^def\\s+(setup|draw)\\s*\\(\\s*\\)\\s*:", Pattern.MULTILINE);
-
- // 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, mouseReleasedMeth, mouseDraggedMeth,
- keyPressedMeth, keyReleasedMeth, keyTypedMeth, initMeth, stopMeth;
-
- // Adapted from Jython's PythonInterpreter.java exec(String s) to preserve
- // the source file name, so that errors have the file name instead of
- // "<string>"
- private void interpretSketch() {
- try {
- Py.setSystemState(interp.getSystemState());
- Py.exec(Py.compile_flags(programText, pySketchPath,
- CompileMode.exec, new CompilerFlags()), interp.getLocals(),
- null);
- Py.flushLine();
- } catch (Throwable t) {
- checkForRendererChangeException(t);
- while (t.getCause() != null) {
- t = t.getCause();
- }
- t.printStackTrace(System.err);
- System.exit(-1);
- }
- }
-
- protected void setFields() {
- builtins.__setitem__("key", new PyUnicode(Character.toString(key)));
- }
-
- public PAppletJythonDriver(final InteractiveConsole interp,
- final String sketchPath, final String programText) {
- this.programText = programText;
- this.pySketchPath = sketchPath;
- this.sketchPath = new File(sketchPath).getParent();
- this.isStaticMode = !ACTIVE_METHOD_DEF.matcher(programText).find();
- Runner.log("Mode: ", (isStaticMode ? "static" : "active"));
- this.builtins = (PyStringMap)interp.getSystemState().getBuiltins();
- this.interp = interp;
- initializeStatics(builtins);
- setSet();
- populateBuiltins();
- setFields();
- builtins.__setitem__("this", Py.java2py(this));
- builtins.__setitem__("g", Py.java2py(g));
- builtins.__setitem__("exit", new PyObject() {
- @Override
- public PyObject __call__(final PyObject[] args, final String[] kws) {
- finishedLatch.countDown();
- return Py.None;
- }
- });
-
- if (!isStaticMode) {
- // Executing the sketch will bind method names ("draw") to PyCode
- // objects (the sketch's draw method), which can then be invoked
- // during the run loop
- interpretSketch();
- }
-
- // Find and cache any PApplet callbacks defined in the Python sketch
- drawMeth = interp.get("draw");
- setupMeth = interp.get("setup");
- mousePressedMeth = interp.get("mousePressed");
- mouseClickedMeth = interp.get("mouseClicked");
- mouseReleasedMeth = interp.get("mouseReleased");
- mouseDraggedMeth = interp.get("mouseDragged");
- keyPressedMeth = interp.get("keyPressed");
- keyReleasedMeth = interp.get("keyReleased");
- keyTypedMeth = interp.get("keyTyped");
- initMeth = interp.get("init");
- stopMeth = interp.get("stop");
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentHidden(final ComponentEvent e) {
- finishedLatch.countDown();
- }
- });
- }
-
- @Override
- public void start() {
- // I want to quit on runtime exceptions.
- // Processing just sits there by default.
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
- public void uncaughtException(Thread t, Throwable e) {
- e.printStackTrace(System.err);
- System.exit(-1);
- }
- });
- super.start();
+ abstract protected void populateBuiltins();
+
+ protected final PyStringMap builtins;
+ protected final InteractiveConsole interp;
+ private final String pySketchPath;
+ private final String programText;
+
+ private final CountDownLatch finishedLatch = new CountDownLatch(1);
+
+ // A static-mode sketch must be interpreted from with the setup() method.
+ // All others are interpreted during construction in order to harvest method
+ // definitions, which we then invoke during the run loop.
+ private final boolean isStaticMode;
+
+ // The presence of either setup() or draw() indicates that this is not a
+ // static sketch.
+ private static final Pattern ACTIVE_METHOD_DEF = Pattern.compile(
+ "^def\\s+(setup|draw)\\s*\\(\\s*\\)\\s*:", Pattern.MULTILINE);
+
+ // 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,
+ mouseReleasedMeth, mouseDraggedMeth, keyPressedMeth, keyReleasedMeth, keyTypedMeth, initMeth,
+ stopMeth;
+
+ // Adapted from Jython's PythonInterpreter.java exec(String s) to preserve
+ // the source file name, so that errors have the file name instead of
+ // "<string>"
+ private void interpretSketch() {
+ try {
+ Py.setSystemState(interp.getSystemState());
+ Py.exec(Py.compile_flags(programText, pySketchPath, CompileMode.exec, new CompilerFlags()),
+ interp.getLocals(), null);
+ Py.flushLine();
+ } catch (Throwable t) {
+ checkForRendererChangeException(t);
+ while (t.getCause() != null) {
+ t = t.getCause();
+ }
+ t.printStackTrace(System.err);
+ System.exit(-1);
}
-
- @Override
- public void init() {
- try {
- if (initMeth != null) {
- builtins.__setitem__("frame", Py.java2py(frame));
- initMeth.__call__();
- }
- } finally {
- super.init();
- }
+ }
+
+ protected void setFields() {
+ builtins.__setitem__("key", new PyUnicode(Character.toString(key)));
+ }
+
+ public PAppletJythonDriver(final InteractiveConsole interp, final String sketchPath,
+ final String programText) {
+ this.programText = programText;
+ this.pySketchPath = sketchPath;
+ this.sketchPath = new File(sketchPath).getParent();
+ this.isStaticMode = !ACTIVE_METHOD_DEF.matcher(programText).find();
+ Runner.log("Mode: ", (isStaticMode ? "static" : "active"));
+ this.builtins = (PyStringMap)interp.getSystemState().getBuiltins();
+ this.interp = interp;
+ initializeStatics(builtins);
+ setSet();
+ populateBuiltins();
+ setFields();
+ builtins.__setitem__("this", Py.java2py(this));
+ builtins.__setitem__("g", Py.java2py(g));
+ builtins.__setitem__("exit", new PyObject() {
+ @Override
+ public PyObject __call__(final PyObject[] args, final String[] kws) {
+ finishedLatch.countDown();
+ return Py.None;
+ }
+ });
+
+ if (!isStaticMode) {
+ // Executing the sketch will bind method names ("draw") to PyCode
+ // objects (the sketch's draw method), which can then be invoked
+ // during the run loop
+ interpretSketch();
}
- public void blockUntilFinished() throws InterruptedException {
- finishedLatch.await();
- }
-
- /**
- * Permit the punning use of set() by mucking with the builtin "set" Type.
- * If you call it with 3 arguments, it acts like the Processing set(x, y,
- * whatever) method. If you call it with 0 or 1 args, it constructs a Python
- * set.
- */
- private void setSet() {
- builtins.__setitem__("set", new PyJavaType() {
- {
- builtin = true;
- init(PySet.class, new HashSet<PyJavaType>());
- invalidateMethodCache();
- }
-
- @Override
- public PyObject __call__(final PyObject[] args, final String[] kws) {
- switch (args.length) {
- default:
- return super.__call__(args, kws);
- case 3: {
- final PyObject x = args[0];
- final PyType tx = x.getType();
- final PyObject y = args[1];
- final PyType ty = y.getType();
- final PyObject c = args[2];
- final PyType tc = c.getType();
- if (tx == PyInteger.TYPE && ty == PyInteger.TYPE
- && tc == PyInteger.TYPE) {
- set(x.asInt(), y.asInt(), c.asInt());
- return Py.None;
- } else if (tx == PyInteger.TYPE && ty == PyInteger.TYPE
- && tc.getProxyType() != null
- && tc.getProxyType() == PImage.class) {
- set(x.asInt(), y.asInt(), (processing.core.PImage)c
- .__tojava__(processing.core.PImage.class));
- return Py.None;
- } else {
- return super.__call__(args, kws);
- }
- }
- }
- }
- });
+ // Find and cache any PApplet callbacks defined in the Python sketch
+ drawMeth = interp.get("draw");
+ setupMeth = interp.get("setup");
+ mousePressedMeth = interp.get("mousePressed");
+ mouseClickedMeth = interp.get("mouseClicked");
+ mouseReleasedMeth = interp.get("mouseReleased");
+ mouseDraggedMeth = interp.get("mouseDragged");
+ keyPressedMeth = interp.get("keyPressed");
+ keyReleasedMeth = interp.get("keyReleased");
+ keyTypedMeth = interp.get("keyTyped");
+ initMeth = interp.get("init");
+ stopMeth = interp.get("stop");
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentHidden(final ComponentEvent e) {
+ finishedLatch.countDown();
+ }
+ });
+ }
+
+ @Override
+ public void start() {
+ // I want to quit on runtime exceptions.
+ // Processing just sits there by default.
+ Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+ public void uncaughtException(Thread t, Throwable e) {
+ e.printStackTrace(System.err);
+ System.exit(-1);
+ }
+ });
+ super.start();
+ }
+
+ @Override
+ public void init() {
+ try {
+ if (initMeth != null) {
+ builtins.__setitem__("frame", Py.java2py(frame));
+ initMeth.__call__();
+ }
+ } finally {
+ super.init();
}
-
- /**
- * Populate the Python builtins namespace with PConstants.
- */
- public static void initializeStatics(final PyStringMap builtins) {
- for (final Field f : PConstants.class.getDeclaredFields()) {
- final int mods = f.getModifiers();
- if (Modifier.isPublic(mods) || Modifier.isStatic(mods)) {
- try {
- builtins.__setitem__(f.getName(), Py.java2py(f.get(null)));
- } catch (final Exception e) {
- e.printStackTrace();
- }
+ }
+
+ public void blockUntilFinished() throws InterruptedException {
+ finishedLatch.await();
+ }
+
+ /**
+ * Permit the punning use of set() by mucking with the builtin "set" Type.
+ * If you call it with 3 arguments, it acts like the Processing set(x, y,
+ * whatever) method. If you call it with 0 or 1 args, it constructs a Python
+ * set.
+ */
+ private void setSet() {
+ builtins.__setitem__("set", new PyJavaType() {
+ {
+ builtin = true;
+ init(PySet.class, new HashSet<PyJavaType>());
+ invalidateMethodCache();
+ }
+
+ @Override
+ public PyObject __call__(final PyObject[] args, final String[] kws) {
+ switch (args.length) {
+ default:
+ return super.__call__(args, kws);
+ case 3: {
+ final PyObject x = args[0];
+ final PyType tx = x.getType();
+ final PyObject y = args[1];
+ final PyType ty = y.getType();
+ final PyObject c = args[2];
+ final PyType tc = c.getType();
+ if (tx == PyInteger.TYPE && ty == PyInteger.TYPE && tc == PyInteger.TYPE) {
+ set(x.asInt(), y.asInt(), c.asInt());
+ return Py.None;
+ } else if (tx == PyInteger.TYPE && ty == PyInteger.TYPE && tc.getProxyType() != null
+ && tc.getProxyType() == PImage.class) {
+ set(x.asInt(), y.asInt(),
+ (processing.core.PImage)c.__tojava__(processing.core.PImage.class));
+ return Py.None;
+ } else {
+ return super.__call__(args, kws);
}
+ }
}
- }
-
- private void checkForRendererChangeException(final Throwable t) {
- if (t.getCause() instanceof RendererChangeException) {
- // This is an expected condition. PApplet uses an exception
- // to signal a change to the rendering context, so we unwrap
- // the Python exception to extract the signal, and pass it
- // up the stack.
- throw (RendererChangeException)t.getCause();
- }
- }
-
- /**
- * We have to override PApplet's size method in order to reset the Python
- * context's knowledge of the magic variables that reflect the state of the
- * sketch's world, particularly width and height.
- */
- @Override
- public void size(final int iwidth, final int iheight,
- final String irenderer, final String ipath) {
- super.size(iwidth, iheight, irenderer, ipath);
- setFields();
- builtins.__setitem__("g", Py.java2py(g));
- builtins.__setitem__("frame", Py.java2py(frame));
- }
-
- @Override
- public void setup() {
- // Put all of PApplet's globals into the Python context
- setFields();
- builtins.__setitem__("frame", Py.java2py(frame));
-
+ }
+ });
+ }
+
+ /**
+ * Populate the Python builtins namespace with PConstants.
+ */
+ public static void initializeStatics(final PyStringMap builtins) {
+ for (final Field f : PConstants.class.getDeclaredFields()) {
+ final int mods = f.getModifiers();
+ if (Modifier.isPublic(mods) || Modifier.isStatic(mods)) {
try {
- if (isStaticMode) {
- // A static sketch gets called once, from this spot.
- Runner.log("Interpreting static-mode sketch.");
- interpretSketch();
- } else if (setupMeth != null) {
- // Call the Python sketch's setup()
- setupMeth.__call__();
- }
- } catch (final PyException e) {
- checkForRendererChangeException(e);
- throw e;
+ builtins.__setitem__(f.getName(), Py.java2py(f.get(null)));
+ } catch (final Exception e) {
+ e.printStackTrace();
}
+ }
}
-
- @Override
- public void draw() {
- if (drawMeth == null) {
- Runner.log("Calling super.draw() in what I assume is a static-mode sketch.");
- super.draw();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- drawMeth.__call__();
- }
+ }
+
+ private void checkForRendererChangeException(final Throwable t) {
+ if (t.getCause() instanceof RendererChangeException) {
+ // This is an expected condition. PApplet uses an exception
+ // to signal a change to the rendering context, so we unwrap
+ // the Python exception to extract the signal, and pass it
+ // up the stack.
+ throw (RendererChangeException)t.getCause();
}
-
- @Override
- public void loadPixels() {
- super.loadPixels();
- builtins.__setitem__("pixels", Py.java2py(pixels));
+ }
+
+ /**
+ * We have to override PApplet's size method in order to reset the Python
+ * context's knowledge of the magic variables that reflect the state of the
+ * sketch's world, particularly width and height.
+ */
+ @Override
+ public void size(final int iwidth, final int iheight, final String irenderer, final String ipath) {
+ super.size(iwidth, iheight, irenderer, ipath);
+ setFields();
+ builtins.__setitem__("g", Py.java2py(g));
+ builtins.__setitem__("frame", Py.java2py(frame));
+ }
+
+ @Override
+ public void setup() {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ builtins.__setitem__("frame", Py.java2py(frame));
+
+ try {
+ if (isStaticMode) {
+ // A static sketch gets called once, from this spot.
+ Runner.log("Interpreting static-mode sketch.");
+ interpretSketch();
+ } else if (setupMeth != null) {
+ // Call the Python sketch's setup()
+ setupMeth.__call__();
+ }
+ } catch (final PyException e) {
+ checkForRendererChangeException(e);
+ throw e;
}
-
- @Override
- public void mouseClicked() {
- if (mouseClickedMeth == null) {
- super.mouseClicked();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- mouseClickedMeth.__call__();
- }
+ }
+
+ @Override
+ public void draw() {
+ if (drawMeth == null) {
+ Runner.log("Calling super.draw() in what I assume is a static-mode sketch.");
+ super.draw();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ drawMeth.__call__();
}
-
- @Override
- public void mousePressed() {
- if (mousePressedMeth == null) {
- super.mousePressed();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- mousePressedMeth.__call__();
- }
+ }
+
+ @Override
+ public void loadPixels() {
+ super.loadPixels();
+ builtins.__setitem__("pixels", Py.java2py(pixels));
+ }
+
+ @Override
+ public void mouseClicked() {
+ if (mouseClickedMeth == null) {
+ super.mouseClicked();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ mouseClickedMeth.__call__();
}
-
- @Override
- public void mouseReleased() {
- if (mouseReleasedMeth == null) {
- super.mouseReleased();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- mouseReleasedMeth.__call__();
- }
+ }
+
+ @Override
+ public void mousePressed() {
+ if (mousePressedMeth == null) {
+ super.mousePressed();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ mousePressedMeth.__call__();
}
-
- @Override
- public void mouseDragged() {
- if (mouseDraggedMeth == null) {
- super.mouseDragged();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- mouseDraggedMeth.__call__();
- }
+ }
+
+ @Override
+ public void mouseReleased() {
+ if (mouseReleasedMeth == null) {
+ super.mouseReleased();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ mouseReleasedMeth.__call__();
}
-
- @Override
- public void keyPressed() {
- if (keyPressedMeth == null) {
- super.keyPressed();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- keyPressedMeth.__call__();
- }
+ }
+
+ @Override
+ public void mouseDragged() {
+ if (mouseDraggedMeth == null) {
+ super.mouseDragged();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ mouseDraggedMeth.__call__();
}
-
- @Override
- public void keyReleased() {
- if (keyReleasedMeth == null) {
- super.keyReleased();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- keyReleasedMeth.__call__();
- }
+ }
+
+ @Override
+ public void keyPressed() {
+ if (keyPressedMeth == null) {
+ super.keyPressed();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ keyPressedMeth.__call__();
}
-
- @Override
- public void keyTyped() {
- if (keyTypedMeth == null) {
- super.keyTyped();
- } else {
- // Put all of PApplet's globals into the Python context
- setFields();
- keyTypedMeth.__call__();
- }
+ }
+
+ @Override
+ public void keyReleased() {
+ if (keyReleasedMeth == null) {
+ super.keyReleased();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ keyReleasedMeth.__call__();
}
-
- // Minim sketches seem to want to override stop()
- @Override
- public void stop() {
- try {
- if (stopMeth != null) {
- stopMeth.__call__();
- }
- } finally {
- super.stop();
- }
+ }
+
+ @Override
+ public void keyTyped() {
+ if (keyTypedMeth == null) {
+ super.keyTyped();
+ } else {
+ // Put all of PApplet's globals into the Python context
+ setFields();
+ keyTypedMeth.__call__();
+ }
+ }
+
+ // Minim sketches seem to want to override stop()
+ @Override
+ public void stop() {
+ try {
+ if (stopMeth != null) {
+ stopMeth.__call__();
+ }
+ } finally {
+ super.stop();
}
+ }
}
View
485 runtime/src/jycessing/Runner.java
@@ -46,266 +46,255 @@
import javax.swing.SwingUtilities;
public class Runner {
- static boolean VERBOSE = false;
-
- static void log(final Object... objs) {
- if (!VERBOSE) {
- return;
- }
- for (final Object o : objs) {
- System.err.print(String.valueOf(o));
- }
- System.err.println();
- }
+ static boolean VERBOSE = false;
- // Slurp the given Reader into a String.
- private static String read(final Reader r) throws IOException {
- final BufferedReader reader = new BufferedReader(r);
- final StringBuilder sb = new StringBuilder(1024);
- String line;
- try {
- while ((line = reader.readLine()) != null) {
- sb.append(line).append("\n");
- }
- return sb.toString();
- } finally {
- reader.close();
- }
+ static void log(final Object... objs) {
+ if (!VERBOSE) {
+ return;
}
-
- private static String read(final InputStream in) throws IOException {
- return read(new InputStreamReader(in, "UTF-8"));
+ for (final Object o : objs) {
+ System.err.print(String.valueOf(o));
}
-
- /**
- * Add a URL (referring to a jar file or class directory) to the current
- * classloader. Of course, this is a filthy hack, which depends on an
- * implementation detail (i.e., that the system classloader is a
- * URLClassLoader). But it certainly works with all known Sun JVMs of recent
- * vintage, and with OS X's JVMs.
- *
- * <p>
- * See <a href=
- * "http://robertmaldon.blogspot.com/2007/11/dynamically-add-to-eclipse-junit.html"
- * >this blog post</a>.
- *
- */
- private static void addJar(final URL url) throws Exception {
- final URLClassLoader classLoader =
- (URLClassLoader)ClassLoader.getSystemClassLoader();
- for (final URL u : classLoader.getURLs()) {
- if (u.equals(url)) {
- return;
- }
- }
- final Method method =
- URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
- method.setAccessible(true);
- method.invoke(classLoader, new Object[] { url });
- log("Added ", url, " to classpath.");
+ System.err.println();
+ }
+
+ // Slurp the given Reader into a String.
+ private static String read(final Reader r) throws IOException {
+ final BufferedReader reader = new BufferedReader(r);
+ final StringBuilder sb = new StringBuilder(1024);
+ String line;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ return sb.toString();
+ } finally {
+ reader.close();
}
-
- /**
- * Add the given path to the list of paths searched for DLLs (as in those
- * loaded by loadLibrary). A hack, which depends on the presence of a
- * particular field in ClassLoader. Known to work on all recent Sun JVMs and
- * OS X.
- *
- * <p>
- * See <a href="http://forums.sun.com/thread.jspa?threadID=707176">this
- * thread</a>.
- */
- private static void addLibraryPath(final String newPath) throws Exception {
- final Field field = ClassLoader.class.getDeclaredField("usr_paths");
- field.setAccessible(true);
- final String[] paths = (String[])field.get(null);
- for (final String path : paths) {
- if (newPath.equals(path)) {
- return;
- }
- }
- final String[] tmp = new String[paths.length + 1];
- System.arraycopy(paths, 0, tmp, 0, paths.length);
- tmp[paths.length] = newPath;
- field.set(null, tmp);
- log("Added ", newPath, " to java.library.path.");
+ }
+
+ private static String read(final InputStream in) throws IOException {
+ return read(new InputStreamReader(in, "UTF-8"));
+ }
+
+ /**
+ * Add a URL (referring to a jar file or class directory) to the current
+ * classloader. Of course, this is a filthy hack, which depends on an
+ * implementation detail (i.e., that the system classloader is a
+ * URLClassLoader). But it certainly works with all known Sun JVMs of recent
+ * vintage, and with OS X's JVMs.
+ *
+ * <p>
+ * See <a href=
+ * "http://robertmaldon.blogspot.com/2007/11/dynamically-add-to-eclipse-junit.html"
+ * >this blog post</a>.
+ *
+ */
+ private static void addJar(final URL url) throws Exception {
+ final URLClassLoader classLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+ for (final URL u : classLoader.getURLs()) {
+ if (u.equals(url)) {
+ return;
+ }
}
-
- /**
- * Recursively search the given directory for jar files and directories
- * containing dynamic libraries, adding them to the classpath and the
- * library path respectively.
- */
- private static void searchForExtraStuff(final File dir) throws Exception {
- if (dir == null) {
- throw new IllegalArgumentException("null dir");
- }
-
- log("Searching: ", dir);
-
- final File[] dlls = dir.listFiles(new FilenameFilter() {
- public boolean accept(final File dir, final String name) {
- return name.matches("^.+\\.(so|dll|jnilib)$");
- }
- });
- if (dlls != null && dlls.length > 0) {
- addLibraryPath(dir.getAbsolutePath());
- } else {
- log("No DLLs in ", dir);
- }
-
- final File[] jars = dir.listFiles(new FilenameFilter() {
- public boolean accept(final File dir, final String name) {
- return name.matches("^.+\\.jar$");
- }
- });
- if (!(jars == null || jars.length == 0)) {
- for (final File jar : jars) {
- addJar(jar.toURI().toURL());
- }
- } else {
- log("No JARs in ", dir);
- }
-
- final File[] dirs = dir.listFiles(new FileFilter() {
- public boolean accept(final File f) {
- log("Looking at ", f);
- return f.isDirectory() && f.getName().charAt(0) != '.';
- }
- });
- if (!(dirs == null || dirs.length == 0)) {
- for (final File d : dirs) {
- searchForExtraStuff(d);
- }
- } else {
- log("No dirs in ", dir);
- }
+ final Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
+ method.setAccessible(true);
+ method.invoke(classLoader, new Object[] { url });
+ log("Added ", url, " to classpath.");
+ }
+
+ /**
+ * Add the given path to the list of paths searched for DLLs (as in those
+ * loaded by loadLibrary). A hack, which depends on the presence of a
+ * particular field in ClassLoader. Known to work on all recent Sun JVMs and
+ * OS X.
+ *
+ * <p>
+ * See <a href="http://forums.sun.com/thread.jspa?threadID=707176">this
+ * thread</a>.
+ */
+ private static void addLibraryPath(final String newPath) throws Exception {
+ final Field field = ClassLoader.class.getDeclaredField("usr_paths");
+ field.setAccessible(true);
+ final String[] paths = (String[])field.get(null);
+ for (final String path : paths) {
+ if (newPath.equals(path)) {
+ return;
+ }
+ }
+ final String[] tmp = new String[paths.length + 1];
+ System.arraycopy(paths, 0, tmp, 0, paths.length);
+ tmp[paths.length] = newPath;
+ field.set(null, tmp);
+ log("Added ", newPath, " to java.library.path.");
+ }
+
+ /**
+ * Recursively search the given directory for jar files and directories
+ * containing dynamic libraries, adding them to the classpath and the
+ * library path respectively.
+ */
+ private static void searchForExtraStuff(final File dir) throws Exception {
+ if (dir == null) {
+ throw new IllegalArgumentException("null dir");
}
- public static void main(final String[] args) throws Exception {
- runFromCommandLineArguments(args);
- System.exit(0);
+ log("Searching: ", dir);
+
+ final File[] dlls = dir.listFiles(new FilenameFilter() {
+ public boolean accept(final File dir, final String name) {
+ return name.matches("^.+\\.(so|dll|jnilib)$");
+ }
+ });
+ if (dlls != null && dlls.length > 0) {
+ addLibraryPath(dir.getAbsolutePath());
+ } else {
+ log("No DLLs in ", dir);
}
- /**
- * @param args
- * @throws IOException
- * @throws FileNotFoundException
- * @throws Exception
- */
- public static void
- runFromCommandLineArguments(final String[] args) throws Exception {
- if (args.length < 1) {
- throw new RuntimeException(
- "I need the path of your Python script as an argument.");
- }
-
- // -Dverbose=true for some logging
- VERBOSE = Boolean.getBoolean("verbose");
-
- final Properties buildnum = new Properties();
- buildnum.load(Runner.class
- .getResourceAsStream("buildnumber.properties"));
- log("processing.py build ", buildnum.getProperty("buildnumber"));
-
- // The last argument is the path to the Python sketch
- final String sketchPath = args[args.length - 1];
-
- // This will throw an exception and die if the given file is not there
- // or not readable.
- final String sketchSource = read(new FileReader(sketchPath));
-
- runSketch(args, sketchPath, sketchSource);
+ final File[] jars = dir.listFiles(new FilenameFilter() {
+ public boolean accept(final File dir, final String name) {
+ return name.matches("^.+\\.jar$");
+ }
+ });
+ if (!(jars == null || jars.length == 0)) {
+ for (final File jar : jars) {
+ addJar(jar.toURI().toURL());
+ }
+ } else {
+ log("No JARs in ", dir);
}
- private static final Pattern JAR_RESOURCE =
- Pattern.compile("jar:file:(.+?)/processing-py.jar!/jycessing/buildnumber.properties");
- private static final Pattern FILE_RESOURCE = Pattern
- .compile("file:(.+?)/bin/jycessing/buildnumber.properties");
-
- private static File getLibrariesDir() {
- String propsResource;
- try {
- propsResource =
- URLDecoder.decode(
- Runner.class.getResource("buildnumber.properties")
- .toString(), "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Impossible: " + e);
- }
- {
- final Matcher m = JAR_RESOURCE.matcher(propsResource);
- if (m.matches()) {
- log("We're running from a JAR file.");
- return new File(m.group(1), "libraries");
- }
- }
- {
- final Matcher m = FILE_RESOURCE.matcher(propsResource);
- if (m.matches()) {
- log("We're running from class files.");
- return new File(m.group(1), "libraries");
- }
- }
- System.err
- .println("WARNING: I can't figure out where my libraries directory is.");
- return new File("libraries");
+ final File[] dirs = dir.listFiles(new FileFilter() {
+ public boolean accept(final File f) {
+ log("Looking at ", f);
+ return f.isDirectory() && f.getName().charAt(0) != '.';
+ }
+ });
+ if (!(dirs == null || dirs.length == 0)) {
+ for (final File d : dirs) {
+ searchForExtraStuff(d);
+ }
+ } else {
+ log("No dirs in ", dir);
}
+ }
+
+ public static void main(final String[] args) throws Exception {
+ runFromCommandLineArguments(args);
+ System.exit(0);
+ }
+
+ /**
+ * @param args
+ * @throws IOException
+ * @throws FileNotFoundException
+ * @throws Exception
+ */
+ public static void runFromCommandLineArguments(final String[] args) throws Exception {
+ if (args.length < 1) {
+ throw new RuntimeException("I need the path of your Python script as an argument.");
+ }
+
+ // -Dverbose=true for some logging
+ VERBOSE = Boolean.getBoolean("verbose");
- public static void runSketch(final String[] args, final String sketchPath,
- final String sketchSource) throws Exception {
- // Recursively search the "libraries" directory for jar files and
- // directories containing dynamic libraries, adding them to the
- // classpath and the library path respectively.
-
- // jar:file:/opt/feinberg/processing.py/processing-py.jar
- // or
- // file:/opt/feinberg/processing.py/bin/jycessing/buildnumber.properties
-
- final File libraries = getLibrariesDir();
- searchForExtraStuff(libraries);
-
- // Where is the sketch located?
- final String sketchDir =
- new File(sketchPath).getCanonicalFile().getParent();
-
- final Properties props = new Properties();
- props.setProperty("python.path", libraries.getAbsolutePath()
- + File.pathSeparator + sketchDir);
- PythonInterpreter.initialize(null, props, new String[] { "" });
-
- Py.initPython();
- final InteractiveConsole interp = new InteractiveConsole();
-
- // This hack seems to be necessary in order to redirect stdout for unit
- // tests
- interp.setOut(System.out);
-
- // Tell PApplet to make its home there, so that it can find the data
- // folder
- System.setProperty("user.dir", sketchDir);
-
- // Add it to the Python library path for auxilliary modules
- Py.getSystemState().path.insert(0, new PyString(sketchDir));
-
- // For error messages
- interp.set("__file__", sketchPath);
-
- interp.exec(read(Runner.class.getResourceAsStream("core.py")));
- // Bind the sketch to a PApplet
- final PAppletJythonDriver applet =
- new DriverImpl(interp, sketchPath, sketchSource);
-
- try {
- PApplet.runSketch(args, applet);
- applet.blockUntilFinished();
- log("Applet is finished. Disposing window.");
- ((Window)SwingUtilities.getRoot(applet)).dispose();
- } catch (final Throwable t) {
- Py.printException(t);
- } finally {
- log("Cleaning up interpreter.");
- interp.cleanup();
- }
+ final Properties buildnum = new Properties();
+ buildnum.load(Runner.class.getResourceAsStream("buildnumber.properties"));
+ log("processing.py build ", buildnum.getProperty("buildnumber"));
+
+ // The last argument is the path to the Python sketch
+ final String sketchPath = args[args.length - 1];
+
+ // This will throw an exception and die if the given file is not there
+ // or not readable.
+ final String sketchSource = read(new FileReader(sketchPath));
+
+ runSketch(args, sketchPath, sketchSource);
+ }
+
+ private static final Pattern JAR_RESOURCE = Pattern
+ .compile("jar:file:(.+?)/processing-py.jar!/jycessing/buildnumber.properties");
+ private static final Pattern FILE_RESOURCE = Pattern
+ .compile("file:(.+?)/bin/jycessing/buildnumber.properties");
+
+ private static File getLibrariesDir() {
+ String propsResource;
+ try {
+ propsResource =
+ URLDecoder.decode(Runner.class.getResource("buildnumber.properties").toString(), "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Impossible: " + e);
+ }
+ {
+ final Matcher m = JAR_RESOURCE.matcher(propsResource);
+ if (m.matches()) {
+ log("We're running from a JAR file.");
+ return new File(m.group(1), "libraries");
+ }
+ }
+ {
+ final Matcher m = FILE_RESOURCE.matcher(propsResource);
+ if (m.matches()) {
+ log("We're running from class files.");
+ return new File(m.group(1), "libraries");
+ }
+ }
+ System.err.println("WARNING: I can't figure out where my libraries directory is.");
+ return new File("libraries");
+ }
+
+ public static void runSketch(final String[] args, final String sketchPath,
+ final String sketchSource) throws Exception {
+ // Recursively search the "libraries" directory for jar files and
+ // directories containing dynamic libraries, adding them to the
+ // classpath and the library path respectively.
+
+ // jar:file:/opt/feinberg/processing.py/processing-py.jar
+ // or
+ // file:/opt/feinberg/processing.py/bin/jycessing/buildnumber.properties
+
+ final File libraries = getLibrariesDir();
+ searchForExtraStuff(libraries);
+
+ // Where is the sketch located?
+ final String sketchDir = new File(sketchPath).getCanonicalFile().getParent();
+
+ final Properties props = new Properties();
+ props.setProperty("python.path", libraries.getAbsolutePath() + File.pathSeparator + sketchDir);
+ PythonInterpreter.initialize(null, props, new String[] { "" });
+
+ Py.initPython();
+ final InteractiveConsole interp = new InteractiveConsole();
+
+ // This hack seems to be necessary in order to redirect stdout for unit
+ // tests
+ interp.setOut(System.out);
+
+ // Tell PApplet to make its home there, so that it can find the data
+ // folder
+ System.setProperty("user.dir", sketchDir);
+
+ // Add it to the Python library path for auxilliary modules
+ Py.getSystemState().path.insert(0, new PyString(sketchDir));
+
+ // For error messages
+ interp.set("__file__", sketchPath);
+
+ interp.exec(read(Runner.class.getResourceAsStream("core.py")));
+ // Bind the sketch to a PApplet
+ final PAppletJythonDriver applet = new DriverImpl(interp, sketchPath, sketchSource);
+
+ try {
+ PApplet.runSketch(args, applet);
+ applet.blockUntilFinished();
+ log("Applet is finished. Disposing window.");
+ ((Window)SwingUtilities.getRoot(applet)).dispose();
+ } catch (final Throwable t) {
+ Py.printException(t);
+ } finally {
+ log("Cleaning up interpreter.");
+ interp.cleanup();
}
+ }
}
View
38 runtime/src/jycessing/UnexpectedInvocationError.java
@@ -3,26 +3,24 @@
import org.python.core.PyObject;
public class UnexpectedInvocationError extends RuntimeException {
- private static String buildMessage(final String name, final PyObject[] args,
- final String[] kws) {
- final StringBuilder sb = new StringBuilder();
- sb.append("I don't know how to handle a call to ");
- sb.append(name).append('(');
- for (int i = 0; i < args.length; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append(args[i].getType());
- }
- sb.append("\n");
- sb.append("If ").append('"').append(name).append('"');
- sb.append(" is a Python builtin, please report this to ");
- sb.append("the processing.py project as a bug!");
- return sb.toString();
+ private static String buildMessage(final String name, final PyObject[] args, final String[] kws) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("I don't know how to handle a call to ");
+ sb.append(name).append('(');
+ for (int i = 0; i < args.length; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(args[i].getType());
}
+ sb.append("\n");
+ sb.append("If ").append('"').append(name).append('"');
+ sb.append(" is a Python builtin, please report this to ");
+ sb.append("the processing.py project as a bug!");
+ return sb.toString();
+ }
- public UnexpectedInvocationError(final String name, final PyObject[] args,
- final String[] kws) {
- super(buildMessage(name, args, kws));
- }
+ public UnexpectedInvocationError(final String name, final PyObject[] args, final String[] kws) {
+ super(buildMessage(name, args, kws));
+ }
}
View
16 runtime/src/jycessing/WrappedInteger.java
@@ -4,14 +4,14 @@
abstract public class WrappedInteger extends PyInteger {
- @Override
- abstract public int getValue();
+ @Override
+ abstract public int getValue();
- public WrappedInteger() {
- super(0);
- }
+ public WrappedInteger() {
+ super(0);
+ }
- public static void main(final String[] args) throws Exception {
- System.err.println(Class.forName("int"));
- }
+ public static void main(final String[] args) throws Exception {
+ System.err.println(Class.forName("int"));
+ }
}
View
209 testing/tests/test/jycessing/JycessingTests.java
@@ -12,111 +12,106 @@
public class JycessingTests {
- private static String run(final String testResource) throws Exception {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final PrintStream saved = System.out;
- try {
- System.setOut(new PrintStream(baos, true));
- Runner.runFromCommandLineArguments(new String[] { "testing/test_resources/test_"
- + testResource + ".py" });
- return new String(baos.toByteArray()).replaceAll("\r\n", "\n")
- .replaceAll("\r", "\n");
- } finally {
- System.setOut(saved);
- }
- }
-
- private static void testImport(final String module) throws Exception {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final PrintStream saved = System.out;
- try {
- System.setOut(new PrintStream(baos, true));
- final String testClass = module + "_test";
- final String bogusFileName = "<test " + module + ">";
- final String testText = "import " + module + "\nprint 'OK'\nexit()";
- Runner.runSketch(new String[] { testClass }, bogusFileName,
- testText);
- assertEquals("OK\n",
- new String(baos.toByteArray()).replaceAll("\r\n", "\n")
- .replaceAll("\r", "\n"));
- } finally {
- System.setOut(saved);
- }
- }
-
- @Test
- public void inherit_str() throws Exception {
- assertEquals("cosmic\n12\n[12, 13]\n", run("inherit_str"));
- }
-
- @Test
- public void static_size() throws Exception {
- assertEquals("OK\n", run("static_size"));
- }
-
- @Test
- public void set_builtins() throws Exception {
- assertEquals("128\nset(['banana'])\nissubclass: True\nset(['baz'])\n",
- run("set"));
- }
-
- @Test
- public void map_builtins() throws Exception {
- assertEquals("50\n13\n", run("map"));
- }
-
- @Test
- public void md5() throws Exception {
- assertEquals("bb649c83dd1ea5c9d9dec9a18df0ffe9\n", run("md5"));
- }
-
- @Test
- public void urllib2() throws Exception {
- testImport("urllib2");
- }
-
- @Test
- public void urllib() throws Exception {
- testImport("urllib");
- }
-
- @Test
- public void load_in_initializer() throws Exception {
- assertEquals("OK\n", run("load_in_initializer"));
- }
-
- @Test
- public void datetime() throws Exception {
- testImport("datetime");
- }
-
- @Test
- public void calendar() throws Exception {
- testImport("calendar");
- }
-
- @Test
- public void processing_core() throws Exception {
- assertEquals("[ 1.0, 2.0, 3.0 ]\n<type 'processing.core.PFont'>\n",
- run("pcore"));
- }
-
- @Test
- public void pvector() throws Exception {
- assertEquals("OK\n", run("pvector"));
- }
-
- @Test
- public void loadPixels() throws Exception {
- assertEquals("OK\n", run("loadPixels"));
- }
-
- @Test
- public void unicode() throws Exception {
- assertEquals("OK\n", run("unicode"));
- }
-
- public static void main(final String[] args) {
- JUnitCore.runClasses(JycessingTests.class);
- }
+ private static String run(final String testResource) throws Exception {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final PrintStream saved = System.out;
+ try {
+ System.setOut(new PrintStream(baos, true));
+ Runner.runFromCommandLineArguments(new String[] { "testing/test_resources/test_"
+ + testResource + ".py" });
+ return new String(baos.toByteArray()).replaceAll("\r\n", "\n").replaceAll("\r", "\n");
+ } finally {
+ System.setOut(saved);
+ }
+ }
+
+ private static void testImport(final String module) throws Exception {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final PrintStream saved = System.out;
+ try {
+ System.setOut(new PrintStream(baos, true));
+ final String testClass = module + "_test";
+ final String bogusFileName = "<test " + module + ">";
+ final String testText = "import " + module + "\nprint 'OK'\nexit()";
+ Runner.runSketch(new String[] { testClass }, bogusFileName, testText);
+ assertEquals("OK\n",
+ new String(baos.toByteArray()).replaceAll("\r\n", "\n").replaceAll("\r", "\n"));
+ } finally {
+ System.setOut(saved);
+ }
+ }
+
+ @Test
+ public void inherit_str() throws Exception {
+ assertEquals("cosmic\n12\n[12, 13]\n", run("inherit_str"));
+ }
+
+ @Test
+ public void static_size() throws Exception {
+ assertEquals("OK\n", run("static_size"));
+ }
+
+ @Test
+ public void set_builtins() throws Exception {
+ assertEquals("128\nset(['banana'])\nissubclass: True\nset(['baz'])\n", run("set"));
+ }
+
+ @Test
+ public void map_builtins() throws Exception {
+ assertEquals("50\n13\n", run("map"));
+ }
+
+ @Test
+ public void md5() throws Exception {
+ assertEquals("bb649c83dd1ea5c9d9dec9a18df0ffe9\n", run("md5"));
+ }
+
+ @Test
+ public void urllib2() throws Exception {
+ testImport("urllib2");
+ }
+
+ @Test
+ public void urllib() throws Exception {
+ testImport("urllib");
+ }
+
+ @Test
+ public void load_in_initializer() throws Exception {
+ assertEquals("OK\n", run("load_in_initializer"));
+ }
+
+ @Test
+ public void datetime() throws Exception {
+ testImport("datetime");
+ }
+
+ @Test
+ public void calendar() throws Exception {
+ testImport("calendar");
+ }
+
+ @Test
+ public void processing_core() throws Exception {
+ assertEquals("[ 1.0, 2.0, 3.0 ]\n<type 'processing.core.PFont'>\n", run("pcore"));
+ }
+
+ @Test
+ public void pvector() throws Exception {
+ assertEquals("OK\n", run("pvector"));
+ }
+
+ @Test
+ public void loadPixels() throws Exception {
+ assertEquals("OK\n", run("loadPixels"));
+ }
+
+ @Test
+ public void unicode() throws Exception {
+ assertEquals("OK\n", run("unicode"));
+ }
+
+ public static void main(final String[] args) {
+ JUnitCore.runClasses(JycessingTests.class);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.