MappedExternalBytes.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 22 Sep 2015 16:28:42 +0100
branchjv
changeset 18759 c1217211909c
parent 17911 a99f15c5efa5
permissions -rw-r--r--
Changed identification strings to contain jv-branch ...to make explicit that this distribution is not the official one used by eXept and therefore that eXept is not to be blamed in case of any problem.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     1
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     2
 COPYRIGHT (c) 2003 by eXept Software AG
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
     3
	      All Rights Reserved
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     4
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     5
 This software is furnished under a license and may be used
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     6
 only in accordance with the terms of that license and with the
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
     9
 other person.  No title to or ownership of the software is
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    10
 hereby transferred.
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    11
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    12
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    13
"{ Package: 'stx:libbasic' }"
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    14
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    15
ExternalBytes subclass:#MappedExternalBytes
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    16
	instanceVariableNames:''
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    17
	classVariableNames:''
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    18
	poolDictionaries:''
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    19
	category:'System-Support'
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    20
!
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    21
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    22
!MappedExternalBytes class methodsFor:'documentation'!
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    23
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    24
copyright
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    25
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    26
 COPYRIGHT (c) 2003 by eXept Software AG
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    27
	      All Rights Reserved
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    28
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    29
 This software is furnished under a license and may be used
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    30
 only in accordance with the terms of that license and with the
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    32
 be provided or otherwise made available to, or used by, any
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    33
 other person.  No title to or ownership of the software is
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    34
 hereby transferred.
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    35
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    36
!
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    37
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    38
documentation
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    39
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    40
    Much like externalBytes - however, instances of MappedExternalBytes are created
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    41
    by mapping virtual memory (i.e. mmap).
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    42
    For now, this class provides only the minimum required protocol to support
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    43
    the VideoForLinux API for video grabbing.
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    44
    (actually, all that is found here is a redefined finalization method, as my instances
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    45
    must be freed by unmapping the underlying memory, as opposed to instances of my superclass,
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    46
    which must be freed w.r.t. malloc).
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    47
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    48
    More will (might be required) be added in the future.
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    49
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    50
    [authors:]
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    51
	Claus Gittinger
7200
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    52
"
f361199b159e comments
Claus Gittinger <cg@exept.de>
parents: 7183
diff changeset
    53
! !
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    54
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    55
!MappedExternalBytes methodsFor:'freeing'!
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    56
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    57
finalize
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    58
    "some MappedExternalBytes object was finalized;
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    59
     free the associated heap memory with it"
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    60
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    61
%{  /* NOCONTEXT */
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    62
#if defined(HAS_MMAP)
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    63
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    64
    char *_mem = (char *)(__INST(address_));
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    65
    OBJ sz = __INST(size);
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    66
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    67
# ifdef SUPERDEBUG
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    68
    console_fprintf(stderr, "MappedExternalBytes finalize\n");
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    69
# endif
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    70
    if (__isSmallInteger(sz)) {
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    71
	if (_mem && (OBJ)_mem != nil) {
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    72
# ifdef SUPERDEBUG
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    73
	    console_fprintf(stderr, "MappedExternalBytes munmap (%x, %d)\n", _mem, __intVal(sz));
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    74
# endif
10409
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    75
	    munmap (_mem, __intVal(sz));
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    76
	}
2976ff00cd0d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7200
diff changeset
    77
	__INST(address_) = __INST(size) = nil;
7183
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    78
    }
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    79
#endif /* HAS_MMAP */
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    80
%}
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    81
! !
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    82
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    83
!MappedExternalBytes class methodsFor:'documentation'!
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    84
ab6e3916efd6 initial checkin
penk
parents:
diff changeset
    85
version
17892
d86c8bd5ece3 Merged with CVS
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17883
diff changeset
    86
    ^ '$Header: /cvs/stx/stx/libbasic/MappedExternalBytes.st,v 1.3 2007/02/22 15:27:19 cg Exp $'
17846
24edc476ac18 Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17845
diff changeset
    87
! !
17892
d86c8bd5ece3 Merged with CVS
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17883
diff changeset
    88
17910
8d796ca8bd1d Merged with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17892
diff changeset
    89
17911
a99f15c5efa5 Updated with /trunk
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17910
diff changeset
    90