-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_vector_registration.ps1
More file actions
53 lines (44 loc) · 2.2 KB
/
add_vector_registration.ps1
File metadata and controls
53 lines (44 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$file = 'Source/JaiScript/include/jaiscript/core/class_builder.hpp'
$content = Get-Content $file -Raw
$searchPattern = @'
return script_value(std::monostate{}, engine_weak); // null
});
return *this;
}
public:
// Add property with getter/setter
'@
$replacement = @'
return script_value(std::monostate{}, engine_weak); // null
});
// Register bound_cpp_vector<T> if this property is a std::vector
if constexpr (detail::is_specialization_v<P, std::vector>) {
using element_type = typename P::value_type;
std::string wrapper_type_name = std::string("bound_cpp_vector<") + typeid(element_type).name() + ">";
// Check if already registered
auto existing = engine_.get_class_definition_by_type(std::type_index(typeid(bound_cpp_vector<element_type>)));
if (!existing) {
// Register bound_cpp_vector<element_type> with array-like methods
class_builder<bound_cpp_vector<element_type>>(engine_, wrapper_type_name)
.method("size", &bound_cpp_vector<element_type>::size)
.method("empty", &bound_cpp_vector<element_type>::empty)
.method("clear", &bound_cpp_vector<element_type>::clear)
.method("push_back", static_cast<void(bound_cpp_vector<element_type>::*)(const element_type&)>(&bound_cpp_vector<element_type>::push_back))
.method("push", static_cast<void(bound_cpp_vector<element_type>::*)(const element_type&)>(&bound_cpp_vector<element_type>::push_back)) // Alias
.method("pop_back", &bound_cpp_vector<element_type>::pop_back)
.method("pop", &bound_cpp_vector<element_type>::pop_back) // Alias
.build();
}
}
return *this;
}
public:
// Add property with getter/setter
'@
if ($content -match [regex]::Escape($searchPattern)) {
$content = $content -replace [regex]::Escape($searchPattern), $replacement
$content | Set-Content $file -NoNewline
Write-Host "Successfully added bound_cpp_vector registration!"
} else {
Write-Host "Pattern not found - searching for alternative..."
}