September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,17 +0,0 @@
|
|||
link printf
|
||||
|
||||
procedure main()
|
||||
(x := foo(1,2,3)).print() # create and show a foo
|
||||
printf("Fieldnames of foo x : ") # show fieldnames
|
||||
every printf(" %i",fieldnames(x)) # __s (self), __m (methods), vars
|
||||
printf("\n")
|
||||
printf("var 1 of foo x = %i\n", x.var1) # read var1 from outside x
|
||||
x.var1 := -1 # change var1 from outside x
|
||||
x.print() # show we changed it
|
||||
end
|
||||
|
||||
class foo(var1,var2,var3) # class with no set/read methods
|
||||
method print()
|
||||
printf("foo var1=%i, var2=%i, var3=%i\n",var1,var2,var3)
|
||||
end
|
||||
end
|
||||
21
Task/Break-OO-privacy/FreeBASIC/break-oo-privacy.freebasic
Normal file
21
Task/Break-OO-privacy/FreeBASIC/break-oo-privacy.freebasic
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
'FB 1.05.0 Win64
|
||||
|
||||
#Undef Private
|
||||
#Undef Protected
|
||||
#Define Private Public
|
||||
#Define Protected Public
|
||||
|
||||
Type MyType
|
||||
Public :
|
||||
x As Integer = 1
|
||||
Protected :
|
||||
y As Integer = 2
|
||||
Private :
|
||||
z As Integer = 3
|
||||
End Type
|
||||
|
||||
Dim mt As MyType
|
||||
Print mt.x, mt.y, mt.z
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
16
Task/Break-OO-privacy/Kotlin/break-oo-privacy.kotlin
Normal file
16
Task/Break-OO-privacy/Kotlin/break-oo-privacy.kotlin
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
|
||||
class ToBeBroken {
|
||||
@Suppress("unused")
|
||||
private val secret: Int = 42
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val tbb = ToBeBroken()
|
||||
val props = ToBeBroken::class.declaredMemberProperties
|
||||
for (prop in props) {
|
||||
prop.isAccessible = true // make private properties accessible
|
||||
println("${prop.name} -> ${prop.get(tbb)}")
|
||||
}
|
||||
}
|
||||
7
Task/Break-OO-privacy/Zkl/break-oo-privacy.zkl
Normal file
7
Task/Break-OO-privacy/Zkl/break-oo-privacy.zkl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class C{var [private] v; fcn [private] f{123} class [private] D {}}
|
||||
C.v; C.f; C.D; // all generate NotFoundError exceptions
|
||||
However:
|
||||
C.fcns //-->L(Fcn(nullFcn),Fcn(f))
|
||||
C.fcns[1]() //-->123
|
||||
C.classes //-->L(Class(D))
|
||||
C.vars //-->L(L("",Void)) (name,value) pairs
|
||||
Loading…
Add table
Add a link
Reference in a new issue