"Fossies" - the Fresh Open Source Software Archive

Member "google-gadgets-for-linux-0.11.2/extensions/webkit_script_runtime/tests/dbus_object_test_shell.cc" (11 May 2009, 1922 Bytes) of package /linux/misc/old/google-gadgets-for-linux-0.11.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2   Copyright 2008 Google Inc.
    3 
    4   Licensed under the Apache License, Version 2.0 (the "License");
    5   you may not use this file except in compliance with the License.
    6   You may obtain a copy of the License at
    7 
    8        http://www.apache.org/licenses/LICENSE-2.0
    9 
   10   Unless required by applicable law or agreed to in writing, software
   11   distributed under the License is distributed on an "AS IS" BASIS,
   12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13   See the License for the specific language governing permissions and
   14   limitations under the License.
   15 */
   16 
   17 #include <ggadget/logger.h>
   18 #include <ggadget/scriptable_helper.h>
   19 #include <ggadget/scriptable_interface.h>
   20 #include <ggadget/extension_manager.h>
   21 #include <ggadget/script_context_interface.h>
   22 #include <ggadget/tests/native_main_loop.h>
   23 #include <ggadget/tests/init_extensions.h>
   24 #include "../js_script_context.h"
   25 
   26 using namespace ggadget;
   27 
   28 class GlobalObject : public ScriptableHelperNativeOwnedDefault {
   29  public:
   30   DEFINE_CLASS_ID(0x7067c76cc0d84d11, ScriptableInterface);
   31   GlobalObject() {
   32   }
   33   virtual bool IsStrict() const { return false; }
   34 };
   35 
   36 static GlobalObject *global;
   37 static NativeMainLoop main_loop;
   38 
   39 // Called by the initialization code in js_shell.cc.
   40 // Used to compile a standalone js_shell.
   41 bool InitCustomObjects(ScriptContextInterface *context) {
   42   SetGlobalMainLoop(&main_loop);
   43   global = new GlobalObject();
   44   context->SetGlobalObject(global);
   45 
   46   static const char *kExtensions[] = {
   47     "dbus_script_class/dbus-script-class",
   48     "libxml2_xml_parser/libxml2-xml-parser"
   49   };
   50 
   51   int argc = 0;
   52   const char **argv = NULL;
   53   INIT_EXTENSIONS(argc, argv, kExtensions);
   54 
   55   ScriptExtensionRegister ext_register(context, NULL);
   56   ExtensionManager::GetGlobalExtensionManager()->RegisterLoadedExtensions(
   57       &ext_register);
   58 
   59   return true;
   60 }
   61 
   62 void DestroyCustomObjects(ScriptContextInterface *context) {
   63   delete global;
   64 }