/hg/release/icedtea-web-1.4: all output messages redirected to P...
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Fri Oct 25 03:17:10 PDT 2013
changeset 175dda8f15e5 in /hg/release/icedtea-web-1.4
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.4?cmd=changeset;node=175dda8f15e5
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Oct 25 11:07:08 2013 +0200
all output messages redirected to PLUGIN_{DEBUG,ERROR} macros
diffstat:
ChangeLog | 15 +++++
plugin/icedteanp/IcedTeaJavaRequestProcessor.cc | 20 +++---
plugin/icedteanp/IcedTeaNPPlugin.cc | 12 ++--
plugin/icedteanp/IcedTeaPluginRequestProcessor.cc | 6 +-
plugin/icedteanp/IcedTeaPluginUtils.cc | 6 +-
plugin/icedteanp/IcedTeaPluginUtils.h | 2 +-
plugin/icedteanp/IcedTeaRunnable.cc | 3 +-
plugin/icedteanp/IcedTeaScriptablePluginObject.cc | 46 ++++++++--------
tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc | 61 +++++++++++++++++++++++
9 files changed, 124 insertions(+), 47 deletions(-)
diffs (truncated from 547 to 500 lines):
diff -r e1dfddeb801d -r 175dda8f15e5 ChangeLog
--- a/ChangeLog Tue Oct 22 11:46:27 2013 +0200
+++ b/ChangeLog Fri Oct 25 11:07:08 2013 +0200
@@ -1,3 +1,18 @@
+2013-10-25 Jiri Vanek <jvanek at redhat.com>
+
+ all output messages redirected to PLUGIN_{DEBUG,ERROR} macros
+ * plugin/icedteanp/IcedTeaJavaRequestProcessor.cc: affected
+ * plugin/icedteanp/IcedTeaNPPlugin.cc: affected
+ * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: affected
+ * plugin/icedteanp/IcedTeaPluginUtils.cc: affected
+ * plugin/icedteanp/IcedTeaPluginUtils.h: affected
+ * plugin/icedteanp/IcedTeaRunnable.cc: affected
+ * plugin/icedteanp/IcedTeaScriptablePluginObject.cc: affected
+ * tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc: added
+ (TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on)) and
+ (TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_off)) which call new
+ (doDebugErrorRun) and are measuring refactoring impacts.
+
2013-10-22 Jiri Vanek <jvanek at redhat.com>
More synchronized error/debug methods
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc Fri Oct 25 11:07:08 2013 +0200
@@ -78,7 +78,7 @@
result->error_msg->append(" ");
}
- printf("Error on Java side: %s\n", result->error_msg->c_str());
+ PLUGIN_ERROR("Error on Java side: %s\n", result->error_msg->c_str());
result->error_occurred = true;
result_ready = true;
@@ -965,7 +965,7 @@
java_result = java_request.newArray(java_array_type, length_str);
if (java_result->error_occurred) {
- printf("Unable to create array\n");
+ PLUGIN_ERROR("Unable to create array\n");
id->append("-1");
return;
}
@@ -984,7 +984,7 @@
createJavaObjectFromVariant(instance, value, &value_id);
if (value_id == "-1") {
- printf("Unable to populate array\n");
+ PLUGIN_ERROR("Unable to populate array\n");
id->clear();
id->append("-1");
return;
@@ -1020,7 +1020,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get JSObject class id\n");
+ PLUGIN_ERROR("Unable to get JSObject class id\n");
id->clear();
id->append("-1");
return;
@@ -1036,7 +1036,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get JSObject constructor id\n");
+ PLUGIN_ERROR("Unable to get JSObject constructor id\n");
id->clear();
id->append("-1");
return;
@@ -1060,7 +1060,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to create JSObject\n");
+ PLUGIN_ERROR("Unable to create JSObject\n");
id->clear();
id->append("-1");
return;
@@ -1077,7 +1077,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred) {
- printf("Unable to find classid for %s\n", className.c_str());
+ PLUGIN_ERROR("Unable to find classid for %s\n", className.c_str());
id->append("-1");
return;
}
@@ -1092,7 +1092,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred) {
- printf("Unable to find string constructor for %s\n", className.c_str());
+ PLUGIN_ERROR("Unable to find string constructor for %s\n", className.c_str());
id->append("-1");
return;
}
@@ -1104,7 +1104,7 @@
java_result = java_request.newString(stringArg);
if (java_result->error_occurred) {
- printf("Unable to create requested object\n");
+ PLUGIN_ERROR("Unable to create requested object\n");
id->append("-1");
return;
}
@@ -1117,7 +1117,7 @@
java_result = java_request.newObjectWithConstructor("[System]", jsObjectClassID, jsObjectConstructorID, args);
if (java_result->error_occurred) {
- printf("Unable to create requested object\n");
+ PLUGIN_ERROR("Unable to create requested object\n");
id->append("-1");
return;
}
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc Fri Oct 25 11:07:08 2013 +0200
@@ -249,7 +249,7 @@
if (IcedTeaPluginUtilities::file_exists(custom_jre+"/bin/java")){
return custom_jre+"/bin/java";
} else {
- fprintf(stderr, "Your custom jre (/bin/java check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
+ PLUGIN_ERROR("Your custom jre (/bin/java check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
}
}
return appletviewer_default_executable;
@@ -262,7 +262,7 @@
if (IcedTeaPluginUtilities::file_exists(custom_jre+"/lib/rt.jar")){
return custom_jre+"/lib/rt.jar";
} else {
- fprintf(stderr, "Your custom jre (/lib/rt.jar check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
+ PLUGIN_ERROR("Your custom jre (/lib/rt.jar check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
}
}
return appletviewer_default_rtjar;
@@ -318,7 +318,7 @@
identifier = browser_functions.getstringidentifier("document");
if (!browser_functions.hasproperty(instance, window_ptr, identifier))
{
- printf("%s not found!\n", "document");
+ PLUGIN_ERROR("%s not found!\n", "document");
}
browser_functions.getproperty(instance, window_ptr, identifier, &member_ptr);
@@ -1939,7 +1939,7 @@
np_error = plugin_test_appletviewer ();
if (np_error != NPERR_NO_ERROR)
{
- fprintf(stderr, "Unable to find java executable %s\n", get_plugin_executable().c_str());
+ PLUGIN_ERROR("Unable to find java executable %s\n", get_plugin_executable().c_str());
return np_error;
}
@@ -2150,7 +2150,7 @@
if (java_result->error_occurred)
{
- printf("Error: Unable to fetch applet instance id from Java side.\n");
+ PLUGIN_ERROR("Error: Unable to fetch applet instance id from Java side.\n");
return NULL;
}
@@ -2160,7 +2160,7 @@
if (java_result->error_occurred)
{
- printf("Error: Unable to fetch applet instance id from Java side.\n");
+ PLUGIN_ERROR("Error: Unable to fetch applet instance id from Java side.\n");
return NULL;
}
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc Fri Oct 25 11:07:08 2013 +0200
@@ -440,7 +440,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get member name for setMember. Error occurred: %s\n", java_result->error_msg->c_str());
+ PLUGIN_ERROR("Unable to get member name for setMember. Error occurred: %s\n", java_result->error_msg->c_str());
//goto cleanup;
}
@@ -521,7 +521,7 @@
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());
+ PLUGIN_ERROR("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());
//goto cleanup;
}
@@ -799,7 +799,7 @@
if (!browser_functions.hasproperty(instance, parent_ptr, member_identifier))
{
- printf("%s not found!\n", browser_functions.utf8fromidentifier(member_identifier));
+ PLUGIN_ERROR("%s not found!\n", browser_functions.utf8fromidentifier(member_identifier));
}
((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, member_identifier, member_ptr);
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaPluginUtils.cc
--- a/plugin/icedteanp/IcedTeaPluginUtils.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaPluginUtils.cc Fri Oct 25 11:07:08 2013 +0200
@@ -399,7 +399,7 @@
wchar_t c;
- if (plugin_debug) printf("Converted UTF-16LE string: ");
+ PLUGIN_DEBUG("Converted UTF-16LE string: ");
result_unicode_str->clear();
for (int i = begin; i < begin+length; i+=2)
@@ -413,14 +413,14 @@
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9'))
{
- if (plugin_debug) printf("%c", c);
+ PLUGIN_DEBUG("%c", c);
}
result_unicode_str->push_back(c);
}
// not routing via debug print macros due to wide-string issues
- if (plugin_debug) printf(". Length=%d\n", result_unicode_str->length());
+ PLUGIN_DEBUG(". Length=%d\n", result_unicode_str->length());
}
/*
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaPluginUtils.h
--- a/plugin/icedteanp/IcedTeaPluginUtils.h Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaPluginUtils.h Fri Oct 25 11:07:08 2013 +0200
@@ -82,7 +82,7 @@
{ \
if (((JavaResultData*) result_data)->error_occurred) \
{ \
- printf("Error: Error occurred on Java side: %s.\n", \
+ PLUGIN_ERROR("Error: Error occurred on Java side: %s.\n", \
((JavaResultData*) result_data)->error_msg->c_str()); \
return; \
} \
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaRunnable.cc
--- a/plugin/icedteanp/IcedTeaRunnable.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaRunnable.cc Fri Oct 25 11:07:08 2013 +0200
@@ -38,6 +38,7 @@
#include <stdio.h>
#include "IcedTeaRunnable.h"
+#include "IcedTeaPluginUtils.h"
NS_IMPL_ISUPPORTS1 (IcedTeaRunnable, nsIRunnable)
@@ -69,7 +70,7 @@
NS_IMETHODIMP
IcedTeaRunnableMethod::Run ()
{
- printf("Running method...\n");
+ PLUGIN_DEBUG("Running method...\n");
(*method) (thread_data, result);
return NS_OK;
}
diff -r e1dfddeb801d -r 175dda8f15e5 plugin/icedteanp/IcedTeaScriptablePluginObject.cc
--- a/plugin/icedteanp/IcedTeaScriptablePluginObject.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/plugin/icedteanp/IcedTeaScriptablePluginObject.cc Fri Oct 25 11:07:08 2013 +0200
@@ -49,19 +49,19 @@
void
IcedTeaScriptablePluginObject::deAllocate(NPObject *npobj)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::deAllocate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::deAllocate %p\n", npobj);
}
void
IcedTeaScriptablePluginObject::invalidate(NPObject *npobj)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invalidate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invalidate %p\n", npobj);
}
bool
IcedTeaScriptablePluginObject::hasMethod(NPObject *npobj, NPIdentifier name)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::hasMethod %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::hasMethod %p\n", npobj);
return false;
}
@@ -69,7 +69,7 @@
IcedTeaScriptablePluginObject::invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args,
uint32_t argCount,NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invoke %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invoke %p\n", npobj);
return false;
}
@@ -77,14 +77,14 @@
IcedTeaScriptablePluginObject::invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invokeDefault %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::hasProperty(NPObject *npobj, NPIdentifier name)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::hasProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::hasProperty %p\n", npobj);
return false;
}
@@ -97,7 +97,7 @@
//NPObject* obj = IcedTeaScriptablePluginObject::get_scriptable_java_package_object(getInstanceFromMemberPtr(npobj), name);
//OBJECT_TO_NPVARIANT(obj, *result);
- //printf ("Filling variant %p with object %p\n", result);
+ //PLUGIN_ERROR ("Filling variant %p with object %p\n", result);
}
return false;
@@ -106,21 +106,21 @@
bool
IcedTeaScriptablePluginObject::setProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::setProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::setProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::removeProperty(NPObject *npobj, NPIdentifier name)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::removeProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::enumerate %p\n", npobj);
return false;
}
@@ -128,7 +128,7 @@
IcedTeaScriptablePluginObject::construct(NPObject *npobj, const NPVariant *args, uint32_t argCount,
NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::construct %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::construct %p\n", npobj);
return false;
}
@@ -217,7 +217,7 @@
IcedTeaScriptableJavaPackageObject::invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args,
uint32_t argCount,NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invoke %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invoke %p\n", npobj);
return false;
}
@@ -225,7 +225,7 @@
IcedTeaScriptableJavaPackageObject::invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invokeDefault %p\n", npobj);
return false;
}
@@ -331,14 +331,14 @@
bool
IcedTeaScriptableJavaPackageObject::removeProperty(NPObject *npobj, NPIdentifier name)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::removeProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptableJavaPackageObject::enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::enumerate %p\n", npobj);
return false;
}
@@ -346,7 +346,7 @@
IcedTeaScriptableJavaPackageObject::construct(NPObject *npobj, const NPVariant *args, uint32_t argCount,
NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::construct %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::construct %p\n", npobj);
return false;
}
@@ -566,7 +566,7 @@
if (id == "-1")
{
- printf("Unable to create arguments on Java side\n");
+ PLUGIN_ERROR("Unable to create arguments on Java side\n");
return false;
}
@@ -603,7 +603,7 @@
IcedTeaScriptableJavaObject::invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::invokeDefault %p\n", npobj);
return false;
}
@@ -676,7 +676,7 @@
java_result = java_request.getArrayLength(instance_id);
if (java_result->error_occurred)
{
- printf("ERROR: Couldn't fetch array length\n");
+ PLUGIN_ERROR("ERROR: Couldn't fetch array length\n");
return false;
}
@@ -752,7 +752,7 @@
browser_functions.utf8fromidentifier(name) &&
!strcmp(browser_functions.utf8fromidentifier(name), "length"))
{
- printf("ERROR: Array length is not a modifiable property\n");
+ PLUGIN_ERROR("ERROR: Array length is not a modifiable property\n");
return false;
} else if ( ((IcedTeaScriptableJavaObject*) npobj)->isArray() &&
browser_functions.intfromidentifier(name) >= 0) // else if array and requesting index
@@ -761,7 +761,7 @@
java_result = java_request.getArrayLength(instance_id);
if (java_result->error_occurred)
{
- printf("ERROR: Couldn't fetch array length\n");
+ PLUGIN_ERROR("ERROR: Couldn't fetch array length\n");
return false;
}
@@ -813,14 +813,14 @@
bool
IcedTeaScriptableJavaObject::removeProperty(NPObject *npobj, NPIdentifier name)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::removeProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptableJavaObject::enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::enumerate %p\n", npobj);
return false;
}
diff -r e1dfddeb801d -r 175dda8f15e5 tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc
--- a/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc Tue Oct 22 11:46:27 2013 +0200
+++ b/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc Fri Oct 25 11:07:08 2013 +0200
@@ -34,7 +34,9 @@
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+#include <fstream>
#include <UnitTest++.h>
+#include <stdio.h>
#include <npapi.h>
@@ -47,6 +49,8 @@
extern void trim(std::string& str);
extern bool file_exists(std::string filename);
+void doDebugErrorRun();
+
TEST(NPVariantAsString) {
NPVariant var;
STRINGZ_TO_NPVARIANT("test", var);
@@ -122,3 +126,60 @@
bool b = IcedTeaPluginUtilities::file_exists(f1);
CHECK_EQUAL(b, false);
}
+
+
+void doDebugErrorRun() {
+ FILE* old1 = stdout;
+ FILE* old2 = stderr;
+ char* buf1 = " ";
+ char* buf2 = " ";
+ stdout = fmemopen (buf1, strlen (buf1), "rw");
+ stderr = fmemopen (buf2, strlen (buf2), "rw");
+
More information about the distro-pkg-dev
mailing list