Subj : Help needed (creating and returning a C++ object through a JS function!!! ) To : netscape.public.mozilla.jseng From : sivaramd@esntechnologies.co.in (sivaramd) Date : Wed Jul 16 2003 03:35 am 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 members id(int) name(string) JSBool JSCEmployee::ConstructObject(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { //create the object JSObject* jobj = JS_NewObject(cx,&Employee_class,NULL,NULL); *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(z.name);// should pring the value of name in the object. I am not getting the correct result. .