From 937f18667d16f630100f78e1730c2485c573d59a Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Fri, 9 Mar 2018 09:47:53 +0100 Subject: [PATCH] first commit --- .gitignore | 2 + .idea/C_CPP.iml | 2 + .idea/codeStyles/Project.xml | 29 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + 01_ENV/build.sh | 14 + 01_ENV/clean.sh | 4 + 01_ENV/main.c | 21 ++ 01_ENV/main.s | 58 ++++ 01_ENV/main_plain.c | 19 + 01_ENV/objdump-S_a.out.txt | 324 ++++++++++++++++++ 02_MENT/build.sh | 3 + 02_MENT/limits.cpp | 20 ++ 02_MENT/limits_println.cpp | 21 ++ 02_MENT/main_02_MENT.cpp | 31 ++ 02_MENT/printlnDemo.cpp | 17 + .../typedMemory.xcodeproj/project.pbxproj | 259 ++++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 13166 bytes .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 + .../xcschemes/typedMemory.xcscheme | 91 +++++ .../xcschemes/xcschememanagement.plist | 22 ++ 02_MENT/typedMemory/typedMemory/main.cpp | 73 ++++ .../typedMemory/typedMemory/typedMemory.cpp | 104 ++++++ .../typedMemory/typedMemory/typedMemory.hpp | 25 ++ 03_FLOW_a/build.sh | 2 + 03_FLOW_a/main_mp2_FLOW_a.cpp | 137 ++++++++ 03_FLOW_b/build.sh | 2 + 03_FLOW_b/controlFlowIntr | Bin 0 -> 15156 bytes 03_FLOW_b/main_ISR.cpp | 27 ++ 03_FLOW_b/run.sh | 9 + 03_FLOW_c/AP2-dc.cpp | 239 +++++++++++++ 03_FLOW_c/build.sh | 2 + 04_UDEF/RationalNumber.cpp | 28 ++ 04_UDEF/RationalNumber.hpp | 12 + 04_UDEF/main_04_UDEF_a.cpp | 40 +++ 04_UDEF/main_04_UDEF_e.cpp | 52 +++ 05_OO/AnsiConsoleDemo.cpp | 29 ++ 05_OO/build.sh | 3 + 05_OO/main_mp4_OO_a_vehicles.cpp | 105 ++++++ 05_OO/main_mp4_OO_b.cpp | 198 +++++++++++ 05_OO/shapes_main.cpp | 87 +++++ 06_POLY/main_mp5_POLY.cpp | 281 +++++++++++++++ 07_STD/6_STD_stacks/genericStack.hpp | 72 ++++ 07_STD/6_STD_stacks/intStack.cpp | 40 +++ 07_STD/6_STD_stacks/intStack.hpp | 26 ++ 07_STD/6_STD_stacks/main.cpp | 97 ++++++ 07_STD/grundgeruest.cpp | 17 + 08_PTRN/Car.cpp | 19 + 08_PTRN/Car.hpp | 18 + 08_PTRN/Logger.cpp | 15 + 08_PTRN/Logger.hpp | 19 + 08_PTRN/Truck.cpp | 16 + 08_PTRN/Truck.hpp | 17 + 08_PTRN/Vehicle.cpp | 15 + 08_PTRN/Vehicle.hpp | 18 + 08_PTRN/VehicleFactory.cpp | 19 + 08_PTRN/VehicleFactory.hpp | 10 + 08_PTRN/main.cpp | 71 ++++ 10_PITF/banking_base_rawptr.cpp | 121 +++++++ 10_PITF/build.sh | 3 + 10_PITF/doubleDelete/LifeCycleProbe.cpp | 54 +++ 10_PITF/doubleDelete/LifeCycleProbe.hpp | 23 ++ 10_PITF/doubleDelete/main.cpp | 38 ++ 10_PITF/main_objectSlicing.cpp | 67 ++++ .../CopyOnWrite.xcodeproj/project.pbxproj | 245 +++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 34240 bytes .../xcschemes/CopyOnWrite.xcscheme | 88 +++++ .../xcschemes/xcschememanagement.plist | 22 ++ .../CopyOnWrite/OneByOneMatrix.cpp | 77 +++++ .../CopyOnWrite/CopyOnWrite/OneByOneMatrix.h | 42 +++ 11_PUTT/CopyOnWrite/CopyOnWrite/main.cpp | 86 +++++ helpers/AnsiConsole.cpp | 58 ++++ helpers/AnsiConsole.h | 34 ++ helpers/println.hpp | 124 +++++++ .../02_MENT_gg.xcodeproj/project.pbxproj | 253 ++++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 11742 bytes .../xcschemes/02_MENT_gg.xcscheme | 91 +++++ .../xcschemes/xcschememanagement.plist | 22 ++ .../limits2/limits2.xcodeproj/project.pbxproj | 255 ++++++++++++++ .../contents.xcworkspacedata | 7 + .../UserInterfaceState.xcuserstate | Bin 0 -> 11356 bytes .../xcschemes/limits2.xcscheme | 91 +++++ .../xcschemes/xcschememanagement.plist | 22 ++ xcode_projects/limits2/limits2/main.cpp | 26 ++ 88 files changed, 4774 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/C_CPP.iml create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 01_ENV/build.sh create mode 100644 01_ENV/clean.sh create mode 100644 01_ENV/main.c create mode 100644 01_ENV/main.s create mode 100644 01_ENV/main_plain.c create mode 100644 01_ENV/objdump-S_a.out.txt create mode 100644 02_MENT/build.sh create mode 100644 02_MENT/limits.cpp create mode 100644 02_MENT/limits_println.cpp create mode 100644 02_MENT/main_02_MENT.cpp create mode 100644 02_MENT/printlnDemo.cpp create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/project.pbxproj create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/typedMemory.xcscheme create mode 100644 02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 02_MENT/typedMemory/typedMemory/main.cpp create mode 100644 02_MENT/typedMemory/typedMemory/typedMemory.cpp create mode 100644 02_MENT/typedMemory/typedMemory/typedMemory.hpp create mode 100644 03_FLOW_a/build.sh create mode 100644 03_FLOW_a/main_mp2_FLOW_a.cpp create mode 100644 03_FLOW_b/build.sh create mode 100644 03_FLOW_b/controlFlowIntr create mode 100644 03_FLOW_b/main_ISR.cpp create mode 100644 03_FLOW_b/run.sh create mode 100644 03_FLOW_c/AP2-dc.cpp create mode 100644 03_FLOW_c/build.sh create mode 100644 04_UDEF/RationalNumber.cpp create mode 100644 04_UDEF/RationalNumber.hpp create mode 100644 04_UDEF/main_04_UDEF_a.cpp create mode 100644 04_UDEF/main_04_UDEF_e.cpp create mode 100644 05_OO/AnsiConsoleDemo.cpp create mode 100644 05_OO/build.sh create mode 100644 05_OO/main_mp4_OO_a_vehicles.cpp create mode 100644 05_OO/main_mp4_OO_b.cpp create mode 100644 05_OO/shapes_main.cpp create mode 100644 06_POLY/main_mp5_POLY.cpp create mode 100644 07_STD/6_STD_stacks/genericStack.hpp create mode 100644 07_STD/6_STD_stacks/intStack.cpp create mode 100644 07_STD/6_STD_stacks/intStack.hpp create mode 100644 07_STD/6_STD_stacks/main.cpp create mode 100644 07_STD/grundgeruest.cpp create mode 100644 08_PTRN/Car.cpp create mode 100644 08_PTRN/Car.hpp create mode 100644 08_PTRN/Logger.cpp create mode 100644 08_PTRN/Logger.hpp create mode 100644 08_PTRN/Truck.cpp create mode 100644 08_PTRN/Truck.hpp create mode 100644 08_PTRN/Vehicle.cpp create mode 100644 08_PTRN/Vehicle.hpp create mode 100644 08_PTRN/VehicleFactory.cpp create mode 100644 08_PTRN/VehicleFactory.hpp create mode 100644 08_PTRN/main.cpp create mode 100644 10_PITF/banking_base_rawptr.cpp create mode 100644 10_PITF/build.sh create mode 100644 10_PITF/doubleDelete/LifeCycleProbe.cpp create mode 100644 10_PITF/doubleDelete/LifeCycleProbe.hpp create mode 100644 10_PITF/doubleDelete/main.cpp create mode 100644 10_PITF/main_objectSlicing.cpp create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.pbxproj create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/CopyOnWrite.xcscheme create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.cpp create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.h create mode 100644 11_PUTT/CopyOnWrite/CopyOnWrite/main.cpp create mode 100644 helpers/AnsiConsole.cpp create mode 100644 helpers/AnsiConsole.h create mode 100644 helpers/println.hpp create mode 100644 xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.pbxproj create mode 100644 xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/02_MENT_gg.xcscheme create mode 100644 xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 xcode_projects/limits2/limits2.xcodeproj/project.pbxproj create mode 100644 xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/limits2.xcscheme create mode 100644 xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist create mode 100644 xcode_projects/limits2/limits2/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d512c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +cmake-build-debug +xcode_projects \ No newline at end of file diff --git a/.idea/C_CPP.iml b/.idea/C_CPP.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/C_CPP.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..05ae881 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/01_ENV/build.sh b/01_ENV/build.sh new file mode 100644 index 0000000..eeb81d7 --- /dev/null +++ b/01_ENV/build.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# generate main.s, main.o, b.out +pcc -O0 -S main.c +as -o main.o main.s +#ld -o b.out main.o /lib/crt0.o /lib/crti.o -lc +pcc -o b.out main.o + +# generate a.out +pcc -O0 -g main.c + +# generate assembly intermixed with source code +objdump -S a.out > objdump-S_a.out.txt + diff --git a/01_ENV/clean.sh b/01_ENV/clean.sh new file mode 100644 index 0000000..889d8f2 --- /dev/null +++ b/01_ENV/clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +rm *.o *.s *.out + diff --git a/01_ENV/main.c b/01_ENV/main.c new file mode 100644 index 0000000..285a15f --- /dev/null +++ b/01_ENV/main.c @@ -0,0 +1,21 @@ +#include + +int global = 8150; + + +int sum(int,int); + +int sum(int a, int b){ + int result = 451; + result = a + b; + return result; +} + + +int main(int argc, char **argv) +{ + int local=4711; + printf("Hello, world!\nglobal=%d local=%d\n", global, local); + local = sum(global, local); + return local; +} diff --git a/01_ENV/main.s b/01_ENV/main.s new file mode 100644 index 0000000..f9a1224 --- /dev/null +++ b/01_ENV/main.s @@ -0,0 +1,58 @@ + .data + .align 4 + .globl global + .type global,@object + .size global,4 +global: + .long 8150 + .text + .align 4 + .globl sum + .type sum,@function +sum: + enter $8,$0 +.L461: +.L465: + movl $451,-4(%ebp) + movl 8(%ebp),%eax + addl 12(%ebp),%eax + movl %eax,-4(%ebp) + movl -4(%ebp),%eax + movl %eax,-8(%ebp) + jmp .L463 +.L463: + movl -8(%ebp),%eax + leave + ret + .size sum,.-sum + .align 4 + .globl main + .type main,@function +main: + enter $8,$0 +.L469: +.L473: + movl $4711,-4(%ebp) + pushl -4(%ebp) + pushl global + pushl $.L475 + call printf + addl $12, %esp + pushl -4(%ebp) + pushl global + call sum + addl $8, %esp + movl %eax,-4(%ebp) + movl -4(%ebp),%eax + movl %eax,-8(%ebp) + jmp .L471 +.L471: + movl -8(%ebp),%eax + leave + ret + .size main,.-main + .section .rodata + .size .L475,34 +.L475: + .ascii "Hello, world!\012global=%d local=%d\012\0" + .ident "PCC: Portable C Compiler 1.2.0.DEVEL 20160115 for i686-pc-linux-gnu" diff --git a/01_ENV/main_plain.c b/01_ENV/main_plain.c new file mode 100644 index 0000000..b5a353f --- /dev/null +++ b/01_ENV/main_plain.c @@ -0,0 +1,19 @@ +#include + +int global = 8150; + +int sum(int a, int b){ + int result = 451; + result = a + b; + return result; +} + + +int main(int argc, char **argv) +{ + int local=4711; + printf("Hello, world!\nglobal=%d local=%d\n", global, local); + local = sum(global, local); + return local; +} + diff --git a/01_ENV/objdump-S_a.out.txt b/01_ENV/objdump-S_a.out.txt new file mode 100644 index 0000000..f8aa422 --- /dev/null +++ b/01_ENV/objdump-S_a.out.txt @@ -0,0 +1,324 @@ + +a.out: file format elf32-i386 + + +Disassembly of section .init: + +08048278 <_init>: + 8048278: 53 push %ebx + 8048279: 83 ec 08 sub $0x8,%esp + 804827c: e8 8f 00 00 00 call 8048310 <__x86.get_pc_thunk.bx> + 8048281: 81 c3 7f 1d 00 00 add $0x1d7f,%ebx + 8048287: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax + 804828d: 85 c0 test %eax,%eax + 804828f: 74 05 je 8048296 <_init+0x1e> + 8048291: e8 2a 00 00 00 call 80482c0 <__gmon_start__@plt> + 8048296: e8 45 01 00 00 call 80483e0 <__do_global_ctors_aux> + 804829b: 83 c4 08 add $0x8,%esp + 804829e: 5b pop %ebx + 804829f: c3 ret + +Disassembly of section .plt: + +080482a0 : + 80482a0: ff 35 04 a0 04 08 pushl 0x804a004 + 80482a6: ff 25 08 a0 04 08 jmp *0x804a008 + 80482ac: 00 00 add %al,(%eax) + ... + +080482b0 : + 80482b0: ff 25 0c a0 04 08 jmp *0x804a00c + 80482b6: 68 00 00 00 00 push $0x0 + 80482bb: e9 e0 ff ff ff jmp 80482a0 <_init+0x28> + +080482c0 <__gmon_start__@plt>: + 80482c0: ff 25 10 a0 04 08 jmp *0x804a010 + 80482c6: 68 08 00 00 00 push $0x8 + 80482cb: e9 d0 ff ff ff jmp 80482a0 <_init+0x28> + +080482d0 <__libc_start_main@plt>: + 80482d0: ff 25 14 a0 04 08 jmp *0x804a014 + 80482d6: 68 10 00 00 00 push $0x10 + 80482db: e9 c0 ff ff ff jmp 80482a0 <_init+0x28> + +Disassembly of section .text: + +080482e0 <_start>: + 80482e0: 31 ed xor %ebp,%ebp + 80482e2: 5e pop %esi + 80482e3: 89 e1 mov %esp,%ecx + 80482e5: 83 e4 f0 and $0xfffffff0,%esp + 80482e8: 50 push %eax + 80482e9: 54 push %esp + 80482ea: 52 push %edx + 80482eb: 68 30 85 04 08 push $0x8048530 + 80482f0: 68 d0 84 04 08 push $0x80484d0 + 80482f5: 51 push %ecx + 80482f6: 56 push %esi + 80482f7: 68 8c 84 04 08 push $0x804848c + 80482fc: e8 cf ff ff ff call 80482d0 <__libc_start_main@plt> + 8048301: f4 hlt + 8048302: 66 90 xchg %ax,%ax + 8048304: 66 90 xchg %ax,%ax + 8048306: 66 90 xchg %ax,%ax + 8048308: 66 90 xchg %ax,%ax + 804830a: 66 90 xchg %ax,%ax + 804830c: 66 90 xchg %ax,%ax + 804830e: 66 90 xchg %ax,%ax + +08048310 <__x86.get_pc_thunk.bx>: + 8048310: 8b 1c 24 mov (%esp),%ebx + 8048313: c3 ret + 8048314: 66 90 xchg %ax,%ax + 8048316: 66 90 xchg %ax,%ax + 8048318: 66 90 xchg %ax,%ax + 804831a: 66 90 xchg %ax,%ax + 804831c: 66 90 xchg %ax,%ax + 804831e: 66 90 xchg %ax,%ax + +08048320 <__ctors>: + 8048320: e8 34 01 00 00 call 8048459 <__x86.get_pc_thunk.ax> + 8048325: 05 db 1c 00 00 add $0x1cdb,%eax + 804832a: 56 push %esi + 804832b: 53 push %ebx + 804832c: 8d 64 24 fc lea -0x4(%esp),%esp + 8048330: 8d 88 24 ff ff ff lea -0xdc(%eax),%ecx + 8048336: 8b 11 mov (%ecx),%edx + 8048338: 83 fa ff cmp $0xffffffff,%edx + 804833b: 74 2b je 8048368 <__ctors+0x48> + 804833d: 8d 5a ff lea -0x1(%edx),%ebx + 8048340: 8d 34 91 lea (%ecx,%edx,4),%esi + 8048343: 8d 04 9d 00 00 00 00 lea 0x0(,%ebx,4),%eax + 804834a: 29 c6 sub %eax,%esi + 804834c: 85 d2 test %edx,%edx + 804834e: 74 0a je 804835a <__ctors+0x3a> + 8048350: ff 14 9e call *(%esi,%ebx,4) + 8048353: 85 db test %ebx,%ebx + 8048355: 8d 5b ff lea -0x1(%ebx),%ebx + 8048358: 75 f6 jne 8048350 <__ctors+0x30> + 804835a: 8d 64 24 04 lea 0x4(%esp),%esp + 804835e: 5b pop %ebx + 804835f: 5e pop %esi + 8048360: c3 ret + 8048361: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + 8048368: 8b 71 04 mov 0x4(%ecx),%esi + 804836b: 85 f6 test %esi,%esi + 804836d: 74 eb je 804835a <__ctors+0x3a> + 804836f: ba 01 00 00 00 mov $0x1,%edx + 8048374: eb 04 jmp 804837a <__ctors+0x5a> + 8048376: 66 90 xchg %ax,%ax + 8048378: 89 c2 mov %eax,%edx + 804837a: 8d 42 01 lea 0x1(%edx),%eax + 804837d: 8b 1c 81 mov (%ecx,%eax,4),%ebx + 8048380: 85 db test %ebx,%ebx + 8048382: 75 f4 jne 8048378 <__ctors+0x58> + 8048384: eb b7 jmp 804833d <__ctors+0x1d> + 8048386: 8d 76 00 lea 0x0(%esi),%esi + 8048389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +08048390 <__dtors>: + 8048390: e8 c4 00 00 00 call 8048459 <__x86.get_pc_thunk.ax> + 8048395: 05 6b 1c 00 00 add $0x1c6b,%eax + 804839a: 53 push %ebx + 804839b: 8d 64 24 f8 lea -0x8(%esp),%esp + 804839f: 8d 90 2c ff ff ff lea -0xd4(%eax),%edx + 80483a5: 89 d3 mov %edx,%ebx + 80483a7: 83 c3 04 add $0x4,%ebx + 80483aa: 8b 42 04 mov 0x4(%edx),%eax + 80483ad: 85 c0 test %eax,%eax + 80483af: 74 1a je 80483cb <__dtors+0x3b> + 80483b1: eb 0d jmp 80483c0 <__dtors+0x30> + 80483b3: 90 nop + 80483b4: 90 nop + 80483b5: 90 nop + 80483b6: 90 nop + 80483b7: 90 nop + 80483b8: 90 nop + 80483b9: 90 nop + 80483ba: 90 nop + 80483bb: 90 nop + 80483bc: 90 nop + 80483bd: 90 nop + 80483be: 90 nop + 80483bf: 90 nop + 80483c0: 8d 5b 04 lea 0x4(%ebx),%ebx + 80483c3: ff d0 call *%eax + 80483c5: 8b 03 mov (%ebx),%eax + 80483c7: 85 c0 test %eax,%eax + 80483c9: 75 f5 jne 80483c0 <__dtors+0x30> + 80483cb: 8d 64 24 08 lea 0x8(%esp),%esp + 80483cf: 5b pop %ebx + 80483d0: c3 ret + 80483d1: eb 0d jmp 80483e0 <__do_global_ctors_aux> + 80483d3: 90 nop + 80483d4: 90 nop + 80483d5: 90 nop + 80483d6: 90 nop + 80483d7: 90 nop + 80483d8: 90 nop + 80483d9: 90 nop + 80483da: 90 nop + 80483db: 90 nop + 80483dc: 90 nop + 80483dd: 90 nop + 80483de: 90 nop + 80483df: 90 nop + +080483e0 <__do_global_ctors_aux>: + 80483e0: e8 74 00 00 00 call 8048459 <__x86.get_pc_thunk.ax> + 80483e5: 05 1b 1c 00 00 add $0x1c1b,%eax + 80483ea: 8b 90 24 00 00 00 mov 0x24(%eax),%edx + 80483f0: 85 d2 test %edx,%edx + 80483f2: 74 04 je 80483f8 <__do_global_ctors_aux+0x18> + 80483f4: c3 ret + 80483f5: 8d 76 00 lea 0x0(%esi),%esi + 80483f8: c7 80 24 00 00 00 01 movl $0x1,0x24(%eax) + 80483ff: 00 00 00 + 8048402: e9 19 ff ff ff jmp 8048320 <__ctors> + 8048407: 89 f6 mov %esi,%esi + 8048409: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi + +08048410 <__do_global_dtors_aux>: + 8048410: 53 push %ebx + 8048411: e8 fa fe ff ff call 8048310 <__x86.get_pc_thunk.bx> + 8048416: 81 c3 ea 1b 00 00 add $0x1bea,%ebx + 804841c: 8d 64 24 f8 lea -0x8(%esp),%esp + 8048420: 8b 83 20 00 00 00 mov 0x20(%ebx),%eax + 8048426: 85 c0 test %eax,%eax + 8048428: 75 0f jne 8048439 <__do_global_dtors_aux+0x29> + 804842a: e8 61 ff ff ff call 8048390 <__dtors> + 804842f: c7 83 20 00 00 00 01 movl $0x1,0x20(%ebx) + 8048436: 00 00 00 + 8048439: 8d 64 24 08 lea 0x8(%esp),%esp + 804843d: 5b pop %ebx + 804843e: c3 ret + 804843f: 90 nop + +08048440 <__call___do_global_ctors_aux>: + 8048440: 8d 64 24 f4 lea -0xc(%esp),%esp + 8048444: 8d 64 24 0c lea 0xc(%esp),%esp + 8048448: c3 ret + 8048449: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi + +08048450 <__call___do_global_dtors_aux>: + 8048450: 8d 64 24 f4 lea -0xc(%esp),%esp + 8048454: 8d 64 24 0c lea 0xc(%esp),%esp + 8048458: c3 ret + +08048459 <__x86.get_pc_thunk.ax>: + 8048459: 90 nop + 804845a: 90 nop + 804845b: 90 nop + 804845c: 90 nop + 804845d: 90 nop + 804845e: 90 nop + 804845f: 90 nop + 8048460: 90 nop + 8048461: 8b 04 24 mov (%esp),%eax + 8048464: c3 ret + 8048465: 66 90 xchg %ax,%ax + 8048467: 90 nop + +08048468 : +int global = 8150; + + +int sum(int,int); + +int sum(int a, int b){ + 8048468: c8 08 00 00 enter $0x8,$0x0 + int result = 451; + 804846c: c7 45 fc c3 01 00 00 movl $0x1c3,-0x4(%ebp) + result = a + b; + 8048473: 8b 45 08 mov 0x8(%ebp),%eax + 8048476: 03 45 0c add 0xc(%ebp),%eax + 8048479: 89 45 fc mov %eax,-0x4(%ebp) + return result; + 804847c: 8b 45 fc mov -0x4(%ebp),%eax + 804847f: 89 45 f8 mov %eax,-0x8(%ebp) + 8048482: eb 00 jmp 8048484 +} + 8048484: 8b 45 f8 mov -0x8(%ebp),%eax + 8048487: c9 leave + 8048488: c3 ret + 8048489: 8d 76 00 lea 0x0(%esi),%esi + +0804848c
: + + +int main(int argc, char **argv) +{ + 804848c: c8 08 00 00 enter $0x8,$0x0 + int local=4711; + 8048490: c7 45 fc 67 12 00 00 movl $0x1267,-0x4(%ebp) + printf("Hello, world!\nglobal=%d local=%d\n", global, local); + 8048497: ff 75 fc pushl -0x4(%ebp) + 804849a: ff 35 1c a0 04 08 pushl 0x804a01c + 80484a0: 68 58 85 04 08 push $0x8048558 + 80484a5: e8 06 fe ff ff call 80482b0 + 80484aa: 83 c4 0c add $0xc,%esp + local = sum(global, local); + 80484ad: ff 75 fc pushl -0x4(%ebp) + 80484b0: ff 35 1c a0 04 08 pushl 0x804a01c + 80484b6: e8 ad ff ff ff call 8048468 + 80484bb: 83 c4 08 add $0x8,%esp + 80484be: 89 45 fc mov %eax,-0x4(%ebp) + return local; + 80484c1: 8b 45 fc mov -0x4(%ebp),%eax + 80484c4: 89 45 f8 mov %eax,-0x8(%ebp) + 80484c7: eb 00 jmp 80484c9 +} + 80484c9: 8b 45 f8 mov -0x8(%ebp),%eax + 80484cc: c9 leave + 80484cd: c3 ret + 80484ce: 66 90 xchg %ax,%ax + +080484d0 <__libc_csu_init>: + 80484d0: 55 push %ebp + 80484d1: 57 push %edi + 80484d2: 56 push %esi + 80484d3: 53 push %ebx + 80484d4: e8 37 fe ff ff call 8048310 <__x86.get_pc_thunk.bx> + 80484d9: 81 c3 27 1b 00 00 add $0x1b27,%ebx + 80484df: 83 ec 0c sub $0xc,%esp + 80484e2: 8b 6c 24 20 mov 0x20(%esp),%ebp + 80484e6: 8d b3 24 ff ff ff lea -0xdc(%ebx),%esi + 80484ec: e8 87 fd ff ff call 8048278 <_init> + 80484f1: 8d 83 24 ff ff ff lea -0xdc(%ebx),%eax + 80484f7: 29 c6 sub %eax,%esi + 80484f9: c1 fe 02 sar $0x2,%esi + 80484fc: 85 f6 test %esi,%esi + 80484fe: 74 25 je 8048525 <__libc_csu_init+0x55> + 8048500: 31 ff xor %edi,%edi + 8048502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi + 8048508: 83 ec 04 sub $0x4,%esp + 804850b: ff 74 24 2c pushl 0x2c(%esp) + 804850f: ff 74 24 2c pushl 0x2c(%esp) + 8048513: 55 push %ebp + 8048514: ff 94 bb 24 ff ff ff call *-0xdc(%ebx,%edi,4) + 804851b: 83 c7 01 add $0x1,%edi + 804851e: 83 c4 10 add $0x10,%esp + 8048521: 39 f7 cmp %esi,%edi + 8048523: 75 e3 jne 8048508 <__libc_csu_init+0x38> + 8048525: 83 c4 0c add $0xc,%esp + 8048528: 5b pop %ebx + 8048529: 5e pop %esi + 804852a: 5f pop %edi + 804852b: 5d pop %ebp + 804852c: c3 ret + 804852d: 8d 76 00 lea 0x0(%esi),%esi + +08048530 <__libc_csu_fini>: + 8048530: f3 c3 repz ret + +Disassembly of section .fini: + +08048534 <_fini>: + 8048534: 53 push %ebx + 8048535: 83 ec 08 sub $0x8,%esp + 8048538: e8 d3 fd ff ff call 8048310 <__x86.get_pc_thunk.bx> + 804853d: 81 c3 c3 1a 00 00 add $0x1ac3,%ebx + 8048543: e8 c8 fe ff ff call 8048410 <__do_global_dtors_aux> + 8048548: 83 c4 08 add $0x8,%esp + 804854b: 5b pop %ebx + 804854c: c3 ret diff --git a/02_MENT/build.sh b/02_MENT/build.sh new file mode 100644 index 0000000..04a14d3 --- /dev/null +++ b/02_MENT/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +clang++ -std=c++14 -I../helpers/ -o limits.out limits_println.cpp +clang++ -std=c++14 -I../helpers/ -o println.out printlnDemo.cpp diff --git a/02_MENT/limits.cpp b/02_MENT/limits.cpp new file mode 100644 index 0000000..45c47aa --- /dev/null +++ b/02_MENT/limits.cpp @@ -0,0 +1,20 @@ +#include +#include + +int main() +{ + std::cout << "type\tsizeof\tlowest\t\thighest\n"; + std::cout << "float\t" << sizeof(float) << '\t' + << std::numeric_limits::lowest() << '\t' + << std::numeric_limits::max() << '\n'; + std::cout << "double\t" << sizeof(double) << '\t' + << std::numeric_limits::lowest() << '\t' + << std::numeric_limits::max() << '\n'; + std::cout << "int\t" << sizeof(int) << '\t' + << std::numeric_limits::lowest() << '\t' + << std::numeric_limits::max() << '\n'; + std::cout << "long\t" << sizeof(long) << '\t' + << std::numeric_limits::lowest() << '\t' + << std::numeric_limits::max() << '\n'; +} + diff --git a/02_MENT/limits_println.cpp b/02_MENT/limits_println.cpp new file mode 100644 index 0000000..732d923 --- /dev/null +++ b/02_MENT/limits_println.cpp @@ -0,0 +1,21 @@ +#include "println.hpp" +#include + +int main() +{ + println("type\t sizeof\t\t lowest\t\t\t\t highest\n"); + println("float \t ",sizeof(float), "\t\t\t", + std::numeric_limits::lowest(), "\t\t", + std::numeric_limits::max()); + println("double\t ",sizeof(double), "\t\t\t", + std::numeric_limits::lowest(), "\t\t", + std::numeric_limits::max()); + println("int \t ",sizeof(int), "\t\t\t", + std::numeric_limits::lowest(), "\t\t\t", + std::numeric_limits::max()); + println("long \t ",sizeof(long), " \t\t", + std::numeric_limits::lowest(), '\t', + std::numeric_limits::max()); + + } + diff --git a/02_MENT/main_02_MENT.cpp b/02_MENT/main_02_MENT.cpp new file mode 100644 index 0000000..caa166f --- /dev/null +++ b/02_MENT/main_02_MENT.cpp @@ -0,0 +1,31 @@ +// file: main_02_MENT.cpp +// THIS IS C++, use clang++ + +#include "../helpers/println.hpp" +#include + +struct PascalString{ + int length; // number of chars used + char characters[256]; // chars of some character string +}; + +int hexDigitToInt(char hexDigit){ +int value = -1; +// TBD +return value; +} + +int hexStringToInt(PascalString binaryDigits){ +int returnValue = -1; + +return returnValue; +} + +int main(int argc, char** argv, char** envp){ + PascalString s = {3, '1', '0', '0'}; + PascalString s2 = {4, 'f', 'f', 'f', 'f'}; + println(hexStringToInt(s)); + println(hexStringToInt(s2)); + return 0; +} + diff --git a/02_MENT/printlnDemo.cpp b/02_MENT/printlnDemo.cpp new file mode 100644 index 0000000..66d1dc7 --- /dev/null +++ b/02_MENT/printlnDemo.cpp @@ -0,0 +1,17 @@ +#include "println.hpp" + + +int main() +{ + println("this program shows how to use println()"); + int i=1; + println(i); // type int + double d=2.78; + println(d); // type double + println(""); // just an empty line: + println("i=", i, " d=", d);// more than one + print("i=", i); // print all with separate statements + print(" d=", d); // no "ln" -> no newline + println(""); +} + diff --git a/02_MENT/typedMemory/typedMemory.xcodeproj/project.pbxproj b/02_MENT/typedMemory/typedMemory.xcodeproj/project.pbxproj new file mode 100644 index 0000000..814f6de --- /dev/null +++ b/02_MENT/typedMemory/typedMemory.xcodeproj/project.pbxproj @@ -0,0 +1,259 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 654370B41E9788E30085F153 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 654370B31E9788E30085F153 /* main.cpp */; }; + 654371471E9ED16D0085F153 /* typedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 654371451E9ED16D0085F153 /* typedMemory.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 654370AE1E9788E30085F153 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 654370B01E9788E30085F153 /* typedMemory */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = typedMemory; sourceTree = BUILT_PRODUCTS_DIR; }; + 654370B31E9788E30085F153 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 654371451E9ED16D0085F153 /* typedMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = typedMemory.cpp; sourceTree = ""; }; + 654371461E9ED16D0085F153 /* typedMemory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = typedMemory.hpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 654370AD1E9788E30085F153 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 654370A71E9788E30085F153 = { + isa = PBXGroup; + children = ( + 654370B21E9788E30085F153 /* typedMemory */, + 654370B11E9788E30085F153 /* Products */, + ); + sourceTree = ""; + }; + 654370B11E9788E30085F153 /* Products */ = { + isa = PBXGroup; + children = ( + 654370B01E9788E30085F153 /* typedMemory */, + ); + name = Products; + sourceTree = ""; + }; + 654370B21E9788E30085F153 /* typedMemory */ = { + isa = PBXGroup; + children = ( + 654370B31E9788E30085F153 /* main.cpp */, + 654371451E9ED16D0085F153 /* typedMemory.cpp */, + 654371461E9ED16D0085F153 /* typedMemory.hpp */, + ); + path = typedMemory; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 654370AF1E9788E30085F153 /* typedMemory */ = { + isa = PBXNativeTarget; + buildConfigurationList = 654370B71E9788E30085F153 /* Build configuration list for PBXNativeTarget "typedMemory" */; + buildPhases = ( + 654370AC1E9788E30085F153 /* Sources */, + 654370AD1E9788E30085F153 /* Frameworks */, + 654370AE1E9788E30085F153 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = typedMemory; + productName = typedMemory; + productReference = 654370B01E9788E30085F153 /* typedMemory */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 654370A81E9788E30085F153 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = HSEL; + TargetAttributes = { + 654370AF1E9788E30085F153 = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 654370AB1E9788E30085F153 /* Build configuration list for PBXProject "typedMemory" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 654370A71E9788E30085F153; + productRefGroup = 654370B11E9788E30085F153 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 654370AF1E9788E30085F153 /* typedMemory */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 654370AC1E9788E30085F153 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 654370B41E9788E30085F153 /* main.cpp in Sources */, + 654371471E9ED16D0085F153 /* typedMemory.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 654370B51E9788E30085F153 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 654370B61E9788E30085F153 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 654370B81E9788E30085F153 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 654370B91E9788E30085F153 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 654370AB1E9788E30085F153 /* Build configuration list for PBXProject "typedMemory" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 654370B51E9788E30085F153 /* Debug */, + 654370B61E9788E30085F153 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 654370B71E9788E30085F153 /* Build configuration list for PBXNativeTarget "typedMemory" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 654370B81E9788E30085F153 /* Debug */, + 654370B91E9788E30085F153 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 654370A81E9788E30085F153 /* Project object */; +} diff --git a/02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..536168f --- /dev/null +++ b/02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate b/02_MENT/typedMemory/typedMemory.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..781d91195afde6acbbb1d573b85a4bfa93a68419 GIT binary patch literal 13166 zcmc(F30RcX_y1j9W?*18hS>pUh8YBuRYAlR1=B<%K}1PufL9zHW^iUuNzFT!mThL6 z+P6%>T*@>vE6Xe^ZO>fO_AJ|MwawD(ciwp!VEWSc+y8m~&+i8h4>Rw*@44rmd(P*6 z&bha~#qIJ3a&nF#j0mELLs3Y=jpT}J?DKe^-{tkx*uC|$`G$ahs@>^pnB{`URrY|l zB_84B>vyPeF_NNaq(KQti~6E8l#Vh`Khz&(qAXN`O3@f}85)bmq07;DRE8#?ax@WD zplUP)U5OeIk7lAKGz)pqJTxCIMAx7j&(KpZJ=%cU(IaRldKB$K zkD=Y@ar89Wi=ILI(E)S_y@lRJ@1qaUY4jQT9DRYlM&F|!(2wXRbRPYNe#bH#i{r2y zE3gu4u?{EVB<#ScxG&Dcxi}9O;^BA*Y!!jn0~O`3_HEFg>o$qI5Kxs}{W){+gRopg|g$TspY*-f4$ z2gobr4e};AM2?b^Ptm98Uiu8(N1vsy&{yee^mTfSen3B@AJLELY5EEM zlzvOUquhJLlk1xeP9o%i^-R0o)L7#ALgt)$Klt zVvr2QqBx{P@l(nxv*z$^{%P>P(|@b&4Q{93-;U%+!3d-6NQKmlW2cz4PGujQH#oO6 zx3na4%$PwrnFI6k2WJ-Mj492`%`X{Tkdt2k?W5~d3FAsir+9sH{4LG~zQo(m+RS?b z;emB18KrJUdSpOGWI|??h>}=$${t=WOQdR91K}(bvfP_{J`^BgFdaRQ-F7DZbr3>|~E?ZYw{o5vJ*y z=>j!WeV}`BLjZ7~cZqc>W0w|HUaz~}=^N*-cKKcPZcxb3-R7(x)uSnF#B4MerEWzz zC>Q0S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ty5K zTxJ+&7;mUBOfpm%stt7pw_&cqZ)i1KZCGTu#=s0K40jt=8`c=^F>E$GXxL`hVc2Qd zW!P)jZ+O9Q!0?jcnBkP+UBml^(}qtCpBcU|oHJZ7MjPcurBQ9v84X60G0~W19Aq48 zoNkk{WC-ki8Lab4p2#P-C^iCYsNN_;r+MB*ojpCx{gcsB8y#P1R>CSFQHNhFCS z-I8>7(wd}ulI~4fm$W%)YtlnW4=3$N+L?4P=}^*}Zl0HxRGU;s6H%Z?mollNR zmL{sMvM0GE*_Rwh{yh1o zR;@L~I^J4ky~^5T4Okajmso?=Ypu(yw_0zr-eJAVy2g5swZppIy2pCZddPa% zdenN{`nL5W>nGOFtY28qTEDUWV*S$=ZPVJ4Z5Er&X1Ar`eA^&fk!`50)K+e* zwl&yh+FUlb&1;)$TVlJ(w#K&Aw#~M~_NZ;Q?Md6ywtcq!wj;LVwzqAkZ134Vw4Jt{ zv3+j)()Oe6Qi?t$D`j*_O-f73ij=!jo=VxD@_fo$DetFzn(}$dS1I45{FL%*%I_%` zQ!d$a?PYe}?y zlsRe~yue%hr>v-1jyyJl5CC6Ki zqmB<9Upszu{Nnh{aWR#qN>XD|<5Cr=`qbpqzNy)1cc!gQTc5T)ZFkz + + diff --git a/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/typedMemory.xcscheme b/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/typedMemory.xcscheme new file mode 100644 index 0000000..8ad5a88 --- /dev/null +++ b/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/typedMemory.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist b/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..25d6d3f --- /dev/null +++ b/02_MENT/typedMemory/typedMemory.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + typedMemory.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 654370AF1E9788E30085F153 + + primary + + + + + diff --git a/02_MENT/typedMemory/typedMemory/main.cpp b/02_MENT/typedMemory/typedMemory/main.cpp new file mode 100644 index 0000000..1972ae4 --- /dev/null +++ b/02_MENT/typedMemory/typedMemory/main.cpp @@ -0,0 +1,73 @@ +// main.cpp +// typedMemory + +#include +#include +#include "typedMemory.hpp" + + + + +struct compund { + int theInt; + double theDouble; +}; + + +/* this illustrates that what the compiler needs to do + to store local variables in the stack frame. Compare + this to the code in main().*/ +/*void foobar(){ + unsigned int x = 0x04030201; + char c1 = 'C'; + char c2 = '+'; + char c3 = '+'; + char c4 = '!'; + double d1 = 16.0; + compund k1 = {0x04030201, 16.0}; + compund k2 = {0, 0.0}; +}*/ + + +int main(int argc, const char * argv[]) { + TypedMemory mem; + + mem.putUInt(0, 0x04030201); + mem.putChar(4,'C'); + mem.putChar(5,'+'); + mem.putChar(6,'+'); + mem.putChar(7,'!'); + mem.putDouble(0x30, 16.0 /*355.0/113.0*/); + + std::cout << std::setbase(16); + std::cout << "0x" << mem.getUInt(0) << std::endl; + std::cout << mem.getChar(4) + << mem.getChar(5) + << mem.getChar(6) + << mem.getChar(7) << std::endl; + std::cout << "0x" << mem.getUInt(4) << std::endl; + std::cout << mem.getDouble(0x30) << " (" << sizeof(double) << " bytes)" << std::endl; + + compund a = {0x04030201, 16.0}; + compund b = {0, 0.0}; + mem.putAnything(16, &a, sizeof(compund)); + mem.getAnything(16, &b, sizeof(compund)); + std::cout << "a = (0x" << a.theInt << ", " << a.theDouble << ")" << std::endl; + std::cout << "b = (0x" << b.theInt << ", " << b.theDouble << ")" << std::endl; + std::cout << std::setbase(10); + + std::cout << mem.hexDump() << std::endl; + + return 0; +} + + + + + + + + + + + diff --git a/02_MENT/typedMemory/typedMemory/typedMemory.cpp b/02_MENT/typedMemory/typedMemory/typedMemory.cpp new file mode 100644 index 0000000..ab70999 --- /dev/null +++ b/02_MENT/typedMemory/typedMemory/typedMemory.cpp @@ -0,0 +1,104 @@ +// typedMemory.cpp + +#include "typedMemory.hpp" +#include +#include + + +void TypedMemory::putChar(int position, unsigned char c) +{ + rawMemory[position] = reinterpret_cast(c); +} + +unsigned char TypedMemory::getChar(int position){ + return reinterpret_cast(rawMemory[position]); +} + +void TypedMemory::putUInt(int position, unsigned int i){ + int numBytes = sizeof(i); + unsigned int byteMask = 0xff << ((numBytes-1)*8); + for(int k=0; k> ((numBytes-1-k)*8); + byteMask >>= 8; + } + /* equvalent code for sizeof(unsigned int) == 4: + uint8_t byte_a = (i & 0xff); + uint8_t byte_b = (i & 0xff00) >> 8; + uint8_t byte_c = (i & 0xff0000) >> 16; + uint8_t byte_d = (i & 0xff000000) >> 24; + + rawMemory[position+0] = byte_d; + rawMemory[position+1] = byte_c; + rawMemory[position+2] = byte_b; + rawMemory[position+3] = byte_a; + */ + +} + + +unsigned int TypedMemory::getUInt(int position){ + unsigned int result = 0; + int numBytes = sizeof(result); + for(int i=0; i(&rawMemory[position]); + double * pd = reinterpret_cast(pv); + *pd=d; +} + +double TypedMemory::getDouble(int position){ + void * pv = reinterpret_cast(&rawMemory[position]); + double * pd = reinterpret_cast(pv); + return *pd; +} + +void TypedMemory::putAnything(int position, void* src, int size){ + for (int i=0; i(src)[i]; + } +} + +void TypedMemory::getAnything(int position, void* dest, int size){ + for (int i=0; i(dest)[i] = rawMemory[position+i]; + } +} + + +std::string TypedMemory::hexDump(){ + std::string result; + std::string printables; + std::ostringstream os; + + os << std::setbase(16); + int i=0; + while(i(rawMemory[i]); + os << " "; + if(std::isprint(rawMemory[i])){ + printables += static_cast(rawMemory[i]); + }else{ + printables += '.'; + } + i++; + } + os << printables << std::endl; + printables = ""; + } + + os << std::setbase(10); + result = os.str(); + return result; +} diff --git a/02_MENT/typedMemory/typedMemory/typedMemory.hpp b/02_MENT/typedMemory/typedMemory/typedMemory.hpp new file mode 100644 index 0000000..6e23d4c --- /dev/null +++ b/02_MENT/typedMemory/typedMemory/typedMemory.hpp @@ -0,0 +1,25 @@ +// typedMemory.hpp + +#ifndef typedMemory_hpp +#define typedMemory_hpp +#include +#include + +struct TypedMemory { + static const int RAWMEMORYSIZE=128;//1024; + uint8_t rawMemory[RAWMEMORYSIZE]; + + void putChar(int position, unsigned char c); // position in bytes starting at 0 + unsigned char getChar(int position); + // void putShort(int position); + // char getShort(int position); + void putUInt(int position, unsigned int i); + unsigned int getUInt(int position); + void putDouble(int position, double d); + double getDouble(int position); + void putAnything(int position, void* src, int size); + void getAnything(int position, void* dest, int size); + std::string hexDump(); +}; + +#endif diff --git a/03_FLOW_a/build.sh b/03_FLOW_a/build.sh new file mode 100644 index 0000000..9093d33 --- /dev/null +++ b/03_FLOW_a/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +clang++ -std=c++14 -I ../helpers -o flow.out main_mp2_FLOW_a.cpp ../helpers/AnsiConsole.cpp diff --git a/03_FLOW_a/main_mp2_FLOW_a.cpp b/03_FLOW_a/main_mp2_FLOW_a.cpp new file mode 100644 index 0000000..dd18cd6 --- /dev/null +++ b/03_FLOW_a/main_mp2_FLOW_a.cpp @@ -0,0 +1,137 @@ +#include /* file main_mp2_FLOW_a.cpp */ +#include "AnsiConsole.h" + +AnsiConsole console; int firstLine; int currentTick; Colors currentColor; +#define INITPRINT(label) {firstLine=__LINE__;console.printText(2*currentTick,0,label,Colors::BLACK);} +#define PRINT printLineNumber(__LINE__) +void printLineNumber(int lineNumber); + +void recurse(int); // forward declaration because of firstLine initialization +void start_Recursion(){ + INITPRINT("Recursion"); + PRINT;recurse(10); + PRINT; +} +void recurse(int turns){ + PRINT; if(turns>0){ + PRINT; recurse(turns - 1); + } + PRINT; +} + + + + + + + + + +void start_Sequence(void){ + INITPRINT("Sequence"); + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; +} + + + + + + + +void start_SeqSelection(void){ + INITPRINT("Selection"); + PRINT; int b = 1; + PRINT; if (b == 1){ + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; }else{ + PRINT; + PRINT; + PRINT; + PRINT; + PRINT; + }PRINT; + PRINT; +} + + + +void start_Iteration(void){ + INITPRINT("Iteration"); + PRINT; int i=9; + PRINT; while(i>=0){ + PRINT; i--; + }PRINT; + PRINT; +} + + +int func_1(int arg); + +// Sequence, Selection, Iteration, Subroutine +void start_subroutine(void){ + INITPRINT("Subroutine"); + PRINT; func_1(1); + PRINT; func_1(1); + PRINT; +} + +int func_1(int arg){ + PRINT; int local_1; + PRINT; + PRINT; + PRINT; + PRINT; return arg * local_1; +} + + + + +int main(int argc, const char * argv[]) { + console.clearScreen(); + currentColor = Colors::BLUE; + start_Sequence(); + currentColor = Colors::RED; + start_SeqSelection(); + currentColor = Colors::YELLOW; + start_subroutine(); + currentColor = Colors::GREEN; + start_Iteration(); + currentColor = Colors::CYAN; + start_Recursion(); + + //start_goto(); + //start_switch(); + //start_interrupt(); + //start_coroutine(); + //start_exception(); + std::string s; + std::cin >> s; + + return 0; +} + +void printLineNumber(int lineNumber){ + std::string line = std::to_string(lineNumber); + currentTick++; + console.printText(currentTick*2-1, 1+lineNumber-firstLine, line, currentColor); +} + + +/*void printLineNumber(int lineNumber){ + std::string line = std::to_string(lineNumber); + console.printText(currentTick*2, 1+lineNumber-firstLine, line, currentColor); + currentTick++; +}*/ + diff --git a/03_FLOW_b/build.sh b/03_FLOW_b/build.sh new file mode 100644 index 0000000..844f053 --- /dev/null +++ b/03_FLOW_b/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +clang++ -std=c++14 -o controlFlowIntr main_ISR.cpp diff --git a/03_FLOW_b/controlFlowIntr b/03_FLOW_b/controlFlowIntr new file mode 100644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rn)Zolaw8qA#9x^4WMYpM&`pcn`)? ztT;cACBxd`;NRDid8cF zJ{A~R%5hn5i9Z^-4J97eUn=Z#bA^7F;wQ<*Sjr@O2*(Ng-F{e4I6;_8_F`}oo)(zT zrrb23ia59@T?DwFap<{q!f;0}Yk49*yQ4ER<&rSD6=U@-3( zsgI4~3*l*F55H|7<~^mr!{6Bfh^9?Jg_zFq&yBae~!c&L= z%J_3t_$O6(y%sLZf2In5xeC8rh3Bg9LKVIhmTH!mryi}si7K40!hceQPgY^R0f2tQ zI`HPd67$Bt67#0N62DZ1qfo=%SceBLS9~qYKKlS33=#Rx>%*Y@?t%Bw7zXlf1z!ur z@Z5#xZalw%2cd=ET=4r7T*s>aE8Q`LJ*aAefTL%Q<6J$voF|nd)317Nb1!=rJ4}UG zdHGt}TbQeNsrS6AyjNAS;#MfRmYw7pi(gaKvU@C5Xbu!hjOAyEC4S`wv&1d;&AZ!L zRw!8BRFJoPJ6T~LF|4HxWaX1iY2zsE7^SU(XAkZXR~>_v>`LX@RyvqiJp4F~)t$TF zv8>J=PRC;j&JQyrw{CZwOd;>^Y!gplf5e{qRKZOra6)_cy7xQ#8>syOXz$$a^jB0+ zeQer+HudKFtmS4j;^>r#_sA}fLnADDyXtAwgXZYdT{z? +#include +#include + +volatile int j; + +//extern "C" { +void ISR(int iarg){ + std::cout << "ISR j=" << j << "\n"; +} +//} + +void install_ISR(void){ + signal(SIGUSR1, ISR); +} + +int main(int argc, const char * argv[]) { + std::cout << "process ID = " << getpid() << "\n"; + install_ISR(); + for(int i=0; i<300*1000*1000; i++){ + i= i +10; i-=10; j=i; + } + std::cout << "done.\n"; + return 0; +} + diff --git a/03_FLOW_b/run.sh b/03_FLOW_b/run.sh new file mode 100644 index 0000000..b4b5f7d --- /dev/null +++ b/03_FLOW_b/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash +./controlFlowIntr & +echo $! +sleep 1 +kill -SIGUSR1 $! +sleep 1 +kill -SIGUSR1 $! +kill -SIGUSR1 $! + diff --git a/03_FLOW_c/AP2-dc.cpp b/03_FLOW_c/AP2-dc.cpp new file mode 100644 index 0000000..5a545b3 --- /dev/null +++ b/03_FLOW_c/AP2-dc.cpp @@ -0,0 +1,239 @@ +// based on http://www.stroustrup.com/dc.c +// by Bjarne Stroustrup +// The desk calculator +// pp 107-117, sec 6.1, A Desk calculator +// No guarantees offered. Constructive comments to bs@research.att.com + + +/* + expr_list: + expression PRINT // PRINT is \n + expression PRINT expr_list + + expression: + expression + term + expression - term + term + + term: + term / power + term * power + power + + power: + power # primary // char '^' produces problems with terminal input + primary + + + primary: + NUMBER + ( expression ) + + +while statt for +erweitern um o,i oder HexaDezimal mit &, |, x, + */ + + +#include +#include +#include + +using namespace std; + +int no_of_errors; // note: default initialized to 0 +bool doPrintCalculations = true; + + +unsigned int error(const char* s) +{ + no_of_errors++; + cerr << "error: " << s << '\n'; + return 1; +} + +enum Token_value { + NUMBER, // '0' ... '9' + PLUS='+', MINUS='-', MUL='*', DIV='/', + PRINT='\n', POWER='#', LP='(', RP=')' +}; + +Token_value global_token = PRINT; +unsigned int number_value; + +unsigned int asciToInt(string string_value){ + unsigned int result = 0; + for(size_t i=0; i> number_value; + string string_value; + string_value = ch; + while (cin.get(ch) && isdigit(ch)) + string_value += ch; // string_value.push_back(ch); // to work around library bug + cin.putback(ch); + number_value = asciToInt(string_value); + return global_token=NUMBER; + } + default: + error("bad token"); + return global_token=PRINT; + } +} + + +unsigned int expression(); // cannot do without (indirect recursion) + + +unsigned int primary() // handle primaries +{ + Token_value current_token = get_token(); + + switch (current_token) { + case NUMBER:{ + unsigned int v = number_value; + get_token(); // proceed global_token to next token (i.e. operator or '\n') + return v; + } + case LP:{ + unsigned int e = expression(); + if (global_token != RP) return error(") expected"); + get_token(); // eat ')' in order to proceed global_token to next token + return e; + } + default: + return error("primary expected"); + } +} + +unsigned int power() // 2 ^ 3 +{ + unsigned int left = primary(); + unsigned int right = 0; + + for (;;) + switch (global_token) { + case POWER:{ + right = primary(); + if (doPrintCalculations) printf("%u # %u\n", left, right); + unsigned int base = left; + left = 1; + for (int i=0; i "; + cout << expression() << '\n'; + } + return no_of_errors; +} diff --git a/03_FLOW_c/build.sh b/03_FLOW_c/build.sh new file mode 100644 index 0000000..3674a68 --- /dev/null +++ b/03_FLOW_c/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +clang++ -std=c++14 -o dc.out AP2-dc.cpp diff --git a/04_UDEF/RationalNumber.cpp b/04_UDEF/RationalNumber.cpp new file mode 100644 index 0000000..fe25204 --- /dev/null +++ b/04_UDEF/RationalNumber.cpp @@ -0,0 +1,28 @@ +// file: RationalNumber.cpp +#include "RationalNumber.hpp" + +RationalNumber addRationalNumbers(RationalNumber left, RationalNumber right){ + RationalNumber result; + // add left and right + return result; +} + +RationalNumber operator+ (RationalNumber left, RationalNumber right){ + return addRationalNumbers(left, right); +} + +// for println() +std::string as_string(RationalNumber r){ + std::string result = "("; + result += std::to_string(r.zaehler); + result += "/"; + result += std::to_string(r.nenner); + result += ")"; + return result; +} + +/*std::ostream& operator<< (std::ostream& os, RationalNumber &toBePrinted){ + os << "(" << toBePrinted.zaehler << "/" + << toBePrinted.nenner << ")"; + return os; +}*/ diff --git a/04_UDEF/RationalNumber.hpp b/04_UDEF/RationalNumber.hpp new file mode 100644 index 0000000..160509c --- /dev/null +++ b/04_UDEF/RationalNumber.hpp @@ -0,0 +1,12 @@ +// file: RationalNumber.hpp +#include + +struct RationalNumber{ + int zaehler; + int nenner; +}; + +RationalNumber addRationalNumbers(RationalNumber left, RationalNumber right); +RationalNumber operator+ (RationalNumber left, RationalNumber right); +std::string as_string(RationalNumber); // for println() +//std::ostream& operator<< (std::ostream& os, RationalNumber &toBePrinted); // for cout diff --git a/04_UDEF/main_04_UDEF_a.cpp b/04_UDEF/main_04_UDEF_a.cpp new file mode 100644 index 0000000..92e5cc4 --- /dev/null +++ b/04_UDEF/main_04_UDEF_a.cpp @@ -0,0 +1,40 @@ +// file: main_04_UDEF_a.cpp +#include "../helpers/println.hpp" +#include "RationalNumber.hpp" +#include + +// location 1 + +// this declares an alias for type , which is called calctype +//typedef unsigned int calctype; +//typedef int calctype; +//typedef double calctype; +typedef RationalNumber calctype; + +// location 2 + + +void doCalculation(calctype a, calctype b){ + + calctype c = a + b; + +// here is some advanced computation on arguments a and b +// for(){ ... +// if(){ ... +// for(){ ... + + println("a = ", a); + println("b = ", b); + println("c = ", c); +} + + +int main(int argc, char** argv, char** envp){ + + calctype a; + calctype b; + + doCalculation(a,b); + + return 0; +} diff --git a/04_UDEF/main_04_UDEF_e.cpp b/04_UDEF/main_04_UDEF_e.cpp new file mode 100644 index 0000000..5e97943 --- /dev/null +++ b/04_UDEF/main_04_UDEF_e.cpp @@ -0,0 +1,52 @@ +// file main_04_UDEF_e.cpp +#include "../helpers/println.hpp" +#include + +const int bitsPerOctet=8; + +struct BinaryOctet { + bool evenParity; // set to true if number of '1' in bitsAsDigits is even, false otherwise + char bitsAsDigits[bitsPerOctet]; // bit values as chars + BinaryOctet(int x=0); + BinaryOctet(const BinaryOctet&) = default; +}; + +BinaryOctet::BinaryOctet(int x){ + // TODO: implement +} + + +BinaryOctet doCalculation(BinaryOctet a, BinaryOctet b){ + BinaryOctet result; + + for(; a != b; b--){ + a = a + 1; + a = a / b; + } + result = a + b; + + return result; +} + +// for println(); +std::string as_string(BinaryOctet a){ + std::string result = "("; + // TODO: implement + result += ")"; + return result; +} + +// for std::cout +/*std::ostream& operator<< (std::ostream& os, const BinaryOctet &toBePrinted){ + os << "(" << ")"; + return os; +}*/ + +int main(int argc, char **argv) +{ + BinaryOctet a = 0b00001111; + BinaryOctet b = 0b00000110; + println("result = ", doCalculation(a,b)); + //std::cout << "result = " << doCalculation(a,b) << std::endl; + return 0; +} diff --git a/05_OO/AnsiConsoleDemo.cpp b/05_OO/AnsiConsoleDemo.cpp new file mode 100644 index 0000000..136daf0 --- /dev/null +++ b/05_OO/AnsiConsoleDemo.cpp @@ -0,0 +1,29 @@ +#include +#include +#include "AnsiConsole.h" + +/* + see + https://en.wikipedia.org/wiki/ANSI_escape_code + https://gist.github.com/vratiu/9780109 + https://gist.github.com/RobinMalfait/7881398 + */ + + +int main(int argc, char **argv) +{ + ansiConsole.clearScreen(); + // x=1 and y=1 is the upper left corner + // x and y are more like column and row + ansiConsole.printText(4,4,"Hello, World!"); + + // draw a pixel, sort of + ansiConsole.printText(3,3,"*"); + // draw a line + for(int i=0;i<10;i++){ + ansiConsole.printText(2+i,2,"-", Colors::GREEN); + } + ansiConsole.printText(5,15,"end."); + + return 0; +} diff --git a/05_OO/build.sh b/05_OO/build.sh new file mode 100644 index 0000000..b56fae7 --- /dev/null +++ b/05_OO/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +clang++ -std=c++14 -o shape_main.out -I ../helpers/ shapes_main.cpp ../helpers/AnsiConsole.cpp +clang++ -std=c++14 -o ansiConsole.out -I ../helpers/ AnsiConsoleDemo.cpp ../helpers/AnsiConsole.cpp diff --git a/05_OO/main_mp4_OO_a_vehicles.cpp b/05_OO/main_mp4_OO_a_vehicles.cpp new file mode 100644 index 0000000..9eeac3d --- /dev/null +++ b/05_OO/main_mp4_OO_a_vehicles.cpp @@ -0,0 +1,105 @@ +#include +#include + + +//====================================== + +class Vehicle { +protected: + int _numSeats; +public: + Vehicle(int numSeats=0);// may serve as default ctor (i.e. no arguments) + virtual ~Vehicle(); + virtual int payload() = 0; + int numSeats(); // a 'getter' method to get a value; no 'setter' here +}; + +//====================================== + +class Car : public Vehicle { +protected: + int _maxWeight; // german: zulässiges Gesamtgewicht +public: + Car(int numSeats, int maxWeight); + virtual int payload(); + +}; + +//====================================== + +class Truck : public Vehicle { +protected: + int _payload; +public: + Truck(int numSeats, int payload); + virtual int payload(); +}; + +//====================================== + +Vehicle::Vehicle(int numSeats){ + _numSeats = numSeats; +} + +Vehicle::~Vehicle(){ + std::cout << "destroying a Vehicle" << std::endl; +} + +int Vehicle::numSeats(){ + return _numSeats; +} + +//====================================== + +Car::Car(int numSeats, int maxWeight){ + _numSeats = numSeats; + _maxWeight = maxWeight; +} + +int Car::payload(){ + return _maxWeight - (_numSeats*75); +} + +//====================================== + +Truck::Truck(int numSeats, int payload){ + _numSeats = numSeats; + _payload = payload; +} + +int Truck::payload(){ + return _payload; +} + +//====================================== + + +void printVehicleInfo(Vehicle* v){ + std::cout << "typeid=`" << typeid(*v).name() << "`" + << " numSeats=" << v->numSeats() + << " payload=" << v->payload() << std::endl; +} + +int main(int argc, const char * argv[]) { + + Car* c = new Car(5, 1000); // create a new object of class Car in free store + Truck* t = new Truck(3, 7500); + + std::cout << "1" << std::endl; + std::cout << "c: numSeats=" << c->numSeats() << " payload=" << c->payload() << std::endl; + std::cout << "t: numSeats=" << t->numSeats() << " payload=" << t->payload() << std::endl; + + std::cout << std::endl << "2" << std::endl; + Vehicle* v = c; // a Car `is a` Vehicle => implicitly convertible + printVehicleInfo(v); + v = t; // a Truck `is a` Vehicle => implicitly convertible + printVehicleInfo(v); + + + // release memory occupied by t,c for use by future objects created by `new` + // do NOT release v. it is only an alias + delete t; + delete c; + + return 0; +} diff --git a/05_OO/main_mp4_OO_b.cpp b/05_OO/main_mp4_OO_b.cpp new file mode 100644 index 0000000..25160e8 --- /dev/null +++ b/05_OO/main_mp4_OO_b.cpp @@ -0,0 +1,198 @@ +// file main_mp4_OO_b.cpp +#include +#include + +//======================================= + +struct FooVal { + FooVal(int initialValue=0); + ~FooVal(); +private: + int _someValue; +}; + +//======================================= + +class FooBase { + FooVal _value; +public: + FooBase(); + FooBase(int initialValue); + virtual ~FooBase(); +}; + +//======================================= + +class FooDerived : public FooBase { + int _ival; +public: + FooDerived(int initialValue); + ~FooDerived(); +}; + +//======================================= + +class Bar { + FooBase *_helperObject; +public: + Bar(); + ~Bar(); +}; + +//======================================= + +FooVal::FooVal(int initialValue) +: _someValue(initialValue) +{ + std::cout << "FooVal::FooVal()" << std::endl; +} + +FooVal::~FooVal(){ + std::cout << "FooVal::~FooVal()" << std::endl; +} + +FooBase::FooBase(){ + std::cout << "FooBase::FooBase()" << std::endl; +} + +FooBase::FooBase(int initialValue) +: _value(initialValue) +{ + std::cout << "FooBase::FooBase(int)" << std::endl; +} + +FooBase::~FooBase(){ + std::cout << "FooBase::~FooBase(" << std::endl; +} + +FooDerived::FooDerived(int initialValue) +: FooBase(initialValue), _ival(0) +{ + std::cout << "FooDerived::FooDerived()" << std::endl; +} + +FooDerived::~FooDerived(){ + std::cout << "FooDerived::~FooDerived()" << std::endl; +} + +Bar::Bar(){ + _helperObject = new FooDerived(0); +} + +Bar::~Bar(){ + delete _helperObject; +} + + +struct StackObject { +private: + void* operator new(size_t size) noexcept { + bool noStackObjectOnHeap = false; + assert(noStackObjectOnHeap); + return nullptr; + } +}; + + +struct A : public StackObject { + A(){std::cout << "+A ";} + //A(const A&){std::cout << "+A";} + ~A(){std::cout << "-A ";} +}; + +struct B : public StackObject { + B(){std::cout << "+B ";} + //B(const B&){std::cout << "+B";} + ~B(){std::cout << "-B ";} +}; + + +struct C : public StackObject { + C(){std::cout << "+C ";} + //C(const C&){std::cout << "+C";} + ~C(){std::cout << "-C ";} +}; + +class HeapObject{ +public: + void* operator new (size_t size); + HeapObject(); + virtual ~HeapObject(); + static bool assertionsHold(); +protected: +private: + static int ctorCount; + static int dtorCount; + static int newCount; + // static void remove(HeapObject *); + HeapObject(const HeapObject&) = delete; + HeapObject& operator=(const HeapObject&) = delete; +}; + +int HeapObject::ctorCount = 0; +int HeapObject::dtorCount = 0; +int HeapObject::newCount = 0; + +void* HeapObject::operator new (size_t size){ + newCount++; + return new char[size]; +} + +HeapObject::HeapObject(){ + ctorCount++; +} + +HeapObject::~HeapObject(){ + dtorCount++; +} + +bool HeapObject::assertionsHold(){ + assert(ctorCount == newCount); // all objects have been allocated on heap + assert(ctorCount == dtorCount); // all objects have been deleted + return true; +} + + +class K : public HeapObject +{ +public: + K(){std::cout << "+K ";} + ~K(){std::cout << "-K ";} +}; + +class L { +public: + L(){std::cout << "+L ";} + ~L(){std::cout << "-L ";} +}; + + +class M { +public: + M(){std::cout << "+M ";} + ~M(){std::cout << "-M ";} +}; + + + +int main(int argc, const char * argv[]) { + Bar * bar = new Bar(); + // ... + delete bar; // implies "delete _helperObject"; + + FooBase *obj = new FooDerived(7); + delete obj; + + { + C c; + K* k = new K(); + delete k; + } + + HeapObject::assertionsHold(); + std::cout << " ENDE" << std::endl; + return 0; +} + + + diff --git a/05_OO/shapes_main.cpp b/05_OO/shapes_main.cpp new file mode 100644 index 0000000..fc7b247 --- /dev/null +++ b/05_OO/shapes_main.cpp @@ -0,0 +1,87 @@ +#include +#include +#include "AnsiConsole.h" + +struct Position{ + int x; + int y; + Position(int x_=0, int y_=0){ x=x_;y=y_;} +}; + +class Point{ +protected: + Position _position; +public: + Point(int x=0, int y=0); + void draw(); +}; + +Point::Point(int x, int y){ + _position = Position(x,y); +} + +void Point::draw(){ + ansiConsole.printText(_position.x,_position.y,"*", Colors::RED); +} + +class Circle{ +protected: + Position _position; + int _radius; +public: + Circle(int x=0, int y=0, int radius=0); + void draw(); +}; + +Circle::Circle(int x, int y, int radius){ + _position = Position(x,y); + _radius=radius; +} + +void Circle::draw(){ + /* see https://de.wikibooks.org/wiki/Formelsammlung_Mathematik:_Geometrie + * Höhensatz des Euklid + * */ + int x_start = _position.x - _radius/2; + int x_stop = _position.x + _radius/2; + + for(int i=x_start; i<=x_stop; i++){ + double x_relative = double(i) - double(x_start); + double h = sqrt(x_relative*(x_stop-x_start-x_relative)); + ansiConsole.printText(_position.x + int(x_relative)- _radius/2, + _position.y +h,"#", + Colors::GREEN); + ansiConsole.printText(_position.x + int(x_relative)- _radius/2, + _position.y -h,"#", + Colors::GREEN); + + } +} + +int main(int argc, char **argv) +{ + // x=1 and y=1 is the upper left corner + // x and y are more like column and row + ansiConsole.printText(5,5,"Hello, World!"); + + Point* p = new Point(10,10); + p->draw(); + + Point* p2 = new Point(2,10); + p2->draw(); + + + Circle* c = new Circle(30, 15, 10); + c->draw(); + + Point* p3= new Point(30,15); + p3->draw(); + + + delete p; + delete p2; + delete p3; + delete c; + + return 0; +} diff --git a/06_POLY/main_mp5_POLY.cpp b/06_POLY/main_mp5_POLY.cpp new file mode 100644 index 0000000..0fc6517 --- /dev/null +++ b/06_POLY/main_mp5_POLY.cpp @@ -0,0 +1,281 @@ +// file main_mp5_POLY.cpp +#include +#include + +class Base { +public: + void overriddenMethod(); + void overriddenMethod(int); + void overriddenMethod(std::string); + void nonVirtualMethod(void); + virtual void virtualMethod(void); + /* + virtual void virtualAndOverridden(void); + virtual void virtualAndOverridden(int); + virtual void virtualAndOverridden(std::string);*/ +}; + +class Derived_1 : public Base { +public: + Derived_1(); + ~Derived_1(); + void nonVirtualMethod(void); + virtual void virtualMethod(void); + +/* virtual void virtualAndOverridden(void); + virtual void virtualAndOverridden(int); + virtual void virtualAndOverridden(std::string);*/ +}; + +class Derived_2 : public Derived_1 { +public: + void nonVirtualMethod(void); + virtual void virtualMethod(void); +}; + +// see https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors +Derived_1::Derived_1(){ + virtualMethod(); // 6a +} + +Derived_1::~Derived_1(){ + virtualMethod(); // 6b +} + +// ------------------- +void Base::overriddenMethod(void){ + std::cout << "Base::overriddenMethod(void)" << std::endl; +} + +void Base::overriddenMethod(int){ + std::cout << "Base::overriddenMethod(int)" << std::endl; +} + +void Base::overriddenMethod(std::string){ + std::cout << "Base::overriddenMethod(std::string)" << std::endl; +} + +void Base::nonVirtualMethod(void){ + std::cout << "Base::nonVirtualMethod(void)" << std::endl; +} + +void Base::virtualMethod(void){ + std::cout << "Base::virtualMethod" << std::endl; +} + + +/* +void Base::virtualAndOverridden(void){ + std::cout << "Base::virtualAndOverridden(void)" << std::endl; +} + +void Base::virtualAndOverridden(int){ + std::cout << "Base::virtualAndOverridden(int)" << std::endl; +} + +void Base::virtualAndOverridden(std::string){ + std::cout << "Base::virtualAndOverridden(std::string)" << std::endl; +} +*/ + +// ------------------- +void Derived_1::nonVirtualMethod(void){ + std::cout << "Derived_1::nonVirtualMethod" << std::endl; +} +void Derived_1::virtualMethod(void){ + std::cout << "Derived_1::virtualMethod" << std::endl; +} + + +/* +void Derived_1::virtualAndOverridden(void){ + std::cout << "Derived_1::virtualAndOverridden(void)" << std::endl; +} + +void Derived_1::virtualAndOverridden(int){ + std::cout << "Derived_1::virtualAndOverridden(int)" << std::endl; +} + +void Derived_1::virtualAndOverridden(std::string){ + std::cout << "Derived_1::virtualAndOverridden(std::string)" << std::endl; +} +*/ + + +// ------------------- +void Derived_2::nonVirtualMethod(void){ + std::cout << "Derived_2::nonVirtualMethod" << std::endl; +} +void Derived_2::virtualMethod(void){ + std::cout << "Derived_2::virtualMethod" << std::endl; +} + + + +/* + illustrates binding of method invocations + compile time vs. run time binding + */ + +void foobar(void){ + + std::cout << "6a) "; + Derived_2* pR = new Derived_2(); + + Base* pBase = pR; + Derived_1* pDerived_1 = pR; + Derived_2* pDerived_2 = pR; + + std::cout << "1) "; + pBase->virtualMethod(); // 1) + + std::cout << "2) "; + pBase->nonVirtualMethod(); // 2) + + std::cout << "3) "; + pDerived_2->virtualMethod(); // 3) + + std::cout << "4) "; + pDerived_2->nonVirtualMethod(); // 4) + + std::cout << "5) "; + static_cast(pDerived_2)->nonVirtualMethod(); // 5) + + std::cout << "7) "; + static_cast(pDerived_2)->nonVirtualMethod(); // 7) + + std::cout << "8) "; + pDerived_1->nonVirtualMethod(); // 8) + + std::cout << "9) "; + pDerived_1->virtualMethod(); // 9) + + std::cout << "10a) "; + pBase->Base::virtualMethod(); // 10a) + + std::cout << "10b) "; + pDerived_2->Derived_1::virtualMethod(); // 10b) + + std::cout << "11 "; + pDerived_2->overriddenMethod(17); // 11) + + std::cout << "12 "; + pDerived_2->overriddenMethod(); // 12) + + std::cout << "13 "; + pDerived_2->overriddenMethod(std::string("x")); // 13) + + std::cout << "14 "; + dynamic_cast(pBase)->virtualMethod(); // 14) + + std::cout << "15 "; + Base* baseObject = new Base(); + Derived_2* d2Object = dynamic_cast(baseObject); + if(d2Object){ // 15) + std::cout << "+" << std::endl; + }else{ + std::cout << "-" << std::endl; + } + + /* + std::cout << "16 "; + pDerived_2->virtualAndOverridden(17); // 16) + + std::cout << "17 "; + pDerived_2->virtualAndOverridden(); // 17) + + std::cout << "18 "; + pDerived_2->virtualAndOverridden(std::string("x")); // 18) + */ + + + std::cout << "6b) "; + delete pR; +} + +/* + void foo(){ + for(int i=0; inonVirtualMethod2(); + delete ps; + } + } + + void bar(int i){ + Base s; + s.nonVirtualMethod2(); + if(i>0){ + bar(i-1); + } + }*/ + +typedef void (*funcPointer_void_void)(void); + +void sing_gingle(void){ + std::cout << "gingle "; +} + +void sing_bells(void){ + std::cout << "bells "; +} + +void sing_surf(void){ + std::cout << "surf "; +} + +void sing_safari(void){ + std::cout << "surfin safari "; +} + +std::vector songOfSeason(int currentTemperatureCelsius) { + std::vector result; + + if(currentTemperatureCelsius <= 0){ + result.push_back(sing_gingle); + result.push_back(sing_bells); + result.push_back(sing_gingle); + result.push_back(sing_bells); + }else{ + result.push_back(sing_surf); + result.push_back(sing_surf); + result.push_back(sing_safari); + result.push_back(sing_surf); + result.push_back(sing_surf); + result.push_back(sing_safari); + } + + return result; +} + +void sing(int currentTemperatureCelsius){ + std::vector song = songOfSeason(currentTemperatureCelsius); + + // traditional C-style for-loop + for(int i=0; i + +// good: encapsulation +// good: separation of interface and implementation +// good: arbitrary element type +// good: arbitrary capacity +// bad: implementation in .hpp +// bad: compiler error messages are difficult to read + +template +struct genericStack { + int tos; // top of stack, i.e. index of next write/push + ElementType elements[capacity]; +public: + genericStack(); + void push(ElementType element); + ElementType pop(); + int size(); // number of elements pushed + bool isEmpty(); + void clear(); + void print(); +}; + + +// ============= implementation ============= + +template +genericStack::genericStack() +: tos(0) +{ + +} + +template +void genericStack::push(ElementType element){ + elements[tos++] = element; +} + +template +ElementType genericStack::pop(){ + return elements[--tos]; +} + +template +int genericStack::size(){ // number of elements pushed + return tos; +} + +template +bool genericStack::isEmpty(){ + return tos == 0; +} + +template +void genericStack::clear(){ + tos = 0; +} + +template +void genericStack::print(){ + std::cout << size() << " of " << capacity << " allocated." << std::endl; + for (int i=0; i + +const int intStack::capacity; + +intStack::intStack() +: tos(0) +{ + +} + +void intStack::push(int element){ + elements[tos++] = element; +} + +int intStack::pop(){ + return elements[--tos]; +} + +int intStack::size(){ // number of elements pushed + return tos; +} + +bool intStack::isEmpty(){ + return tos == 0; +} + +void intStack::clear(){ + tos = 0; +} + +void intStack::print(){ + std::cout << size() << " of " << capacity << " allocated." << std::endl; + for (int i=0; i +#include "intStack.hpp" +#include "genericStack.hpp" +#include +#include + + +void use_intStack(){ + intStack s_1; + for(int i=0; i<10;i++){ + s_1.push(i*i); + } + std::cout << "s_1 : " << std::endl; + s_1.print(); + // replace top element by 4711: + s_1.pop(); + s_1.push(4711); + // swap topmost two elements: + int tmp1 = s_1.pop(); + int tmp2 = s_1.pop(); + s_1.push(tmp1); + s_1.push(tmp2); + std::cout << "draining s_1 : " << std::endl; + while(!s_1.isEmpty()){ + std::cout << s_1.pop() << std::endl; + } +} + + +void use_genericStack(){ + genericStack s_2; + genericStack s_3; + for(int i=0; i<10;i++){ + s_2.push(i*i); + s_3.push(i*i * 1.1); + } + s_2.print(); + s_3.print(); +} + +void use_std_containers(){ + std::vector v; + v.push_back(17); // append an element at the end + int i = v.back(); // get last element + int j = v[0]; // access by subscript operator + if ((i==j) && (i==17)){ // + v.pop_back(); // remove last element + v.clear(); // remove all elements + } + long s = v.size(); // get size; size() <= max_size() + std::list l; + l.push_back(17); // append an element at the end + l.push_front(s); // put an element in front of the list +} + +void printVector(const std::vector& v){ + for(int j=0; j v(100); + for(int i=0; i<10; i++){ + v[i*i] = i; + } + v.push_back(17); + printVector(v); + std::sort(v.begin(), v.end()); + printVector(v); + std::transform(v.begin(), v.end(), v.begin(), + [](int i) { return i*10; }); // use lambda expression here + printVector(v); +} + +int main(int argc, const char * argv[]) { + std::cout << "use_intStack()" << std::endl; + std::cout << "--------------" << std::endl; + use_intStack(); + std::cout << "use_genericStack()" << std::endl; + std::cout << "------------------" << std::endl; + use_genericStack(); + + std::cout << "use_std_containers()" << std::endl; + std::cout << "------------------" << std::endl; + use_std_containers(); + std::cout << "use_std_algorithms()" << std::endl; + std::cout << "------------------" << std::endl; + use_std_algorithms(); + + return 0; +} diff --git a/07_STD/grundgeruest.cpp b/07_STD/grundgeruest.cpp new file mode 100644 index 0000000..b969ed8 --- /dev/null +++ b/07_STD/grundgeruest.cpp @@ -0,0 +1,17 @@ +// based on example from http://en.cppreference.com/w/cpp/numeric/random/rand +#include +#include +#include + +struct BinaryOctet { + bool evenParity; + char bitsAsDigits[bitsPerOctet]; +}; + +int main() +{ + std::srand(std::time(0)); // use current time as seed for random generator + int random_variable = std::rand(); + std::cout << "Random value on [0 " << RAND_MAX << "]: " + << random_variable << '\n'; +} diff --git a/08_PTRN/Car.cpp b/08_PTRN/Car.cpp new file mode 100644 index 0000000..d787391 --- /dev/null +++ b/08_PTRN/Car.cpp @@ -0,0 +1,19 @@ +#include "Car.hpp" + +Car::Car(std::string model, int maxWeight) +: Vehicle(model) +{ + _maxWeight = maxWeight; +} + +int Car::maxWeight(){ + return _maxWeight; +} + +int Car::payload_kg(){ + return _maxWeight - 75 * 5; // subtract weight of passangers +} + +Vehicle* Car::clone(){ + return new Car(model(), _maxWeight); +} diff --git a/08_PTRN/Car.hpp b/08_PTRN/Car.hpp new file mode 100644 index 0000000..ad92b28 --- /dev/null +++ b/08_PTRN/Car.hpp @@ -0,0 +1,18 @@ +#ifndef Car_hpp +#define Car_hpp + +#include "Vehicle.hpp" + + +class Car : public Vehicle { + int _maxWeight; +public: + Car(std::string model, int maxWeight); + int maxWeight(); + virtual int payload_kg(); + virtual Vehicle* clone(); + //virtual Vehicle* newInstance(); +}; + + +#endif diff --git a/08_PTRN/Logger.cpp b/08_PTRN/Logger.cpp new file mode 100644 index 0000000..29df18d --- /dev/null +++ b/08_PTRN/Logger.cpp @@ -0,0 +1,15 @@ +// file Logger.cpp +#include "Logger.hpp" + +Logger* Logger::_theInstance = nullptr; + +Logger* Logger::getInstance(){ + if (!_theInstance){ + _theInstance = new StdoutLogger(); + } + return _theInstance; +} + +void StdoutLogger::log(std::string message, std::string file, int line){ + std::cerr << message << " in " << file << " line " << line << std::endl; +} diff --git a/08_PTRN/Logger.hpp b/08_PTRN/Logger.hpp new file mode 100644 index 0000000..9b3006c --- /dev/null +++ b/08_PTRN/Logger.hpp @@ -0,0 +1,19 @@ +// file Logger.hpp +#ifndef Logger_hpp +#define Logger_hpp + +#include + +class Logger { + static Logger* _theInstance; +public: + virtual void log(std::string message, std::string file="", int line=0) = 0; + static Logger* getInstance(); +}; + +class StdoutLogger: public Logger { +public: + void log(std::string message, std::string file="", int line=0); +}; + +#endif diff --git a/08_PTRN/Truck.cpp b/08_PTRN/Truck.cpp new file mode 100644 index 0000000..4a2ce96 --- /dev/null +++ b/08_PTRN/Truck.cpp @@ -0,0 +1,16 @@ +#include "Truck.hpp" + +Truck::Truck(std::string model, int payload_kg) +: Vehicle(model) +{ + _payload_kg = payload_kg; +} + +int Truck::payload_kg(){ + return _payload_kg; +} + + +Vehicle* Truck::clone(){ + return new Truck(model(),_payload_kg); +} diff --git a/08_PTRN/Truck.hpp b/08_PTRN/Truck.hpp new file mode 100644 index 0000000..0e3ea26 --- /dev/null +++ b/08_PTRN/Truck.hpp @@ -0,0 +1,17 @@ +#ifndef Truck_hpp +#define Truck_hpp + +#include "Vehicle.hpp" + + +class Truck : public Vehicle { + int _payload_kg; // max number kilograms to load +public: + Truck(std::string model, int payload_kg); + virtual int payload_kg(); + virtual Vehicle* clone(); + //virtual Vehicle* newInstance(); +}; + +#endif + diff --git a/08_PTRN/Vehicle.cpp b/08_PTRN/Vehicle.cpp new file mode 100644 index 0000000..c4b73d7 --- /dev/null +++ b/08_PTRN/Vehicle.cpp @@ -0,0 +1,15 @@ +#include "Vehicle.hpp" + +Vehicle::Vehicle(std::string model){ + this->_model = model; +} + +Vehicle::~Vehicle(){ +} + +std::string Vehicle::model(){ + return _model; +} + + + diff --git a/08_PTRN/Vehicle.hpp b/08_PTRN/Vehicle.hpp new file mode 100644 index 0000000..350940e --- /dev/null +++ b/08_PTRN/Vehicle.hpp @@ -0,0 +1,18 @@ +#ifndef Vehicle_hpp +#define Vehicle_hpp + +#include + +class Vehicle { + std::string _model; +public: + Vehicle(std::string model); + virtual ~Vehicle(); + std::string model(); + virtual int payload_kg() = 0; + virtual Vehicle* clone() {return nullptr;} // idiom "virtual constructor" + //virtual Vehicle* newInstance() = 0; // idiom "virtual constructor" +}; + + +#endif diff --git a/08_PTRN/VehicleFactory.cpp b/08_PTRN/VehicleFactory.cpp new file mode 100644 index 0000000..e0bc75f --- /dev/null +++ b/08_PTRN/VehicleFactory.cpp @@ -0,0 +1,19 @@ +// file VehicleFactory.cpp +#include "VehicleFactory.hpp" +#include "Car.hpp" +#include "Truck.hpp" + +/* + A factory creates objects based un runtime information + a) within the process (data values, Types i.e.e virtual methods) + b) input from files or user input + Th is simple Factory differentiates only based on a value. + */ +Vehicle* vehicleForPayload(std::string model, int weight){ + if (weight < 3500){ + return new Car(model, weight); + }else{ + return new Truck(model, weight); + } +} + diff --git a/08_PTRN/VehicleFactory.hpp b/08_PTRN/VehicleFactory.hpp new file mode 100644 index 0000000..d568cd7 --- /dev/null +++ b/08_PTRN/VehicleFactory.hpp @@ -0,0 +1,10 @@ +// file VehicleFactory.hpp +#ifndef VehicleFactory_hpp +#define VehicleFactory_hpp + +#include "Vehicle.hpp" + +Vehicle* vehicleForPayload(std::string model, int weight); + + +#endif diff --git a/08_PTRN/main.cpp b/08_PTRN/main.cpp new file mode 100644 index 0000000..bcbed14 --- /dev/null +++ b/08_PTRN/main.cpp @@ -0,0 +1,71 @@ +#include "Car.hpp" +#include "Truck.hpp" +#include "Logger.hpp" +#include "VehicleFactory.hpp" + +#include +#include + +void workOnCopy_naive(std::vector vehicles){ + std::vector tempVec; + for (int i=0; i(currentVehicle); // RTTI type check + Truck* truckToCopy = dynamic_cast(currentVehicle);// may be nullptr + if(carToCopy){ + tempVec.push_back(new Car(carToCopy->model(), carToCopy->maxWeight())); // type dependency to Car + }else if(truckToCopy){ + tempVec.push_back(new Truck(truckToCopy->model(), truckToCopy->payload_kg())); // type dependecy + }else{ + // TODO: what do we do here? + // Did someone add a new class to the code base? + return; // BUG: copies aren't free'd + } + } + // work on copies ... + // ... + for(auto vehi : tempVec){ + std::cout << vehi->model() << " " << vehi->payload_kg() << " kg" << std::endl; + } + for (int i=0; i vehicles){ // uses RAII, virtual ctor + + class RAIIvector { // local RAII helper class + public: + std::vector tempVec; + ~RAIIvector(){ + for(auto vehi : tempVec){ + delete vehi; + } + tempVec.clear(); + } + }; + RAIIvector rv; + + for(auto vehi : vehicles){ + rv.tempVec.push_back(vehi->clone()); + } + // work on copies ... + // ... + for(auto vehi : rv.tempVec){ + std::cout << vehi->model() << " " << vehi->payload_kg() << " kg" << std::endl; + } + // compiler WILL invoke RAIIvector::~RAIIvector() here +} + + +int main(int argc, const char * argv[]) { + std::vector vehicles; + vehicles.push_back(vehicleForPayload("Volkswagen Golf", 900)); // use factory for construction + vehicles.push_back(vehicleForPayload("Magirus Deutz", 18*1000)); + Logger::getInstance()->log("work naively", __FILE__, __LINE__); + workOnCopy_naive(vehicles); + Logger::getInstance()->log("work smartly", __FILE__, __LINE__); + workOnCopy_smart(vehicles); + return 0; +} diff --git a/10_PITF/banking_base_rawptr.cpp b/10_PITF/banking_base_rawptr.cpp new file mode 100644 index 0000000..94adf9d --- /dev/null +++ b/10_PITF/banking_base_rawptr.cpp @@ -0,0 +1,121 @@ +#include +#include +#include +#include "println.hpp" + + +struct StackObject { +private: + void* operator new(size_t size) noexcept { + bool noStackObjectOnHeap = false; + assert(noStackObjectOnHeap); + return nullptr; + } +}; + + +class HeapObject{ +public: + void* operator new (size_t size); + HeapObject(); + virtual ~HeapObject(); + static bool assertionsHold(); +protected: +private: + static int ctorCount; + static int dtorCount; + static int newCount; + // static void remove(HeapObject *); + HeapObject(const HeapObject&) = delete; + HeapObject& operator=(const HeapObject&) = delete; +}; + +int HeapObject::ctorCount = 0; +int HeapObject::dtorCount = 0; +int HeapObject::newCount = 0; + +void* HeapObject::operator new (size_t size){ + newCount++; + return new char[size]; +} + +HeapObject::HeapObject(){ + ctorCount++; +} + +HeapObject::~HeapObject(){ + dtorCount++; +} + +bool HeapObject::assertionsHold(){ + assert(ctorCount == newCount); // all objects have been allocated on heap + assert(ctorCount == dtorCount); // all objects have been deleted + return true; +} + +typedef double MoneyUnitType; // should be fixed point class + +class Cash : public HeapObject { +public: + MoneyUnitType _value; + Cash(MoneyUnitType value) : _value(value){} +}; + +typedef std::vector Wallet; + +Wallet consumerWallet_A; +Wallet consumerWallet_B; + +Cash * createCashFor(int i){ + return new Cash(static_cast(i)); +} + +void flushWallet(Wallet& toBeEmptied){ // should be in dtor of sorrounding class + for(int i=0; i + +LifeCycleProbe::LifeCycleProbe(){ + this->id=0; + std::cout << "default ctor id=" << id << std::endl; +#ifdef HAS_RESOURCE_POINTER + resource = new int; +#endif +} + +LifeCycleProbe::LifeCycleProbe(int id){ + this->id=id; + std::cout << "ctor(int) id=" << id << std::endl; +#ifdef HAS_RESOURCE_POINTER + resource = new int; +#endif +} + + +LifeCycleProbe::LifeCycleProbe(const LifeCycleProbe& other){ + std::cout << "copy ctor (source id=" << other.id + << " to id=" << other.id + 9 << ")" << std::endl; + this->id=other.id + 9; +#ifdef HAS_RESOURCE_POINTER + this->resource = other.resource; +#endif +} + +LifeCycleProbe& LifeCycleProbe::operator=(const LifeCycleProbe& other){ + std::cout << "assignment (old id=" << this->id + << " source id=" << other.id + << " new id=" << other.id + 11 << ")" << std::endl; + this->id = other.id + 11; + return *this; +} + + +LifeCycleProbe::~LifeCycleProbe(){ + std::cout << "dtor id=" << id << std::endl; +#ifdef HAS_RESOURCE_POINTER + std::cout << "deleting resource" << *resource << std::endl; + delete resource; +#endif +} + +void LifeCycleProbe::printID(){ + std::cout << "printID() id=" << id << std::endl; +} + + diff --git a/10_PITF/doubleDelete/LifeCycleProbe.hpp b/10_PITF/doubleDelete/LifeCycleProbe.hpp new file mode 100644 index 0000000..c5accda --- /dev/null +++ b/10_PITF/doubleDelete/LifeCycleProbe.hpp @@ -0,0 +1,23 @@ +// LifeCycleProbe.hpp +// DoubleDelete + +#ifndef LifeCycleProbe_hpp +#define LifeCycleProbe_hpp + +//#define HAS_RESOURCE_POINTER + +class LifeCycleProbe { + int id; +#ifdef HAS_RESOURCE_POINTER + int *resource; +#endif +public: + LifeCycleProbe(); + LifeCycleProbe(int id); + LifeCycleProbe(const LifeCycleProbe&); + LifeCycleProbe& operator=(const LifeCycleProbe&); + ~LifeCycleProbe(); + void printID(); +}; + +#endif diff --git a/10_PITF/doubleDelete/main.cpp b/10_PITF/doubleDelete/main.cpp new file mode 100644 index 0000000..02bd943 --- /dev/null +++ b/10_PITF/doubleDelete/main.cpp @@ -0,0 +1,38 @@ +// main.cpp +// DoubleDelete + + +#include "LifeCycleProbe.hpp" +#include + +void callByPointer(LifeCycleProbe* p){ + p->printID(); +} + +void callByReference(LifeCycleProbe& r){ + r.printID(); +} + +void callByValue(LifeCycleProbe v){ + v.printID(); +} + +int main(int argc, const char * argv[]) { + + LifeCycleProbe probe(1000); + + std::cout << "three invocations ===========" << std::endl; + callByPointer(&probe); + callByReference(probe); + callByValue(probe); + + { + std::cout << "assigment ===========" << std::endl; + LifeCycleProbe blockProbe(2000); + blockProbe = probe; + blockProbe.printID(); + } + + std::cout << "The End. ===========" << std::endl; + return 0; +} diff --git a/10_PITF/main_objectSlicing.cpp b/10_PITF/main_objectSlicing.cpp new file mode 100644 index 0000000..c48a868 --- /dev/null +++ b/10_PITF/main_objectSlicing.cpp @@ -0,0 +1,67 @@ +// main.cpp +// objectSlicing + +#include +#include + +class Base{ + int _a; +public: + Base(){} + virtual ~Base() {} + Base(int aa) :_a(aa) {} + int value_a(); + virtual int value_virtual(); +}; + +int Base::value_a(){ + return _a; +} + +int Base::value_virtual(){ + return _a; +} + +class Derived : public Base { + int _b; +public: + Derived(int x, int y) : Base(x), _b(y) {} + virtual int value_virtual(); +}; + +int Derived::value_virtual(){ + return _b; +} + +void passByPointer(Base* bp){ + std::cout << "->value_a() = " << bp->value_a() << std::endl; + std::cout << "->value_virtual() = " << bp->value_virtual() << std::endl; +} + +void passByValue(Base b){ + std::cout << ".value_a() = " << b.value_a() << std::endl; + std::cout << ".value_virtual() = " << b.value_virtual() << std::endl; +} + +int main(int argc, const char * argv[]) { + Derived d(1,2); + + std::cout << "d.value_virtual() = " << d.value_virtual() << std::endl; + + std::cout << std::endl << "pass pointer to base class " << std::endl; + passByPointer(&d); // pass pointer to base class + + std::cout << std::endl << "pass by value (i.e. object of class Base) " << std::endl; + passByValue(d); // pass Base-object by value -> object slicing: d is "transformed" int an object of class Base + + std::cout << std::endl << "store Derived objects in std::vector" << std::endl; + std::vector v; + v.push_back(d); // object slicing + std::cout << ".value_a() = " << v[0].value_a() << std::endl; + std::cout << ".value_virtual() = " << v[0].value_virtual() << std::endl; + + return 0; +} + + + diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.pbxproj b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.pbxproj new file mode 100644 index 0000000..14d1bd8 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.pbxproj @@ -0,0 +1,245 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 65413E911CEB65E5008BE849 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65413E901CEB65E5008BE849 /* main.cpp */; }; + 65413E991CEB6612008BE849 /* OneByOneMatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 65413E8B1CEB65E5008BE849 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 65413E8D1CEB65E5008BE849 /* CopyOnWrite */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CopyOnWrite; sourceTree = BUILT_PRODUCTS_DIR; }; + 65413E901CEB65E5008BE849 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OneByOneMatrix.cpp; sourceTree = ""; }; + 65413E981CEB6612008BE849 /* OneByOneMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneByOneMatrix.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 65413E8A1CEB65E5008BE849 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 65413E841CEB65E5008BE849 = { + isa = PBXGroup; + children = ( + 65413E8F1CEB65E5008BE849 /* CopyOnWrite */, + 65413E8E1CEB65E5008BE849 /* Products */, + ); + sourceTree = ""; + }; + 65413E8E1CEB65E5008BE849 /* Products */ = { + isa = PBXGroup; + children = ( + 65413E8D1CEB65E5008BE849 /* CopyOnWrite */, + ); + name = Products; + sourceTree = ""; + }; + 65413E8F1CEB65E5008BE849 /* CopyOnWrite */ = { + isa = PBXGroup; + children = ( + 65413E901CEB65E5008BE849 /* main.cpp */, + 65413E971CEB6612008BE849 /* OneByOneMatrix.cpp */, + 65413E981CEB6612008BE849 /* OneByOneMatrix.h */, + ); + path = CopyOnWrite; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 65413E8C1CEB65E5008BE849 /* CopyOnWrite */ = { + isa = PBXNativeTarget; + buildConfigurationList = 65413E941CEB65E5008BE849 /* Build configuration list for PBXNativeTarget "CopyOnWrite" */; + buildPhases = ( + 65413E891CEB65E5008BE849 /* Sources */, + 65413E8A1CEB65E5008BE849 /* Frameworks */, + 65413E8B1CEB65E5008BE849 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CopyOnWrite; + productName = CopyOnWrite; + productReference = 65413E8D1CEB65E5008BE849 /* CopyOnWrite */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 65413E851CEB65E5008BE849 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0620; + ORGANIZATIONNAME = HSEL; + TargetAttributes = { + 65413E8C1CEB65E5008BE849 = { + CreatedOnToolsVersion = 6.2; + }; + }; + }; + buildConfigurationList = 65413E881CEB65E5008BE849 /* Build configuration list for PBXProject "CopyOnWrite" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 65413E841CEB65E5008BE849; + productRefGroup = 65413E8E1CEB65E5008BE849 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 65413E8C1CEB65E5008BE849 /* CopyOnWrite */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 65413E891CEB65E5008BE849 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 65413E911CEB65E5008BE849 /* main.cpp in Sources */, + 65413E991CEB6612008BE849 /* OneByOneMatrix.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 65413E921CEB65E5008BE849 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 65413E931CEB65E5008BE849 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 65413E951CEB65E5008BE849 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 65413E961CEB65E5008BE849 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 65413E881CEB65E5008BE849 /* Build configuration list for PBXProject "CopyOnWrite" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 65413E921CEB65E5008BE849 /* Debug */, + 65413E931CEB65E5008BE849 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 65413E941CEB65E5008BE849 /* Build configuration list for PBXNativeTarget "CopyOnWrite" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 65413E951CEB65E5008BE849 /* Debug */, + 65413E961CEB65E5008BE849 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 65413E851CEB65E5008BE849 /* Project object */; +} diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..62b8b09 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..21ac3eded6bd905037b87fbcfe6c7ace44e324dd GIT binary patch literal 34240 zcmd6Q2V7I<_xF8na_@};2ul-C_L4nhISEOC2qc(+Zph)5!eh$eD~Tq2LiCklu{qKKGF6cZ&xDN#mL5GtaQXd;#o%LyCdAbJQF(MJpt z9%2=-npi`uC0K$Z&LGYtE+j4@E+#G^E+sA_E+?)at|YD{b`dubHxs*wTZmhU+lbqV zhlxjsJ;bBLW5nac6U39m%fu_hK4L%d9`Qc$0r4Smi1>*3nD~VFj`*JVf%p+2L?Q{2 zA~_025hxNV(QFilGEo-FMmZ=K%|*p%9;!rYq(NF#g=$a(T8fOQ2{og3WJ6uZj@)Pf z4I&TnA|E;lZ9r$EbI?Y#32jE_qVv#&=pyn=@*MJ9@&fW=@-p&D@)~jrxsBXG-bmg| z-b&s<-c8;|K1e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lyN;feLcc@jOzo-|K}r@*80m^~eyUXRbS+H^a|aq32@H9iEpw-+8BbqrA~xg*Vlk;m!2sc=Nr5-ud1Nui9JXt?@Q`+q}!YE4+4Z zkGI#`=UwGp@7?6Rz%1f0?cQ6w_j;f7KI7f%eZl*Z_Z9EQ-tWBMdw=l$ z-{rntzB_$S`S$u=7PdS{Qurxz2tURD`}X}G#H>={ literal 0 HcmV?d00001 diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/CopyOnWrite.xcscheme b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/CopyOnWrite.xcscheme new file mode 100644 index 0000000..ae4057b --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/CopyOnWrite.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..a513042 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + CopyOnWrite.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 65413E8C1CEB65E5008BE849 + + primary + + + + + diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.cpp b/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.cpp new file mode 100644 index 0000000..921f8d8 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.cpp @@ -0,0 +1,77 @@ +// +// OneByOneMatrix.cpp +// CopyOnWrite +// +// Created by clink on 17/05/16. +// Copyright (c) 2016 HSEL. All rights reserved. +// + +#include "OneByOneMatrix.h" + + +#include + +int OneByOneMatrix::s_instanceCounter=0; + + +OneByOneMatrix::OneByOneMatrix() +: m_value(-1), m_referenceCounter(0) +{ + s_instanceCounter++; +} + +OneByOneMatrix::OneByOneMatrix(int initialValue) +: m_value(initialValue), m_referenceCounter(0) +{ + s_instanceCounter++; +} + +OneByOneMatrix::OneByOneMatrix(const OneByOneMatrix& source) +: m_value(source.m_value), m_referenceCounter(source.m_referenceCounter) +{ + s_instanceCounter++; +} + +OneByOneMatrix::~OneByOneMatrix(){ + s_instanceCounter--; +} + +/* + int OneByOneMatrix::value(void) const { + return m_value; + }*/ + +OneByOneMatrix OneByOneMatrix::operator+(const OneByOneMatrix & other){ + return OneByOneMatrix(m_value + other.m_value); +} + +OneByOneMatrix::operator int(){ + return m_value; +} + +OneByOneMatrix& OneByOneMatrix::operator ++(int i){ + m_value++; + return *this; +} + + +bool OneByOneMatrix::operator==(const OneByOneMatrix& other){ + return this->m_value == other.m_value; +} + +bool OneByOneMatrix::operator!=(const OneByOneMatrix& other){ + return !(*this==other); +} + + + +bool OneByOneMatrix::instanceCountExceeds(int max) +{ + bool retval = s_instanceCounter>max; + if (retval){ + std::cout << OneByOneMatrix::s_instanceCounter << " > max=" << max << std::endl; + } + return retval; +} + + diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.h b/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.h new file mode 100644 index 0000000..0eccc69 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite/OneByOneMatrix.h @@ -0,0 +1,42 @@ +// +// OneByOneMatrix.h +// CopyOnWrite +// +// Created by clink on 17/05/16. +// Copyright (c) 2016 HSEL. All rights reserved. +// + +#ifndef __CopyOnWrite__OneByOneMatrix__ +#define __CopyOnWrite__OneByOneMatrix__ + + +class OneByOneMatrix { + + int m_value; + + int m_referenceCounter; // refcounting + static int s_instanceCounter; // assertions +public: + OneByOneMatrix(); + explicit OneByOneMatrix(int initialValue); + OneByOneMatrix(const OneByOneMatrix&); + ~OneByOneMatrix(); + + explicit operator int(); + OneByOneMatrix operator+(const OneByOneMatrix & other); + OneByOneMatrix& operator ++(int); + bool operator==(const OneByOneMatrix& other); + bool operator!=(const OneByOneMatrix& other); + + friend class OneByOneMatrix_CopyOnWrite; + static bool instanceCountExceeds(int max); // assertions +}; + +// imagine this class as an abstraction for very large matrices + +class LargeCowMatrix { + +}; + + +#endif /* defined(__CopyOnWrite__OneByOneMatrix__) */ diff --git a/11_PUTT/CopyOnWrite/CopyOnWrite/main.cpp b/11_PUTT/CopyOnWrite/CopyOnWrite/main.cpp new file mode 100644 index 0000000..9941c93 --- /dev/null +++ b/11_PUTT/CopyOnWrite/CopyOnWrite/main.cpp @@ -0,0 +1,86 @@ +// +// main.cpp +// leistungstestatSurrogat +// +// Created by clink on 11/12/14. +// Copyright (c) 2014 HSEL. All rights reserved. +// + +#include + + +#include "OneByOneMatrix.h" + +int failCounter=0; + +typedef int NumberType; +//typedef OneByOneMatrix NumberType; +//typedef LargeCowMatrix NumberType; + + +void simpleTests(){ + NumberType i1(1); + NumberType i2(2); + NumberType i3=i1+i2; + + if (i3!=NumberType(3)){ + failCounter++; + std::cout << "fail!" << std::endl; + } + + i3++; + if (i3!=NumberType(4)){ + failCounter++; + std::cout << "fail!" << std::endl; + } + + i3=i1; + if (i3!=NumberType(1)){ + failCounter++; + std::cout << "fail!" << std::endl; + } + + if (OneByOneMatrix::instanceCountExceeds(3)){ + failCounter++; + } +} + +void arrayTests(){ + { + const int BUFSIZE=1000; + NumberType singletonValue(4711); + NumberType numbers[BUFSIZE]; + bool didFail=false; + + for(int i=0; i(color) << "m"; // blue + std::cout << text; + std::cout << "\033[0m\n"; // reset attributes +} + + + diff --git a/helpers/AnsiConsole.h b/helpers/AnsiConsole.h new file mode 100644 index 0000000..1d3ad39 --- /dev/null +++ b/helpers/AnsiConsole.h @@ -0,0 +1,34 @@ + +#include + +enum class Colors { + BLACK = 30, + RED = 31, + GREEN = 32, + YELLOW = 33, + BLUE = 34, + MAGENTA = 35, + CYAN = 36, + WHITE = 37 +}; + +class AnsiConsole { + // protected: + // can only be used by members of AnsiConsole and its + // derived classes +protected: + void hideCursor(); + void showCursor(); + void pushCursorPos(); + void popCursorPos(); + +public: + AnsiConsole(); + ~AnsiConsole(); + void clearScreen(); + void printText(int x, int y, std::string text, Colors color=Colors::BLUE); +}; + +extern AnsiConsole ansiConsole; + + diff --git a/helpers/println.hpp b/helpers/println.hpp new file mode 100644 index 0000000..7de0382 --- /dev/null +++ b/helpers/println.hpp @@ -0,0 +1,124 @@ +// +// println.hpp +// printline + + + +#ifndef println_hpp +#define println_hpp + +/* + based on: http://stackoverflow.com/questions/16084379/system-out-println-function-syntax-in-c/16085135#16085135 + initial Author: http://stackoverflow.com/users/264338/mkaes + */ + +#include +#include +#include +using namespace std; + +/* +template +void printer(T t) +{ + std::cout << t << std::endl; +} + +template +void printer(T t, U ...u) +{ + std::cout << t; + printer(u...); +}*/ + +//namespace std { + //string to_string(const string s); + //string to_string(const char* s); + + /* + inline string to_string(const string s){ + return s; + } + + inline string to_string(const char* s){ + return string(s); + }*/ + +//} + + + +/* +void println(T t) +{ + std::cout << std::to_string(t) << std::endl; +} + +template +void println(T t, U ...u) +{ + std::cout << std::to_string(t); + println(u...); +} +*/ + + +//namespace { + +// from: https://stackoverflow.com/questions/16605967/set-precision-of-stdto-string-when-converting-floating-point-values +template +std::string to_string_with_precision(const T a_value, const int n = 6) +{ + std::ostringstream out; + out << std::setprecision(n) << std::scientific << a_value; + return out.str(); +} + +template +std::string as_string(T t){ + using namespace std; + return to_string_with_precision(t); + //return to_string(t); +} + + +template <> + std::string as_string(const char * s){ + return std::string(s); +} + +template <> +std::string as_string(std::string s){ + return s; +} +//} + +template +void println(T t) +{ + std::cout << as_string(t) << std::endl; +} + +template +void println(T t, U ...u) +{ + std::cout << as_string(t); + println(u...); +} + +template +void print(T t) +{ + std::cout << as_string(t); +} + +template +void print(T t, U ...u) +{ + std::cout << as_string(t); + print(u...); +} + + + +#endif /* println_hpp */ diff --git a/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.pbxproj b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.pbxproj new file mode 100644 index 0000000..1a36243 --- /dev/null +++ b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.pbxproj @@ -0,0 +1,253 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 6590867D1EE9FA9400A93466 /* main_02_MENT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6590867C1EE9FA9400A93466 /* main_02_MENT.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 6590866E1EE9F98F00A93466 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 659086701EE9F98F00A93466 /* 02_MENT_gg */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = 02_MENT_gg; sourceTree = BUILT_PRODUCTS_DIR; }; + 6590867C1EE9FA9400A93466 /* main_02_MENT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main_02_MENT.cpp; path = ../../../02_MENT/main_02_MENT.cpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6590866D1EE9F98F00A93466 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 659086671EE9F98F00A93466 = { + isa = PBXGroup; + children = ( + 659086721EE9F98F00A93466 /* 02_MENT_gg */, + 659086711EE9F98F00A93466 /* Products */, + ); + sourceTree = ""; + }; + 659086711EE9F98F00A93466 /* Products */ = { + isa = PBXGroup; + children = ( + 659086701EE9F98F00A93466 /* 02_MENT_gg */, + ); + name = Products; + sourceTree = ""; + }; + 659086721EE9F98F00A93466 /* 02_MENT_gg */ = { + isa = PBXGroup; + children = ( + 6590867C1EE9FA9400A93466 /* main_02_MENT.cpp */, + ); + path = 02_MENT_gg; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6590866F1EE9F98F00A93466 /* 02_MENT_gg */ = { + isa = PBXNativeTarget; + buildConfigurationList = 659086771EE9F98F00A93466 /* Build configuration list for PBXNativeTarget "02_MENT_gg" */; + buildPhases = ( + 6590866C1EE9F98F00A93466 /* Sources */, + 6590866D1EE9F98F00A93466 /* Frameworks */, + 6590866E1EE9F98F00A93466 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = 02_MENT_gg; + productName = 02_MENT_gg; + productReference = 659086701EE9F98F00A93466 /* 02_MENT_gg */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 659086681EE9F98F00A93466 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = HSEL; + TargetAttributes = { + 6590866F1EE9F98F00A93466 = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 6590866B1EE9F98F00A93466 /* Build configuration list for PBXProject "02_MENT_gg" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 659086671EE9F98F00A93466; + productRefGroup = 659086711EE9F98F00A93466 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6590866F1EE9F98F00A93466 /* 02_MENT_gg */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 6590866C1EE9F98F00A93466 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6590867D1EE9FA9400A93466 /* main_02_MENT.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 659086751EE9F98F00A93466 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 659086761EE9F98F00A93466 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 659086781EE9F98F00A93466 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 659086791EE9F98F00A93466 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6590866B1EE9F98F00A93466 /* Build configuration list for PBXProject "02_MENT_gg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 659086751EE9F98F00A93466 /* Debug */, + 659086761EE9F98F00A93466 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 659086771EE9F98F00A93466 /* Build configuration list for PBXNativeTarget "02_MENT_gg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 659086781EE9F98F00A93466 /* Debug */, + 659086791EE9F98F00A93466 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 659086681EE9F98F00A93466 /* Project object */; +} diff --git a/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..c08ac4e --- /dev/null +++ b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..0dae52ca22c881fb31d68649004cdbb456ce23fe GIT binary patch literal 11742 zcmd5?d3;k<_P&&xJPPOI0$hl1!Bg=xJRRHdt=NI9u@l$eMm!sPu@C!k6P|eB61s9Ol~K4lNIDXvX(qZHj^!6E7?Z2lU?L#vX8t-_LEo15%L;2Moy5EMw&K$=R^XgVEChtM24hK{A< zXfYj6C(wzsgqG4WT23qIBw9(Usgu@Fj@Hw;w3)Whd9; zZwmbFvbqYZ)9vv2I#3jfW`xlWq(mwf!FDo>U1=SeUr;zCvv6c;&ftvv)Ik|T@>27% z^Yc@42W1u%4jP(2bkyJ+yHZ<}Uogqzo#ktEIJta}v#FkI@P`K0BNIy5iegb5GN5>r zfD)0BiI|v0G6|D18Ix~CNyv;WAVDm$A{$e%$JpZ_i-^Ut9A>jCZ|cpz%uzkc)8O}d z+-}Zm&&|ln&CkrpOU=#BDM%fZlarA;a&S&|YGHmsX3pTk?A)Olqo(uST@5v!xrJUw zJ!e;1;KO)t4d>-*y2TD->$58d_8wE{-7{=?gKKsZS5yPjbj@&q7|J9d&vW`=_gA~p}}Yf%0am- zibb;+rerFnW*Vkty6tEfDDeh#Bf1F^DU4n3a5dO7vh3puip$cRjg29FPDG_Br5%;9_;ysr5_o;6 z@+-=^#V+!5^}Z9qjZ=xLI?!Y^g(b2+%o<`a4c&^=9cVhTGb1x~AP1^uNzBYF(|}EH z!%)IIuZVGu+6I@usfL@7JYrEJ;{TmME;JL(LhdQT9&7;PtP~zO-_+vLd>0s$r@`TE z=>V$w%Hq=TK~E8q!GpY4$>0YWl9?rWgvZ=#gl5z-y|{E-livZxmgn_4S~^iPnuqEE z4uY?OAoEchEKN6I&*+_KK0khF*o9~jO6foh1z2C!uLA|pV%CrK59+X#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j4L0_OBt-nP-RzF!^r=O{J z>l^fqdavHEpQFEBzeInhe!2c`{Yw36{r&ni`kneW^k?1z8KxQRhB`yN!DELdkm`$_Zglu z95lRTIB7U-c-Qcu;UmMxhEEKa<59dcUJ)N1uZ*|E4~S2VPmj-x&yIg7{%HJ}_z&XG z#h;J=EdFBrm+_b4zmNYZAu1s*!IF@dFgl?wVL`(3gu4>%PFR_+E}=7FbHdhy?FmmL z>`r((;hBWz5)LOENjRGDMq*xKapHu;lEkva^NC+4ev|lJ;t$3dMxSxMae4S9t}@qfOr6j*My6j{btN-X7;N=ubxnq`Ki&eC9M zwJfqMw%lP^YFTMnZMomF*7A_0)3U|#q-DS5u;qy5sO1gI3Cn5AS<45ObC!#iE0!NE z|Fk--GprtKn{}~uxpl2|vvsR=hxKvmF6(aV9_!22!`36#*R5|_-?qMEJ!$>PX0+XG zn{AtCTVz{qTVY#cd&Jgh+ilxp+iyE)J7ha-d&_pxcG`B<_P*^4+gG;Bwkx*ZQzBAi RU7;5d{?hltA}^Gp_& + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..f5cb70f --- /dev/null +++ b/xcode_projects/02_MENT_gg/02_MENT_gg.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + 02_MENT_gg.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 6590866F1EE9F98F00A93466 + + primary + + + + + diff --git a/xcode_projects/limits2/limits2.xcodeproj/project.pbxproj b/xcode_projects/limits2/limits2.xcodeproj/project.pbxproj new file mode 100644 index 0000000..13a800a --- /dev/null +++ b/xcode_projects/limits2/limits2.xcodeproj/project.pbxproj @@ -0,0 +1,255 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 659086601EE9EC6200A93466 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6590865F1EE9EC6200A93466 /* main.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 6590865A1EE9EC6200A93466 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6590865C1EE9EC6200A93466 /* limits2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = limits2; sourceTree = BUILT_PRODUCTS_DIR; }; + 6590865F1EE9EC6200A93466 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 659086661EE9ECC100A93466 /* println.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = println.hpp; path = ../../../helpers/println.hpp; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 659086591EE9EC6200A93466 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 659086531EE9EC6200A93466 = { + isa = PBXGroup; + children = ( + 6590865E1EE9EC6200A93466 /* limits2 */, + 6590865D1EE9EC6200A93466 /* Products */, + ); + sourceTree = ""; + }; + 6590865D1EE9EC6200A93466 /* Products */ = { + isa = PBXGroup; + children = ( + 6590865C1EE9EC6200A93466 /* limits2 */, + ); + name = Products; + sourceTree = ""; + }; + 6590865E1EE9EC6200A93466 /* limits2 */ = { + isa = PBXGroup; + children = ( + 659086661EE9ECC100A93466 /* println.hpp */, + 6590865F1EE9EC6200A93466 /* main.cpp */, + ); + path = limits2; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6590865B1EE9EC6200A93466 /* limits2 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 659086631EE9EC6200A93466 /* Build configuration list for PBXNativeTarget "limits2" */; + buildPhases = ( + 659086581EE9EC6200A93466 /* Sources */, + 659086591EE9EC6200A93466 /* Frameworks */, + 6590865A1EE9EC6200A93466 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = limits2; + productName = limits2; + productReference = 6590865C1EE9EC6200A93466 /* limits2 */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 659086541EE9EC6200A93466 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = HSEL; + TargetAttributes = { + 6590865B1EE9EC6200A93466 = { + CreatedOnToolsVersion = 8.2.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 659086571EE9EC6200A93466 /* Build configuration list for PBXProject "limits2" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 659086531EE9EC6200A93466; + productRefGroup = 6590865D1EE9EC6200A93466 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6590865B1EE9EC6200A93466 /* limits2 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 659086581EE9EC6200A93466 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 659086601EE9EC6200A93466 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 659086611EE9EC6200A93466 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 659086621EE9EC6200A93466 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 659086641EE9EC6200A93466 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 659086651EE9EC6200A93466 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 659086571EE9EC6200A93466 /* Build configuration list for PBXProject "limits2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 659086611EE9EC6200A93466 /* Debug */, + 659086621EE9EC6200A93466 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 659086631EE9EC6200A93466 /* Build configuration list for PBXNativeTarget "limits2" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 659086641EE9EC6200A93466 /* Debug */, + 659086651EE9EC6200A93466 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 659086541EE9EC6200A93466 /* Project object */; +} diff --git a/xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..c99cd96 --- /dev/null +++ b/xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate b/xcode_projects/limits2/limits2.xcodeproj/project.xcworkspace/xcuserdata/clink.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..6637b37b0392b4eb0dcc7d00b2676c7e7015bc60 GIT binary patch literal 11356 zcmd5?d3=*q*1k)UW^0L`aMz^fCJQbo(OC=XZHM)9v2+1)MYBpJ8|SoJ}rxTx}0{TeS$U z+BJ z&~!8hacDkjL`}$ryl636f^I;|&@E^cx)p6h+tFQU2il2tp}Wyuv=1Fd_o4^UL+BVf zjvhx(qLb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Zw(k)4AlGY_{NV+5G&ZKQgcO`|A4kkUG zbSmkSq_2`y$@b)&IVp2f+$n7-EM-fVBN ud+kf?%j_NY750_(RrWjVciOkv@3P-(|C9ZAH=82DU)s&CB9zMh$o~Qn)C7e9 literal 0 HcmV?d00001 diff --git a/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/limits2.xcscheme b/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/limits2.xcscheme new file mode 100644 index 0000000..3527a29 --- /dev/null +++ b/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/limits2.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist b/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..5fe8a4f --- /dev/null +++ b/xcode_projects/limits2/limits2.xcodeproj/xcuserdata/clink.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + limits2.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 6590865B1EE9EC6200A93466 + + primary + + + + + diff --git a/xcode_projects/limits2/limits2/main.cpp b/xcode_projects/limits2/limits2/main.cpp new file mode 100644 index 0000000..3fd3576 --- /dev/null +++ b/xcode_projects/limits2/limits2/main.cpp @@ -0,0 +1,26 @@ +// main.cpp +// limits2 + + + +#include "../../../helpers/println.hpp" +#include + + +int main() +{ + println("type\t sizeof\t\t lowest\t\t\t\t highest\n"); + println("float \t ",sizeof(float), "\t\t\t", + std::numeric_limits::lowest(), "\t\t", + std::numeric_limits::max()); + println("double\t ",sizeof(double), "\t\t\t", + std::numeric_limits::lowest(), "\t\t", + std::numeric_limits::max()); + println("int \t ",sizeof(int), "\t\t\t", + std::numeric_limits::lowest(), "\t\t\t", + std::numeric_limits::max()); + println("long \t ",sizeof(long), " \t\t", + std::numeric_limits::lowest(), '\t', + std::numeric_limits::max()); + + }