473,563 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spidermonkey embedding: How can I set Class Properties?


Greetings,

I am embedding Spidermonkey in a C app. and I'm having trouble setting
class (not instance) property values. For example, I am setting up
the class as follows:
static JSBool constructor(JSC ontext *cx, JSObject *obj, uintN argc, jsval
*argv, jsval *rval)
{
printf("constru ctor argc = %d\n", argc);
*rval = OBJECT_TO_JSVAL (obj);
return JS_TRUE;
}

main()
{
....
static JSClass my_class = {
"MyClass", JSCLASS_HAS_PRI VATE,
JS_PropertyStub ,JS_PropertyStu b,JS_PropertySt ub,JS_PropertyS tub,
JS_EnumerateStu b,JS_ResolveStu b,JS_ConvertStu b,JS_FinalizeSt ub
};
static JSPropertySpec class_props[] = {
{"Prop1", 0, JSPROP_ENUMERAT E},
{0}
};
JSObject *proto;

proto = JS_InitClass(cx , JS_GetGlobalObj ect(cx), 0, &my_class,
constructor, 1, NULL, NULL, class_props, NULL);

The above code correctly (verified through a JavaScript program)
creates a new class with the Prop1 class property.

The following code correctly adds an _instance_ property:

jsval val = INT_TO_JSVAL(42 );
JS_SetProperty( cx, proto, "MyProp2", &val);

After three days I still can't figure out how to set the value of the class
property,
or, for that matter, create a new class property with a particular value. I
am looking to
do something like this:
jsval val = INT_TO_JSVAL(88 );
JS_SetProperty( cx, ???, "Prop1", &val);

Any help would really be appreciated.

Blake McBride
bl***@integra-online.com

Jul 23 '05 #1
3 4857
Blake McBride wrote:
Greetings,

I am embedding Spidermonkey in a C app. and I'm having trouble setting
class (not instance) property values. For example, I am setting up
the class as follows:


I think you're lost - what has this got to do with JavaScript?

See ya! :-)

[...]

--
Rob
Jul 23 '05 #2
RobG wrote:
Blake McBride wrote:
I am embedding Spidermonkey in a C app. and I'm having trouble
setting class (not instance) property values. For example,
I am setting up the class as follows:


I think you're lost - what has this got to do with JavaScript?


Lost maybe, but this sort of has something to do with javascript. But
this group is more about the use of the language then its
implementations . A good group to ask questions about the Spidermonkey
and/or Rhino implementations is - netscape.public .mozilla.jseng -, as
there they may get the attention of the authors of those
implementations .

Richard.
Jul 23 '05 #3
Spidermonkey is Mozilla's JavaScript engine. I'm trying to embed it in a C
application.

"RobG" <rg***@iinet.ne t.auau> wrote in message
news:NP******** **********@news .optus.net.au.. .
Blake McBride wrote:
Greetings,

I am embedding Spidermonkey in a C app. and I'm having trouble setting
class (not instance) property values. For example, I am setting up
the class as follows:


I think you're lost - what has this got to do with JavaScript?

See ya! :-)

[...]

--
Rob

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1986
by: vincent Salaun | last post by:
hi all, here's my problem : I've embedded a python interpreter in our java application (based on the NetBeans palteforrm) using the Jython API : http://www.jython.org/docs/javadoc/index.html So, i've used the PythonInterpreter class to instanciate an interpreter and to integrate it but the its environnement doesn't seem to be the
5
611
by: Victor Fees | last post by:
I have an XML string in a database that I would like to display using XSLT. All of that works like a champ, but I can't figure out how to embed the XML inside an ASPX page. For example, I have an ASPX page with a Header User Control and a Footer User Control. I'd like to put the transformed XML right in the middle. It seems like this is...
1
2221
by: wyl_lyf | last post by:
Hello! I know that spidermonkey can compile and detect if the javascript has any syntax errors. But I'm not sure if it can handle javascript to be ran on the server-side? example: ..response.write("<html>"...) any ideas? thanks!
3
2862
by: Isaac Gouy | last post by:
1) Running a standalone script with SpiderMonkey on Linux js -f scriptfile.js scriptarg How can I get the value of scriptarg from within the JavaScript scriptfile? 2) Running a standalone script with SpiderMonkey on Linux How can I do formated printing to stdout?
6
2987
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player =...
1
5188
by: MissMarie | last post by:
I've been playing around with DIV tables in myspace to better learn how to rewrite my own code for my business site without having to pay someone to design it. I've tried embedding a slideshow into a div table and after I save it I noticed that the slideshow does not show up and the embed code I added is altered. Can anyone help me figure this...
6
2631
by: Chad Crabtree | last post by:
As I'm sure some of you already know there is quite a bit of stir on Reddit about a few Javascript Rails clones. Both of them run on Rhino, which brings me to my question. Why is it that both Trimpath and the google guy choose to run on rhino vs Spidermonky. I'm coming here as it's the only place I can think of to find a cogent answer. ...
17
7854
by: anthony | last post by:
I want to embed some BMP files into an OLE field (called BMP) in an existing table using code. I've created the code that grabs the filename from the image folder, finds the corresponding record in the table and opens that record for editing (RST.Edit). However, I'm having difficulty putting the image into the OLE field. If I borrow from the...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.