Help needed (creating and returning a C++ object through a JS function!!! )

I am writing javascript code to return an object from C++ code.

Let us assume I have a class CEmployee with two members id & name.

I want to create an object of it and retrun it to Java Script code
through a function . I have written the following code. I am not
getting the correct result.

(I have done the js_init class , writing wrapper function ,
registration of the class with engine and other stuff in my code.)


Can you please help me........


JSCEmployee is a wrapper class  and CEmployee() is a C++ class with
id(int) name(string)


JSCEmployee::ConstructObject(JSContext *cx, JSObject *obj, uintN argc,
jsval *argv, jsval *rval)

            //create the object

            JSObject* jobj    =

            *rval = OBJECT_TO_JSVAL(jobj );  

            return JS_TRUE;            



 I have written the following JS code. Since I have initialized the
CEmployee object with 99 in the constructor the following code should
print 99.But it is giving the value as undefined.

My aim is to create an object of CEmployee in the wrapper class
function constructobject() and return it through JS.

JSCode :

  Var c = new CEmployee();// new object of CEmployee created

  Var z = c.ConstructObject();// should return the CEmployee object
created in   this method.

Print(;// should pring the value of name in the object.

I am not getting the correct result.
7/16/2003 9:35:31 AM
netscape.mozilla.jseng 1530 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 43


Similar Artilces:

need help in creating function
I have a DropDownList populated with Book Titles from a simple Access DB. I need to obtain the other attributes of the Book DB Table and send them to a little shopping cart. The selected book title is "ddlBooks.SelectedItem.Text". I can't quite figure out how to query my DB using "ddlBooks.SelectedItem.Text" to obtain the cost, author, etc. so I can send these values to my Data Table Shopping Cart. I have a BookID in the DB, I assume I need to use that as well. I'm trying to write a function called GetBookAttributes() to handle this situation. Any advice or...

create js objects in C
I would like to create new JavaScript objects from C. I have a test script that looks like this function JSTestObject() { this.Name = "ABC"; } JSTestObject.prototype.SomeProperty = "TestObject"; JSTestObject.prototype.OnTest = function(arg1) { return 6; } RegisterObject(JSTestObject); The RegisterObject() function tells my C code about this object. I then want to do in C the equivalent of var foo = new JSTestObject(); I can get a new object but I can not call any of the methods in the prototype. Here is what I am doing now. void Regist...

Create an instance of a JS object from C
Hi! I'm pretty new to spidermonkey and I'm amazed fast I could integrate it into my app. I guess I'm just blind, but I can't find a function to create an instance of a Class within the context. -- Code -- JSClass dummyClass = { "Dummy", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, dummyGetFunc, dummySetFunc, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, dummyDestructor }; -- /Code -- Assume all these functions exists, and that the class was registered via JS_InitClass(). Now I want to populate my context with ...

Need help with creating Tab objects
Hello, I'm trying to create a window which has tabs. I'm supposed to use PFC, but the documentation isn't very clear on how to create a tab control and tab pages. What I did was inherited a sheet window, then inherited from u_tab. I then right mouse click on the tab control to insert tabpage, but the option to insert tabpage isn't enabled. Where did I go wrong? Thanks for the help. Trang. In article <01beb6a2$6bdf3520$>, says... > Hello, > > I'm trying to create a window wh...

Creating JS functions from C++ at runtime
Hi, I'm writing a XUL application that, as a part of it's job, reads SVG object definitions from an XML file, creates them in C++ code and appends to an SVG element within a XUL document. The object definitions also contain event handlers written in JavaScript. I want to construct the function definitions for the event handlers and make them available to the XUL application. This is what I'm stumbled over. It there a way to create a new JS function from C++? Thanks, -- Vitaly ...

need help with creating a C++ DLL...
I am attempting, not so successfully, to create a DLL using MS Visual C++ to be called from a PB 6.5 app. I have no problem creating the DLL, I'm just using the simple win32 DLL project wiz that MS VC++ has. It creates a DLL with one exported function that returns an integer. No matter what I try I still get an error stating that there is an error calling the external function (I wish it would be a bit more informative). It's finding the DLL fine, just can't get it to call the function. The local external function is defined in a window : FUNCTION integer fnBp_calc() LIBR...

Eval()+Object+Function()=Need Some Help!
Hi, I would really appreciate some help, since i'm about to go bizzerk. I need to evaluate some code within a scope of a document, i.e. from a chrome popup. My first idea was to create a method: window.opener.content.document.test=function(str) {alert(document.location)} But it fails (alerts chrome xul location), so after couple of hours i discovered that eval() can take a second parameter: And that it's no longer possible to do object.eval() which is a shame. So.... Work...

Need Help--implementing functions in C#???
Hi y'all I think i have some problem in here perhaps you guys can help.I have this code: 1 public void AddQstrWhere(ref string TmpStr,string Parameter) 2 { 3 if(TmpStr=="") 4 { 5 TmpStr +="WHERE"+Parameter; 6 } 7 else 8 { 9 TmpStr +="AND"+Parameter; 10 } 11 } 12 13 14 public string querySlsPerson; 15 //public string queryLastSls; 16 public ArrayList CLSGetSalesman(string szSalesmanID) 17 { 18 19 20 // TODO: Add CLSReportManager.CLSGetSales...

object create/destroy and function return values
Hi, I'm trying to figure out how PowerBuilder handles objects passed as return values. I have a main function, called by a remote object (Web PB). I cannot create the transaction in the user object constructor because the user name and password are variable and are passed in. I declare a transaction in the main function, but do not create it. Then I call a function that creates the transaction and returns it. Q: Is this by reference? Am I leaving behind a copy in the f_createtrans function? Then I connect in the main function. If there is an error in connecting or any other vi...

Need help creating an extension for Mozilla Mail
Hello all, I need some help from some Mozilla Mail developers. I have asked around in #mozilla on irc and I've received some general answers to my problem. I have been assigned a project at work to create an extension for Mozilla Mail to replace an existing Java based plug-in for Netscape 4.7. The extension basically needs to modify what happens when the user executes the "Send Mail" function ie when the "Send" button is pressed on the Message Composition window. When the user clicks the Send button, the extension should be called causing a UI to app...

need help with creating xpi for Mozilla Firebird
Hi, I tried to build a xpi for Firebird using the document written by Michele Dal Corso , but I must've done something wrong. It would only change the bookmarks but not the menu's. Can someone give me a hint, what went wrong? or, if the server doesn't supports xpi: Thanks in advance Abdulkadir Topal (German Mozilla Firebird localization) Hello, Abdulkadir. In your language pack, local...

Issue Creating Function Under Object (C API)
Hi Folks, 1-) I want to create a function, let's say helloWorld under an object Test using SpiderMonkey C Api, so in the script I can run something like this: .... JS_EvaluateScript(cx, TestObj, "Test.helloWorld(\"hello world!\")" ,31, "test.js", 0, &v); .... 2-) I can create the function and execute it, but not using the object "Test", this only works if I call the helloWorld function alone, with no parent object, like this: .... JS_EvaluateScript(cx, TestObj, "helloWorld(\"hello world!\")&qu...

