473,654 Members | 3,108 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 4862
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
1990
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 something that should be doable, but I can't quite figure it out. Is anyone out there doing this,...
1
2224
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
2869
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
2996
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 = Player() game.loadPlayer(player) player.moveTo(location)
1
5191
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 out? The embed code that I'm talking about is three quarters down the code page under {PHOTOS},...
6
2633
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. My guess since I have thought about it is to leverage Java libraries. Would that be the only...
17
7862
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 code that appears in http://support.microsoft.com/default.aspx/kb/158941, then at RST!BMP.Class =...
0
8290
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
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.