Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
57a63ce7
Commit
57a63ce7
authored
Jan 13, 2010
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mozilla plugin: Replace near-identical code repetitions with calls to helper.
parent
9bec486d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
35 deletions
+18
-35
projects/mozilla/control/npolibvlc.cpp
projects/mozilla/control/npolibvlc.cpp
+8
-35
projects/mozilla/control/nporuntime.h
projects/mozilla/control/nporuntime.h
+10
-0
No files found.
projects/mozilla/control/npolibvlc.cpp
View file @
57a63ce7
...
...
@@ -100,43 +100,23 @@ LibvlcRootNPObject::getProperty(int index, NPVariant &result)
switch
(
index
)
{
case
ID_root_audio
:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
audioObj
)
audioObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcAudioNPObject
>::
getClass
());
InstantObj
<
LibvlcAudioNPObject
>
(
audioObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
audioObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
case
ID_root_input
:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
inputObj
)
inputObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcInputNPObject
>::
getClass
());
InstantObj
<
LibvlcInputNPObject
>
(
inputObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
inputObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
case
ID_root_playlist
:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
playlistObj
)
playlistObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcPlaylistNPObject
>::
getClass
());
InstantObj
<
LibvlcPlaylistNPObject
>
(
playlistObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
playlistObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
case
ID_root_subtitle
:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
subtitleObj
)
subtitleObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcSubtitleNPObject
>::
getClass
());
InstantObj
<
LibvlcSubtitleNPObject
>
(
subtitleObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
subtitleObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
case
ID_root_video
:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
videoObj
)
videoObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcVideoNPObject
>::
getClass
());
InstantObj
<
LibvlcVideoNPObject
>
(
videoObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
videoObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
case
ID_root_VersionInfo
:
...
...
@@ -757,12 +737,7 @@ LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
}
case
ID_playlist_items
:
{
// create child object in lazyman fashion to avoid
// ownership problem with firefox
if
(
!
playlistItemsObj
)
playlistItemsObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcPlaylistItemsNPObject
>::
getClass
());
InstantObj
<
LibvlcPlaylistItemsNPObject
>
(
playlistItemsObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
playlistItemsObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
}
...
...
@@ -1379,10 +1354,8 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
}
case
ID_video_marquee
:
{
if
(
!
marqueeObj
)
marqueeObj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
LibvlcMarqueeNPObject
>::
getClass
());
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
marqueeObj
),
result
);
InstantObj
<
LibvlcMarqueeNPObject
>
(
marqueeObj
);
OBJECT_TO_NPVARIANT
(
NPN_RetainObject
(
marqueeObj
),
result
);
return
INVOKERESULT_NO_ERROR
;
}
}
...
...
projects/mozilla/control/nporuntime.h
View file @
57a63ce7
...
...
@@ -42,6 +42,9 @@ static bool RuntimeNPClassInvokeDefault(NPObject *npobj,
class
RuntimeNPObject
:
public
NPObject
{
public:
// Lazy child object cration helper. Doing this avoids
// ownership problems with firefox.
template
<
class
T
>
void
InstantObj
(
NPObject
*&
obj
);
/*
** utility functions
...
...
@@ -174,6 +177,13 @@ private:
NPIdentifier
*
methodIdentifiers
;
};
template
<
class
T
>
inline
void
RuntimeNPObject
::
InstantObj
(
NPObject
*&
obj
)
{
if
(
!
obj
)
obj
=
NPN_CreateObject
(
_instance
,
RuntimeNPClass
<
T
>::
getClass
());
}
template
<
class
T
>
static
NPObject
*
RuntimeNPClassAllocate
(
NPP
instance
,
NPClass
*
aClass
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment