[Freeswitch-svn] [commit] r3472 - in freeswitch/trunk/src/mod/languages: mod_spidermonkey mod_spidermonkey_core_db mod_spidermonkey_teletone

Freeswitch SVN anthm at freeswitch.org
Tue Nov 28 15:52:04 EST 2006


Author: anthm
Date: Tue Nov 28 15:52:04 2006
New Revision: 3472

Modified:
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c

Log:
fix a few js issues

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Tue Nov 28 15:52:04 2006
@@ -409,7 +409,7 @@
 }
 
 
-static switch_status_t sm_load_file(char *filename, sm_loadable_module_t **new_module)
+static switch_status_t sm_load_file(char *filename)
 {
 	sm_loadable_module_t *module = NULL;
 	apr_dso_handle_t *dso = NULL;
@@ -424,7 +424,6 @@
 
 	assert(filename != NULL);
 
-	*new_module = NULL;
 	status = apr_dso_load(&dso, filename, module_manager.pool);
 
 	while (loading) {
@@ -447,7 +446,7 @@
 			break;
 		}
 
-		if ((module = switch_core_permanent_alloc(sizeof(sm_loadable_module_t))) == 0) {
+		if (!(module = (sm_loadable_module_t *) switch_core_permanent_alloc(sizeof(*module)))) {
 			err = "Could not allocate memory\n";
 			break;
 		}
@@ -465,11 +464,10 @@
 	module->module_interface = module_interface;
 	
 	module->lib = dso;
-	*new_module = module;
 
 	switch_core_hash_insert(module_manager.mod_hash, (char *) module->filename, (void *) module);
 	
-	for (mp = module_interface; mp; mp = mp->next) {
+	for (mp = module->module_interface; mp; mp = mp->next) {
 		switch_core_hash_insert(module_manager.load_hash, (char *)mp->name, (void *) mp);
 	}
 	
@@ -484,7 +482,6 @@
 	switch_size_t len = 0;
 	char *path;
 	char *file;
-	sm_loadable_module_t *new_module = NULL;
 
 #ifdef WIN32
 	const char *ext = ".dll";
@@ -517,7 +514,7 @@
 		}
 	}
 	
-	return sm_load_file(path, &new_module);
+	return sm_load_file(path);
 }
 
 static switch_status_t load_modules(void)
@@ -961,6 +958,13 @@
 		}
 	}
 
+    if (argc > 4) {
+        int32 samps;
+        uint32_t pos = 0;
+        JS_ValueToInt32(cx, argv[4], &samps);
+        switch_core_file_seek(&fh, &pos, samps, SEEK_CUR);
+    }
+
 	memset(&fh, 0, sizeof(fh));
 	cb_state.extra = &fh;
 	cb_state.ret = BOOLEAN_TO_JSVAL( JS_FALSE );
@@ -1214,13 +1218,13 @@
 		char *app_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		char *app_arg = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
 		struct js_session *jss = JS_GetPrivate(cx, obj);
-		jsrefcount saveDepth;
+		//jsrefcount saveDepth;
 
 		if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
 			if (application_interface->application_function) {
-				saveDepth = JS_SuspendRequest(cx);
+				//saveDepth = JS_SuspendRequest(cx);
 				application_interface->application_function(jss->session, app_arg);
-				JS_ResumeRequest(cx, saveDepth);
+				//JS_ResumeRequest(cx, saveDepth);
 				retval = JS_TRUE;
 			}
 		} 

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c	Tue Nov 28 15:52:04 2006
@@ -31,7 +31,7 @@
  */
 #include "mod_spidermonkey.h"
 
-static const char modname[] = "DB";
+static const char modname[] = "CoreDB";
 
 struct db_obj {
     switch_memory_pool_t *pool;
@@ -148,10 +148,9 @@
 {
 	struct db_obj *dbo = JS_GetPrivate(cx, obj);
 	*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
-	
-	if (dbo->stmt) {
-		int running = 1;
 
+    if (dbo->stmt) {
+		int running = 1;
 		while (running < 5000) {
 			int result = switch_core_db_step(dbo->stmt);
 			if (result == SQLITE_ROW) {
@@ -210,10 +209,9 @@
 		dbo->stmt = NULL;
 	}
 
-	if (argc > 0) {		
+	if (argc > 0) {
 		char *sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
-
-		if(switch_core_db_prepare(dbo->db, sql, 0, &dbo->stmt, 0)) {
+		if(switch_core_db_prepare(dbo->db, sql, -1, &dbo->stmt, 0)) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s\n", switch_core_db_errmsg(dbo->db));
 		} else {
 			*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
@@ -266,18 +264,14 @@
 }
 
 JSClass db_class = {
-	"DB", JSCLASS_HAS_PRIVATE, 
+	modname, JSCLASS_HAS_PRIVATE, 
 	JS_PropertyStub,  JS_PropertyStub,	db_getProperty,  JS_PropertyStub, 
 	JS_EnumerateStub, JS_ResolveStub,	JS_ConvertStub,	  db_destroy, NULL, NULL, NULL,
 	db_construct
 };
 
 
-
-
-
-
-switch_status_t spidermonkey_load(JSContext *cx, JSObject *obj)
+switch_status_t db_load(JSContext *cx, JSObject *obj)
 {
 
 	JS_InitClass(cx,
@@ -291,14 +285,13 @@
 				 db_props,
 				 db_methods
 				 );
-
 	return SWITCH_STATUS_SUCCESS;
 }
 
 
 const sm_module_interface_t DB_module_interface = {
 	/*.name = */ modname,
-	/*.spidermonkey_load*/ spidermonkey_load,
+	/*.spidermonkey_load*/ db_load,
 	/*.next*/ NULL
 };
 

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c	Tue Nov 28 15:52:04 2006
@@ -357,7 +357,7 @@
 };
 
 
-switch_status_t spidermonkey_load(JSContext *cx, JSObject *obj)
+switch_status_t teletone_load(JSContext *cx, JSObject *obj)
 {
 	JS_InitClass(cx,
 				 obj,
@@ -376,7 +376,7 @@
 
 const sm_module_interface_t teletone_module_interface = {
 	/*.name = */ modname,
-	/*.spidermonkey_load*/ spidermonkey_load,
+	/*.spidermonkey_load*/ teletone_load,
 	/*.next*/ NULL
 };
 



More information about the Freeswitch-svn mailing list