-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from LinkinPF/lmp_dev
Build BPF generator using the builder pattern
- Loading branch information
Showing
5 changed files
with
172 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package bpf | ||
|
||
import "os" | ||
|
||
//定义生成者模式中的Builder,这里的CBuilder是C文件生成的方法 | ||
type CBuilder interface { | ||
AddCommonCFileFront() | ||
AddPrivateCFile() | ||
AddCommonCFileEnd() | ||
} | ||
|
||
//具体来创建python文件的ConcreteBuilder | ||
type ConcreteBuilderC struct { | ||
f os.File | ||
status bool | ||
} | ||
|
||
//返回ConcreteBuilderPy的实例 | ||
func NewConcreteBuilderC() ConcreteBuilderC { | ||
return ConcreteBuilderC{ | ||
f: os.File{}, //TODO.. | ||
status: false, | ||
} | ||
} | ||
|
||
//实现接口的方法 | ||
func (c *ConcreteBuilderC)AddCommonCFileFront() { | ||
//TODO.. | ||
} | ||
func (c *ConcreteBuilderC)AddPrivateCFile() { | ||
//TODO.. | ||
} | ||
func (c *ConcreteBuilderC)AddCommonCFileEnd() { | ||
//TODO.. | ||
} | ||
|
||
//最后生成的成果 | ||
type ProductC struct { | ||
f os.File | ||
status bool | ||
} | ||
|
||
//生成成果, | ||
func (b *ConcreteBuilderPy)GetResultC() ProductC { | ||
return ProductC{ | ||
f: b.f, | ||
status: true, | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package bpf | ||
|
||
import "os" | ||
|
||
// 定义生成者模式中的Builder,这里的Builder是python文件生成的方法 | ||
type PyBuilder interface { | ||
AddCommonPyFileFront() | ||
AddPrivatePyFile() | ||
AddCommonPyFileEnd() | ||
} | ||
|
||
//具体来创建python文件的ConcreteBuilder | ||
type ConcreteBuilderPy struct { | ||
f os.File | ||
status bool | ||
} | ||
|
||
//返回ConcreteBuilderPy的实例 | ||
func NewConcreteBuilderPy() ConcreteBuilderPy { | ||
return ConcreteBuilderPy{ | ||
f: os.File{}, //TODO.. | ||
status: false, | ||
} | ||
} | ||
|
||
//实现接口的方法 | ||
func (c *ConcreteBuilderPy)AddCommonPyFileFront() { | ||
//TODO.. | ||
} | ||
func (c *ConcreteBuilderPy)AddPrivatePyFile() { | ||
//TODO.. | ||
} | ||
func (c *ConcreteBuilderPy)AddCommonPyFileEnd() { | ||
//TODO.. | ||
} | ||
|
||
//最后生成的成果 | ||
type ProductPy struct { | ||
f os.File | ||
status bool | ||
} | ||
|
||
//生成成果, | ||
func (b *ConcreteBuilderPy)GetResultPy() ProductPy { | ||
return ProductPy{ | ||
f: b.f, | ||
status: true, | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters