ProtoObject.st
author Stefan Vogel <sv@exept.de>
Wed, 30 Nov 2016 16:58:18 +0100
changeset 21079 d83ede99b688
parent 21078 c57b7b3dc73a
child 21084 5a98e59ee251
permissions -rw-r--r--
#BUGFIX by stefan class: ProtoObject added: #isBridgeProxy changed: #shallowCopyOf:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     1
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     3
              All Rights Reserved
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     4
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     5
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     6
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
     9
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    10
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    11
"
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
18351
dc6c93a03b6d class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 16158
diff changeset
    14
"{ NameSpace: Smalltalk }"
dc6c93a03b6d class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 16158
diff changeset
    15
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
nil subclass:#ProtoObject
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
6912
d2e78827a065 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6911
diff changeset
    20
	category:'Kernel-Objects'
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!ProtoObject class methodsFor:'documentation'!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    25
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    26
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    27
 COPYRIGHT (c) 2004 by eXept Software AG
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    28
              All Rights Reserved
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    29
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    30
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    31
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    33
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    34
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    35
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    36
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    37
!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8500
diff changeset
    38
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    a minimum object without much protocol;
7659
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
    42
    Provides the minimum required to prevent inspectors from crashing,
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
    43
    and debuggers from blocking.
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
    44
    (i.e. instead of inheriting from nil, better inherit from this).
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
    45
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    Named after a similar class found in Dolphin-Smalltalk.
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    [author:]
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        Claus Gittinger (not much authoring, though)
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
! !
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
21076
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    53
!ProtoObject class methodsFor:'helpers'!
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    54
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    55
shallowCopyOf:anObject
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    56
    "return a copy of anObject with shared subobjects (a shallow copy)
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    57
     i.e. the copy shares referenced instvars with its original."
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    58
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    59
%{  /* NOCONTEXT */
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    60
    int ninsts, spc, sz;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    61
    OBJ theCopy;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    62
    OBJ cls = __qClass(anObject);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    63
    int flags = __intVal(__ClassInstPtr(cls)->c_flags);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    64
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    65
    /*
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    66
     * bail out for special objects ..
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    67
     */
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    68
    if (((flags & ~ARRAYMASK) == 0)
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    69
     && ((flags & ARRAYMASK) != WKPOINTERARRAY)) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    70
        sz = __qSize(anObject);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    71
        __PROTECT__(anObject);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    72
        __qNew(theCopy, sz);    /* OBJECT ALLOCATION */
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    73
        __UNPROTECT__(anObject);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    74
        if (theCopy) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    75
            cls = __qClass(anObject);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    76
            spc = __qSpace(theCopy);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    77
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    78
            theCopy->o_class = cls; __STORE_SPC(theCopy, cls, spc);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    79
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    80
            sz = sz - OHDR_SIZE;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    81
            if (sz) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    82
                char *src, *dst;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    83
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    84
                src = (char *)(__InstPtr(anObject)->i_instvars);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    85
                dst = (char *)(__InstPtr(theCopy)->i_instvars);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    86
#ifdef bcopy4
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    87
                {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    88
                    /* care for odd-number of longs */
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    89
                    int nW = sz >> 2;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    90
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    91
                    if (sz & 3) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    92
                        nW++;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    93
                    }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    94
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    95
                    bcopy4(src, dst, nW);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    96
                }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    97
#else
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    98
                bcopy(src, dst, sz);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
    99
