Skip to content

Commit

Permalink
minor fixes in module 2
Browse files Browse the repository at this point in the history
* make SizeOf and SizeOfPointers theory tasks
* custom name for FunctionPointers task

Signed-off-by: Evgenii Moiseenko <[email protected]>
  • Loading branch information
eupp committed May 26, 2023
1 parent d9cae8d commit 005e3bb
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 134 deletions.
5 changes: 3 additions & 2 deletions MemoryManagement/MemoryLayout/FunctionPointers/task-info.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
type: edu
custom_name: Function Pointers
files:
- name: CMakeLists.txt
visible: false
- name: test/test.cpp
visible: false
- name: src/task.cpp
visible: true
placeholders:
- offset: 90
length: 109
placeholder_text: return 0;
- name: test/test.cpp
visible: false
13 changes: 0 additions & 13 deletions MemoryManagement/MemoryLayout/SizeOf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,10 @@ project(MemoryManagement-MemoryLayout-SizeOf)

set(CMAKE_CXX_STANDARD 14)

set(OUTPUT_CPP_TASK MemoryManagement-MemoryLayout-SizeOf-output-cpp)
set(OUTPUT_TXT_TASK MemoryManagement-MemoryLayout-SizeOf-output-txt)

# custom command to produce output.txt file, because its content
# is platform-specific and need to be generated on student's machine
add_executable(${OUTPUT_CPP_TASK} test/output.cpp)
add_custom_target(${OUTPUT_TXT_TASK}
COMMAND ${OUTPUT_CPP_TASK} ${CMAKE_CURRENT_SOURCE_DIR}/test/output.txt
DEPENDS ${OUTPUT_CPP_TASK}
)

# Files from `./src` directory
set(SRC
src/main.cpp)


# Running learner side code
# Use PROJECT_NAME dependent names of targets for the plugin support to work correctly.
add_executable(${PROJECT_NAME}-run ${SRC})
add_dependencies(${PROJECT_NAME}-run ${OUTPUT_TXT_TASK})
10 changes: 1 addition & 9 deletions MemoryManagement/MemoryLayout/SizeOf/task-info.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
type: output
type: theory
files:
- name: CMakeLists.txt
visible: false
- name: test/output.txt
visible: false
- name: test/output.cpp
visible: false
- name: src/main.cpp
visible: true
placeholders:
- offset: 53
length: 788
placeholder_text: /* TODO */
13 changes: 6 additions & 7 deletions MemoryManagement/MemoryLayout/SizeOf/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ in modern computer architectures.
Below, you can find a table containing the information about common predefined types:
whether their size is platform dependent, what their exact or typical size is,
and what value range they encode.
In order to complete this task, print the sizes of these types to the terminal
(in the same order as they appear in the table, each number on its own line).
Check if the printed numbers match their counterparts in the table.

You can also run the program attached to this step to print
the sizes of these types to the terminal.
Therefore, you can check whether the sizes of these types on your system
match the numbers given in the table.

| Type | Description | Platform Dependent? | Size* | Value Range |
|-----------------|------------------------------------------------------------|---------------------|-------|--------------------|
Expand All @@ -87,9 +87,8 @@ Check if the printed numbers match their counterparts in the table.
| `bool` | boolean values | Yes | 1 | false, true |



*Size is given in bytes, for platform-independent types exact size is given,
for platform-dependent types typical size is given.
*Size is given in bytes, for platform-independent types the exact size is given,
for platform-dependent types the typical size is given.



Expand Down
34 changes: 0 additions & 34 deletions MemoryManagement/MemoryLayout/SizeOf/test/output.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions MemoryManagement/MemoryLayout/SizeOf/test/output.txt

This file was deleted.

14 changes: 1 addition & 13 deletions MemoryManagement/MemoryLayout/SizeOfPointer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@ project(MemoryManagement-MemoryLayout-SizeOfPointer)

set(CMAKE_CXX_STANDARD 14)

set(OUTPUT_CPP_TASK MemoryManagement-MemoryLayout-SizeOfPointers-output-cpp)
set(OUTPUT_TXT_TASK MemoryManagement-MemoryLayout-SizeOfPointers-output-txt)

# custom command to produce output.txt file, because its content
# is platform-specific and need to be generated on student's machine
add_executable(${OUTPUT_CPP_TASK} test/output.cpp)
add_custom_target(${OUTPUT_TXT_TASK}
COMMAND ${OUTPUT_CPP_TASK} ${CMAKE_CURRENT_SOURCE_DIR}/test/output.txt
DEPENDS ${OUTPUT_CPP_TASK}
)

# Files from `./src` directory
set(SRC
src/main.cpp)


# Running learner side code
# Use PROJECT_NAME dependent names of targets for the plugin support to work correctly.
add_executable(${PROJECT_NAME}-run ${SRC})
add_dependencies(${PROJECT_NAME}-run ${OUTPUT_TXT_TASK})

12 changes: 2 additions & 10 deletions MemoryManagement/MemoryLayout/SizeOfPointer/task-info.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
type: output
type: theory
custom_name: SizeOf Pointers
files:
- name: CMakeLists.txt
visible: false
- name: test/output.txt
visible: false
- name: test/output.cpp
visible: false
- name: src/main.cpp
visible: true
placeholders:
- offset: 38
length: 135
placeholder_text: /* TODO */
visible: true
15 changes: 8 additions & 7 deletions MemoryManagement/MemoryLayout/SizeOfPointer/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ meaning that its value range includes negative values.
This is expected, since one can subtract a "bigger" pointer `q` from a "smaller" pointer `p`
and get a negative number as the result.

In order to complete this task, print the sizes of the `char*`, `size_t`, and `ptrdiff_t` types to the terminal
(in this order, each number on its own line).
The program attached to this step prints the sizes of the `char*`, `size_t`, and `ptrdiff_t` types to the terminal.


| Type | Description | Platform Dependent? | Size in bytes (exact or typical) | Signed/Unsigned |
|-------------|-------------------------------------------|---------------------|----------------------------------|-----------------|
| `char*` | pointer type | Yes | 4 (x32), 8 (x64) | - |
| `size_t` | type to store size of types | Yes | 4 (x32), 8 (x64) | Unsigned |
| `ptrdiff_t` | type to store difference between pointers | Yes | 4 (x32), 8 (x64) | Signed |
| Type | Description | Platform Dependent? | Size* | Signed/Unsigned |
|-------------|-------------------------------------------|---------------------|------------------|-----------------|
| `char*` | pointer type | Yes | 4 (x32), 8 (x64) | - |
| `size_t` | type to store size of types | Yes | 4 (x32), 8 (x64) | Unsigned |
| `ptrdiff_t` | type to store difference between pointers | Yes | 4 (x32), 8 (x64) | Signed |


*Size is given in bytes, for platform-independent types the exact size is given,
for platform-dependent types the typical size is given.
20 changes: 0 additions & 20 deletions MemoryManagement/MemoryLayout/SizeOfPointer/test/output.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions MemoryManagement/MemoryLayout/SizeOfPointer/test/output.txt

This file was deleted.

0 comments on commit 005e3bb

Please sign in to comment.