nporuntime.cpp 3 KB
Newer Older
1 2 3 4
/*****************************************************************************
 * runtime.cpp: support for NPRuntime API for Netscape Script-able plugins
 *              FYI: http://www.mozilla.org/projects/plugins/npruntime.html
 *****************************************************************************
5
 * Copyright (C) 2005-2012 VLC authors and VideoLAN
6 7
 *
 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 9 10
 *          Jean-Baptiste Kempf <jb@videolan.org>
 *          JP Dinger <jpd@videolan.org>
 *          Nicolas Chauvet <kwizart@gmail.com>
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

27 28 29 30
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

Rafaël Carré's avatar
Rafaël Carré committed
31
#include "vlcplugin.h"
32 33 34 35 36 37 38

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "nporuntime.h"

39
RuntimeNPObject::InvokeResult RuntimeNPObject::getProperty(int, npapi::OutVariant&)
40 41 42 43 44
{
    /* default behaviour */
    return INVOKERESULT_GENERIC_ERROR;
}

45
RuntimeNPObject::InvokeResult RuntimeNPObject::setProperty(int, const NPVariant &)
46 47 48 49 50
{
    /* default behaviour */
    return INVOKERESULT_GENERIC_ERROR;
}

51
RuntimeNPObject::InvokeResult RuntimeNPObject::removeProperty(int)
52 53 54 55 56
{
    /* default behaviour */
    return INVOKERESULT_GENERIC_ERROR;
}

57
RuntimeNPObject::InvokeResult RuntimeNPObject::invoke(int, const NPVariant *, uint32_t, npapi::OutVariant& )
58 59 60 61 62
{
    /* default beahviour */
    return INVOKERESULT_GENERIC_ERROR;
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
63
RuntimeNPObject::InvokeResult RuntimeNPObject::invokeDefault(const NPVariant *, uint32_t, npapi::OutVariant&)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
{
    /* return void */
    return INVOKERESULT_NO_ERROR;
}

bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result)
{
    switch( result )
    {
        case INVOKERESULT_NO_ERROR:
            return true;
        case INVOKERESULT_GENERIC_ERROR:
            break;
        case INVOKERESULT_NO_SUCH_METHOD:
            NPN_SetException(this, "No such method or arguments mismatch");
            break;
        case INVOKERESULT_INVALID_ARGS:
            NPN_SetException(this, "Invalid arguments");
            break;
        case INVOKERESULT_INVALID_VALUE:
            NPN_SetException(this, "Invalid value in assignment");
            break;
        case INVOKERESULT_OUT_OF_MEMORY:
            NPN_SetException(this, "Out of memory");
            break;
    }
    return false;
}