#endif
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   100
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   101
                flags &= ARRAYMASK;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   102
                if (flags == POINTERARRAY) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   103
                    ninsts = __BYTES2OBJS__(sz);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   104
                } else {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   105
                    ninsts = __intVal(__ClassInstPtr(cls)->c_ninstvars);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   106
                }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   107
                if (ninsts) {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   108
                    do {
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   109
                        OBJ el;
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   110
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   111
                        el = __InstPtr(theCopy)->i_instvars[ninsts-1];
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   112
                        __STORE_SPC(theCopy, el, spc);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   113
                    } while (--ninsts);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   114
                }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   115
            }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   116
            RETURN (theCopy);
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   117
        }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   118
    }
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   119
%}.
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   120
    "/ fallBack for special objects & memoryAllocation failure case
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   121
21079
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   122
    ^ self error:'ProtoObject>>#shallowCopyOf: failed'
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   123
! !
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   124
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   125
!ProtoObject methodsFor:'StepInterruptContext'!
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   126
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   127
inspect
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   128
    "this method is required to allow inspection of the object"
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   129
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   130
    ^ (Object compiledMethodAt:#inspect)
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   131
        valueWithReceiver:self
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   132
        arguments:nil
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   133
        selector:#inspect
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   134
!
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   135
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   136
instVarAt:index
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   137
    "this method is required to allow inspection of the object"
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   138
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   139
    ^ (Object compiledMethodAt:#instVarAt:)
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   140
        valueWithReceiver:self
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   141
        arguments:{index}
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   142
        selector:#instVarAt:
21076
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   143
! !
67699e10cae2 #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 21075
diff changeset
   144
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
!ProtoObject methodsFor:'error handling'!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
doesNotUnderstand:aMessage
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    "this message is sent by the runtime system (VM) when
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
     a message is not understood by some object (i.e. there
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
     is no method for that selector). The original message has
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
     been packed into aMessage (i.e. the receiver, selector and
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
     any arguments) and the original receiver is then sent the
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     #doesNotUnderstand: message.
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
     Here, we raise another signal which usually enters the debugger.
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
     You can of course redefine #doesNotUnderstand: in your classes
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
     to implement message delegation, 
8500
10d47cede03c Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents: 7661
diff changeset
   157
     or handle the MessageNotUnderstood exception gracefully."
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    <context: #return>
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
8500
10d47cede03c Speed up MessageNotUnderstood exception sending by layz computation
Stefan Vogel <sv@exept.de>
parents: 7661
diff changeset
   161
    ^ MessageNotUnderstood raiseRequestWith:aMessage
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
! !
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
!ProtoObject methodsFor:'queries'!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
class
19678
85ad5275e07c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18439
diff changeset
   167
    "return the receiver's class"
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
%{  /* NOCONTEXT */
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    RETURN ( __Class(self) );
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
%}
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
"
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
*** WARNING
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
***
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
*** this method has been automatically created,
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
*** since all nil-subclasses should respond to some minimum required
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
*** protocol.
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
***
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
*** Inspection and/or debugging of instances may not be possible,
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
*** if you remove/change this method. 
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
"
19678
85ad5275e07c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18439
diff changeset
   184
85ad5275e07c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18439
diff changeset
   185
    "Modified (comment): / 30-04-2016 / 15:51:12 / cg"
10589
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   186
!
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   187
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   188
identityHash
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   189
    "return an Integer useful as a hash key for the receiver.
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   190
     This hash should return same values for the same object (i.e. use
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   191
     this to hash on identity of objects).
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   192
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   193
     We cannot use the Objects address (as other smalltalks do) since
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   194
     no object-table exists and the hashval must not change when objects
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   195
     are moved by the collector. Therefore we assign each object a unique
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   196
     Id in the object header itself as its hashed upon.
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   197
     (luckily we have 11 bits spare to do this - unluckily its only 11 bits).
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   198
     Time will show, if 11 bits are enough; if not, another entry in the
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   199
     object header will be needed, adding 4 bytes to every object. Alternatively,
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   200
     hashed-upon objects could add an instvar containing the hash value."
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   201
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   202
%{  /* NOCONTEXT */
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   203
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   204
    REGISTER unsigned INT hash;
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   205
    static unsigned nextHash = 0;
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   206
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   207
    if (__isNonNilObject(self)) {
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   208
        hash = __GET_HASH(self);
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   209
        if (hash == 0) {
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   210
            /* has no hash yet */
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   211
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   212
            if (++nextHash > __MAX_HASH__) {
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   213
                nextHash = 1;
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   214
            }
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   215
            hash = nextHash;
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   216
            __SET_HASH(self, hash);
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   217
        }
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   218
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   219
        /*
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   220
         * now, we got 11 bits for hashing;
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   221
         * make it as large as possible; since most hashers use the returned
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   222
         * key and take it modulo some prime number, this will allow for
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   223
         * better distribution (i.e. bigger empty spaces) in hashed collection.
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   224
         */
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   225
        hash = __MAKE_HASH__(hash);
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   226
        RETURN ( __mkSmallInteger(hash) );
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   227
    }
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   228
%}.
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   229
    ^ 0 "never reached, since redefined in UndefinedObject and SmallInteger"
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   230
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   231
    "Created: / 31-05-2007 / 23:18:40 / cg"
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
! !
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
!ProtoObject methodsFor:'testing'!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
21079
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   236
isBridgeProxy
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   237
    ^ false
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   238
!
d83ede99b688 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 21078
diff changeset
   239
12571
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   240
ifNil:aBlock
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   241
    ^ self
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   242
!
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   243
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   244
ifNotNil:aBlockOrValue
18439
b9ef8e4966e4 class: ProtoObject
Stefan Vogel <sv@exept.de>
parents: 18351
diff changeset
   245
    (aBlockOrValue isBlock and:[aBlockOrValue argumentCount == 1]) ifTrue:[
16158
93042fc9827e class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 12571
diff changeset
   246
        ^ aBlockOrValue value:self.
93042fc9827e class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 12571
diff changeset
   247
    ].
12571
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   248
    ^ aBlockOrValue value
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   249
!
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   250
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
isBehavior
18351
dc6c93a03b6d class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 16158
diff changeset
   252
    "return true, if the receiver is describing another object's behavior.
9222
1dccfa01fb06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   253
     False is returned here - the method is only redefined in Behavior."
1dccfa01fb06 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   254
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    ^ false
7661
71d2cac1b959 some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents: 7659
diff changeset
   256
!
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
7661
71d2cac1b959 some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents: 7659
diff changeset
   258
isBlock
71d2cac1b959 some tests aded to avoid trouble in debugger
Claus Gittinger <cg@exept.de>
parents: 7659
diff changeset
   259
    ^ false
7659
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   260
!
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   261
21078
c57b7b3dc73a #BUGFIX by Maren
matilk
parents: 21077
diff changeset
   262
isBridgeProxy
c57b7b3dc73a #BUGFIX by Maren
matilk
parents: 21077
diff changeset
   263
    ^ false
c57b7b3dc73a #BUGFIX by Maren
matilk
parents: 21077
diff changeset
   264
!
c57b7b3dc73a #BUGFIX by Maren
matilk
parents: 21077
diff changeset
   265
7659
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   266
isException
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   267
    ^ false
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   268
!
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   269
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   270
isExceptionHandler
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   271
    ^ false
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   272
!
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   273
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   274
isJavaObject
4def16a2e6e1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6912
diff changeset
   275
    ^ false
10589
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   276
!
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   277
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   278
isLazyValue
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   279
    ^ false
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   280
47f2edd1ffc6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 9222
diff changeset
   281
    "Created: / 03-06-2007 / 14:02:12 / cg"
10591
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   282
!
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   283
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   284
isLiteral
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   285
    ^ false
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   286
d5122476748b changed #isLiteral
Claus Gittinger <cg@exept.de>
parents: 10589
diff changeset
   287
    "Created: / 04-06-2007 / 17:19:10 / cg"
21075
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   288
!
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   289
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   290
isNil
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   291
    ^ false.
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   292
!
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   293
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   294
isProtoObject
d61cf84d605a #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 19678
diff changeset
   295
    ^ true
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
! !
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
!ProtoObject class methodsFor:'documentation'!
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
version
19678
85ad5275e07c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18439
diff changeset
   301
    ^ '$Header$'
12571
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   302
!
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   303
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
   304
version_CVS
19678
85ad5275e07c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18439
diff changeset
   305
    ^ '$Header$'
6844
75e52e680723 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
! !
16158
93042fc9827e class: ProtoObject
Claus Gittinger <cg@exept.de>
parents: 12571
diff changeset
   307