Skip to content

Commit

Permalink
Minor changes needed for new wrapit
Browse files Browse the repository at this point in the history
  • Loading branch information
peremato committed Nov 28, 2023
1 parent 8e500bb commit 2548ec9
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 46 deletions.
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
Expat_jll = "2e619515-83b5-522b-bb60-26c02a35a201"
Geant4_jll = "872b6946-528a-5ac7-9145-d37eec569368"
Geant4_julia_jll = "e202cb52-5471-567a-9cb0-0ca301e27810"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand All @@ -27,8 +26,7 @@ G4Vis = ["Makie", "Colors", "StaticArrays", "Rotations", "LinearAlgebra", "IGLWr

[compat]
CSV = "0.10"
CxxWrap = "0.13"
Geant4_julia_jll = "0.1.10"
CxxWrap = "0.14"
GeometryBasics = "0.4"
IGLWrap_jll = "2.4.0"
julia = "1.9"
Expand Down
4 changes: 2 additions & 2 deletions gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ if(WRAPIT_EXECUTABLE)
configure_file(${SOURCE_DIR}/Geant4.wit.in ${SOURCE_DIR}/Geant4.wit @ONLY)
add_custom_command(OUTPUT ${SOURCE_DIR}/cpp/jlGeant4.cxx
COMMAND mkdir -p ${SOURCE_DIR}/jl
COMMAND ${WRAPIT_EXECUTABLE} --force -v 1 ${SOURCE_DIR}/Geant4.wit
COMMAND ${WRAPIT_EXECUTABLE} --force -v 5 ${SOURCE_DIR}/Geant4.wit
WORKING_DIRECTORY ${SOURCE_DIR}
DEPENDS ${SOURCE_DIR}/Geant4.wit ${SOURCE_DIR}/Geant4-veto.h ${SOURCE_DIR}/cpp/Geant4Wrap.h)
else()
message(STATUS "The executable wrapit was not found. Building wrapper using the generated jlGeant4.cxx/h files from the sources.")
endif()

file(GLOB GEN_SOURCES CONFIGURE_DEPENDS ${SOURCE_DIR}/cpp/jl_*.cxx)
file(GLOB GEN_SOURCES CONFIGURE_DEPENDS ${SOURCE_DIR}/cpp/Jl*.cxx)
add_library(Geant4Wrap SHARED ${SOURCE_DIR}/cpp/Geant4Wrap.cxx ${SOURCE_DIR}/cpp/jlGeant4.cxx ${GEN_SOURCES})

#target_compile_definitions(Geant4Wrap PUBLIC VERBOSE_IMPORT)
Expand Down
15 changes: 15 additions & 0 deletions gen/Geant4-veto.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ size_t G4ProcessVector::length()
size_t G4ProcessVector::size()
void CLHEP::RandPoissonQ::shootArray(CLHEP::HepRandomEngine *, const int, long *, double)

G4VMPLData::physicsVector
CLHEP::HepXHat
CLHEP::HepYHat
CLHEP::HepZHat
CLHEP::HepRotation::IDENTITY
HepGeom::Transform3D::Identity
CLHEP::HepLorentzRotation::IDENTITY
std::istream
std::ostream
std::basic_istream
std::basic_ostream
std::__wrap_iter
# G4ReferenceCountedHandle


25 changes: 15 additions & 10 deletions gen/Geant4.wit
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
module_name = "Geant4"
export_jl_fname = "jl/Geant4-export.jl"
module_jl_fname = "jl/Geant4-generated.jl"
out_cpp_fname = "cpp/jlGeant4.cxx"
out_h_fname = "cpp/jlGeant4.h"
export_jl_fname = "Geant4-export.jl"
module_jl_fname = "Geant4-generated.jl"
out_cpp_fname = "jlGeant4.cxx"
out_h_fname = "jlGeant4.h"
out_cxx_dir = "cpp"
out_jl_dir = "jl"

include_dirs = [ "/usr/local/opt/llvm/include/c++/v1",
"/usr/local/opt/llvm@13/lib/clang/13.0.1/include",
"./cpp",
"/Users/mato/.julia/artifacts/9d4b417a98ec8f720b8871baefe87108f864656f/include/Geant4",
"/Users/mato/.julia/artifacts/873cac66ad4ed154c44c11514f103918776c832d/include",
clang_opts = [ "-v",
"-isystem", "/opt/homebrew/opt/llvm@13/include/c++/v1",
"-isystem", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-isystem", "/opt/homebrew/opt/llvm@13/lib/clang/13.0.1/include"]

include_dirs = [ "./cpp",
"/Users/mato/.julia/artifacts/195e8ebe80b203de04fe4bf64d497607f244ee27/include/Geant4",
"/Users/mato/.julia/artifacts/2aef78b1d17dbf26549ac8be58ffb34bfbf97786/include",
"/Applications/Julia-1.9.app/Contents/Resources/julia/include/julia",
"/Users/mato/.julia/artifacts/eb9099719fd3959a5d4f2e7f445657537479e22c/lib/cmake/JlCxx/../../../include"]
"/Users/mato/.julia/artifacts/2526f1faf6c345898421326fb03a88a5e7875b71/lib/cmake/JlCxx/../../../include"]

input = [ "Geant4Wrap.h",
"G4RunManager.hh",
Expand Down Expand Up @@ -147,6 +150,8 @@ input = [ "Geant4Wrap.h",
"G4StateManager.hh",
"G4VStateDependent.hh",
"G4ApplicationState.hh",
#---Miscellaneous---------
# "G4ReferenceCountedHandle.hh",
]

extra_headers = [ "G4MaterialCutsCouple.hh", "G4FieldManager.hh", "G4VSensitiveDetector.hh", "G4ParticleMessenger.hh", "G4IonTable.hh" ]
Expand Down
19 changes: 12 additions & 7 deletions gen/Geant4.wit.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module_name = "Geant4"
export_jl_fname = "jl/Geant4-export.jl"
module_jl_fname = "jl/Geant4-generated.jl"
out_cpp_fname = "cpp/jlGeant4.cxx"
out_h_fname = "cpp/jlGeant4.h"
export_jl_fname = "Geant4-export.jl"
module_jl_fname = "Geant4-generated.jl"
out_cpp_fname = "jlGeant4.cxx"
out_h_fname = "jlGeant4.h"
out_cxx_dir = "cpp"
out_jl_dir = "jl"

include_dirs = [ "/usr/local/opt/llvm/include/c++/v1",
"/usr/local/opt/llvm@13/lib/clang/13.0.1/include",
"./cpp",
clang_opts = [ "-v",
"-isystem", "/opt/homebrew/opt/llvm@13/include/c++/v1",
"-isystem", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"-isystem", "/opt/homebrew/opt/llvm@13/lib/clang/13.0.1/include"]

include_dirs = [ "./cpp",
"@Geant4_INCLUDE_DIRS@",
"@XercesC_INCLUDE_DIR@",
"@Julia_INCLUDE_DIRS@",
Expand Down Expand Up @@ -147,6 +150,8 @@ input = [ "Geant4Wrap.h",
"G4StateManager.hh",
"G4VStateDependent.hh",
"G4ApplicationState.hh",
#---Miscellaneous---------
# "G4ReferenceCountedHandle.hh",
]

extra_headers = [ "G4MaterialCutsCouple.hh", "G4FieldManager.hh", "G4VSensitiveDetector.hh", "G4ParticleMessenger.hh", "G4IonTable.hh" ]
Expand Down
11 changes: 9 additions & 2 deletions gen/cpp/Geant4Wrap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <stdexcept>

// --------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
G4bool G4JLExceptionHandler::Notify(const char* originOfException,
const char* exceptionCode,
G4ExceptionSeverity severity,
Expand Down Expand Up @@ -131,4 +131,11 @@ void G4JLMagField::GetFieldValue( const G4double point[3], G4double* field) cons
G4bool G4JLStateDependent::Notify(G4ApplicationState to) {
auto from = G4StateManager::GetStateManager()->GetPreviousState();
return notify(from, to, notify_d);
}
}


//-------------------------------------------------------------------------------------------------
// Explicit template instantiations
//-------------------------------------------------------------------------------------------------
//template class G4ReferenceCountedHandle<G4VTouchable>;
//template class std::vector<G4Element*>;
5 changes: 1 addition & 4 deletions gen/jlGeant4-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ The auto_veto parameter is set to true, generation of the wrappers that would ha


CLHEP::HepEulerAngles::EA
G4Allocator<G4Event>
G4Allocator<G4HCofThisEvent>
G4Allocator<G4PrimaryParticle>
G4Allocator<G4PrimaryVertex>
G4ChordFinder
G4DCtable
G4DecayTable
Expand Down Expand Up @@ -47,6 +43,7 @@ G4VUserPrimaryVertexInformation
G4VisExtent
G4VoxelLimits
G4WorkerThread
TrajectoryVector
__void__
const HepGeom::Normal3D<double>
const HepGeom::Point3D<double>
Expand Down
32 changes: 16 additions & 16 deletions src/G4Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ export G4RandFlat, G4RandBit, G4RandGamma, G4RandGauss, G4RandExponential, G4Ran
export CxxPtr, ConstCxxPtr, CxxRef, ConstCxxRef, move!, preserve, @ui_cmd, StdVector

#---Useful Geant4 Typedefs-------------------------------------------------------------------------
const G4RotationMatrix = CLHEP!HepRotation
const G4ThreeVector = CLHEP!Hep3Vector
const G4Transform3D = HepGeom!Transform3D
const G4Random = CLHEP!HepRandom
if isdefined(Geant4,:CLHEP!RandFlat) # make it compatible with previous version of wrappers
const G4RandFlat = CLHEP!RandFlat
const G4RandBit = CLHEP!RandBit
const G4RandGamma = CLHEP!RandGamma
const G4RandGauss = CLHEP!RandGaussQ
const G4RandExponential = CLHEP!RandExponential
const G4RandGeneral = CLHEP!RandGeneral
end
const G4Random!getTheSeed = CLHEP!HepRandom!getTheSeed
const G4Random!setTheSeed = CLHEP!HepRandom!setTheSeed
const G4Random!getTheEngine = CLHEP!HepRandom!getTheEngine
const G4Random!setTheEngine = CLHEP!HepRandom!setTheEngine
typedef(t, n) = isdefined(Geant4, t) && eval(:(const $n = $t))

typedef(:CLHEP!HepRotation, :G4RotationMatrix)
typedef(:CLHEP!Hep3Vector, :G4ThreeVector)
typedef(:CLHEP!HepRandom, :G4Random)
typedef(:HepGeom!Transform3D, :G4Transform3D)
typedef(:CLHEP!RandFlat, :G4RandFlat)
typedef(:CLHEP!RandBit, :G4RandBit)
typedef(:CLHEP!RandGamma, :G4RandGamma)
typedef(:CLHEP!RandGaussQ, :G4RandGaussQ)
typedef(:CLHEP!RandExponential, :G4RandExponential)
typedef(:CLHEP!RandGeneral, :G4RandGeneral)
typedef(:CLHEP!HepRandom!getTheSeed, :G4Random!getTheSeed)
typedef(:CLHEP!HepRandom!setTheSeed, :G4Random!setTheSeed)
typedef(:CLHEP!HepRandom!getTheEngine, :G4Random!getTheEngine)
typedef(:CLHEP!HepRandom!setTheEngine, :G4Random!setTheEngine)

Base.show(io::IO, p::G4ThreeVector) = print(io, "G4ThreeVector($(x(p)),$(y(p)),$(z(p)))")
"""
Expand Down
4 changes: 2 additions & 2 deletions src/Geant4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module Geant4
gendir = normpath(joinpath(@__DIR__, "../gen"))
if isdir(joinpath(gendir, "build/lib"))
include(joinpath(gendir, "jl/Geant4-export.jl"))
@wrapmodule(joinpath(gendir, "build/lib", "libGeant4Wrap.$(Libdl.dlext)"))
@wrapmodule(()->joinpath(gendir, "build/lib", "libGeant4Wrap.$(Libdl.dlext)"))
else
using Geant4_julia_jll
include(Geant4_julia_jll.Geant4_exports)
@wrapmodule(Geant4_julia_jll.libGeant4Wrap)
@wrapmodule(()->Geant4_julia_jll.libGeant4Wrap)
end

function __init__()
Expand Down

0 comments on commit 2548ec9

Please sign in to comment.