Re: The future of binary embedding

2012-03-01 Thread Bobby Holley

 Does anyone have an idea about how much work it would take to maintain
 python-xpcom?


Lots.

I don't know much about pyxpcom, but I imagine it being pretty analogous to
XPConnect (our JS-XPCOM bridge). XPConnect is probably the most notorious
module in Gecko - it's complicated, scary, and easy to get wrong. We
already sink a ton of engineering resources into it, and wouldn't if it
weren't so fundamental to our entire architecture.

More importantly, for a number of reasons the DOM is becoming more
intimately tied to JS: we're removing the abstraction layer that
sorta-kinda makes the DOM language-agnostic (it's too slow), and we're
writing new custom DOM bindings.

So if it isn't true already, pyxpcom won't be able to script the DOM
anymore, which makes it significantly less useful. Reversing this course
(and maintaining a separate set of python DOM bindings) is pretty much out
of the question: it incurs a performance penalty for the Web that we don't
want to pay, and it would take months and months of engineering by Boris,
Kyle, Peter, Blake, Ben, Johnny, Olli, and myself to make happen.

In a nutshell, script bindings aren't easy - this stuff is some of the most
complicated and delicate code in Gecko. So the issue isn't that Benjamin is
too lazy or proud to keep the relevant embedding APIs. The issue is that
there is a very small group of people in the world who have the knowledge
to build and maintain something like this, and they have other priorities.

bholley
___
dev-embedding mailing list
dev-embedding@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-embedding


Re: Show stopper issue for our GECKO 1.9.2 embedding project and we have expensive business impact

2011-12-29 Thread Bobby Holley
lord_nemesis, the code is hard to read in email form. Would you mind
putting it on http://pastebin.mozilla.org/ and sending out the link?

Cheers,
-bholley

On Thu, Dec 22, 2011 at 8:39 AM, Benjamin Smedberg benja...@smedbergs.uswrote:

 On 12/22/2011 10:45 AM, lord_nemesis wrote:

 Hello Benjamin (I am putting the name directly as I got help through
 him and now having issue in that area),
This issue is putting us in most discomfort situation in business
 line... Please take time and help us out from here

 Problem:
   We have a page that that is throwing a JS exception when running in
 our embedded gecko browser, but working fine in firefox. The page a
 javascript function which checks the value of a global though an if
 condition. the same is set an initial value in thehead  section of
 the page. some thing like this

 I really have no clue about the correct way to do what you're doing.
 Perhaps bholley.

 --BDS


 test = ;

 myfunc()
 {
  if (test  ...) {
  }
 }

 as you can see, test is not a var type. Its a global property. In our
 embedded gecko application, we are getting a ReferenceError: test is
 undefined exception when trying to check the value of test. This is
 however not happening in Firefox browser  built from the same
 codebase.

 After some debugging, we arrived at the conclusion that our own code
 to call  javascript functions on the page is causing some issue.

 our code for the same looks some thing like this. This is used to
 invoke custom js functions in some pages, but not on on the particular
 one that we are having problem with. can you please see if there is
 anything wrong with this code and also help us with solving the
 problem.



 CallJavaScript(const CString  strJSFnName, const CStringArray
 paramArray, CString  strRetVal)
 {
  try {
nsresult resultVal = NS_OK;
nsCOMPtrnsIDOMDocument  domDoc;

if(nsnull == m_webNavigation ) //null check to avoid crash
   show blank page incase of Webnavigation handle null
{
 return false;
}

// Get the Document DOM
resultVal = m_webNavigation-

 GetDocument(getter_AddRefs(**domDoc));

if (NS_FAILED(resultVal))
{
 return false;
}

// Get Document from DOM.
nsCOMPtrnsIDocument  doc = do_QueryInterface(domDoc,
 resultVal);
if (NS_FAILED(resultVal))
{
 return false;
}

// Get the Script Global Object from Document

nsCOMPtr**nsIScriptGlobalObject  scriptGlobalObj(doc-

 GetScriptGlobalObject());

if (scriptGlobalObj == nsnull) {
 return false;
}

// Get the Script Context
nsCOMPtrnsIScriptContext  scriptContext(scriptGlobalObj-

 GetContext());

if (scriptContext == nsnull) {
 return false;
}

// Get the JSContext.
JSContext *pJSContext =
 reinterpret_castJSContext*(**scriptContext-**GetNativeContext());
JSObject *pJSObject = scriptGlobalObj-**GetGlobalJSObject();

{
 AutoSetupJSContext setupJSContext(pJSContext);

 jsval jsReturnVal = 0;

 // Build the Input argument list
 int argCount =paramArray.GetSize();
 jsval *pJSInputArgs = new jsval[argCount];

 for (int argIndex = 0; argIndex  argCount; +
 +argIndex) {
  CString argStr = paramArray.GetAt(argIndex);
  jschar *pJSArgChars = (jschar *)
 (argStr.GetBuffer(argStr.**GetLength()));
  JSString *jsArgStr =
 JS_NewUCStringCopyZ(**pJSContext, pJSArgChars);
  argStr.ReleaseBuffer();
  pJSInputArgs[argIndex] =
 STRING_TO_JSVAL(jsArgStr);
 }

 int jsFuncNameLen = WideCharToMultiByte(CP_ACP, 0,
 (LPCWSTR)(LPCTSTR)strJSFnName, -1, 0, 0, NULL, NULL);
 char* pJSFuncName = new char[jsFuncNameLen + 1];
 WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)
 (LPCTSTR)strJSFnName, -1, pJSFuncName, jsFuncNameLen, NULL, NULL);

 JSBool isJSCallSuccess =
 JS_CallFunctionName(**pJSContext, pJSObject, pJSFuncName, argCount,
 pJSInputArgs,jsReturnVal);


 class AutoSetupJSContext {
 public:
  AutoSetupJSContext(JSContext *pJSContext)
 : m_JSContextStack(), m_pJSContext(pJSContext)
  {
nsresult resultVal = NS_OK;

// Get the JSContext Stack.
m_JSContextStack = 
 do_GetService(@mozilla.org/**js/xpc/http://mozilla.org/js/xpc/
 ContextStack;1,resultVal);
ASSERT(m_JSContextStack != nsnull);

// Push the JSContext to JSContext Stack.
resultVal = m_JSContextStack-Push(m_**pJSContext);
ASSERT(resultVal == NS_OK);

// Set an