]> git.sesse.net Git - vlc/blob - mozilla/control/nporuntime.cpp
all: rewrite of mozilla plugin
[vlc] / mozilla / control / nporuntime.cpp
1 /*****************************************************************************
2  * runtime.cpp: support for NPRuntime API for Netscape Script-able plugins
3  *              FYI: http://www.mozilla.org/projects/plugins/npruntime.html
4  *****************************************************************************
5  * Copyright (C) 2005 the VideoLAN team
6  *
7  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #include "config.h"
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <stdlib.h>
29
30 /* Mozilla stuff */
31 #ifdef HAVE_MOZILLA_CONFIG_H
32 #   include <mozilla-config.h>
33 #endif
34
35 #include "nporuntime.h"
36 #include "vlcplugin.h"
37
38 RuntimeNPObject::InvokeResult RuntimeNPObject::getProperty(int index, NPVariant *result)
39 {
40     /* default behaviour */
41     return INVOKERESULT_GENERIC_ERROR;
42 }
43
44 RuntimeNPObject::InvokeResult RuntimeNPObject::setProperty(int index, const NPVariant *value)
45 {
46     /* default behaviour */
47     return INVOKERESULT_GENERIC_ERROR;
48 }
49
50 RuntimeNPObject::InvokeResult RuntimeNPObject::removeProperty(int index)
51 {
52     /* default behaviour */
53     return INVOKERESULT_GENERIC_ERROR;
54 }
55
56 RuntimeNPObject::InvokeResult RuntimeNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result)
57 {
58     /* default beahviour */
59     return INVOKERESULT_GENERIC_ERROR;
60 }
61
62 RuntimeNPObject::InvokeResult RuntimeNPObject::invokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result)
63 {
64     /* return void */
65     VOID_TO_NPVARIANT(*result);
66     return INVOKERESULT_NO_ERROR;
67 }
68
69 bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result)
70 {
71     switch( result )
72     {
73         case INVOKERESULT_NO_ERROR:
74             return true;
75         case INVOKERESULT_GENERIC_ERROR:
76             break;
77         case INVOKERESULT_NO_SUCH_METHOD:
78             NPN_SetException(this, "No such method or arguments mismatch");
79             break;
80         case INVOKERESULT_INVALID_ARGS:
81             NPN_SetException(this, "Invalid arguments");
82             break;
83         case INVOKERESULT_INVALID_VALUE:
84             NPN_SetException(this, "Invalid value in assignment");
85             break;
86         case INVOKERESULT_OUT_OF_MEMORY:
87             NPN_SetException(this, "Out of memory");
88             break;
89     }
90     return false;
91 }
92