Skip to content

Commit

Permalink
Added some sections
Browse files Browse the repository at this point in the history
  • Loading branch information
olekscode committed Dec 17, 2023
1 parent b596ec6 commit 9c10faa
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions General/ProgrammaticCodeManipulation.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Programmatic Code Manipulation

In this article, we will present some code snippets that demonstrate how we can manipulate the source code (packages, classes, methods, variables, traits, pragmas, etc.) programmatically, without using the SystemBrowser. Those techniques can be very useful for reflective operations, code generation, testing, etc.
In this article, we will present some code snippets that demonstrate how we can manipulate the source code (packages, classes, methods, variables, traits, etc.) programmatically, without using the SystemBrowser. Those techniques can be very useful for reflective operations, code generation, testing, etc.

This article explains only those operations that **modify** the code. We will write a separate article on **querrying code** (looking for method senders, class references, pragma usages, etc.).

## Packages

### Creating a new package

### Removing a package

### Creating a package without installing it

_(how to create an instance of a package without installing it into the image? - e.g., for testing)_

## Classes

### Creating a new class
Expand All @@ -16,6 +26,10 @@ builder := Object << #MyClass slots: { }; package: 'MyPackage'. class := bui

The first statement will return an instance of `FluidClassBuilder`. The second statement will build the class, install it into the image, and assign it to the variable. If `MyPackage` does not exist, it will be created.

### Creating an anonymous class

### Removing a class

## Methods

### Adding a method to a class
Expand All @@ -40,4 +54,22 @@ Finally, to avoid the error when generating a code in a fresh image, you should
Author
useAuthor: 'Dummy Name'
during: [ MyClass compile: sourceCode ].
```
```

### Removing a method from a class

## Variables

## Traits

### Adding trait to a class

### Removing trait from a class

### Creating a new trait

### Adding methods to a trait

## Useful links

- A toolkit to generate Pharo code: <https://github.com/juliendelplanque/PharoCodeGenerator>
Expand Down

0 comments on commit 9c10faa

Please sign in to comment.