Skip to content

Commit

Permalink
remove Func.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
defisym committed Jul 12, 2023
1 parent ba8376c commit b3a1f28
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Extensions/Func/Func.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ inline void CallFuncCore(LPRDATA rdPtr, std::wstring& funcName, std::wstring& pa
}

inline void IterateObjectCore(LPRDATA rdPtr, short oil,
const std::function<void(const std::vector<LPRO>&)>& callback) {
std::vector<LPRO> toIterate;
const std::function<void(const ObjectSelection::SelObj&)>& callback) {
ObjectSelection::SelObj toIterate;
const auto flag = rdPtr->pSelect->ObjectIsSelected(oil)
? ForEachFlag_SelectedOnly
: ForEachFlag_Default;
Expand Down
4 changes: 2 additions & 2 deletions Extensions/Func/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ short WINAPI DLLExport Action_IterateObject(LPRDATA rdPtr, long param1, long par
const auto oil = (short)OIL_GetParameter(rdPtr);
*rdPtr->pOnItObjName = (LPCWSTR)CNC_GetStringParameter(rdPtr);

IterateObjectCore(rdPtr, oil, [&] (const std::vector<LPRO>& toIterate) {
IterateObjectCore(rdPtr, oil, [&] (const ObjectSelection::SelObj& toIterate) {
rdPtr->pSelect->KeepScopeCall(rdPtr->bKeepScope, [&] () {
for (const auto& object : toIterate) {
rdPtr->pObject = object;
Expand All @@ -472,7 +472,7 @@ short WINAPI DLLExport Action_IterateObjectFunc(LPRDATA rdPtr, long param1, long
*rdPtr->pOnItObjName = (LPCWSTR)CNC_GetStringParameter(rdPtr);
std::wstring Param = (LPCWSTR)CNC_GetStringParameter(rdPtr);

IterateObjectCore(rdPtr, oil, [&] (const std::vector<LPRO>& toIterate) {
IterateObjectCore(rdPtr, oil, [&] (const ObjectSelection::SelObj& toIterate) {
const FuncInfoObject funcObj(rdPtr, *rdPtr->pOnItObjName, Param);

rdPtr->pSelect->KeepScopeCall(rdPtr->bKeepScope, [&] () {
Expand Down
Binary file modified Extensions/Func/ToInstall/Files/Data/Runtime/Unicode/Func.mfx
Binary file not shown.
4 changes: 4 additions & 0 deletions Extensions/Func/ToInstall/Files/Examples/Func/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Func.exe
Func.dat

Modules/*.*
Binary file not shown.
Binary file modified Extensions/Func/ToInstall/Files/Examples/Func/Func.mfa
Binary file not shown.
Binary file modified Extensions/Func/ToInstall/Files/Extensions/Unicode/Func.mfx
Binary file not shown.
33 changes: 18 additions & 15 deletions Extensions/_3rdLib/ObjectSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ constexpr auto ForEachFlag_ForceAll = 0b00000001;
constexpr auto ForEachFlag_SelectedOnly = 0b00000010;

class ObjectSelection {
private:
public:
using Filter = std::function<bool(LPRDATA, LPRO)>;
using ForEachCallBack = std::function<void(LPRO)>;

using SelObj = std::vector<LPRO>;

public:
struct Scope {
// State
BYTE rh2ActionLoop;
BYTE rh2ActionOn;
BYTE rh2ActionLoop;
BYTE rh2ActionOn;

int rh2ActionCount;
int rh2ActionLoopCount;
int rh2ActionCount;
int rh2ActionLoopCount;

LPEVG rhEventGroup;
LPEVG rhEventGroup;

// Objects
std::map<LPOIL, SelObj> objects;
Expand All @@ -49,11 +48,15 @@ class ObjectSelection {
rhEventGroup = rhPtr->rhEventGroup;
}

// ACT_STARTLOOP -> execute
// Use explice restore instead of RAII:
// for the case user saved scope but didn't restore it
// and runtime released it when Func object is destroyed
inline void RestoreActionState(const LPRDATA rdPtr) const {
RestoreActionState(rdPtr->rHo.hoAdRunHeader);
}
inline void RestoreActionState(const LPRH rhPtr) const {
// ACT_STARTLOOP -> execute

// restore rh2ActionLoop will continue loop
// fastloop will restore rh2ActionLoop & rh2ActionLoopCount & rhEventGroup
// rh2ActionOn must be true as immediate event is called in action
Expand All @@ -79,8 +82,10 @@ class ObjectSelection {
LPRH rhPtr;
LPOBL ObjectList;
LPOIL OiList;
LPQOI QualToOiList; // need update every time before using
int oiListItemSize;
LPQOI QualToOiList; // need to be updated each time before using

// For 2.5 only:
int oiListItemSize = sizeof(objInfoList) + sizeof(LPVOID);

inline bool FilterQualifierObjects(const LPRDATA rdPtr, const short oiList, const bool negate
, const Filter& filterFunction
Expand Down Expand Up @@ -220,14 +225,12 @@ class ObjectSelection {

public:
explicit ObjectSelection(const LPRDATA rdPtr)
:ObjectSelection(rdPtr->rHo.hoAdRunHeader) {}
:ObjectSelection(rdPtr->rHo.hoAdRunHeader) {}
explicit ObjectSelection(const LPRH rhPtr) {
this->rhPtr = rhPtr;
this->ObjectList = rhPtr->rhObjectList; //get a pointer to the mmf object list
this->OiList = rhPtr->rhOiList; //get a pointer to the mmf object info list
this->QualToOiList = rhPtr->rhQualToOiList; //get a pointer to the mmf qualifier to Oi list

oiListItemSize = sizeof(objInfoList) + sizeof(LPVOID);
}

//Get oil
Expand Down Expand Up @@ -399,15 +402,15 @@ class ObjectSelection {
SelectObjects(GetLPOIL(oiList), objects, count);
}

inline void SelectObjects(const LPOIL pObjectInfo, const std::vector<LPRO>& objects) const {
inline void SelectObjects(const LPOIL pObjectInfo, const SelObj& objects) const {
if (objects.empty()) {
return;
}

SelectObjects(pObjectInfo, objects.data(), objects.size());
}

inline void SelectObjects(const short oiList, const std::vector<LPRO>& objects) const {
inline void SelectObjects(const short oiList, const SelObj& objects) const {
SelectObjects(GetLPOIL(oiList), objects);
}

Expand Down

0 comments on commit b3a1f28

Please sign in to comment.