473,700 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Spidermonkey embedding: How can I set Class Properties?


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;

static JSClass my_class = {
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},
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
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

Jul 23 '05 #1
3 4868
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?

See ya! :-)


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 .

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

"RobG" <rg***@iinet.ne t.auau> wrote in message
news:NP******** **********@news .optus.net.au.. .
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?

See ya! :-)



Jul 23 '05 #4

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

Similar topics

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
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,...
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!
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?
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)
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},...
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...
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 =...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
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...
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...
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: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.