Inherited Object, Created Object, Shared Object, Function call
I am developing a web site and I will have different objects for different divisions. There is a core group of functionality all objects will need, as expressed in u_html_form, etc. What I am is wondering is the best way (quickest and least memory used) to create the core functionality. Should each divisions object create the core functionality object, should the division objects be inherited from the core functionality object, should they get a shared object with the core functionality, or should I just use function calls. I am leaning towards inheritance, but I am not sure. An...

Need help with if statement for no records returned VS2005 C#
I have opened the same thread in the C section. But I think it's better to post my problem here because I am programming in VS 2005, so it's .NET. Ok so here's my problem: I have made a search funtion for the database which all works but now I want an error to show in a label if the database doesn't return any records. The query that I wrote works too well since it's always showing the error even if records get returned. Below I will post the code of the design and the HTML source code. BTW it's VS 2005, with C# and it's a website so ASP.NET. I hope all the information is posted. Desig...

Web resources about - Help needed (creating and returning a C++ object through a JS function!!! ) - netscape.mozilla.jseng

Talk:Trigonometric functions - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Mathematics , a collaborative effort to improve the coverage of Mathematics on Wikipedia. If ...

TV binging, exercise skipping linked to poor cognitive function
Bad habits early in life may affect brain power later, researchers suggest.

iPhone best tricks and functions - Business Insider
Your iPhone can do a lot more than you think.

Review: HP Spectre 360 A Perfect Mix Of Style, Form, Function
HP Inc. delivers a brushed-aluminum laptop with a new 6th Generation Intel i7 processor, making it one of the best-looking, best-priced and best-performing ...

HPE Offers Catalog of Virtual Network Functions for Telcos
The vendor's OpenNFV Solution Portal gives carriers a single place to find a range of VNFs that are pre-tested to run on their networks.

Why Global Corporations Need To Redesign Their Strategic Planning Function
Corporate strategy teams play an important role in guiding business leaders to make smarter, better and more informed decisions, especially in ...

Sponsored post: Garmin’s fenix 3 Pairs Form and Function with GPS Watch
... timepiece to polish off a professional look, or strap on a rugged stopwatch for our workouts. But when it comes to everyday use, the functional ...

Code Craft – Embedding C++: Timing Virtual Functions
... compiler just like the standard language types. A subtype inherits the characteristics of its parent type and can use, or not, the member functions ...

Madras HC asks police to allow Tipu’s birth anniversary function
... Station on a petition filed by Ismail, General Secretary of Thamizhaga Makkal Jananayaga Katchi, seeking grant of permission to hold the function. ...

Colorado governor: This Planned Parenthood shooting may be a function of inflammatory rhetoric from bloggers ...
Via Grabien , skip to 4:45 of the clip below for the key bit. I naively thought we were (mostly) done with “climate of hate” stupidity after ...

Resources last updated: 12/11/2015 12:25:23 AM